use of org.apache.xbean.blueprint.context.impl.QNameNamespaceHandler in project geronimo-xbean by apache.
the class BlueprintTestSupport method parse.
protected static BlueprintContainerImpl parse(String plan, String schema) throws Exception {
Properties properties = new Properties();
URL propUrl = BlueprintTestSupport.class.getClassLoader().getResource(schema);
InputStream in = propUrl.openStream();
try {
properties.load(in);
} finally {
in.close();
}
Set<Class> classes = new HashSet<Class>();
ClassLoader cl = BlueprintTestSupport.class.getClassLoader();
for (Map.Entry entry : properties.entrySet()) {
String key = (String) entry.getKey();
if (!key.contains(".")) {
String className = (String) entry.getValue();
Class clazz = cl.loadClass(className);
classes.add(clazz);
}
}
classes.add(QName.class);
Map<String, Class<? extends PropertyEditor>> propertyEditors = new HashMap<String, Class<? extends PropertyEditor>>();
propertyEditors.put(MilliLittersPropertyEditor.class.getName(), MilliLittersPropertyEditor.class);
final NamespaceHandler xbeanHandler = new XBeanNamespaceHandler(NAMESPACE_URI.toString(), BlueprintTestSupport.class.getClassLoader().getResource("restaurant.xsd"), classes, propertyEditors, properties);
final NamespaceHandler qnameHandler = new QNameNamespaceHandler();
SimpleNamespaceHandlerSet handlers = new SimpleNamespaceHandlerSet();
handlers.addNamespace(NAMESPACE_URI, xbeanHandler.getSchemaLocation(NAMESPACE_URI.toString()), xbeanHandler);
handlers.addNamespace(QNAME_URI, xbeanHandler.getSchemaLocation(NAMESPACE_URI.toString()), qnameHandler);
return parse(plan, handlers);
}
Aggregations