Package nexj.core.util

Examples of nexj.core.util.Lookup


   public static Lookup/*<Object, UpgradeState>*/ getInitialState(VersionUpgrade version)
      throws MetadataException
   {
      assert version != null;

      Lookup stateMap = new HashTab();

      // need to roll back all to validate that all alter/drop steps have associated create steps
      for (VersionUpgrade u = version.getUpgrade().getLastVersion(); u != null; u = u.getPrev())
      {
         u.undo(getState(stateMap, u));
      }

      // validate state initial state to catch alter/drop steps lacking associated create steps
      for (Lookup.Iterator itr = stateMap.valueIterator(); itr.hasNext();)
      {
         ((UpgradeState)itr.next()).start();
      }

      // roll forward to the requested version
View Full Code Here


    */
   public void validate(ContextMetadata metadata, ExceptionHolder warnings)
   {
      super.validate(metadata, warnings);

      Lookup stateMap = new HashTab();
      MetadataCompoundValidationException eh = null;

      if (m_lastVersion != null && !m_metadata.getVersion().equals(m_lastVersion.getName()))
      {
         eh = new MetadataCompoundValidationException();

         MetadataValidationException e = new MetadataValidationException("err.upgrade.lastVersion",
            new Object[]{m_lastVersion.getName(), m_metadata.getVersion()});

         setProperties(e);
         eh.addException(e);
      }

      // roll back the state and validate that can undo each step and state is still valid
      for (VersionUpgrade version = m_lastVersion; version != null; version = version.getPrev())
      {
         try
         {
            version.undo(getState(stateMap, version));
         }
         catch (UncheckedException e)
         {
            eh = version.addException(eh, e);
         }
      }

      if (eh != null)
      {
         throw eh;
      }

      // validate initial state to catch alter/drop steps lacking associated create steps
      for (Lookup.Iterator itr = stateMap.valueIterator(); itr.hasNext();)
      {
         ((UpgradeState)itr.next()).start();
      }

      // validate that the overall state is still valid after every upgrade version is applied
      for (VersionUpgrade version = m_firstVersion; version != null; version = version.getNext())
      {
         try
         {
            version.apply(getState(stateMap, version));
         }
         catch (UncheckedException e)
         {
            eh = version.addException(eh, e);
         }
      }

      if (eh != null)
      {
         throw eh;
      }

      for (Lookup.Iterator itr = stateMap.valueIterator(); itr.hasNext();)
      {
         ((UpgradeState)itr.next()).end();
      }
   }
View Full Code Here

      throws IOException, ParserException, CompilerException, ScriptingException
   {
      GlobalEnvironment env = machine.getGlobalEnvironment();
      Parser parser = new SchemeParser(env);
      Compiler compiler = new Compiler();
      Lookup posMapSaved = env.getTextPositionMap();
      Lookup posMap = new IdentityHashTab();

      if (!reader.markSupported())
      {
         reader = new BufferedReader(reader);
      }
View Full Code Here

      {
         loader.addIOFixup(new XMLMetadataHelper.ContextFixup(loader.getHelper())
         {
            public void fixup()
            {
               Lookup aliasQueueMap = new HashTab();

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

                  if (channel instanceof MessageQueue)
                  {
                     MessageQueue queue = (MessageQueue)channel;
                     MessageQueue oldQueue = (MessageQueue)aliasQueueMap.put(queue.getAlias(), queue);

                     if (oldQueue == null)
                     {
                        queue.setFirst(true);
                     }
                     else
                     {
                        queue.setFirst(false);
                        aliasQueueMap.put(queue.getAlias(), oldQueue);

                        if (!ObjUtil.equal(queue.getDestination(), oldQueue.getDestination()))
                        {
                           throw new MetadataValidationException("err.meta.integration.mq.destinationMismatch",
                              new Object[]{queue.getName(), oldQueue.getName(), queue.getAlias()});
View Full Code Here

      {
         loader.addIOFixup(new XMLMetadataHelper.ContextFixup(loader.getHelper())
         {
            public void fixup()
            {
               Lookup aliasMailMap = new HashTab();

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

                  if (channel instanceof Mail)
                  {
                     Mail mailChannel = (Mail)channel;
                     Mail oldMailChannel = (Mail)aliasMailMap.put(mailChannel.getAlias(), mailChannel);

                     if (oldMailChannel == null)
                     {
                        mailChannel.setFirst(true);
                     }
                     else
                     {
                        mailChannel.setFirst(false);
                        aliasMailMap.put(mailChannel.getAlias(), oldMailChannel);

                        MetadataValidationException e = new MetadataValidationException(
                           "err.meta.mail.duplicateAlias", new Object[]{mailChannel.getName(), oldMailChannel.getName()});

                        mailChannel.setProperties(e);
View Full Code Here

            attrMap.put(head, head);
         }
         else if (head instanceof Pair)
         {
            Pair subAttrList = (Pair)head;
            Lookup subAttrMap = new HashTab();

            if (!(subAttrList.getHead() instanceof Symbol))
            {
               throw new IllegalStateException();
            }
View Full Code Here

               }
            }
         }
      }

      Lookup out = new HashTab(valueInvDepMap.keyCount());

      // Transfer to a map of arrays
      for (Lookup.Iterator it = valueInvDepMap.iterator(); it.hasNext();)
      {
         AttributeMeta key = (AttributeMeta)it.next();
         Collection col = (Collection)it.getValue();

         out.put(key, col.toArray(new AttributeMeta[col.size()]));
      }

      return out;
   }
View Full Code Here

         }
         else
         {
            s_logger.debug("Error processing the composite message; trying to process it in chunks", e);

            Lookup objectParts = getObjectParts(tobj, message.getRoot(), new HashTab());
            CompoundIntegrationException ex = new CompoundIntegrationException(e.getMessage());

            out.setObject(new FailSafeFormatter(ex, bCommit).divideAndFormat(objectParts));

            if (ex.getExceptionCount() > 0)
View Full Code Here

      public Collection divideAndFormat(Lookup objectParts)
      {
         int nMapSize = objectParts.size();
         Collection result = new ArrayList(nMapSize);
         int nChunkSize = (nMapSize + CHUNK_COUNT - 1) / CHUNK_COUNT;
         Lookup chunk = new HashTab(nChunkSize);

         if (s_logger.isDebugEnabled())
         {
            s_logger.debug("Dividing message of size " + objectParts.size() + " into chunks of size " + nChunkSize);
         }

         for (Lookup.Iterator itr = objectParts.iterator(); itr.hasNext(); )
         {
            chunk.put(itr.next(), itr.getValue());
           
            if (chunk.size() == nChunkSize)
            {
               result.addAll(formatChunk(chunk, 0));
               chunk.clear();
            }
         }

         result.addAll(formatChunk(chunk, 0));
View Full Code Here

      {
         if (m_nRefState == WEAK_REF)
         {
            cleanup();

            Lookup map = new HashTab(m_instanceArray.length);
            boolean bLazy = ((WeakKeyTab)m_instanceMap).m_bLazy;
            int i, k;

            for (i = k = 0; i < m_nCount; ++i)
            {
               Instance instance = m_instanceArray[i].getInstance();

               if (instance != null)
               {
                  map.put(instance, Primitive.createInteger(k));
                  m_instanceArray[k] = instance;
                  ++k;
               }
               else
               {
View Full Code Here

TOP

Related Classes of nexj.core.util.Lookup

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.