Package nexj.core.meta.integration

Examples of nexj.core.meta.integration.Message


  
   public void testDuplicateNames() throws Exception
   {
      Map msgRegistry = getMessageRegistry(XSDMessageImporterTest.class.getResource("duplicateelements.xsd"));

      Message msg = (Message)msgRegistry.get("validTime");
      StringWriter writer = new StringWriter();
      XMLMetadataExporter exporter = new XMLMetadataExporter(writer);
      exporter.exportMessage(msg);

      // Check result
      assertEquals("validTime", msg.getName());

      CompositeMessagePart comp = msg.getRoot();

      assertTrue(comp.getDescription().startsWith("An interval of time specifying"));
      assertEquals(CompositeMessagePart.RANDOM, comp.getAggregation());
      assertEquals(4, comp.getPartCount());
View Full Code Here


   }

   public void testComplexType() throws Exception
   {
      Map msgRegistry = getMessageRegistry(XSDMessageImporterTest.class.getResource("complextype.xsd"));
      Message msg = (Message)msgRegistry.get("validTime");
      StringWriter writer = new StringWriter();
      XMLMetadataExporter exporter = new XMLMetadataExporter(writer);
      exporter.exportMessage(msg);

      // Check result
      assertEquals("validTime", msg.getName());

      CompositeMessagePart comp = msg.getRoot();

      assertEquals(1, comp.getPartCount());
      comp = (CompositeMessagePart)comp.getPart(0);
      assertEquals("elemwithtypereferral", comp.getName());
      assertTrue(comp instanceof CompositeMessagePartRef);
      comp = ((CompositeMessagePartRef)comp).getRefPart();

      msg = (Message)msgRegistry.get("IVL_TS");
      assertNotNull(msg);
      assertSame(comp, msg.getRoot());
      assertEquals(1, comp.getPartCount());
      assertEquals("low", comp.getPart(0).getName());
      assertEquals(Primitive.ANY_ORDINAL, ((PrimitiveMessagePart)comp.getPart(0)).getType().getOrdinal());

      // Test export
View Full Code Here

         TransferObject tobj = (TransferObject)obj;
         String sDerivedMessageName = tobj.getClassName();

         if (!StringUtil.isEmpty(sDerivedMessageName))
         {
            Message derivedMessage = m_context.getMetadata().getMessage(sDerivedMessageName);
            Message baseMessage = null;

            if (parentPart == null// root of message (includes root part referencing another message)
            {
               baseMessage = ((RootXMLMessagePartMapping)part.getRoot().getMapping()).getRootMessage();
            }
View Full Code Here

            if (data instanceof TransferObject)
            {
               // Write non-primitive ANY-type data
               String sClassName = ((TransferObject)data).getClassName();
               Interface iface = ((XMLMessagePartMapping)part.getMapping()).getInterface();
               Message msg;

               try
               {
                  if (iface != null)
                  {
                     msg = iface.getRequestTable().findMessage(sClassName);

                     if (msg == null)
                     {
                        msg = iface.getResponseTable().findMessage(sClassName);
                     }

                     // Support inheritance in xsd:anyType tables
                     if (msg == null)
                     {
                        Message derivedMessage = m_context.getMetadata().getMessage(sClassName);

                        msg = iface.getRequestTable().findBaseMessage(derivedMessage);

                        if (msg == null)
                        {
View Full Code Here

      boolean bRestartable = false;
      byte nAcceptedEnvelopes = 0;

      for (Iterator itr = table.getMessageIterator(); itr.hasNext();)
      {
         Message message = (Message)itr.next();
         RootXMLMessagePartMapping mapping = (RootXMLMessagePartMapping)message.getRoot().getMapping();
         Message old = (Message)map.put((mapping.getNamespace() != null) ? mapping.getNamespace().getURI() : "",
            mapping.getNodeName(), message);

         if (old != null)
         {
            if (old.isUpcast(message) && old.getDerivation() != Message.DERIVATION_FINAL)
            {
               // Re-put old
               map.put((mapping.getNamespace() != null) ? mapping.getNamespace().getURI() : "",
                  mapping.getNodeName(), old);
            }
            else if (message.isUpcast(old) && message.getDerivation() != Message.DERIVATION_FINAL)
            {
               // base message "message" is already in table
            }
            else
            {
               throw new MetadataException("err.meta.integration.xml.dupMessageElement",
                  new Object[]{mapping.getNodeName(), old.getName(), message.getName()});
            }
         }

         nAcceptedEnvelopes |= mapping.getEnvelope();
View Full Code Here

                        CompositeMessagePart referencedPart = ref.getRefPart();

                        tobj.setClassName(referencedPart.getName());

                        RootXMLMessagePartMapping refRootMapping = (RootXMLMessagePartMapping)referencedPart.getMapping();
                        Message derivedMessage = getDerivedMessage(attributes, refRootMapping, part.getFullPath());

                        if (derivedMessage != null)
                        {
                           Message referencedMessage = refRootMapping.getRootMessage();

                           Message.validatePolymorphism(referencedMessage, derivedMessage, part);
                           tobj.setClassName(derivedMessage.getName());
                           part = derivedMessage.getRoot();
                           valuePart = ((XMLMessagePartMapping)part.getMapping()).getValuePart();
View Full Code Here

      RootXMLMessagePartMapping rootMapping;

      if (part == null)
      {
         // Identify the XML message being parsed
         Message msg = (Message)m_messageMap.get(sURI, sLocalName);

         if (msg != null)
         {
            part = msg.getRoot();
         }

         if (part == null)
         {
            if (bError)
            {
               throw new IntegrationException("err.integration.xml.unsupportedMessage",
                  new Object[]{sURI, sLocalName});
            }

            return false;
         }

         rootMapping = (RootXMLMessagePartMapping)part.getMapping();
         assert m_stack.getSize() == 1;
         m_stack.setTopMessagePart(part);
         m_stack.setTopBaseMessagePart(part);

         if (s_logger.isDebugEnabled())
         {
            s_logger.debug("Identified the XML message as \"" + part.getName() + "\"");
         }

         ((TransferObject)m_stack.getTopObject()).setClassName(part.getName());
         m_headerPart = rootMapping.getHeaderPart();
         m_bRestart = (rootMapping.getSchemaResourceMap() != null) || (m_headerPart != null);
         m_baseRootPart = part;
      }
      else
      {
         // Verify root element of message being parsed
         rootMapping = (RootXMLMessagePartMapping)part.getMapping();

         if (!matches(m_baseRootPart, sURI, sLocalName))
         {
            if (bError)
            {
               throw new IntegrationException("err.integration.xml.invalidDocRoot",
                  new Object[]{sURI, sLocalName});
            }

            return false;
         }

         if (m_headerPart != rootMapping.getHeaderPart())
         {
            m_headerPart = rootMapping.getHeaderPart();
            m_bRestart = true;
         }
      }

      TransferObject tobj = (TransferObject)m_stack.getTopObject();

      if (!m_bRestart)
      {
         parseAttributes(tobj, (CompositeMessagePart)part, attributes);
      }

      Message derivedMessage = getDerivedMessage(attributes, rootMapping, part.getFullPath());
      Message primaryMessage = rootMapping.getRootMessage();

      tobj.setClassName(primaryMessage.getName());

      if (derivedMessage != null)
      {
         CompositeMessagePart derivedMessageRoot = derivedMessage.getRoot();
         RootXMLMessagePartMapping derivedMessageRootMapping = (RootXMLMessagePartMapping)derivedMessageRoot.getMapping();

         Message.validatePolymorphism(primaryMessage, derivedMessage, derivedMessageRoot);
         m_stack.setTopBaseMessagePart(part);
         part = derivedMessageRoot;
         m_stack.setTopMessagePart(part);
         tobj.setClassName(derivedMessage.getName());

         MessagePart headerPart = derivedMessageRootMapping.getHeaderPart();

         if (m_headerPart != headerPart)
         {
            m_headerPart = headerPart;
            m_bRestart = true;
         }
      }
      else
      {
         if (primaryMessage.getDerivation() == Message.DERIVATION_ABSTRACT)
         {
            throw new IntegrationException("err.integration.abstractMessage",
               new Object[]{primaryMessage.getName(), part.getFullPath()});
         }
      }

      m_bProcessRoot = false;
View Full Code Here

   {
      if (anyPart.getType() == Primitive.ANY)
      {
         Interface iface = ((XMLMessagePartMapping)anyPart.getMapping()).getInterface();
         XMLMessageParserTable table = (XMLMessageParserTable)iface.getRequestTable().getParserTable();
         Message msg = (Message)table.getMessageMap().get(sURI, sLocalName);
         MessagePart part = null;

         if (msg == null)
         {
            table = (XMLMessageParserTable)iface.getResponseTable().getParserTable();
            msg = (Message)table.getMessageMap().get(sURI, sLocalName);
         }

         if (msg != null)
         {
            part = msg.getRoot();
         }

         if (part == null)
         {
            return false;
         }

         Message derivedMessage = getDerivedMessage(attributes, (RootXMLMessagePartMapping)part.getMapping(), null);
         MessagePart basePart = part;

         if (derivedMessage != null)
         {
            if (s_logger.isDebugEnabled())
            {
               s_logger.debug("Identified the XML anyType message as \"" + msg.getName() +
                  "\", using derived message \"" + derivedMessage.getName() + "\"");
            }

            msg = derivedMessage;
            part = derivedMessage.getRoot();
         }
         else
         {
            if (s_logger.isDebugEnabled())
            {
View Full Code Here

    * attribute but no derived message corresponding to that type can be found in the mapping.
    */
   public Message getDerivedMessage(Attributes attributes, RootXMLMessagePartMapping mapping, String sLocation)
   {
      String sType = attributes.getValue(XMLUtil.XSI_NAMESPACE, "type");
      Message message = mapping.getRootMessage();

      if (sType != null && (message.getBaseMessage() != null || message.getDerivedMessageCount() != 0))
      {
         String sURI = getURILocalPart(sType);
         Message derivedMessage = mapping.getXSDTypeMessage(sURI, m_sLocalName);

         if (sLocation != null && derivedMessage == null)
         {
            throw new IntegrationException("err.integration.xml.unknownType",
               new Object[]{sType, sLocation});
View Full Code Here

         XSDMessageImporter.this.incrementMessageRefCount(typeDef);
      }
     
      public final void fixup()
      {
         Message msg = XSDMessageImporter.this.getRootMessage(m_typeDef);

         m_partRef.setRefPart(msg.getRoot());

         if (msg.getRoot().getDescription() != null)
         {
            if (m_partRef.getDescription() == null)
            {
               m_partRef.setDescription(msg.getRoot().getDescription());
            }
            else
            {
               m_partRef.setDescription(m_partRef.getDescription() + "\r" + msg.getRoot().getDescription());
            }
         }

         convertToMessageInstance(msg);
      }
View Full Code Here

TOP

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

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.