Package nexj.core.util

Examples of nexj.core.util.HashHolder


    * @param connectionsElement The DOM element containing the environment. Can be null to load default connections.
    * @param sConnectionsName The name of the environment.
    */
   protected void loadConnections(Element connectionsElement, final String sConnectionsName)
   {
      final Set connectionSet = new HashHolder();

      if (connectionsElement != null)
      {
         XMLUtil.withFirstChildElement(connectionsElement, "DataSourceConnections", false, new ElementHandler()
         {
            public void handleElement(Element connectionsElement)
            {
               XMLUtil.forEachChildElement(connectionsElement, null,
                  m_helper.new ElementHandler("dataSource")
               {
                  protected String getName(Element element)
                  {
                     return XMLUtil.getReqStringAttr(element, "dataSource");
                  }

                  public void handleElement(Element connectionElement, String sDataSource)
                  {
                     DataSource source = m_metadata.getDataSource(sDataSource);
                     String sExpectedElement = m_metadata.getDataSourceTypeElement(source.getType()) + "Connection";

                     if (!sExpectedElement.equals(connectionElement.getNodeName()))
                     {
                        throw new MetadataException("err.meta.dataSourceConnectionElement",
                           new Object[]{connectionElement.getNodeName(), source.getName(),
                           sConnectionsName, sExpectedElement});
                     }

                     if (!connectionSet.add(source))
                     {
                        throw new MetadataException("err.meta.dupDataSourceConnection", new Object[]{sDataSource});
                     }

                     String sAdapter = XMLUtil.getStringAttr(connectionElement, "adapter");

                     if (sAdapter != null)
                     {
                        source.setAdapter(source.getType().getAdapter(sAdapter));
                     }

                     source.setReadLimit(XMLUtil.getIntAttr(connectionElement, "readLimit", source.getReadLimit()));

                     //Load DataSource-specific attributes.
                     ((XMLPersistenceMetadataLoader)m_helper.getClassInstance(source.getType().getLoader()))
                        .loadConnection(connectionElement, source, XMLMetadataLoader.this);
                  }
               });
            }
         });
      }

      //Call loadConnection to initialize DataSources with no entry in the .connections file.
      for (Iterator itr = m_metadata.getDataSourceIterator(); itr.hasNext();)
      {
         DataSource source = (DataSource)itr.next();

         if (!connectionSet.contains(source))
         {
            int nCookie = getHelper().pushMarker(MetadataValidationException.TYPE_NAME, "DataSourceConnection");
            getHelper().pushMarker("dataSourceConnection", source.getName());

            try
            {
               ((XMLPersistenceMetadataLoader)m_helper.getClassInstance(source.getType().getLoader()))
                  .loadConnection(null, source, XMLMetadataLoader.this);
            }
            catch (MetadataException e)
            {
               m_helper.addException(e);
            }
            finally
            {
               m_helper.restoreMarker(nCookie);
            }
         }
      }

      if (connectionsElement != null && !m_bIntegrationExcluded)
      {
         XMLUtil.withFirstChildElement(connectionsElement, "ChannelConnections", false, new ElementHandler()
         {
            public void handleElement(Element connectionsElement)
            {
               XMLUtil.forEachChildElement(connectionsElement, null,
                  m_helper.new ElementHandler("channel")
               {
                  protected String getName(Element element)
                  {
                     return XMLUtil.getReqStringAttr(element, "channel");
                  }

                  public void handleElement(Element connectionElement, String sChannel)
                  {
                     Channel channel = m_metadata.getChannel(sChannel);
                     String sExpectedElement = m_metadata.getChannelTypeElement(channel.getType()) + "Connection";

                     if (!sExpectedElement.equals(connectionElement.getNodeName()))
                     {
                        throw new MetadataException("err.meta.channelConnectionElement",
                           new Object[]{connectionElement.getNodeName(), channel.getName(),
                           sConnectionsName, sExpectedElement});
                     }

                     if (!connectionSet.add(channel))
                     {
                        throw new MetadataException("err.meta.dupChannelConnection", new Object[]{sChannel});
                     }

                     //Load Channel-specific attributes
                     ((XMLIntegrationMetadataLoader)m_helper.getClassInstance(channel.getType().getLoader()))
                        .loadConnection(connectionElement, channel, XMLMetadataLoader.this);
                  }
               });
            }
         });
      }

      //Call loadConnection to initialize Channels with no entry in the .connections file.
      for (Iterator itr = m_metadata.getChannelIterator(); itr.hasNext();)
      {
         Channel channel = (Channel)itr.next();

         if (!connectionSet.contains(channel))
         {
            int nCookie = getHelper().pushMarker(MetadataValidationException.TYPE_NAME, "ChannelConnection");
            getHelper().pushMarker("channelConnection", channel.getName());

            try
View Full Code Here


      {
         XMLUtil.withFirstChildElement(enumerationElement, "Locales", false, new ElementHandler()
         {
            public void handleElement(Element localesElement)
            {
               final Set localeSet = new HashHolder();

               XMLUtil.forEachChildElement(localesElement, "Locale",
                  m_helper.new ElementHandler("locale")
               {
                  public void handleElement(Element localeElement, String sLocale)
                  {
                     if (!localeSet.add(sLocale))
                     {
                        throw new MetadataException("err.meta.enumLocaleDup",
                           new Object[]{sLocale, sEnumerationName});
                     }

                     XMLUtil.getReqStringAttr(localeElement, "caption");
                  }
               });
            }
         });
      }

      final Set valueSet = new HashHolder();
      m_enumerationValueMap.put(sEnumerationName, valueSet);

      XMLUtil.withFirstChildElement(enumerationElement, "Values", false, new ElementHandler()
      {
         public void handleElement(Element valuesElement)
         {
            final Set nameSet = new HashHolder();
            final Set behaveAsSet = new HashHolder();
            final Set externSet = new HashHolder();
            final List fixupList = new ArrayList();

            XMLUtil.forEachChildElement(valuesElement, "Value",
               m_helper.new ElementHandler("value")
            {
               public void handleElement(Element valueElement, String sName)
               {
                  XMLMetadataHelper.validateName(sName);

                  fixupList.add(sName);

                  if (!nameSet.add(sName))
                  {
                     throw new MetadataException("err.meta.enumValueNameDup",
                        new Object[]{sName, sEnumerationName});
                  }

                  final String sValue = XMLUtil.getReqStringAttr(valueElement, "value");

                  if (!valueSet.add(sValue))
                  {
                     throw new MetadataException("err.meta.enumValueDup",
                        new Object[]{sValue, sEnumerationName});
                  }

                  fixupList.add(sValue);

                  boolean bHasBehavior = XMLUtil.getBooleanAttr(valueElement, "hasBehavior", false);

                  fixupList.add(Boolean.valueOf(bHasBehavior));

                  String sBehaveAsValue = XMLUtil.getStringAttr(valueElement, "behaveAsValue");

                  if (sBehaveAsValue != null)
                  {
                     if (bHasBehavior)
                     {
                        if (!sBehaveAsValue.equals(sValue))
                        {
                           throw new MetadataException("err.meta.enumBehaveAsValueMismatch",
                              new Object[]{sBehaveAsValue, sValue, sEnumerationName});
                        }
                     }
                     else
                     {
                        if (sBehaveAsValue.equals(sValue))
                        {
                           throw new MetadataException("err.meta.enumInvalidSelfReference",
                              new Object[]{sValue, sEnumerationName});
                        }

                        behaveAsSet.add(sBehaveAsValue);
                     }
                  }

                  String sExternValue = XMLUtil.getStringAttr(valueElement, "externalValue");

                  if (sExternValue != null)
                  {
                     if (!externSet.add(sExternValue))
                     {
                        throw new MetadataException("err.meta.enumExternValueDup",
                           new Object[]{sExternValue, sEnumerationName});
                     }
                  }

                  final String sParentValue = XMLUtil.getStringAttr(valueElement, "parentValue");

                  if (sParentValue != null)
                  {
                     if (sParentEnumeration == null)
                     {
                        throw new MetadataException("err.meta.enumParentValue", new Object[]{sEnumerationName});
                     }

                     m_inheritanceFixupList.add(new ContextFixup(m_helper)
                     {
                        public void fixup()
                        {
                           Metaclass parent = m_metadata.getMetaclass(sParentEnumeration);

                           if (!((Set)m_enumerationValueMap.get(sParentEnumeration)).contains(parent.getAttribute("value").getType().convert(sParentValue)))
                           {
                              throw new MetadataLookupException("err.meta.enumParentValueLookup", sParentValue, sParentEnumeration);
                           }
                        }
                     });
                  }
                  else
                  {
                     if (sParentEnumeration != null)
                     {
                        throw new MetadataException("err.meta.enumNoParentValue", new Object[]{sValue, sEnumerationName});
                     }
                  }

                  if (m_bValidatedOnly)
                  {
                     XMLUtil.withFirstChildElement(valueElement, "Locales", false, new ElementHandler()
                     {
                        public void handleElement(Element localesElement)
                        {
                           final Set localeSet = new HashHolder();

                           XMLUtil.forEachChildElement(localesElement, "Locale",
                              m_helper.new ElementHandler("locale")
                           {
                              public void handleElement(Element localeElement, String sLocale)
                              {
                                 if (!localeSet.add(sLocale))
                                 {
                                    throw new MetadataException("err.meta.enumValueLocaleDup",
                                       new Object[]{sLocale, sValue, sEnumerationName});
                                 }
View Full Code Here

      script.setActivity(activity);
      script.setMacro(macro);

      NamedNodeMap attributeMap = stepElement.getAttributes();
      Set attributeSet = new HashHolder(attributeMap.getLength());

      for (int i = 0; i < attributeMap.getLength(); ++i)
      {
         attributeSet.add(attributeMap.item(i).getNodeName());
      }

      Object[] args = new Object[macro.getArgumentCount()];

      for (int i = 0, n = macro.getArgumentCount(); i < n; ++i)
      {
         FlowMacro.Argument arg = macro.getArgument(i);
         String sValue = stepElement.getAttribute(arg.getName());

         if (arg.getType() == null || arg.getType() == Primitive.ANY)
         {
            Object value = helper.parse(sValue, arg.getType() == null,
               flow.getPosMap(), Undefined.VALUE,
               machine.getGlobalEnvironment());

            if (bFull)
            {
               script.setArgumentValue(i, value);
            }

            args[i] = (value == Undefined.VALUE) ? arg.getDefault() : value;
         }
         else
         {
            if (sValue == null)
            {
               args[i] = arg.getDefault();

               if (bFull)
               {
                  script.setArgumentValue(i, Undefined.VALUE);
               }
            }
            else
            {
               args[i] = arg.getType().convert(sValue);

               if (bFull)
               {
                  script.setArgumentValue(i, args[i]);
               }
            }
         }

         if (args[i] == Undefined.VALUE)
         {
            throw new MetadataException("err.meta." + flow.getPropName() + ".missingMacroArg",
               new Object[]{arg.getName(), macro.getName(), flow.getFullName()});
         }

         attributeSet.remove(arg.getName());
      }

      attributeSet.remove("name");
      attributeSet.remove("caption");
      attributeSet.remove("description");
      attributeSet.remove("layout");

      if (attributeSet.size() != 0)
      {
         throw new MetadataException("err.meta." + flow.getPropName() + ".macroArgLookup",
            new Object[]{attributeSet.iterator().next(), macro.getName(), flow.getFullName()});
      }

      script.setBody(new Pair(machine.invoke(macro.getFunction(), args)));

      Lookup flowPosMap = flow.getPosMap();
View Full Code Here

    * @param schema The schema to find the references.
    * @return A set of schemas referenced by the given schema.
    */
   public static Set getReferences(Schema schema)
   {
      Set schemaRefSet = new HashHolder();

      for (Iterator itemIterator = schema.getItemIterator(); itemIterator.hasNext(); )
      {
         addReferences((SchemaItem)itemIterator.next(), schemaRefSet, schema);
      }
View Full Code Here

                  appendParameter(qryBuf, sName, value, bFirst);
                  bFirst = false;

                  if (paramSet == null)
                  {
                     paramSet = new HashHolder(4);
                  }

                  paramSet.add(sName);
               }
            }
View Full Code Here

               Boolean.TRUE
            });

            m_sQueueName = (String)dispatcher.getValue("QUEUE_NAME");
            m_semaphoreMap = new HashTab();
            m_blockingSet = new HashHolder();
            m_nodeByProcessingMessageIdMap = new HashTab();
            m_processingMessagesByNodeNameMap = new HashTab();
            m_messageLoadAttributes = (Pair)dispatcher.getValue("SELECT_ATTRIBUTES", "LOAD_ATTRIBUTES");

            if (startNode(result, dispatcher, bReset, context))
View Full Code Here

            {
               Set transactionSet = (Set)m_processingMessagesByNodeNameMap.get(sNode);

               if (transactionSet == null)
               {
                  transactionSet = new HashHolder(1);
                  m_processingMessagesByNodeNameMap.put(sNode, transactionSet);
               }

               transactionSet.add(binOID);
            }
View Full Code Here

     
      String sPaths = config.getInitParameter("gzipped");
     
      if (sPaths != null)
      {
         m_gzippedSet = new HashHolder();
        
         for (StringTokenizer tokenizer = new StringTokenizer(sPaths, ","); tokenizer.hasMoreTokens();)
         {
            m_gzippedSet.add(tokenizer.nextToken().trim());
         }
View Full Code Here

    */
   protected void reset()
   {
      m_optionalMetaclassMap = new HashTab/*<String, Metaclass>*/();
      m_optionalXMLMetatypeMap = new HashTab/*<QName, XMLMetatype>*/();
      m_requiredMetaclassSet = new HashHolder/*<Metaclass>*/();
      m_requiredXMLMetatypeMap = new HashTab/*<QName, XMLMetatype>*/();

      // define array types for all XSD types since that is how arrays might be marshalled
      for (int i = 0; i <= Primitive.MAX_COUNT; ++i)
      {
View Full Code Here

    */
   public void addIgnore(String sPath)
   {
      if (m_ignoreSet == null)
      {
         m_ignoreSet = new HashHolder();
      }
     
      m_ignoreSet.add(sPath);
   }
View Full Code Here

TOP

Related Classes of nexj.core.util.HashHolder

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.