Package nexj.core.util

Examples of nexj.core.util.ProgressProxy


            }
         });
      }

      // Prepare the progress listener
      ProgressProxy progressProxy = new ProgressProxy(progress);

      if (progress != null)
      {
         progress = progressProxy;
      }

      // Load the repository descriptors and process the elements in them

      if (progress != null)
      {
         progress.progress("info.meta.loadingDescriptors", null, 0);
      }

      Element baseDescElement = m_helper.getDescriptorElement(false);
      Element rootDescElement = m_helper.getDescriptorElement(true);

      progressProxy.setRange(0.01, 0.02);

      m_metadata.setListing(m_helper.getListing(new XMLMetadataHelper.MixinHandler()
         {
            /**
             * Metadata repository information, indexed by namespace.
             */
            private Lookup m_metadataMap = new HashTab();

            private String getMetadataName(String sNamespace)
            {
               MetadataInfo info = ((MetadataInfo)m_metadataMap.get(sNamespace));

               return (info == null || info.metadata == null) ? sNamespace : info.metadata.getName();
            }

            public void handleRepository(XMLMixin mixin)
            {
               String sNamespace = mixin.getNamespace();
               XMLMetadataHelper helper = mixin.getHelper();
               MetadataInfo info = (MetadataInfo)m_metadataMap.get(sNamespace);

               if (info == null)
               {
                  info = new MetadataInfo();
               }

               // get the metadata instance
               if (m_metadataMap.size() == 0)
               {
                  info.metadata = m_metadata;
               }
               else
               {
                  URL rootURL = helper.getRootURL();

                  info.metadata = createXMLMetadata(rootURL.getPath(), rootURL, helper.getBaseURL(), helper);
               }

               // load the version
               loadVersion(info.metadata, helper);
               m_metadataMap.put(sNamespace, info);

               // validate loaded mixin
               if (m_metadata != info.metadata)
               {
                  // Adopt the highest coreVersion available from any of the repositories.
                  if (m_metadata.getCoreVersion() == null || (info.metadata.getCoreVersion() != null &&
                     StringUtil.compareVersionRanges(m_metadata.getCoreVersion(), info.metadata.getCoreVersion()) < 0))
                  {
                     m_metadata.setCoreVersion(info.metadata.getCoreVersion());
                  }

                  if (info.ref == null)
                  {
                     throw new MetadataValidationException("err.meta.mixinNamespace", new Object[]{info.metadata.getName(), sNamespace});
                  }

                  String sVersion = info.ref.getVersion();
                  String sChecksum = info.ref.getChecksum();

                  // validate that repository matches mixin declaration
                  if ((sVersion != null && !sVersion.equals(info.metadata.getVersion()))
                     || (sChecksum != null && !sChecksum.equals(info.metadata.getChecksum())))
                  {
                     throw new MetadataValidationException("err.meta.mixinLinkVersion", new Object[]{
                        info.metadata.getName(),
                        info.metadata.getVersion(),
                        info.metadata.getChecksum(),
                        sVersion,
                        sChecksum,
                        getMetadataName(info.parentNamespace)
                     });
                  }
               }
            }

            public void handleMixinReference(XMLMixin ref, XMLMixin parent)
            {
               String sParentNamespace = parent.getNamespace();
               String sNamespace = ref.getNamespace();
               String sVersion = ref.getVersion();
               String sChecksum = ref.getChecksum();
               MetadataInfo info = (MetadataInfo)m_metadataMap.get(sNamespace);

               if (info == null)
               {
                  info = new MetadataInfo();
                  info.parentNamespace = sParentNamespace;
                  info.ref = (XMLMixin)ref.clone();
                  m_metadataMap.put(sNamespace, info);

                  // mixin declared at top-level is also base
                  if (sParentNamespace.equals(m_metadata.getNamespace()) && sNamespace.equals(m_metadata.getBaseNamespace()))
                  {
                     m_helper.addException(new MetadataValidationException("err.meta.mixinDup",
                        new Object[] {sNamespace, getMetadataName(sParentNamespace)}));
                  }

                  // mixin matches base, but has different version/checksum
                  if (sNamespace.equals(m_metadata.getBaseNamespace()) &&
                     (!sVersion.equals(m_metadata.getBaseVersion()) || !sChecksum.equals(m_metadata.getBaseChecksum())))
                  {
                     m_helper.addException(new MetadataValidationException("err.meta.mixinBaseVersion",
                        new Object[]{sNamespace, sVersion, sChecksum, m_metadata.getBaseVersion(), m_metadata.getBaseChecksum()}));
                  }
               }
               else if (info.ref != null)
               {
                  if (sParentNamespace.equals(info.parentNamespace))
                  {
                     // mixin declared twice in same repository
                     m_helper.addException(new MetadataValidationException("err.meta.mixinDup",
                        new Object[] {sNamespace, getMetadataName(sParentNamespace)}));
                  }

                  // mixin declared more than once with different version/checksum
                  if ((info.ref.getVersion() != null && !info.ref.getVersion().equals(sVersion)) ||
                     (info.ref.getChecksum() != null && !info.ref.getChecksum().equals(sChecksum)))
                  {
                     m_helper.addException(new MetadataValidationException("err.meta.mixinVersion", new Object[] {
                        sNamespace,
                        sVersion,
                        sChecksum,
                        getMetadataName(sParentNamespace),
                        info.ref.getVersion(),
                        info.ref.getChecksum(),
                        getMetadataName(info.parentNamespace)
                     }));
                  }
               }
            }

            public void handleMixinOverrideConflict(XMLMixin ref, XMLMixin mixin)
            {
               throw new MetadataValidationException("err.meta.mixinOverride", new Object[]{ref.getName(), mixin.getName()});
            }

            public void handleCircularReference(XMLMixin mixin)
            {
               throw new MetadataValidationException("err.meta.mixinCycle", new Object[]{mixin.getName()});
            }

            public void handleResourceConflict(XMLResource first, XMLResource second)
            {
               m_helper.addException(new MetadataValidationException("err.meta.mixinConflict",
                  new Object[]{
                     first.getName(),
                     getMetadataName(first.getNamespace()),
                     getMetadataName(second.getNamespace())
                  }));
            }

            public void handleLinkFailure(XMLMixin ref, Exception e)
            {
               if (e instanceof MetadataValidationException)
               {
                  m_helper.addException((MetadataValidationException)e);
               }
               else
               {
                  throw new MetadataException("err.meta.mixin", new Object[]{ref}, e);
               }
            }

            public void handleAlternateResource(XMLResource first, XMLResource second)
            {
            }

            public void handleResourceOverride(XMLResource source, XMLResource overridden)
            {
            }

            final class MetadataInfo
            {
               /**
                * The metadata instance of the repository.
                */
               private XMLMetadata metadata;

               /**
                * The namespace of the repository that linked this repository.
                */
               private String parentNamespace;

               /**
                * The reference that caused this repository to be linked.
                */
               private XMLMixin ref;
            }
         }));

      m_helper.setMetadataCoreVersion(
         m_metadata.getCoreVersion(), m_metadata.getUpgradeResources());

      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)
            {
               if (s_logger.isDebugEnabled())
               {
                  s_logger.debug("Adding imported message \"" + sName + "\"");
               }

               m_metadata.addMessage((Message)itr.getValue());
            }
            else
            {
               if (s_logger.isDebugEnabled())
               {
                  s_logger.debug("Skipping the overridden imported message \"" + sName + "\"");
               }
            }
         }

         // Resolve Inheritance
         m_helper.fixup(m_preInheritanceMessageFixupList.iterator());
         m_preInheritanceMessageFixupList = null;

         List sortedMessageList = new ArrayList(m_metadata.getMessageCount());

         Message.resolveInheritance(m_metadata.getMessageIterator(), sortedMessageList);

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

         Message.resolveReferences(m_metadata.getMessageIterator());

         progressProxy.shiftRange(0.36);

         m_helper.loadResources(".transformation", "Transformation", "transformation", new ResourceHandler()
         {
            public void handleResource(Element element, String sName)
            {
               loadTransformation(element, sName);
            }
         }, progress);

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

         Transformation.resolveInheritance(m_metadata.getTransformationIterator());

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

         for (Iterator itr = m_metadata.getTransformationIterator(); itr.hasNext(); )
         {
            Transformation transformation = (Transformation)itr.next();

            try
            {
               transformation.finish(m_machine);
            }
            catch (UncheckedException ex)
            {
               m_helper.addException(ex);
            }
         }

         m_helper.checkForError();

         progressProxy.shiftRange(0.37);

         m_helper.loadResources(".interface", "Interface", "interface", new ResourceHandler()
         {
            public void handleResource(Element element, String sName)
            {
               loadInterface(element, sName);
            }
         }, progress);

         progressProxy.shiftRange(0.38);

         m_helper.loadResources(".service", "Service", "service", new ResourceHandler()
         {
            public void handleResource(Element element, String sName)
            {
               loadService(element, sName);
            }
         }, progress);

         finishMessagePartMappings(sortedMessageList.iterator());
      }

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

      m_helper.fixup(m_persistenceMappingFixupList.iterator());
      m_persistenceMappingFixupList = null;
      m_helper.fixup(m_persistenceMappingGenerationList.iterator());
      m_persistenceMappingGenerationList = null;
      m_helper.fixup(m_attributeDependencyList.iterator());
      m_attributeDependencyList = null;
      Attribute.resolveInverseDependency(m_attributeDependencySet.iterator());
      m_attributeDependencySet = null;

      if (m_classAspectArray != null)
      {
         m_helper.fixup(Collections.singleton(new ClassFixup()
         {
            public void fixup()
            {
               ClassAspect.resolvePersistence(m_classAspectArray);
            }
         }).iterator());
      }

      m_helper.fixup(m_inheritance2ndPassFixupList.iterator());
      m_inheritance2ndPassFixupList = null;
      m_helper.fixup(m_class2ndPassList.iterator());
      m_class2ndPassList = null;

      loadLocales();
      progressProxy.shiftRange(0.40);

      m_helper.loadResources(".comp", "Component", "component", new ResourceHandler()
      {
         public void handleResource(Element element, String sName)
         {
            loadComponent(element, sName);
         }
      }, progress);

      m_nStage = STAGE_LOADED_COMPONENTS;
      progressProxy.progress(null, null, 0);

      m_nStage = STAGE_LOAD_ENVIRONMENT_FIXUPS;
      progressProxy.shiftRange(0.405);

      m_helper.fixup(m_environmentFixupList.iterator());

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

      m_helper.fixup(m_componentFixupList.iterator());
      m_componentFixupList = null;
      m_helper.fixup(m_inheritance4thPassFixupList.iterator());
      m_inheritance4thPassFixupList = null;
      m_helper.fixup(m_singletonFixupList.iterator());
      m_singletonFixupList = null;

      m_helper.addResources(m_metadata.getDumpResourceMap(), ".dump", "Dump", "dump");
      m_helper.addResources(m_metadata.getUnitTestResourceMap(), ".utest", "UnitTest", "unittest");
      m_helper.addResources(m_metadata.getUpgradeResourceMap(), ".upgrade", "Upgrade", "upgrade");

      loadExtendedMetadata(baseDescElement, rootDescElement);

      if (m_bValidatedOnly)
      {
         progressProxy.setRange(0.42, 0.96);

         m_helper.validateResources(m_metadata.getUnitTestResourceMap(), "UnitTest", "unittest", new ResourceNameHandler()
         {
            public void handleResource(String sName, String sFullName)
            {
               m_metadata.getUnitTest(sName);
            }
         }, null);

         progressProxy.shiftRange(0.98);

         m_helper.validateResources(m_metadata.getUpgradeResourceMap(), "Upgrade", "upgrade", new ResourceNameHandler()
         {
            public void handleResource(String sName, String sFullName)
            {
               if (m_helper.findResource(sFullName, XMLMetadataHelper.SEARCH_ROOT_THEN_BASE) != null)
               {
                  m_metadata.getUpgrade(sName).validate(m_metadata, m_helper.getWarnings());
               }
            }
         }, null);

         validateExtendedMetadata(progressProxy);
      }

      try
      {
         m_metadata.validate(m_metadata, m_helper.getWarnings());

         if (!StringUtil.isEmpty(sCompatibleURI))
         {
            progressProxy.shiftRange(0.988);
            progressProxy.progress("info.meta.loadCompatibleModel", null, 0);

            Properties compatibleProperties = new Properties(properties);

            compatibleProperties.setProperty(BASE_URL_PROPERTY, "");
            compatibleProperties.setProperty(COMPATIBLE_URL_PROPERTY, "");

            Metadata compatible;

            try
            {
               compatible = new MetadataLoaderDispatcher().load(sCompatibleURI, compatibleProperties, nFlags, null);
            }
            catch (UncheckedException e)
            {
               throw new MetadataCompatibilityException("err.meta.compatibleMetadataLoadFailure", null, e);
            }

            progressProxy.progress("info.meta.verifyModelCompatibility", null, 1);
            m_metadata.checkCompatibility(compatible);
         }
      }
      catch (UncheckedException e)
      {
         m_helper.addException(e);
      }

      if (m_bValidatedOnly)
      {
         progressProxy.shiftRange(.989);

         m_helper.validateResources(m_metadata.getDumpResourceMap(), "Dump", "dump", new ResourceNameHandler()
         {
            public void handleResource(String sName, String sFullName)
            {
               if (m_helper.findResource(sFullName, XMLMetadataHelper.SEARCH_ROOT_THEN_BASE) == null)
               {
                  return;
               }

               InputStream is = null;
               Pair dumpVersion = null;

               try
               {
                  dumpVersion = new DataLoader(null).getDumpVersion(is = m_helper.getResourceAsStream(sFullName));
               }
               catch (Exception e)
               {
                  throw new MetadataException("err.meta.dumpLoad", new Object[]
                  {
                     sName
                  }, e);
               }
               finally
               {
                  IOUtil.close(is);
               }

               if (dumpVersion != null
                  && (!m_metadata.getNamespace().equals(dumpVersion.getHead()) || !m_metadata.getVersion().equals(
                     dumpVersion.getTail())))
               {
                  throw new MetadataException("err.meta.dumpVersion", new Object[]
                  {
                     dumpVersion.getHead(),
                     dumpVersion.getTail(),
                     m_metadata.getNamespace(),
                     m_metadata.getVersion()
                  });
               }
            }
         }, null);
      }

      if (!m_bWritable)
      {
         m_metadata.makeReadOnly();
      }

      m_helper.checkForError();

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

      if (m_helper.getWarnings() != null)
      {
View Full Code Here

TOP

Related Classes of nexj.core.util.ProgressProxy

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.