*/
public void run(InvocationContext context) throws Throwable
{
if (m_channel.getQueue() != null || isBound(m_channel, context))
{
MessageInputStream miStream;
synchronized (m_msgInputStreamMap)
{
miStream = (MessageInputStream)m_msgInputStreamMap.get(in);
if (miStream == null)
{
miStream = m_channel.getMessageStreamFactory(context).createMessageInputStream(in);
m_msgInputStreamMap.put(in, miStream);
}
}
final TransferObject tobj = new TransferObject("TCP", 7);
if (m_channel.isResolvingEnabled())
{
AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
{
// do hostname lookups
tobj.setValue(TCPSender.REMOTE_HOST, remoteAddress.getAddress().getHostName());
tobj.setValue(TCPSender.LOCAL_HOST, localAddress.getAddress().getHostName());
return null;
}
});
}
else
{
tobj.setValue(TCPSender.REMOTE_HOST, remoteAddress.getAddress().getHostAddress());
tobj.setValue(TCPSender.LOCAL_HOST, localAddress.getAddress().getHostAddress());
}
tobj.setValue(TCPSender.REMOTE_PORT, Primitive.createInteger(remoteAddress.getPort()));
tobj.setValue(TCPSender.LOCAL_PORT, Primitive.createInteger(localAddress.getPort()));
tobj.setValue(TCPSender.CHANNEL, m_channel.getName());
tobj.setValue(TCPSender.CLIENT_CERTIFICATES, (certificateArray == null) ? null : new ArrayList(Arrays.asList(certificateArray)));
try
{
if (miStream.next(tobj))
{
Object body;
// get body
InputStream bufStream = new BufferedInputStream(new NoCloseInputStream(miStream));
if (m_channel.getEncoding() != null)
{
String sEncoding = m_channel.getEncoding();
Reader ireader = new BufferedReader(new InputStreamReader(
UTF8BOMIgnoreInputStream.wrap(bufStream, sEncoding), sEncoding));
body = new ReaderInput(ireader);
}
else
{
body = new StreamInput(bufStream);
}
// Is this channel bound to a service
// AND a message queue?
if (m_channel.getQueue() != null
&& isBound(m_channel, context))
{
// Read from the input stream and pass the actual
// data to the application
Input input = (Input)body;
if (m_channel.getEncoding() != null)
{
body = input.getString();
}
else
{
body = input.getBinary();
}
}
if (m_channel.getQueue() != null)
{
TransferObject msgObj = new TransferObject("MessageQueue", 1);
msgObj.setValue(TCPSender.BODY, body);
context.getUnitOfWork().addMessage(m_channel.getQueue(), msgObj);
}
if (isBound(m_channel, context))
{
tobj.setValue(TCPSender.BODY, body);
receive(tobj, m_channel, context);
}
}
else
{
miStream.close();
synchronized (m_msgInputStreamMap)
{
m_msgInputStreamMap.remove(in);
}
}
}
catch (Throwable t)
{
miStream.close();
synchronized (m_msgInputStreamMap)
{
m_msgInputStreamMap.remove(in);
}