Java 类org.springframework.beans.factory.xml.DelegatingEntityResolver 实例源码

项目:gemini.blueprint    文件:OsgiBundleXmlApplicationContext.java   
/**
 * Similar to {@link #createNamespaceHandlerResolver(BundleContext, String, ClassLoader)} , this method creates
 * a special OSGi entity resolver that considers the bundle class path first, falling back to the entity resolver
 * service provided by the Spring DM extender.
 * 
 * @param bundleContext the OSGi context of which the resolver should be aware of
 * @param filter OSGi service filter
 * @param bundleClassLoader classloader for creating the OSGi namespace resolver proxy
 * @return a OSGi aware entity resolver
 */
private EntityResolver createEntityResolver(BundleContext bundleContext, String filter,
        ClassLoader bundleClassLoader) {
    Assert.notNull(bundleContext, "bundleContext is required");
    // create local namespace resolver
    EntityResolver localEntityResolver = new DelegatingEntityResolver(bundleClassLoader);
    // hook in OSGi namespace resolver
    EntityResolver osgiServiceEntityResolver = lookupEntityResolver(bundleContext, filter, localEntityResolver);

    ChainedEntityResolver delegate = new ChainedEntityResolver();
    delegate.addEntityResolver(localEntityResolver, "LocalEntityResolver for bundle "
            + OsgiStringUtils.nullSafeNameAndSymName(bundleContext.getBundle()));

    // hook in OSGi namespace resolver
    delegate.addEntityResolver(osgiServiceEntityResolver, "OSGi Service resolver");

    return delegate;
}
项目:spring-osgi    文件:OsgiBundleXmlApplicationContext.java   
/**
 * Similar to {@link #createNamespaceHandlerResolver(BundleContext, ClassLoader, ClassLoader)}, this method creates
 * a special OSGi entity resolver that considers the bundle class path first, falling back to the entity resolver
 * service provided by the Spring DM extender.
 * 
 * @param bundleContext the OSGi context of which the resolver should be aware of
 * @param filter
 * @param bundleClassLoader classloader for creating the OSGi namespace resolver proxy
 * @return a OSGi aware entity resolver
 */
private EntityResolver createEntityResolver(BundleContext bundleContext, String filter,
        ClassLoader bundleClassLoader) {
    Assert.notNull(bundleContext, "bundleContext is required");
    // create local namespace resolver
    EntityResolver localEntityResolver = new DelegatingEntityResolver(bundleClassLoader);

    // hook in OSGi namespace resolver
    EntityResolver osgiServiceEntityResolver = lookupEntityResolver(bundleContext, filter, localEntityResolver);

    DelegatedEntityResolver delegate = new DelegatedEntityResolver();
    delegate.addEntityResolver(localEntityResolver, "LocalEntityResolver for bundle "
            + OsgiStringUtils.nullSafeNameAndSymName(bundleContext.getBundle()));

    // hook in OSGi namespace resolver
    delegate.addEntityResolver(osgiServiceEntityResolver, "OSGi Service resolver");

    return delegate;
}
项目:gemini.blueprint    文件:NamespacePlugins.java   
private Plugin(Bundle bundle) {
    this.bundle = bundle;

    ClassLoader loader = BundleDelegatingClassLoader.createBundleClassLoaderFor(bundle);

    entity = new DelegatingEntityResolver(loader);
    namespace = new DefaultNamespaceHandlerResolver(loader);
}
项目:spring-osgi    文件:NamespacePlugins.java   
private Plugin(Bundle bundle) {
    this.bundle = bundle;

    ClassLoader loader = BundleDelegatingClassLoader.createBundleClassLoaderFor(bundle);

    entity = new DelegatingEntityResolver(loader);
    namespace = new DefaultNamespaceHandlerResolver(loader);
}
项目:gen-sbconfigurator    文件:DefaultXsdValidator.java   
@Override
public void validate(final InputStream xmlStream)
        throws ValidationFailedException {

    try {
        if (xsdSchema == null) {

            // get the source
            final InputSource inputSource = new InputSource(xmlStream);
            final EntityResolver resolver = new DelegatingEntityResolver(getClass()
                    .getClassLoader());

            // use the DocumentLoader for validation, the DocumentLoader uses the
            // defined XSD of the document, it tries to use the one distributed via
            // the jar, otherwise it looks up the URL
            documentLoader.loadDocument(inputSource, resolver, errorHandler,
                    XmlValidationModeDetector.VALIDATION_XSD, true);
        } else {

            // get the sources
            final Source xmlSource = new StreamSource(xmlStream);
            final Validator validator = xsdSchema.newValidator();

            // validate the document using the default Validator
            validator.validate(xmlSource);
        }
    } catch (final Exception e) {
        throw new ValidationFailedException("The loaded or the validation failed.", e);
    }
}