Search in sources :

Example 1 with XBeanNamespaceHandler

use of org.apache.xbean.blueprint.context.impl.XBeanNamespaceHandler 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);
}
Also used : SimpleNamespaceHandlerSet(org.apache.aries.blueprint.container.SimpleNamespaceHandlerSet) MilliLittersPropertyEditor(org.apache.xbean.blueprint.example.MilliLittersPropertyEditor) HashMap(java.util.HashMap) InputStream(java.io.InputStream) Properties(java.util.Properties) URL(java.net.URL) XBeanNamespaceHandler(org.apache.xbean.blueprint.context.impl.XBeanNamespaceHandler) QNameNamespaceHandler(org.apache.xbean.blueprint.context.impl.QNameNamespaceHandler) PropertyEditor(java.beans.PropertyEditor) MilliLittersPropertyEditor(org.apache.xbean.blueprint.example.MilliLittersPropertyEditor) QNameNamespaceHandler(org.apache.xbean.blueprint.context.impl.QNameNamespaceHandler) NamespaceHandler(org.apache.aries.blueprint.NamespaceHandler) XBeanNamespaceHandler(org.apache.xbean.blueprint.context.impl.XBeanNamespaceHandler) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

PropertyEditor (java.beans.PropertyEditor)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Properties (java.util.Properties)1 NamespaceHandler (org.apache.aries.blueprint.NamespaceHandler)1 SimpleNamespaceHandlerSet (org.apache.aries.blueprint.container.SimpleNamespaceHandlerSet)1 QNameNamespaceHandler (org.apache.xbean.blueprint.context.impl.QNameNamespaceHandler)1 XBeanNamespaceHandler (org.apache.xbean.blueprint.context.impl.XBeanNamespaceHandler)1 MilliLittersPropertyEditor (org.apache.xbean.blueprint.example.MilliLittersPropertyEditor)1