Package nexj.core.util

Examples of nexj.core.util.Lookup$Iterator


    * @param updater The updater that sets the properties.
    * @throws JMSException
    */
   public static void setMessageProperties(Message message, MessagePropertyUpdater updater) throws JMSException
   {
      Lookup propMap = new HashTab();

      for (Enumeration enm = message.getPropertyNames(); enm.hasMoreElements();)
      {
         String sName = (String)enm.nextElement();

         propMap.put(sName, message.getObjectProperty(sName));
      }

      updater.getProperties(message);
      message.clearProperties();

      for (Lookup.Iterator itr = propMap.iterator(); itr.hasNext();)
      {
         itr.next();
         message.setObjectProperty((String)itr.getKey(), itr.getValue());
      }

View Full Code Here


    * @param nId The ordinal id of index
    * @return Name of index or null if not found
    */
   protected String getIndexName(Table table, int nId)
   {
      Lookup indexMap;

      synchronized(s_indexSchemaNameMap)
      {
         // do a lookup to map from a number to a name (e.g. exceptions return an index number in schema instead of name)
         indexMap = (Lookup)s_indexSchemaNameMap.get(table)
      }

      Integer indexOrdinal = Primitive.createInteger(nId);
      String sIndexName = null; // reset for use in lookup stage

      if (indexMap != null)
      {
         sIndexName = (String)indexMap.get(indexOrdinal);

         if (sIndexName != null || indexMap.contains(indexOrdinal))
         {
            return sIndexName;
         }
      }

      // do a refresh from DB (this might cause more hits to DB then necessary
      // if indexOrdinal is actually invalid, but would keep the cache up to date if
      // indexOrdinal is valid and DB schema changed)
      SQLConnection con = null;
      ResultSet rs = null;

      try
      {
         con = getConnection();
         rs = con.getConnection().getMetaData().getIndexInfo(table.getOwnerName(), null, table.getTableName(), false, true);
         indexMap = new HashTab();

         for (int i = 0; rs.next();)
         {
            if (rs.getShort("ORDINAL_POSITION") == 1) // this is first column of index (every index has first column)
            {
               sIndexName = rs.getString("INDEX_NAME");

               if ("PRIMARY".equals(sIndexName)) // MySQL doesn't store index name for Primary Key, it's just called "PRIMARY"
               {
                  sIndexName = table.getPrimaryKey().getName();
               }

               indexMap.put(Primitive.createInteger(++i),
                            table.getTableName() + '.' + sIndexName);
            }
         }

         sIndexName = (String)indexMap.get(indexOrdinal); // find the correct name in cache

         if (sIndexName == null)
         {
            indexMap.put(indexOrdinal, null);
         }
      }
      catch (SQLException e)
      {
         return null; // no conclusive answer
View Full Code Here

               bInstanceFilter = tobj.hasValue("instances");
            }
         }

         int nInvocationCount = request.getInvocationCount();
         Lookup identityMap = new HashTab(nInvocationCount << 1);
         Lookup eventMap = new HashTab(nInvocationCount);
         Event[] eventArray = new Event[nInvocationCount];

         argArray = new Object[nInvocationCount][];
         InstanceFactory instanceFactory = new InstanceFactory(identityMap,
            new ArrayList(nInvocationCount << 3), InstanceFactory.STATE | InstanceFactory.PRE,
            m_context);

         // Instantiate the request objects
         for (int i = 0; i < nInvocationCount; ++i)
         {
            Request.Invocation invocation = request.getInvocation(i);
            TransferObject tobj = invocation.getObject();
            String sEventName = invocation.getEventName();

            if (sEventName == null)
            {
               sEventName = tobj.getEventName();
            }

            if (tobj == null || tobj.getClassName() == null || sEventName == null)
            {
               throw new RequestException("err.rpc.requestTO");
            }

            m_context.setTransient(bTransient);

            Object[] arguments = invocation.getArguments();
            Metaclass metaclass = metadata.getMetaclass(tobj.getClassName());
            Selector selector = metaclass.getSelector(sEventName);
            Member member;
            int nArgCount;

            if (arguments != null)
            {
               nArgCount = arguments.length;
               member = selector.getMember(nArgCount);

               if (member.isStatic() && tobj.getValueCount() != 0)
               {
                  throw new RequestException("err.rpc.requestTO");
               }
            }
            else
            {
               nArgCount = tobj.getValueCount();
               member = selector.findMember(0);

               if (member == null || member.isStatic())
               {
                  member = selector.getMember(nArgCount);

                  if (!member.isStatic())
                  {
                     throw new RequestException("err.rpc.argCount",
                        new Object[]{member.getName(), metaclass.getName()});
                  }
               }
               else
               {
                  nArgCount = 0;
               }
            }

            if (member.isAttribute())
            {
               throw new RequestException("err.rpc.attributeInvocation",
                  new Object[]{member.getName(), metaclass.getName()});
            }

            if (m_context.isProtected() && member.getVisibility() != Metaclass.PUBLIC)
            {
               throw new SecurityViolationException("err.rpc.eventVisibility",
                  new Object[]{member.getName(), metaclass.getName()});
            }

            Event event = (Event)member;
            Object[] args = new Object[nArgCount + 1];

            if (arguments != null)
            {
               for (int k = 0; k < nArgCount; ++k)
               {
                  args[k + 1] = instanceFactory.instantiate(arguments[k]);
               }
            }

            if (event.isStatic())
            {
               args[0] = metaclass;

               if (arguments == null)
               {
                  int nEventArgCount = event.getArgumentCount();

                  if (event.isVarArg())
                  {
                     --nEventArgCount;
                  }

                  for (int k = 0; k < nEventArgCount; ++k)
                  {
                     args[k + 1] = instanceFactory.instantiate(tobj.getValue(event.getArgument(k).getName()));
                  }

                  if (event.isVarArg())
                  {
                     int nArg = nEventArgCount;

                     for (PropertyIterator itr = tobj.getIterator(); itr.hasNext();)
                     {
                        itr.next();

                        Argument arg = event.findArgument(itr.getName());

                        if (arg == null || arg == event.getArgument(nEventArgCount))
                        {
                           args[++nArg] = new Pair(Symbol.define(itr.getName()), instanceFactory.instantiate(itr.getValue()));
                        }
                     }
                  }
               }

               // Allow auditing of static events
               identityMap.put(tobj, null);
            }
            else
            {
               args[0] = instanceFactory.instantiate(tobj);
            }

            eventArray[i] = event;
            argArray[i] = args;
            eventMap.put(tobj, event);
         }

         Lookup diffMap = null;

         // Instantiate the transfer objects from the instance filters
         if (bInstanceFilter)
         {
            diffMap = new HashTab();

            for (int i = 0; i < nFilterCount; ++i)
            {
               m_context.setTransient(bTransient);

               TransferObject tobj = request.getFilter(i);
               Object instances = tobj.findValue("instances");

               if (instances != null)
               {
                  List instanceList = (List)instances;
                  int nCount = instanceList.size();

                  for (int k = 0; k < nCount; ++k)
                  {
                     tobj = (TransferObject)instanceList.get(k);

                     Instance inst = instanceFactory.instantiate(tobj);

                     instanceList.set(k, inst);

                     if (inst != null)
                     {
                        diffMap.put(inst, tobj);
                     }
                  }
               }
            }
         }

         instanceFactory.complete();
         instanceFactory = null;
         GenericServer.auditRequest(identityMap, eventMap, m_context);
         identityMap = null;

         Object[] resultArray = new Object[nInvocationCount << 1];

         // Unset the pending event flag on the request argument instances
         for (int i = 0; i < nInvocationCount; ++i)
         {
            Object[] args = argArray[i];
            Object obj = args[0];

            if (obj instanceof Instance)
            {
               Instance instance = (Instance)obj;

               if (args.length == 1 && eventArray[i].getName().equals(instance.getPendingEventName()))
               {
                  resultArray[i << 1] = instance;
               }

               instance.suspendEvent();
            }
         }

         m_context.setTransient(false);
         uow.invokePendingEvents(false, false);

         // Invoke the events and accumulate the results
         for (int i = 0; i < nInvocationCount; ++i)
         {
            TransferObject tobj = request.getObject(i);
            Event event = eventArray[i];
            Pair attributes = EMPTY_PAIR;
            Object[] args = argArray[i];
            Object obj = args[0];
            int nAttrIndex = -1;

            m_context.setTransient(event.isTransient(bTransient));

            if (event.getArgumentCount() != 0)
            {
               Argument arg = event.findArgument("attributes");

               if (arg != null)
               {
                  nAttrIndex = arg.getOrdinal() + 1;

                  Object value = args[nAttrIndex];

                  attributes = (value instanceof Pair) ? (Pair)value : null;
               }
            }

            if (nAttrIndex < 0)
            {
               Object value = tobj.findValue("attributes", EMPTY_PAIR);

               if (value != EMPTY_PAIR)
               {
                  nAttrIndex = 0;
                  attributes =  (Pair)value;
               }
            }

            if (event.isStatic() && m_context.isProtected() && m_context.isSecure())
            {
               Metaclass metaclass = event.getMetaclass();
               Argument result = event.getResult();

               if (result != null && !result.getType().isPrimitive())
               {
                  metaclass = (Metaclass)result.getType();
               }

               if (nAttrIndex > 0)
               {
                  Pair security = metaclass.checkReadAccess(attributes, m_context.getPrivilegeSet());
  
                  if (security != null)
                  {
                     args[nAttrIndex] = Pair.nconc(security, attributes);
                  }
               }

               metaclass.checkExpressionAccess(findArg(event, "where", args, tobj),  m_context.getPrivilegeSet());
               metaclass.checkOrderByAccess(findArg(event, "orderBy", args, tobj), m_context.getPrivilegeSet());
            }

            boolean bInvoked = false;
            boolean bDeleted = false;

            m_context.setUnitOfWork(uow);
            m_context.setTransient(event.isTransient(bTransient));

            if (obj instanceof Instance)
            {
               Instance instance = (Instance)obj;
               UnitOfWork instanceUOW = instance.getUnitOfWork();

               // Use the instance UoW
               if (!event.isStatic() && instanceUOW != null && instanceUOW != uow)
               {
                  m_context.setUnitOfWork(instanceUOW);
               }

               bInvoked = instance.invokeSuspendedEvent();
               bDeleted = (instance.getState() == Instance.DELETED);

               if (nAttrIndex <= 0)
               {
                  Attribute attribute = instance.getMetaclass().findAttribute("attributes");

                  if (attribute != null && !attribute.isStatic())
                  {
                     attributes = (Pair)instance.getValue(attribute.getOrdinal());
                  }
               }
            }

            if (resultArray[i << 1] == null)
            {
               if (!bDeleted)
               {
                  resultArray[i << 1] = event.invoke(args, m_context.getMachine());
               }
            }
            else
            {
               if (!bInvoked && !bDeleted)
               {
                  event.invoke(args, m_context.getMachine());
               }

               eventArray[i] = null;
            }

            resultArray[(i << 1) + 1] = attributes;
         }

         // Pre-commit all units of work in the context
         for (int i = m_context.getUnitOfWorkCount() - 1; i >= 0; i--)
         {
            UnitOfWork work = m_context.getUnitOfWork(i);

            m_context.setUnitOfWork(work);

            if (work.isTransient())
            {
               work.invokePendingEvents(true, false);
               work.computeHiddenness();
               work.accumulateChanges();
            }
            else
            {
               work.commit(false);
            }
         }

         m_context.setUnitOfWork(uow);

         // Transfer the results into the response object.
         // This is done as a separate step after the commit
         // so that the objects are in the correct state (e.g. with OIDs).
         Response response = new Response();

         identityMap = new HashTab();

         for (int i = 0; i < nInvocationCount; ++i)
         {
            Object result = resultArray[i << 1];
            Pair attributes = request.getInvocation(i).getAttributes();
            int nTF = RPCUtil.TF_HIDDEN;
           
            if (attributes == null)
            {
               attributes = (Pair)resultArray[(i << 1) + 1];

               if (attributes == EMPTY_PAIR)
               {
                  attributes = null;
                  nTF |= RPCUtil.TF_READABLE;
               }
            }
            else if (m_context.isProtected() && m_context.isSecure())
            {
               if (result instanceof Instance)
               {
                  Instance instance = (Instance)result;

                  instance.invoke("load", Pair.nconc(instance.getMetaclass()
                     .checkReadAccess(attributes, m_context.getPrivilegeSet()), attributes));
               }
               else if (result instanceof InstanceList)
               {
                  InstanceList list = (InstanceList)result;
                  Lookup classMap = new HashTab(4);

                  for (int k = 0, n = list.size(); k < n; ++k)
                  {
                     Instance instance = list.getInstance(k);
                     Metaclass metaclass = instance.getMetaclass();
                     Pair all = (Pair)classMap.get(metaclass);

                     if (all == null)
                     {
                        all = Pair.nconc(metaclass.checkReadAccess(
                           attributes, m_context.getPrivilegeSet()), attributes);

                        classMap.put(metaclass, all);
                     }

                     instance.invoke("load", all);
                  }
               }

               nTF |= RPCUtil.TF_READABLE;
            }

            response.addResult(RPCUtil.transfer(result, attributes,
               (eventArray[i] == null) ? diffMap : null, identityMap, nTF));
         }

         // Apply the change filters
         for (int i = 0; i < nFilterCount; ++i)
         {
            TransferObject tobj = request.getFilter(i);
            Metaclass metaclass = metadata.getMetaclass(tobj.getClassName());
            Lookup map = m_context.getClassChangeMap(metaclass);
            Object instances = tobj.findValue("instances");
            Pair attributes = (Pair)tobj.findValue("attributes");
            Pair all = attributes;
            List eventList = new ArrayList();

            if (m_context.isProtected() && m_context.isSecure())
            {
               all = Pair.nconc(metaclass.checkReadAccess(attributes, m_context.getPrivilegeSet()), attributes);
            }

            if (instances != null)
            {
               List instanceList = (List)instances;
               int nCount = instanceList.size();

               for (int k = 0; k < nCount; ++k)
               {
                  Instance instance = (Instance)instanceList.get(k);
                  Object state = map.get(instance);

                  if (state != null)
                  {
                     instance.invoke("load", all);
                     eventList.add(transferEvent(instance, ((Integer)state).byteValue(),
                        attributes, diffMap, identityMap));
                  }
                  else
                  {
                     eventList.add(null);
                  }
               }
            }
            else
            {
               for (Lookup.Iterator itr = map.iterator(); itr.hasNext();)
               {
                  Instance instance = (Instance)itr.next();

                  instance.invoke("load", all);
View Full Code Here

      progressProxy.shiftRange(0.05);

      if (!m_bEnvironmentOnly && !bDataSourceOnly)
      {
         Lookup localeMap = new HashTab();
         m_helper.addResources(localeMap, ".locale", "Locale", "locale");
         loadStrings(localeMap.iterator());

         Lookup stringResMap = new HashTab();
         m_helper.addResources(stringResMap, ".strings", "Strings", "strings");
         loadStrings(stringResMap.iterator());

         if (StringTable.getInstance() == null)
         {
            StringTable.setInstance(m_metadata.getStringTable(Metadata.DEFAULT_LOCALE));
            StringTable.setTimeZone(TZ.UTC);
         }
      }

      progressProxy.shiftRange(0.10);

      m_helper.loadEncryptedResourceURL(configURL, "Server", "server", new ResourceHandler()
      {
         public void handleResource(final Element element, final String sName)
         {
            if (element.getNodeName().equals("Environment"))
            {
               String sConnectionsURL = m_properties.getProperty(CONNECTIONS_URL_PROPERTY);

               if (StringUtil.isEmpty(sConnectionsURL))
               {
                  m_properties.setProperty(CONNECTIONS_URL_PROPERTY, m_sConfigURL);
               }
            }

            NamedNodeMap attrMap = element.getAttributes();

            for (int i = 0; i != attrMap.getLength(); ++i)
            {
               Node node = attrMap.item(i);
               String sOldValue = m_properties.getProperty(node.getNodeName());

               if (StringUtil.isEmpty(sOldValue))
               {
                  m_properties.setProperty(node.getNodeName(), node.getNodeValue());
               }
            }
         }
      }, m_properties);

      m_decryptionDispatcher = new CharacterStreamCipherDispatcher();
      m_decryptionDispatcher.init(m_properties);
      m_helper.setEncryptionSchemeSet(new HashHolder(4));

      loadServer(m_properties);

      String sConnectionsURL = m_properties.getProperty(CONNECTIONS_URL_PROPERTY);
      URL connectionsURL = null;

      if (!StringUtil.isEmpty(sConnectionsURL))
      {
         connectionsURL = XMLMetadataHelper.getURL(sConnectionsURL, false, handler);
         sConnectionsURL = connectionsURL.toString();

         if (s_logger.isInfoEnabled())
         {
            s_logger.info("Connections URL: \"" + sConnectionsURL + "\"");
         }
      }

      m_helper.loadSystemResource("system.dstypes",
         "DataSourceTypes", "dataSourceTypes", new ResourceHandler()
      {
         public void handleResource(Element element, String sName)
         {
            loadDataSourceTypes(element);
         }
      });

      m_helper.loadResources(".dstype", "DataSourceType", "dataSourceType", new ResourceHandler()
      {
         public void handleResource(Element element, String sName)
         {
            loadDataSourceType(element, sName);
         }
      }, progress);

      m_helper.loadResources(".datasource", "DataSource", "dataSource", new ResourceHandler()
      {
         public void handleResource(Element element, String sName)
         {
            loadDataSource(element, sName);
         }
      }, progress);

      if (!m_bIntegrationExcluded)
      {
         m_helper.loadSystemResource("system.chtypes",
            "ChannelTypes", "channelTypes", new ResourceHandler()
         {
            public void handleResource(Element element, String sName)
            {
               loadChannelTypes(element);
            }
         });

         m_helper.loadResources(".chtype", "ChannelType", "channelType", new ResourceHandler()
         {
            public void handleResource(Element element, String sName)
            {
               loadChannelType(element, sName);
            }
         }, progress);

         // Load the SOA definition XML metadata (which may include definitions of other XML metadata)
         m_soaLoader = new XMLSOAMetadataLoader(m_helper);
         m_helper.loadResources(".soadef", "SOADefinition", "soadef", new ResourceHandler()
         {
            public void handleResource(Element element, String sName)
            {
               m_soaLoader.loadDefinition(element, sName);
            }
         }, progress);
         m_soaLoader.resolveReferences();

         // dispatcher channel properties loaded from environment.
         ChannelType type = m_metadata.getChannelType("ObjectQueue");

         m_dispatcherChannel.setType(type);
         m_metadata.addChannel(m_dispatcherChannel);

         m_helper.loadResources(".channel", "Channel", "channel", new ResourceHandler()
         {
            public void handleResource(Element element, String sName)
            {
               loadChannel(element, sName);
            }
         }, progress);
      }

      final Set componentNameSet = new HashHolder();
     
      m_helper.loadResources(".comp", "Component", "component", new ResourceHandler()
      {
         public void handleResource(Element element, String sName)
         {
            if (m_bEnvironmentOnly)
            {
               XMLMetadataHelper.verifyRootElement(element, "Component");

               m_metadata.addComponent(new Component(sName));
            }
           
            componentNameSet.add(sName);
         }
      }, progress);
     
      if (componentNameSet.contains("System.ObjectQueueDispatcher") &&
         Boolean.parseBoolean(properties.getProperty("queueing.enabled", "true")))
      {
      // only enable the dispatcher if the metadata supports it.
         m_dispatcherChannel.setSendable(true);
         m_dispatcherChannel.setReceivable(true);
      }

      if (connectionsURL != null)
      {
         boolean bEnvironment = (sConnectionsURL.equals(m_sConfigURL) ||
            sConnectionsURL.toLowerCase(Locale.ENGLISH).endsWith(".environment"));

         m_helper.loadEncryptedResourceURL(connectionsURL,
            (bEnvironment) ? "Environment" : "Connections",
            (bEnvironment) ? "environment" : "connections",
            new ResourceHandler()
         {
            public void handleResource(final Element element, final String sName)
            {
               loadConnections(element, sName);
            }
         }, m_properties);
      }
      else
      {
         loadConnections(null, null);
      }

      // .server file overrides highest scheme used in the connections file
      m_metadata.setEncryptionScheme(m_properties.getProperty("cipher.scheme",
            CharacterStreamCipherDispatcher.computeMostSecure(m_helper.getEncryptionSchemeSet())));

      if (!bDataSourceOnly)
      {
         loadUIMetadata(baseDescElement, rootDescElement);
      }

      progressProxy.shiftRange(0.12);

      m_helper.fixup(m_ioFixupList.iterator());
      m_ioFixupList = null;

      m_helper.loadResources(".extlib", "ExternalLibrary", "externalLibrary", new ResourceHandler()
      {
         public void handleResource(Element element, String sName)
         {
            loadExternalLibrary(element, sName);
         }
      }, progress);

      m_nStage = STAGE_LOADED_ENVIRONMENT;
      progressProxy.progress(null, null, 1.0);

      if (m_bEnvironmentOnly || bDataSourceOnly)
      {
         m_nStage = STAGE_LOAD_ENVIRONMENT_FIXUPS;
         m_helper.fixup(m_environmentFixupList.iterator()); // safe to run since no J2EE container
         m_nStage = STAGE_FINISHED;

         return m_metadata;
      }

      progressProxy.shiftRange(0.13);

      m_helper.loadResources(".security", "SecurityDescriptor", "securityDescriptor", new ResourceHandler()
      {
         public void handleResource(Element element, String sName)
         {
            loadSecurityDescriptor(element);
         }
      }, progress);

      m_helper.fixup(m_privilegeFixupList.iterator());
      m_privilegeFixupList = null;
      PrivilegeGroup.resolve(m_metadata);

      if (progress != null)
      {
         progressProxy.shiftRange(0.15);
         progress.progress("info.meta.loadingSystemResources", null, 0);
      }

      Context contextSaved = ThreadContextHolder.getContext();

      try
      {
         ThreadContextHolder.setContext(m_machine.getContext());

         m_helper.loadSystemResource("scheme.scm",
            "Library", "library", new CharacterStreamHandler()
         {
            public void handleCharacterStream(Reader reader, String sName) throws IOException
            {
               loadLibrary(reader, sName, true);
            }
         });

         // Load the Dynamic Object System
         m_helper.loadSystemResource("object.scm",
            "Library", "library", new CharacterStreamHandler()
         {
            public void handleCharacterStream(Reader reader, String sName) throws IOException
            {
               loadLibrary(reader, sName, true);
            }
         });

         // Load the Services Oriented Architecture functionality
         m_helper.loadSystemResource("soa.scm",
            "Library", "library", new CharacterStreamHandler()
         {
            public void handleCharacterStream(Reader reader, String sName) throws IOException
            {
               loadLibrary(reader, sName, true);
            }
         });

         m_helper.loadSystemResource("server.scm",
            "Library", "library", new CharacterStreamHandler()
         {
            public void handleCharacterStream(Reader reader, String sName) throws IOException
            {
               loadLibrary(reader, sName, true);
            }
         });

         m_helper.loadSystemResource(Metadata.ROOT_CLASS_NAME + ".meta",
            "Class", "class", new ResourceHandler()
         {
            public void handleResource(Element rootElement, String sName)
            {
               loadClass(rootElement, sName);
            }
         });

         loadExtendedSystemMetadata();

         progressProxy.shiftRange(0.16);

         m_helper.loadResources(".scm", "Library", "library", new CharacterStreamHandler()
         {
            public void handleCharacterStream(Reader reader, String sName) throws IOException
            {
               loadLibrary(reader, sName, false);
            }
         }, progress);
      }
      finally
      {
         ThreadContextHolder.setContext(contextSaved);
      }

      progressProxy.shiftRange(0.23);

      m_helper.loadResources(".meta", "Class", "class", new ResourceHandler()
      {
         public void handleResource(Element element, String sName)
         {
            String sElement = element.getNodeName();

            if (sElement.equals("Class"))
            {
               loadClass(element, sName);
            }
            else if (sElement.equals("Aspect"))
            {
               loadClassAspect(element, sName);
            }
            else
            {
               throw new MetadataException("err.meta.metaDocRoot", new Object[]{sElement});
            }
         }
      }, progress);

      progressProxy.shiftRange(0.24);

      m_helper.loadResources(".enum", "Enumeration", "enum", new ResourceHandler()
      {
         public void handleResource(Element element, String sName)
         {
            loadEnumeration(element, sName);
         }
      }, progress);

      progressProxy.shiftRange(0.25);

      loadUIEventMetadata(baseDescElement, rootDescElement, progress);

      if (progress != null)
      {
         progressProxy.shiftRange(0.26);
         progress.progress("info.meta.resolvingResourceReferences", null, 0);
      }

      m_helper.fixup(m_inheritanceCheckList.iterator());
      m_inheritanceCheckList = null;
      m_helper.fixup(m_attributeGenerationList.iterator());
      m_attributeGenerationList = null;

      m_helper.fixup(Collections.singleton(new ClassFixup()
      {
         public void fixup()
         {
            m_classAspectArray = ClassAspect.resolveAspects(m_metadata);
         }
      }).iterator());

      m_helper.fixup(m_inheritanceFixupList.iterator());
      m_inheritanceFixupList = null;
      m_enumerationValueMap = null;
      m_helper.fixup(m_attributeFixupList.iterator());
      m_attributeFixupList = null;
      m_helper.fixup(m_actionFixupList.iterator());
      m_actionFixupList = null;

      if (m_classAspectArray != null)
      {
         ClassAspect.resolveMembers(m_classAspectArray);
      }

      m_helper.fixup(m_persistenceMappingLoadList.iterator());
      m_persistenceMappingLoadList = null;
      m_helper.fixup(m_attributeResolutionList.iterator());
      m_attributeResolutionList = null;
      m_helper.fixup(m_inheritance1stPassFixupList.iterator());
      m_inheritance1stPassFixupList = null;

      progressProxy.shiftRange(0.27);

      m_helper.loadResources(".action", "Action", "action", new ResourceHandler()
      {
         public void handleResource(Element element, String sName)
         {
            loadFlowMacro(element, sName);
         }
      }, progress);

      progressProxy.shiftRange(0.32);

      m_helper.loadResources(".workflow", "Workflow", "workflow", new ResourceHandler()
      {
         public void handleResource(Element element, String sName)
         {
            loadWorkflow(element, sName);
         }
      }, progress);

      progressProxy.shiftRange(0.33);

      if (!m_bIntegrationExcluded)
      {
         m_helper.loadSystemResource("system.formats",
            "Formats", "formats", new ResourceHandler()
         {
            public void handleResource(Element element, String sName)
            {
               loadFormats(element);
            }
         });

         m_helper.loadResources(".format", "Format", "format", new ResourceHandler()
         {
            public void handleResource(Element element, String sName)
            {
               loadFormat(element, sName);
            }
         }, progress);

         progressProxy.shiftRange(0.34);

         final Lookup importedMessageMap = new HashTab();

         m_helper.loadResources(".xsd", "XSD", "xsd", new ResourceNameHandler()
         {
            public void handleResource(String sName, String sRelativePath)
            {
               loadXSD(m_helper.getResource(sRelativePath).getURL(), sName, importedMessageMap);
            }
         }, progress);

         m_helper.loadResources(".wsdl", "WSDL", "wsdl", new ResourceNameHandler()
         {
            public void handleResource(String sName, String sRelativePath)
            {
               loadXSD(m_helper.getResource(sRelativePath).getURL(), sName, importedMessageMap);
            }
         }, progress);

         m_helper.loadResources(".soaimpl", "SOAImplementation", "soaimpl", new ResourceHandler()
         {
            public void handleResource(Element element, String sName)
            {
               m_soaLoader.loadImplementation(element, sName, m_metadata.getGlobalEnvironment());
            }
         }, progress);

         contextSaved = ThreadContextHolder.getContext();

         try
         {
            ThreadContextHolder.setContext(m_machine.getContext());
            m_soaLoader.initDefinitions(m_machine);
         }
         finally
         {
            ThreadContextHolder.setContext(contextSaved);
         }

         m_helper.loadResources(".message", "Message", "message", new ResourceHandler()
         {
            public void handleResource(Element element, String sName)
            {
               loadMessage(element, sName);
            }
         }, progress);

         // Explicitly-defined Message metadata shall override Message metadata from imported XSDs and WSDLs
         for (Lookup.Iterator itr = importedMessageMap.iterator(); itr.hasNext(); )
         {
            String sName = (String)itr.next();

            if (m_metadata.findMessage(sName) == null)
            {
View Full Code Here

    * @param classElement The DOM element containing the class.
    * @param metaclass The metaclass object.
    */
   protected void loadMetaclass(final Element classElement, final Metaclass metaclass)
   {
      Lookup posMap = new IdentityHashTab(32);

      XMLMetadataHelper.validateName(metaclass.getName());
      metaclass.setResourceName(m_helper.getCurResourceName());
      metaclass.setForward(false);
      loadDocumentation(classElement, metaclass);
View Full Code Here

      attribute.setCompatible(XMLUtil.getBooleanAttr(attributeElement, "compatible", false));
      attribute.setStatic(XMLUtil.getBooleanAttr(attributeElement, "static", false));
      attribute.setReadOnly(XMLUtil.getBooleanAttr(attributeElement, "readOnly", false));
      attribute.setCached(XMLUtil.getBooleanObjAttr(attributeElement, "cached"));

      Lookup posMap = new IdentityHashTab();

      attribute.setValue(m_helper.parse(XMLUtil.getStringAttr(attributeElement, "value"),
         false, sURLPrefix + "$value", posMap, Undefined.VALUE, m_metadata.getGlobalEnvironment()));
      attribute.setInitializer(m_helper.parse(XMLUtil.getStringAttr(attributeElement, "initializer"),
         false, sURLPrefix + "$initializer", posMap, Undefined.VALUE, m_metadata.getGlobalEnvironment()));
View Full Code Here

            event.setResult(loadArgument(resultElement, null));
         }
      });

      String sArgList = XMLUtil.getStringAttr(eventElement, "args");
      final Lookup/*<String, Argument>*/ argMap = new HashTab/*<String, Argument>*/();

      XMLUtil.withFirstChildElement(eventElement, "Arguments", false, new ElementHandler()
      {
         public void handleElement(Element argsElement)
         {
            XMLUtil.forEachChildElement(argsElement, "Argument",
               m_helper.new ElementHandler("argument")
            {
               protected void handleElement(Element argElement, String sArgName)
               {
                  argMap.put(sArgName, loadArgument(argElement, sArgName));
               }
            });
         }
      });

      if (sArgList != null)
      {
         for (StringTokenizer tokenizer = new StringTokenizer(sArgList); tokenizer.hasMoreTokens();)
         {
            String sArgName = tokenizer.nextToken();
            Argument arg = (Argument)argMap.remove(sArgName);

            XMLMetadataHelper.validateName(sArgName);
            event.addArgument((arg == null) ? new Argument(sArgName) : arg);
         }
      }

      MetadataCompoundValidationException e = null;

      for (Iterator/*<Argument>*/ itr = argMap.valueIterator(); itr.hasNext();)
      {
         if (e == null)
         {
            e = new MetadataCompoundValidationException();
         }
View Full Code Here

               action.setNextAction(sRelativeName);
            }
         });
      }

      Lookup posMap = new IdentityHashTab();

      action.setCondition(m_helper.parse(XMLUtil.getStringAttr(actionElement, "condition"),
         false, posMap, Boolean.TRUE, m_metadata.getGlobalEnvironment()));

      String sMethodName = XMLUtil.getStringAttr(actionElement, "method");
View Full Code Here

            new Object[]{attributeSet.iterator().next(), macro.getName(), flow.getFullName()});
      }

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

      Lookup flowPosMap = flow.getPosMap();
      Lookup macroPosMap = macro.getTextPositionMap();

      if (flowPosMap != null && macroPosMap != null)
      {
         for (Lookup.Iterator itr = macroPosMap.iterator(); itr.hasNext();)
         {
            itr.next();
            flowPosMap.put(itr.getKey(), itr.getValue());
         }
      }
View Full Code Here

    * @param assignment The assignment element, which starts the queue processing.
    * @return The last loaded step after the queue element.
    */
   protected Step loadQueue(Element queueElement, final Assignment assignment)
   {
      final Lookup eventMap = new HashTab();
      final Fork fork = new Fork();
      final Decision decision = new Decision();

      fork.setActivity(assignment.getActivity());
      decision.setActivity(assignment.getActivity());

      XMLUtil.forEachChildElement(queueElement, null,
         m_helper.new ElementHandler("queueEvent")
      {
         private boolean m_bTimer;

         protected String getName(Element eventElement)
         {
            return XMLUtil.getStringAttr(eventElement, "name");
         }

         public void handleElement(Element eventElement, String sEventName)
         {
            Node child = eventElement.getFirstChild();
            String sElement = eventElement.getNodeName();
            Concurrent activity = new Concurrent();
            Branch branch = null;

            activity.setFork(fork);

            if (sElement.equals("TimerEvent"))
            {
               if (m_bTimer)
               {
                  throw new MetadataException("err.meta.workflow.multipleQueueTimers",
                     new Object[]{assignment.getName()});
               }

               Timeout timeout = new Timeout();

               timeout.setActivity(activity);
               timeout.setValue(m_helper.parse(XMLUtil.getReqStringAttr(eventElement, "value"),
                  false, activity.getFlow().getPosMap(), null, m_metadata.getGlobalEnvironment()));
               activity.addStep(timeout);

               Wait wait = new Wait(timeout);

               timeout.setNext(wait);
               activity.addStep(wait);

               m_bTimer = true;
            }
            else if (sElement.equals("ClassEvent"))
            {
               AutoCompletion completion = new AutoCompletion(assignment);

               loadWorkflowHandler(eventElement, completion, activity.getFlow());
               activity.addStep(completion);
            }
            else if (sElement.equals("ManualEvent"))
            {
               Object condition = m_helper.parse(XMLUtil.getStringAttr(eventElement, "condition"),
                  false, assignment.getActivity().getFlow().getPosMap(),
                  Boolean.TRUE, m_metadata.getGlobalEnvironment());
               boolean bTarget = loadTarget(eventElement, assignment, condition, sEventName, false);
               Element first = XMLUtil.findFirstElement(child);

               if (first != null && first.getNodeName().equals("UIAction"))
               {
                  loadTarget(first, assignment, condition, sEventName, bTarget);
                  child = first.getNextSibling();
               }

               if (assignment.getManualCompletion() == null)
               {
                  ManualCompletion completion = new ManualCompletion(assignment);

                  activity.addStep(completion);
               }
               else
               {
                  activity = null;
               }
            }
            else if (sElement.equals("ProcessEvent"))
            {
               branch = new Branch();
               decision.addBranch(branch);

               assignment.setSemaphore(true);

               Semaphore semaphore = new Semaphore(assignment.getName() + ":Semaphore", assignment);

               semaphore.setActivity(activity);
               activity.addStep(semaphore);

               Block block = new Block();

               block.setActivity(branch);
               branch.addStep(block);
               loadActivity(child, block.getContainedActivity());
               block.setCleanupCode(semaphore.getExitCode());
            }
            else
            {
               throw new MetadataException("err.meta.workflow.invalidQueueElement",
                  new Object[]{sElement, assignment.getName()});
            }

            if (eventMap.put(sEventName, Boolean.TRUE) != null)
            {
               throw new MetadataException("err.meta.workflow.queueEventDup",
                  new Object[]{sEventName, assignment.getName()});
            }

View Full Code Here

TOP

Related Classes of nexj.core.util.Lookup$Iterator

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.