/** * If namespace handler's schema imports other schemas from cxf-core bundle, this method * may be used to delegate to <code>CXFAPINamespaceHandler</code> to resolve imported schema. * @param namespace * @return if namespace may be resolved by CXFAPINamespaceHandler valid URL is returned. Otherwise * returns <code>null</code> */ protected URL findCoreSchemaLocation(String namespace) { return cxfApiNamespaceHandler.getSchemaLocation(namespace); }
@Override public ComponentMetadata decorate(Node node, ComponentMetadata componentMetadata, ParserContext parserContext) { return handler.decorate(node, componentMetadata, parserContext); } private boolean isValidSchema(String ns, URL url) {
@Override public Metadata parse(Element element, ParserContext parserContext) { return handler.parse(element, parserContext); } @Override
@Override public Set<Class> getManagedClasses() { return handler.getManagedClasses(); } @Override
@Override public Set<Class> getManagedClasses() { return handler.getManagedClasses(); } @Override
/** * If namespace handler's schema imports other schemas from cxf-core bundle, this method * may be used to delegate to <code>CXFAPINamespaceHandler</code> to resolve imported schema. * @param namespace * @return if namespace may be resolved by CXFAPINamespaceHandler valid URL is returned. Otherwise * returns <code>null</code> */ protected URL findCoreSchemaLocation(String namespace) { return cxfApiNamespaceHandler.getSchemaLocation(namespace); }
@Override public ComponentMetadata decorate(Node node, ComponentMetadata componentMetadata, ParserContext parserContext) { return handler.decorate(node, componentMetadata, parserContext); } private boolean isValidSchema(String ns, URL url) {
@Override public Metadata parse(Element element, ParserContext parserContext) { return handler.parse(element, parserContext); } @Override
if (candidates != null) { for (NamespaceHandler h : candidates) { Set<Class> classes = h.getManagedClasses(); boolean compat = true; if (classes != null) {
@Override public URL getSchemaLocation(String s) { URL url = handler.getSchemaLocation(s); if (url != null && url.equals(res)) { Boolean v, newValue; Boolean valid = ((v = cache.get(s)) == null && (newValue = isValidSchema(s, url)) != null && (v = cache.putIfAbsent(s, newValue)) == null) ? newValue : v; return valid ? url : null; } return url; } @Override
private ComponentMetadata decorateCustomNode(Node node, ComponentMetadata enclosingComponent) { NamespaceHandler handler = getNamespaceHandler(node); ParserContextImpl context = new ParserContextImpl(this, registry, enclosingComponent, node); return handler.decorate(node, enclosingComponent, context); }
private Metadata parseCustomElement(Element element, ComponentMetadata enclosingComponent) { NamespaceHandler handler = getNamespaceHandler(element); ParserContextImpl context = new ParserContextImpl(this, registry, enclosingComponent, element); return handler.parse(element, context); }
if (candidates != null) { for (NamespaceHandler h : candidates) { Set<Class> classes = h.getManagedClasses(); boolean compat = true; if (classes != null) {
@Override public URL getSchemaLocation(String s) { URL url = handler.getSchemaLocation(s); if (url != null && url.equals(res)) { Boolean v, newValue; Boolean valid = ((v = cache.get(s)) == null && (newValue = isValidSchema(s, url)) != null && (v = cache.putIfAbsent(s, newValue)) == null) ? newValue : v; return valid ? url : null; } return url; } @Override
private ComponentMetadata decorateCustomNode(Node node, ComponentMetadata enclosingComponent) { NamespaceHandler handler = getNamespaceHandler(node); ParserContextImpl context = new ParserContextImpl(this, registry, enclosingComponent, node); return handler.decorate(node, enclosingComponent, context); }
private Metadata parseCustomElement(Element element, ComponentMetadata enclosingComponent) { NamespaceHandler handler = getNamespaceHandler(element); ParserContextImpl context = new ParserContextImpl(this, registry, enclosingComponent, element); return handler.parse(element, context); }
public URL getSchemaLocation(String namespace) { if (isCmNamespace(namespace)) { String v = namespace.substring("http://aries.apache.org/blueprint/xmlns/blueprint-cm/v".length()); return getClass().getResource("blueprint-cm-" + v + ".xsd"); } else if (isExtNamespace(namespace)) { try { Class<?> extNsHandlerClazz; Bundle extBundle = FrameworkUtil.getBundle(PlaceholdersUtils.class); if (extBundle == null) { // we may not be in OSGi environment extNsHandlerClazz = getClass().getClassLoader().loadClass("org.apache.aries.blueprint.ext.impl.ExtNamespaceHandler"); } else { extNsHandlerClazz = extBundle.loadClass("org.apache.aries.blueprint.ext.impl.ExtNamespaceHandler"); } return ((NamespaceHandler) extNsHandlerClazz.newInstance()).getSchemaLocation(namespace); } catch (Throwable t) { LOGGER.warn("Could not locate ext namespace schema", t); return null; } } else { return null; } }
/** * Tests if a scope attribute value is a custom scope, and if so invokes * the appropriate namespace handler, passing the blueprint scope node. * <p> * Currently this tests for custom scope by looking for the presence of * a ':' char within the scope attribute value. This is valid as long as * the blueprint schema continues to restrict that custom scopes should * require that characters presence. * <p> * * @param scope Value of scope attribute * @param bean DOM element for bean associated to this scope * @return Metadata as processed by NS Handler. * @throws ComponentDefinitionException if an undeclared prefix is used, * if a namespace handler is unavailable for a resolved prefix, * or if the resolved prefix results as the blueprint namespace. */ private ComponentMetadata handleCustomScope(Node scope, Element bean, ComponentMetadata metadata){ URI scopeNS = getNamespaceForAttributeValue(scope); if(scopeNS!=null && !BLUEPRINT_NAMESPACE.equals(scopeNS.toString())){ NamespaceHandler nsHandler = getNamespaceHandler(scopeNS); ParserContextImpl context = new ParserContextImpl(this, registry, metadata, scope); metadata = nsHandler.decorate(scope, metadata, context); }else if(scopeNS!=null){ throw new ComponentDefinitionException("Custom scopes cannot use the blueprint namespace "+scope); } return metadata; }
public URL getSchemaLocation(String namespace) { if (isCmNamespace(namespace)) { String v = namespace.substring("http://aries.apache.org/blueprint/xmlns/blueprint-cm/v".length()); return getClass().getResource("blueprint-cm-" + v + ".xsd"); } else if (isExtNamespace(namespace)) { try { Class<?> extNsHandlerClazz; Bundle extBundle = FrameworkUtil.getBundle(PlaceholdersUtils.class); if (extBundle == null) { // we may not be in OSGi environment extNsHandlerClazz = getClass().getClassLoader().loadClass("org.apache.aries.blueprint.ext.impl.ExtNamespaceHandler"); } else { extNsHandlerClazz = extBundle.loadClass("org.apache.aries.blueprint.ext.impl.ExtNamespaceHandler"); } return ((NamespaceHandler) extNsHandlerClazz.newInstance()).getSchemaLocation(namespace); } catch (Throwable t) { LOGGER.warn("Could not locate ext namespace schema", t); return null; } } else { return null; } }
/** * Tests if a scope attribute value is a custom scope, and if so invokes * the appropriate namespace handler, passing the blueprint scope node. * <p> * Currently this tests for custom scope by looking for the presence of * a ':' char within the scope attribute value. This is valid as long as * the blueprint schema continues to restrict that custom scopes should * require that characters presence. * <p> * * @param scope Value of scope attribute * @param bean DOM element for bean associated to this scope * @return Metadata as processed by NS Handler. * @throws ComponentDefinitionException if an undeclared prefix is used, * if a namespace handler is unavailable for a resolved prefix, * or if the resolved prefix results as the blueprint namespace. */ private ComponentMetadata handleCustomScope(Node scope, Element bean, ComponentMetadata metadata){ URI scopeNS = getNamespaceForAttributeValue(scope); if(scopeNS!=null && !BLUEPRINT_NAMESPACE.equals(scopeNS.toString())){ NamespaceHandler nsHandler = getNamespaceHandler(scopeNS); ParserContextImpl context = new ParserContextImpl(this, registry, metadata, scope); metadata = nsHandler.decorate(scope, metadata, context); }else if(scopeNS!=null){ throw new ComponentDefinitionException("Custom scopes cannot use the blueprint namespace "+scope); } return metadata; }