Package nexj.core.integration

Examples of nexj.core.integration.MessageInputStream


            getCertificate(tobj), getPassword(tobj), getConnectionTimeout(tobj));
         con.setTOS(getTOS(tobj));
         send(tobj, con, null);

         // Get the input channel
         MessageInputStream mis = m_channel.getMessageStreamFactory(null).createMessageInputStream(con.getInputStream());

         con.setReadTimeout(m_channel.getReadTimeout());
         remoteAddr = con.getRemoteAddress();

         InetSocketAddress localAddr = con.getLocalAddress();

         // Create the TransferObject
         response = new TransferObject("TCP", 6);
         response.setValue(TCPSender.REMOTE_HOST, remoteAddr.getAddress().getHostAddress());
         response.setValue(TCPSender.REMOTE_PORT, Primitive.createInteger(remoteAddr.getPort()));
         response.setValue(TCPSender.LOCAL_HOST, localAddr.getAddress().getHostAddress());
         response.setValue(TCPSender.LOCAL_PORT, Primitive.createInteger(localAddr.getPort()));
         response.setValue(TCPSender.CHANNEL, m_channel.getName());

         if (mis.next(response))
         {
            // get body
            BufferedInputStream bufStream = new BufferedInputStream(new NoCloseInputStream(mis));
            Object body;
View Full Code Here


          */
         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);
                  }
View Full Code Here

TOP

Related Classes of nexj.core.integration.MessageInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.