{
socket = getSocket(endpoint);
}
catch (Exception e)
{
throw new MessagingException(CoreMessages.failedToGetOutputStream(), message, e);
}
if (socket == null)
{
// This shouldn't happen
throw new IllegalStateException("could not get socket for endpoint: "
+ endpoint.getEndpointURI().getAddress());
}
try
{
return new CallbackOutputStream(
new DataOutputStream(new BufferedOutputStream(socket.getOutputStream())),
new CallbackOutputStream.Callback()
{
public void onClose() throws Exception
{
releaseSocket(socket, endpoint);
}
});
}
catch (IOException e)
{
throw new MessagingException(CoreMessages.failedToGetOutputStream(), message, e);
}
}