com.sun.org.apache.xml.internal.resolver.CatalogManager Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.resolver.CatalogManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XmlUtil.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static EntityResolver createEntityResolver(@Nullable URL catalogUrl) {
    // set up a manager
    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);
    Catalog catalog = manager.getCatalog();
    try {
        if (catalogUrl != null) {
            catalog.parseCatalog(catalogUrl);
        }
    } catch (IOException e) {
        throw new ServerRtException("server.rt.err",e);
    }
    return workaroundCatalogResolver(catalog);
}
 
Example #2
Source File: XmlUtil.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static EntityResolver createEntityResolver(@Nullable URL catalogUrl) {
    // set up a manager
    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);
    Catalog catalog = manager.getCatalog();
    try {
        if (catalogUrl != null) {
            catalog.parseCatalog(catalogUrl);
        }
    } catch (IOException e) {
        throw new ServerRtException("server.rt.err",e);
    }
    return workaroundCatalogResolver(catalog);
}
 
Example #3
Source File: XmlUtil.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static EntityResolver createEntityResolver(@Nullable URL catalogUrl) {
    // set up a manager
    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);
    Catalog catalog = manager.getCatalog();
    try {
        if (catalogUrl != null) {
            catalog.parseCatalog(catalogUrl);
        }
    } catch (IOException e) {
        throw new ServerRtException("server.rt.err",e);
    }
    return workaroundCatalogResolver(catalog);
}
 
Example #4
Source File: XmlUtil.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static EntityResolver createEntityResolver(@Nullable URL catalogUrl) {
    // set up a manager
    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);
    Catalog catalog = manager.getCatalog();
    try {
        if (catalogUrl != null) {
            catalog.parseCatalog(catalogUrl);
        }
    } catch (IOException e) {
        throw new ServerRtException("server.rt.err",e);
    }
    return workaroundCatalogResolver(catalog);
}
 
Example #5
Source File: XmlUtil.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static EntityResolver createEntityResolver(@Nullable URL catalogUrl) {
    // set up a manager
    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);
    Catalog catalog = manager.getCatalog();
    try {
        if (catalogUrl != null) {
            catalog.parseCatalog(catalogUrl);
        }
    } catch (IOException e) {
        throw new ServerRtException("server.rt.err",e);
    }
    return workaroundCatalogResolver(catalog);
}
 
Example #6
Source File: XmlUtil.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static EntityResolver createEntityResolver(@Nullable URL catalogUrl) {
    // set up a manager
    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);
    Catalog catalog = manager.getCatalog();
    try {
        if (catalogUrl != null) {
            catalog.parseCatalog(catalogUrl);
        }
    } catch (IOException e) {
        throw new ServerRtException("server.rt.err",e);
    }
    return workaroundCatalogResolver(catalog);
}
 
Example #7
Source File: MavenCatalogResolverTest.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void checkReenterability() throws IOException {
	CatalogManager cma = new CatalogManager();
	cma.setIgnoreMissingProperties(true);
	cma.setUseStaticCatalog(false);
	final CatalogResolver cra = new CatalogResolver(cma);
	URL a = getClass().getResource("a/catalog.cat");
	cra.getCatalog().parseCatalog(a);
	InputSource ea = cra.resolveEntity(null,
			"http://www.w3.org/1999/xlink.xsd");
	Assert.assertNotNull(ea);

	CatalogManager cmb = new CatalogManager();
	cmb.setIgnoreMissingProperties(true);
	cmb.setUseStaticCatalog(false);
	final CatalogResolver crb = new CatalogResolver(cmb);
	URL b = getClass().getResource("b/catalog.cat");
	crb.getCatalog().parseCatalog(b);
	InputSource eb = crb.resolveEntity(null,
			"http://www.w3.org/2005/atom-author-link.xsd");
	Assert.assertNotNull(eb);

}
 
Example #8
Source File: XmlUtil.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Default CatalogResolver implementation is broken as it depends on CatalogManager.getCatalog() which will always create a new one when
 *  useStaticCatalog is false.
 *  This returns a CatalogResolver that uses the catalog passed as parameter.
 * @param catalog
 * @return  CatalogResolver
 */
private static CatalogResolver workaroundCatalogResolver(final Catalog catalog) {
    // set up a manager
    CatalogManager manager = new CatalogManager() {
        @Override
        public Catalog getCatalog() {
            return catalog;
        }
    };
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);

    return new CatalogResolver(manager);
}
 
Example #9
Source File: XmlUtil.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Default CatalogResolver implementation is broken as it depends on CatalogManager.getCatalog() which will always create a new one when
 *  useStaticCatalog is false.
 *  This returns a CatalogResolver that uses the catalog passed as parameter.
 * @param catalog
 * @return  CatalogResolver
 */
private static CatalogResolver workaroundCatalogResolver(final Catalog catalog) {
    // set up a manager
    CatalogManager manager = new CatalogManager() {
        @Override
        public Catalog getCatalog() {
            return catalog;
        }
    };
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);

    return new CatalogResolver(manager);
}
 
Example #10
Source File: XmlUtil.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Default CatalogResolver implementation is broken as it depends on CatalogManager.getCatalog() which will always create a new one when
 *  useStaticCatalog is false.
 *  This returns a CatalogResolver that uses the catalog passed as parameter.
 * @param catalog
 * @return  CatalogResolver
 */
private static CatalogResolver workaroundCatalogResolver(final Catalog catalog) {
    // set up a manager
    CatalogManager manager = new CatalogManager() {
        @Override
        public Catalog getCatalog() {
            return catalog;
        }
    };
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);

    return new CatalogResolver(manager);
}
 
Example #11
Source File: XmlUtil.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a default EntityResolver for catalog at META-INF/jaxws-catalog.xml
 */
public static EntityResolver createDefaultCatalogResolver() {

    // set up a manager
    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);
    // parse the catalog
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    Enumeration<URL> catalogEnum;
    Catalog catalog = manager.getCatalog();
    try {
        if (cl == null) {
            catalogEnum = ClassLoader.getSystemResources("META-INF/jax-ws-catalog.xml");
        } else {
            catalogEnum = cl.getResources("META-INF/jax-ws-catalog.xml");
        }

        while(catalogEnum.hasMoreElements()) {
            URL url = catalogEnum.nextElement();
            catalog.parseCatalog(url);
        }
    } catch (IOException e) {
        throw new WebServiceException(e);
    }

    return workaroundCatalogResolver(catalog);
}
 
Example #12
Source File: XmlUtil.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a default EntityResolver for catalog at META-INF/jaxws-catalog.xml
 */
public static EntityResolver createDefaultCatalogResolver() {

    // set up a manager
    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);
    // parse the catalog
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    Enumeration<URL> catalogEnum;
    Catalog catalog = manager.getCatalog();
    try {
        if (cl == null) {
            catalogEnum = ClassLoader.getSystemResources("META-INF/jax-ws-catalog.xml");
        } else {
            catalogEnum = cl.getResources("META-INF/jax-ws-catalog.xml");
        }

        while(catalogEnum.hasMoreElements()) {
            URL url = catalogEnum.nextElement();
            catalog.parseCatalog(url);
        }
    } catch (IOException e) {
        throw new WebServiceException(e);
    }

    return workaroundCatalogResolver(catalog);
}
 
Example #13
Source File: XMLCatalogResolver.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #14
Source File: XmlUtil.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a default EntityResolver for catalog at META-INF/jaxws-catalog.xml
 */
public static EntityResolver createDefaultCatalogResolver() {

    // set up a manager
    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);
    // parse the catalog
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    Enumeration<URL> catalogEnum;
    Catalog catalog = manager.getCatalog();
    try {
        if (cl == null) {
            catalogEnum = ClassLoader.getSystemResources("META-INF/jax-ws-catalog.xml");
        } else {
            catalogEnum = cl.getResources("META-INF/jax-ws-catalog.xml");
        }

        while(catalogEnum.hasMoreElements()) {
            URL url = catalogEnum.nextElement();
            catalog.parseCatalog(url);
        }
    } catch (IOException e) {
        throw new WebServiceException(e);
    }

    return workaroundCatalogResolver(catalog);
}
 
Example #15
Source File: XMLCatalogResolver.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example #16
Source File: XmlUtil.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Default CatalogResolver implementation is broken as it depends on CatalogManager.getCatalog() which will always create a new one when
 *  useStaticCatalog is false.
 *  This returns a CatalogResolver that uses the catalog passed as parameter.
 * @param catalog
 * @return  CatalogResolver
 */
private static CatalogResolver workaroundCatalogResolver(final Catalog catalog) {
    // set up a manager
    CatalogManager manager = new CatalogManager() {
        @Override
        public Catalog getCatalog() {
            return catalog;
        }
    };
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);

    return new CatalogResolver(manager);
}
 
Example #17
Source File: XmlUtil.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a default EntityResolver for catalog at META-INF/jaxws-catalog.xml
 */
public static EntityResolver createDefaultCatalogResolver() {

    // set up a manager
    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);
    // parse the catalog
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    Enumeration<URL> catalogEnum;
    Catalog catalog = manager.getCatalog();
    try {
        if (cl == null) {
            catalogEnum = ClassLoader.getSystemResources("META-INF/jax-ws-catalog.xml");
        } else {
            catalogEnum = cl.getResources("META-INF/jax-ws-catalog.xml");
        }

        while(catalogEnum.hasMoreElements()) {
            URL url = catalogEnum.nextElement();
            catalog.parseCatalog(url);
        }
    } catch (IOException e) {
        throw new WebServiceException(e);
    }

    return workaroundCatalogResolver(catalog);
}
 
Example #18
Source File: XmlUtil.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a default EntityResolver for catalog at META-INF/jaxws-catalog.xml
 */
public static EntityResolver createDefaultCatalogResolver() {

    // set up a manager
    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);
    // parse the catalog
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    Enumeration<URL> catalogEnum;
    Catalog catalog = manager.getCatalog();
    try {
        if (cl == null) {
            catalogEnum = ClassLoader.getSystemResources("META-INF/jax-ws-catalog.xml");
        } else {
            catalogEnum = cl.getResources("META-INF/jax-ws-catalog.xml");
        }

        while(catalogEnum.hasMoreElements()) {
            URL url = catalogEnum.nextElement();
            catalog.parseCatalog(url);
        }
    } catch (IOException e) {
        throw new WebServiceException(e);
    }

    return workaroundCatalogResolver(catalog);
}
 
Example #19
Source File: XmlUtil.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Default CatalogResolver implementation is broken as it depends on CatalogManager.getCatalog() which will always create a new one when
 *  useStaticCatalog is false.
 *  This returns a CatalogResolver that uses the catalog passed as parameter.
 * @param catalog
 * @return  CatalogResolver
 */
private static CatalogResolver workaroundCatalogResolver(final Catalog catalog) {
    // set up a manager
    CatalogManager manager = new CatalogManager() {
        @Override
        public Catalog getCatalog() {
            return catalog;
        }
    };
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);

    return new CatalogResolver(manager);
}
 
Example #20
Source File: XMLCatalogResolver.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #21
Source File: XmlUtil.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Default CatalogResolver implementation is broken as it depends on CatalogManager.getCatalog() which will always create a new one when
 *  useStaticCatalog is false.
 *  This returns a CatalogResolver that uses the catalog passed as parameter.
 * @param catalog
 * @return  CatalogResolver
 */
private static CatalogResolver workaroundCatalogResolver(final Catalog catalog) {
    // set up a manager
    CatalogManager manager = new CatalogManager() {
        @Override
        public Catalog getCatalog() {
            return catalog;
        }
    };
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);

    return new CatalogResolver(manager);
}
 
Example #22
Source File: XMLCatalogResolver.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #23
Source File: EntityResolverFactory.java    From java-9-wtf with Apache License 2.0 5 votes vote down vote up
private static EntityResolver withConfiguredSimpleCatalogManager() {
	// works on Java 9
	final CatalogManager catalogManager = new CatalogManager();
	catalogManager.setIgnoreMissingProperties(true);
	catalogManager.setUseStaticCatalog(false);
	return new CatalogResolver(catalogManager);
}
 
Example #24
Source File: EntityResolverFactory.java    From java-9-wtf with Apache License 2.0 5 votes vote down vote up
private static EntityResolver asInPlugin() {
	// works on Java 9 - WHY?!
	final CatalogManager catalogManager = new CatalogManager();
	catalogManager.setIgnoreMissingProperties(true);
	catalogManager.setUseStaticCatalog(false);
	MavenCatalogResolver catalogResolver = new MavenCatalogResolver(
			catalogManager,
			new UoeDependencyResourceResolver());
	return new ReResolvingEntityResolverWrapper(catalogResolver);
}
 
Example #25
Source File: XMLCatalogResolver.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #26
Source File: MavenCatalogResolver.java    From java-9-wtf with Apache License 2.0 5 votes vote down vote up
public MavenCatalogResolver(CatalogManager catalogManager,
							DependencyResourceResolver dependencyResourceResolver, Log log) {
	super(catalogManager);
	this.catalogManager = catalogManager;
	if (dependencyResourceResolver == null) {
		throw new IllegalArgumentException(
				"Dependency resource resolver must not be null.");
	}
	this.dependencyResourceResolver = dependencyResourceResolver;
	this.log = log != null ? log : new Log();
}
 
Example #27
Source File: MavenCatalogResolver.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public MavenCatalogResolver(CatalogManager catalogManager,
		DependencyResourceResolver dependencyResourceResolver, Log log) {
	super(catalogManager);
	this.catalogManager = catalogManager;
	if (dependencyResourceResolver == null) {
		throw new IllegalArgumentException(
				"Dependency resource resolver must not be null.");
	}
	this.dependencyResourceResolver = dependencyResourceResolver;
	this.log = log != null ? log : NullLog.INSTANCE;
}
 
Example #28
Source File: XmlUtil.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a default EntityResolver for catalog at META-INF/jaxws-catalog.xml
 */
public static EntityResolver createDefaultCatalogResolver() {

    // set up a manager
    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);
    // parse the catalog
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    Enumeration<URL> catalogEnum;
    Catalog catalog = manager.getCatalog();
    try {
        if (cl == null) {
            catalogEnum = ClassLoader.getSystemResources("META-INF/jax-ws-catalog.xml");
        } else {
            catalogEnum = cl.getResources("META-INF/jax-ws-catalog.xml");
        }

        while(catalogEnum.hasMoreElements()) {
            URL url = catalogEnum.nextElement();
            catalog.parseCatalog(url);
        }
    } catch (IOException e) {
        throw new WebServiceException(e);
    }

    return workaroundCatalogResolver(catalog);
}
 
Example #29
Source File: XmlUtil.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Default CatalogResolver implementation is broken as it depends on CatalogManager.getCatalog() which will always create a new one when
 *  useStaticCatalog is false.
 *  This returns a CatalogResolver that uses the catalog passed as parameter.
 * @param catalog
 * @return  CatalogResolver
 */
private static CatalogResolver workaroundCatalogResolver(final Catalog catalog) {
    // set up a manager
    CatalogManager manager = new CatalogManager() {
        @Override
        public Catalog getCatalog() {
            return catalog;
        }
    };
    manager.setIgnoreMissingProperties(true);
    // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
    manager.setUseStaticCatalog(false);

    return new CatalogResolver(manager);
}
 
Example #30
Source File: XMLCatalogResolver.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}