com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver. 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: RawXJC2Mojo.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Creates an instance of catalog resolver.
 * 
 * @return Instance of the catalog resolver.
 * @throws MojoExecutionException
 *             If catalog resolver cannot be instantiated.
 */
protected CatalogResolver createCatalogResolver() throws MojoExecutionException {
	final CatalogManager catalogManager = new CatalogManager();
	catalogManager.setIgnoreMissingProperties(true);
	catalogManager.setUseStaticCatalog(false);
	// TODO Logging
	if (getLog().isDebugEnabled()) {
		catalogManager.setVerbosity(Integer.MAX_VALUE);
	}
	if (getCatalogResolver() == null) {
		return new MavenCatalogResolver(catalogManager, this, getLog());
	} else {
		final String catalogResolverClassName = getCatalogResolver().trim();
		return createCatalogResolverByClassName(catalogResolverClassName);
	}
}
 
Example #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #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 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 #11
Source File: RawXJC2Mojo.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private CatalogResolver createCatalogResolverByClassName(final String catalogResolverClassName)
		throws MojoExecutionException {
	try {
		final Class<?> draftCatalogResolverClass = Thread.currentThread().getContextClassLoader()
				.loadClass(catalogResolverClassName);
		if (!CatalogResolver.class.isAssignableFrom(draftCatalogResolverClass)) {
			throw new MojoExecutionException(
					MessageFormat.format("Specified catalog resolver class [{0}] could not be casted to [{1}].",
							catalogResolver, CatalogResolver.class));
		} else {
			@SuppressWarnings("unchecked")
			final Class<? extends CatalogResolver> catalogResolverClass = (Class<? extends CatalogResolver>) draftCatalogResolverClass;
			final CatalogResolver catalogResolverInstance = catalogResolverClass.newInstance();
			return catalogResolverInstance;
		}
	} catch (ClassNotFoundException cnfex) {
		throw new MojoExecutionException(
				MessageFormat.format("Could not find specified catalog resolver class [{0}].", catalogResolver),
				cnfex);
	} catch (InstantiationException iex) {
		throw new MojoExecutionException(
				MessageFormat.format("Could not instantiate catalog resolver class [{0}].", catalogResolver), iex);
	} catch (IllegalAccessException iaex) {
		throw new MojoExecutionException(
				MessageFormat.format("Could not instantiate catalog resolver class [{0}].", catalogResolver), iaex);
	}
}
 
Example #12
Source File: EntityResolverFactory.java    From java-9-wtf with Apache License 2.0 4 votes vote down vote up
private static EntityResolver blank() {
	// works on Java 9
	return new CatalogResolver();
}
 
Example #13
Source File: EntityResolverFactory.java    From java-9-wtf with Apache License 2.0 4 votes vote down vote up
private static EntityResolver withDefaultSimpleCatalogManager() {
	// works on Java 9
	return new CatalogResolver(new CatalogManager());
}
 
Example #14
Source File: RawXJC2Mojo.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected CatalogResolver getCatalogResolverInstance() {
	if (catalogResolverInstance == null) {
		throw new IllegalStateException("Catalog resolver was not set up yet.");
	}
	return catalogResolverInstance;
}
 
Example #15
Source File: RawXJC2Mojo.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected EntityResolver createEntityResolver(CatalogResolver catalogResolver) {
	final EntityResolver entityResolver = new ReResolvingEntityResolverWrapper(catalogResolver);
	return entityResolver;
}