Exemplo n.º 1
0
  private static EntityResolver getResolver() {
    EntityResolver resolver = null;
    if (resolver == null) {
      // set up a manager
      CatalogManager manager = new CatalogManager();
      manager.setIgnoreMissingProperties(true);
      try {
        // if(System.getProperty(getClass().getName()+".verbose")!=null)
        manager.setVerbosity(0);
      } catch (SecurityException e) {
        // recover by not setting the debug flag.
      }

      // parse the catalog
      ClassLoader cl = Thread.currentThread().getContextClassLoader();
      Enumeration catalogEnum;
      try {
        if (cl == null) catalogEnum = ClassLoader.getSystemResources("/META-INF/jaxws-catalog.xml");
        else catalogEnum = cl.getResources("/META-INF/jaxws-catalog.xml");

        while (catalogEnum.hasMoreElements()) {
          URL url = (URL) catalogEnum.nextElement();
          manager.getCatalog().parseCatalog(url);
        }
      } catch (IOException e) {
        e.printStackTrace();
      }

      resolver = new CatalogResolver(manager);
    }

    return resolver;
  }
 /**
  * Initialization. Create a CatalogManager and set all the properties upfront. This prevents JVM
  * wide system properties or a property file somewhere in the environment from affecting the
  * behaviour of this catalog resolver.
  */
 private void init(String[] catalogs, boolean preferPublic) {
   fCatalogsList = (catalogs != null) ? (String[]) catalogs.clone() : null;
   fPreferPublic = preferPublic;
   fResolverCatalogManager = new CatalogManager();
   fResolverCatalogManager.setAllowOasisXMLCatalogPI(false);
   fResolverCatalogManager.setCatalogClassName("com.sun.org.apache.xml.internal.resolver.Catalog");
   fResolverCatalogManager.setCatalogFiles("");
   fResolverCatalogManager.setIgnoreMissingProperties(true);
   fResolverCatalogManager.setPreferPublic(fPreferPublic);
   fResolverCatalogManager.setRelativeCatalogs(false);
   fResolverCatalogManager.setUseStaticCatalog(false);
   fResolverCatalogManager.setVerbosity(0);
 }