Search in sources :

Example 1 with Namespaces

use of org.apache.aries.blueprint.Namespaces in project aries by apache.

the class BlueprintContextListener method getNamespaceHandlerSetFromClassNames.

protected NamespaceHandlerSet getNamespaceHandlerSetFromClassNames(ServletContext servletContext, ClassLoader tccl, List<String> handlerClassNames) {
    SimpleNamespaceHandlerSet nsSet = new SimpleNamespaceHandlerSet();
    for (String name : handlerClassNames) {
        String trimmedName = name.trim();
        Object instance = null;
        try {
            instance = tccl.loadClass(trimmedName).newInstance();
        } catch (Exception ex) {
            throw new RuntimeException("Failed to load NamespaceHandler: " + trimmedName, ex);
        }
        if (!(instance instanceof NamespaceHandler)) {
            throw new RuntimeException("Invalid NamespaceHandler: " + trimmedName);
        }
        NamespaceHandler nsHandler = (NamespaceHandler) instance;
        Namespaces namespaces = nsHandler.getClass().getAnnotation(Namespaces.class);
        if (namespaces != null) {
            for (String ns : namespaces.value()) {
                nsSet.addNamespace(URI.create(ns), nsHandler.getSchemaLocation(ns), nsHandler);
            }
        }
    }
    return nsSet;
}
Also used : SimpleNamespaceHandlerSet(org.apache.aries.blueprint.container.SimpleNamespaceHandlerSet) Namespaces(org.apache.aries.blueprint.Namespaces) NamespaceHandler(org.apache.aries.blueprint.NamespaceHandler) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 NamespaceHandler (org.apache.aries.blueprint.NamespaceHandler)1 Namespaces (org.apache.aries.blueprint.Namespaces)1 SimpleNamespaceHandlerSet (org.apache.aries.blueprint.container.SimpleNamespaceHandlerSet)1