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;
}
Aggregations