Package nexj.core.rpc

Examples of nexj.core.rpc.TransferObject


   /**
    * @see nexj.core.integration.Sender#send(java.util.Collection)
    */
   public void send(Collection col) throws IntegrationException
   {
      TransferObject tobj;
      TCPConnection con = null;
      InetSocketAddress prevRemoteAddr = null;
      InetSocketAddress prevLocalAddr = null;
      KeyStore prevCertificate = null;
      String sPrevPassword = null;
View Full Code Here


                  producer = session.createProducer(destination);
                  bRetry = false;

                  for (Iterator itr = col.iterator(); itr.hasNext();)
                  {
                     TransferObject tobj = (TransferObject)itr.next();
                     Boolean persistent = (Boolean)tobj.findValue(PERSISTENT);
                     int nPersistenceMode =
                        ((persistent == null) ? m_channel.isPersistent() : persistent.booleanValue()) ?
                        DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
                     Number priority = (Number)tobj.findValue(PRIORITY);
                     int nPriority = (priority == null) ? m_channel.getPriority() : priority.intValue();
                     Number ttl = (Number)tobj.findValue(TTL);
                     long lTTL = (ttl == null) ? m_channel.getTimeToLive() : ttl.longValue();

                     m_sentCounter.add(1);
                     producer.send(createMessage(session, tobj), nPersistenceMode, nPriority, lTTL);
                  }
View Full Code Here

      else
      {
         message.setJMSReplyTo(getDestination((String)replyTo));
      }

      TransferObject properties = (TransferObject)tobj.findValue(PROPERTIES);

      if (properties != null)
      {
         for (PropertyIterator itr = properties.getIterator(); itr.hasNext();)
         {
            String sName = (String)itr.next();
            Object value = itr.getValue();

            if (value instanceof BigDecimal)
View Full Code Here

   {
      nexj.core.runtime.Context contextSaved = ThreadContextHolder.getContext();

      for (Iterator itr = col.iterator(); itr.hasNext();)
      {
         TransferObject tobj = (TransferObject)itr.next();
         Transaction tx = null;

         try
         {
            // Clone the object graph
View Full Code Here

                     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))
                     {
View Full Code Here

    * @return The converted message.
    * @throws JMSException if an error occurs.
    */
   public TransferObject createMessage(Message message) throws JMSException
   {
      TransferObject tobj = new TransferObject();

      tobj.setClassName("MessageQueue");
      tobj.setValue(JMSSender.CHANNEL, m_channel.getName());
      setJMSProperties(tobj, message);

      if (message instanceof TextMessage)
      {
         tobj.setValue(JMSSender.BODY, ((TextMessage)message).getText());
      }
      else if (message instanceof ObjectMessage)
      {
         tobj.setValue(JMSSender.BODY, ((ObjectMessage)message).getObject());
      }
      else if (message instanceof BytesMessage)
      {
         BytesMessage msg = (BytesMessage)message;

         byte[] buf = new byte[2048];
         byte[] data = null;
         int nCount = 0;
         int nRead;

         do
         {
            nRead = msg.readBytes(buf);

            if (nRead > 0)
            {
               if (data == null)
               {
                  nCount = nRead;
                  data = buf;
                  buf = new byte[2048];
               }
               else
               {
                  if (data.length - nCount < nRead)
                  {
                     byte[] tmp = new byte[data.length << 1];
  
                     System.arraycopy(data, 0, tmp, 0, nCount);
                     data = tmp;
                  }

                  System.arraycopy(buf, 0, data, nCount, nRead);
                  nCount += nRead;
               }
            }
         }
         while (nRead == buf.length);

         buf = new byte[nCount];

         if (nCount > 0)
         {
            System.arraycopy(data, 0, buf, 0, nCount);
         }

         tobj.setValue(JMSSender.BODY, new Binary(buf));
      }
      else if (message instanceof MapMessage)
      {
         MapMessage msg = (MapMessage)message;
         TransferObject map = new TransferObject();
        
         for (Enumeration e = msg.getMapNames(); e.hasMoreElements();)
         {
            String sName = (String)e.nextElement();
            map.setValue(sName, convert(msg.getObject(sName)));
         }

         tobj.setValue(JMSSender.BODY, map);
      }
      else if (message instanceof StreamMessage)
View Full Code Here

      tobj.setValue(MESSAGE_ID, message.getJMSMessageID());
      tobj.setValue(JMSSender.PERSISTENT, Boolean.valueOf(message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT));
      tobj.setValue(JMSSender.PRIORITY, Primitive.createInteger(message.getJMSPriority()));

      TransferObject properties = getProperties(message);

      if (properties != null)
      {
         tobj.setValue(JMSSender.PROPERTIES, properties);
      }
View Full Code Here

      if (!e.hasMoreElements())
      {
         return null;
      }

      TransferObject properties = new TransferObject();

      while (e.hasMoreElements())
      {
         String sName = (String)e.nextElement();
        
         properties.setValue(sName, convert(message.getObjectProperty(sName)));
      }

      return properties;
   }
View Full Code Here

                  }
               }

               if (m_channel.getQueue() != null)
               {
                  TransferObject tobj = new TransferObject(1);

                  tobj.setClassName("MessageQueue");
                  tobj.setValue(UDPSender.BODY, body);
                  context.getUnitOfWork().addMessage(m_channel.getQueue(), tobj);
               }

               if (isBound(m_channel, context))
               {
                  TransferObject tobj = new TransferObject(3);
                  InetSocketAddress iaddr = (InetSocketAddress)address;

                  tobj.setClassName("UDP");
                  tobj.setValue(UDPSender.HOST, iaddr.getAddress().getHostAddress());
                  tobj.setValue(UDPSender.PORT, Primitive.createInteger(iaddr.getPort()));
                  tobj.setValue(UDPSender.BODY, body);

                  receive(tobj, m_channel, context);
               }
            }
         }
View Full Code Here

                  )
               );
           
            if (isBound(m_channel, context))
            {
               TransferObject tobj = new TransferObject(2);

               tobj.setClassName("File");
               tobj.setValue(FileSender.FILE, message.getOriginalName());

               BufferedInputStream bufStream = new BufferedInputStream(message.getInputStream());

               //Decode channel data
               if (m_channel.getEncoding() != null)
               {
                  Reader ireader;
                  String sEncoding = m_channel.getEncoding().toLowerCase(Locale.ENGLISH);

                  ireader = new BufferedReader(new InputStreamReader(UTF8BOMIgnoreInputStream.wrap(bufStream, sEncoding), m_channel.getEncoding()));
                 
                  tobj.setValue(Sender.BODY, new ReaderInput(ireader));
               }
               else
               {
                  tobj.setValue(Sender.BODY, new StreamInput(bufStream));
               }
              
               receive(tobj, m_channel, context);
            }
         }
View Full Code Here

TOP

Related Classes of nexj.core.rpc.TransferObject

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.