private NamespaceHandlerResolver createNamespaceHandlerResolver(BundleContext bundleContext, String filter,
ClassLoader bundleClassLoader) {
Assert.notNull(bundleContext, "bundleContext is required");
// create local namespace resolver
// we'll use the default resolver which uses the bundle local class-loader
NamespaceHandlerResolver localNamespaceResolver = new DefaultNamespaceHandlerResolver(bundleClassLoader);
// hook in OSGi namespace resolver
NamespaceHandlerResolver osgiServiceNamespaceResolver = lookupNamespaceHandlerResolver(bundleContext, filter,
localNamespaceResolver);
DelegatedNamespaceHandlerResolver delegate = new DelegatedNamespaceHandlerResolver();
delegate.addNamespaceHandler(localNamespaceResolver, "LocalNamespaceResolver for bundle "
+ OsgiStringUtils.nullSafeNameAndSymName(bundleContext.getBundle()));