Package nexj.core.meta.integration

Examples of nexj.core.meta.integration.Channel


         sChannel = sPath.substring(1, i);
         sPath = sPath.substring(i);
      }

      Metadata metadata = m_context.getMetadata();
      Channel channel = metadata.getChannel(sChannel);

      if (!(channel instanceof HTTPChannel) || !channel.isReceivable())
      {
         throw new RPCException("err.rpc.http.notReceiver", new Object[]{sChannel});
      }
     
      HTTPChannel http = (HTTPChannel)channel;

      if (http.isSecure() && !m_request.isSecure())
      {
         throw new RequestException("err.rpc.http.insecure", new Object[]{sChannel});
      }

      // Deny anonymous access to non-anonymous channels, and vice-versa
      if (HTTPUtil.isAnonymousRequest(m_request, metadata))
      {
         if (http.getAuthMode() != HTTPChannel.AUTH_NONE)
         {
            throw new SecurityViolationException("err.rpc.anonymous");
         }
      }
      else if (http.getAuthMode() == HTTPChannel.AUTH_NONE)
      {
         throw new SecurityViolationException("err.rpc.notAnonymous", new Object[]{sChannel});
      }

      boolean bRequestUsesCertificateAuth = HTTPUtil.isUsingClientCertificateAuthentication(m_request);

      // Deny access to client certificate channels if no certificate present
      if (http.getAuthMode() == HTTPChannel.AUTH_CERT)
      {
         if (!bRequestUsesCertificateAuth)
         {
            throw new SecurityViolationException("err.rpc.http.certificateRequired", new Object[]{sChannel});
         }

         X509Certificate[] certs = (X509Certificate[])m_request.getAttribute(HTTPUtil.CLIENT_CERTIFICATE_ATTRIBUTE_NAME);

         if (certs == null)
         {
            throw new SecurityViolationException("err.integration.missingCertificate", new Object[]{sChannel});
         }

         // The certificate should now be validated against allowed certificates for this channel.
         if (!HTTPUtil.isCertificateMatched(http.getTrustedCertificate(), certs))
         {
            throw new SecurityViolationException("err.integration.unauthorized", new Object[]{sChannel});
         }
      }
      else if (bRequestUsesCertificateAuth)
      {
         // Deny access to non-certificate-auth channels through certificate authentication.
         throw new SecurityViolationException("err.integration.unauthorized", new Object[]{sChannel});
      }

      if (http.getPrivilege() != null && !m_context.getPrivilegeSet().contains(http.getPrivilege()))
      {
         throw new SecurityViolationException("err.integration.unauthorized", new Object[]{sChannel});
      }
     
      m_lMaxRequestSize = http.getMaxRequestSize();

      HTTPAdapter adapter = (HTTPAdapter)channel.getReceiver().getInstance(m_context);

      adapter.setServer(this);

      String sMethod = m_request.getMethod();
      boolean bImplemented;

      if (sMethod.equals("POST"))
      {
         bImplemented = http.isPostImplemented();
      }
      else if (sMethod.equals("GET"))
      {
         bImplemented = http.isGetImplemented();

         if (channel.getBindingCount() > 0 &&
            GENERATE_WSDL_QUERY.equalsIgnoreCase(m_request.getQueryString()))
         {
            SchemaExporter exporter = null;
            MessageTable msgTable = channel.getMessageTable();

            if (msgTable != null)
            {
               Format format = msgTable.getFormat();
View Full Code Here


    * @param tobj the message.
    */
   protected void execute(final TransferObject tobj)
   {
      final String sQueueName = (String)tobj.getValue(ObjectSender.CHANNEL);
      final Channel channel = m_metadata.getChannel(sQueueName);

      run(new ContextRunnable()
      {
         public void err(Throwable t, InvocationContext context) throws Throwable
         {
            s_logger.error("Failed to receive non-persisted message " + tobj, t);
         }

         public String getClientAddress() throws Throwable
         {
            return sQueueName;
         }

         public String getUser() throws Throwable
         {
            return (String)tobj.getValue(ObjectSender.USER);
         }

         public boolean isEnabled() throws Throwable
         {
            return true;
         }

         public void run(InvocationContext context) throws Throwable
         {
            // set unit of work timeout
            Number timeout = ((Number)((Instance)m_metadata.getMetaclass("SysQueue")
               .invoke("getQueue", new Object[] {sQueueName})).getValue("timeout"));
            long lUnitOfWorkTimeout = (timeout == null) ? 0 : timeout.longValue();
            TransactionManager tm = (TransactionManager)m_metadata.getComponent("System.TransactionManager").getInstance(context);

            context.getUnitOfWork().setTimeout(lUnitOfWorkTimeout);

            try
            {
               tm.setTransactionTimeout(86400); // 24 hours
               ((ObjectReceiver)channel.getReceiver().getInstance(context)).receiveServerMessage(context, null, tobj);
            }
            catch (SystemException e)
            {
               ObjUtil.rethrow(e);
            }
View Full Code Here

    * @param sQueueName the name of the queue from which the message is
    *           delivered.
    */
   protected void receive(final Binary id, final String sQueueName, final String sDispatcherId)
   {
      Channel candidateChannel = m_metadata.findChannel(sQueueName);
      final ObjectQueue channel = (candidateChannel instanceof ObjectQueue) ? (ObjectQueue)candidateChannel : null;
      final OID oid = OID.fromBinary(id);

      run(new ContextRunnable()
      {
         public void run(InvocationContext context) throws Throwable
         {
            Instance msg = readMessage(oid, Pair.append(RECEIVE_ATTRIBUTES, m_messageLoadAttributes), context);

            if (msg == null)
            {
               throw new UncheckedException("err.queueing.receive", new Object[]
               {
                  oid
               });
            }

            Metaclass dispatcherClass = m_metadata.getMetaclass("SysObjectQueueDispatcher");
            Channel candidateChannel = m_metadata.findChannel(sQueueName);
            final ObjectQueue channel = (candidateChannel instanceof ObjectQueue) ? (ObjectQueue)candidateChannel : null;

            try
            {
               receiveRun(context, sQueueName, channel, msg, dispatcherClass, sDispatcherId);
View Full Code Here

      Arrays.sort(channelArray, Named.COMPARATOR);

      for (i = 0; i < channelArray.length; ++i)
      {
         Channel channel = channelArray[i];

         if (channel.getType().getExporter() != null)
         {
            getIntegrationMetadataExporter(channel)
               .exportJ2EEDescriptor(channel, nPart, sNamespace, nContainer, nContext);
         }
      }
View Full Code Here

         String sOriginalContents = format(doc);
         Element server = doc.getDocumentElement();

         for (Iterator itr = m_metadata.getChannelIterator(); itr.hasNext();)
         {
            Channel channel = (Channel)itr.next();

            if (channel instanceof Mail && channel.isEnabled())
            {
               XMLUtil.removeNode(XMLUtil.findChildElement(server, "mbean", "name", "jboss:service=" + SysUtil.NAMESPACE + '/' + ((Mail)channel).getAlias()));
            }
         }
View Full Code Here

      String sOriginalContents = format(doc);
      Element connectionFactories = doc.getDocumentElement();

      for (Iterator itr = m_metadata.getChannelIterator(); itr.hasNext();)
      {
         Channel channel = (Channel)itr.next();

         if (channel instanceof MessageQueue && channel.isEnabled())
         {
            MessageQueue mq = (MessageQueue)channel;

            String sConnFactoryType = (channel.isTransactional()) ? "tx-connection-factory" : "no-tx-connection-factory";

            if (mq.isConnectionFactoryManaged())
            {
               String sCFJNDIName = getCFJNDIName(mq);
               Element connectionFactory = XMLUtil.findChildElementBySubelement(
                  connectionFactories, "tx-connection-factory", "jndi-name", sCFJNDIName);

               /*
                * If we change from tx-connection-factory to no-tx-connection-factory or the other way around
                * we delete the old definitions and create new ones from scratch
                */
               if (connectionFactory != null)
               {
                  if (!channel.isTransactional())
                  {
                     XMLUtil.removeNode(connectionFactory);

                     connectionFactory = null;
                  }
               }
               else
               {
                  connectionFactory = XMLUtil.findChildElementBySubelement(
                     connectionFactories, "no-tx-connection-factory", "jndi-name", sCFJNDIName);

                  if (connectionFactory != null)
                  {
                     if (channel.isTransactional())
                     {
                        XMLUtil.removeNode(connectionFactory);

                        connectionFactory = null;
                     }
                  }
               }

               if (mq.getConnectionFactory() == null)
               {
                  if (connectionFactory == null)
                  {
                     connectionFactory = doc.createElement(sConnFactoryType);
                     connectionFactories.appendChild(connectionFactory);
                  }

                  XMLUtil.setChildElement(connectionFactory, CONNECTION_FACTORY_ELEMENTS,
                     "jndi-name", sCFJNDIName, false);

                  XMLUtil.removeNode(XMLUtil.findChildElement(connectionFactory, "local-transaction"));

                  if (channel.isTransactional())
                  {
                     XMLUtil.setChildElement(connectionFactory, CONNECTION_FACTORY_ELEMENTS,
                        "xa-transaction", null, false);
                  }

View Full Code Here

      String sOriginalContents = format(doc);
      Element connectionFactories = doc.getDocumentElement();

      for (Iterator itr = m_metadata.getChannelIterator(); itr.hasNext();)
      {
         Channel channel = (Channel)itr.next();

         if (channel instanceof MessageQueue && channel.isEnabled())
         {
            MessageQueue mq = (MessageQueue)channel;

            if (mq.isConnectionFactoryManaged())
            {
View Full Code Here

         XMLUtil.setChildElement(module, null, "module-option", "name", "securityDomain", "java:/jaas/" + SysUtil.NAMESPACE + "-cert", false);
      }

      for (Iterator itr = m_metadata.getChannelIterator(); itr.hasNext();)
      {
         Channel channel = (Channel)itr.next();

         if (channel instanceof MessageQueue && channel.isEnabled())
         {
            MessageQueue mq = (MessageQueue)channel;

            addApplicationPolicy(policies, getJAASDomain(channel), (channel.isTransactional()) ? "TxCM" : "NoTxCM", getCFJNDIName(mq), mq.getUser(), mq.getPassword());
         }
      }

      // Database connections require user and password
      for (Iterator dsItr = m_metadata.getDataSourceIterator(); dsItr.hasNext();)
View Full Code Here

         XMLUtil.removeNode(XMLUtil.findChildElement(policies,
            "application-policy", "name", SysUtil.NAMESPACE + "-kerberos-silent"));

         for (Iterator itr = m_metadata.getChannelIterator(); itr.hasNext();)
         {
            Channel channel = (Channel)itr.next();

            if (channel instanceof MessageQueue && channel.isEnabled())
            {
               MessageQueue mq = (MessageQueue)channel;

               if (mq.isConnectionFactoryManaged())
               {
View Full Code Here

    * @return The channel object.
    * @throws MetadataLookupException if the channel does not exist.
    */
   public Channel getChannel(String sName)
   {
      Channel channel = findChannel(sName);

      if (channel != null)
      {
         return channel;
      }
View Full Code Here

TOP

Related Classes of nexj.core.meta.integration.Channel

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.