Package org.apache.aries.blueprint.container

Examples of org.apache.aries.blueprint.container.Parser


        return parse(name, handlers);
    }

    protected ComponentDefinitionRegistryImpl parse(String name, NamespaceHandlerRegistry.NamespaceHandlerSet handlers) throws Exception {
        ComponentDefinitionRegistryImpl registry = new ComponentDefinitionRegistryImpl();
        Parser parser = new Parser();
        parser.parse(Collections.singletonList(getClass().getResource(name)));
        parser.populate(handlers, registry);
        return registry;
    }
View Full Code Here


        if (element.hasAttribute(INTERFACE_ATTRIBUTE)) {
            interfaces = Collections.singletonList(element.getAttribute(INTERFACE_ATTRIBUTE));
            factoryMetadata.addProperty("interfaces", createList(context, interfaces));
        }

        Parser parser = getParser(context);
       
        // Parse elements
        List<RegistrationListener> listeners = new ArrayList<RegistrationListener>();
        NodeList nl = element.getChildNodes();
        for (int i = 0; i < nl.getLength(); i++) {
            Node node = nl.item(i);
            if (node instanceof Element) {
                Element e = (Element) node;
                if (isBlueprintNamespace(e.getNamespaceURI())) {
                    if (nodeNameEquals(e, INTERFACES_ELEMENT)) {
                        if (interfaces != null) {
                            throw new ComponentDefinitionException("Only one of " + Parser.INTERFACE_ATTRIBUTE + " attribute or " + INTERFACES_ELEMENT + " element must be used");
                        }
                        interfaces = parseInterfaceNames(e);
                        factoryMetadata.addProperty("interfaces", createList(context, interfaces));                   
                    } else if (nodeNameEquals(e, Parser.SERVICE_PROPERTIES_ELEMENT)) {
                        MapMetadata map = parser.parseServiceProperties(e, factoryMetadata);
                        factoryMetadata.addProperty("serviceProperties", map);
                    } else if (nodeNameEquals(e, Parser.REGISTRATION_LISTENER_ELEMENT)) {
                        listeners.add(parser.parseRegistrationListener(e, factoryMetadata));
                    }
                } else if (BLUEPRINT_CM_NAMESPACE_1_0.equals(e.getNamespaceURI())
                        || BLUEPRINT_CM_NAMESPACE_1_1.equals(e.getNamespaceURI())) {
                    if (nodeNameEquals(e, MANAGED_COMPONENT_ELEMENT)) {
                        MutableBeanMetadata managedComponent = context.parseElement(MutableBeanMetadata.class, null, e);
View Full Code Here

        new MethodCall(ParserContext.class, "getDefaultTimeout"), "5000");
  }
 
  private static class ParserContextMock {
    public<T> T parseElement(Class<T> type, ComponentMetadata enclosingComponent, Element element) {
      return new Parser().parseElement(type, enclosingComponent, element);
    }
View Full Code Here

        if (element.hasAttribute(INTERFACE_ATTRIBUTE)) {
            interfaces = Collections.singletonList(element.getAttribute(INTERFACE_ATTRIBUTE));
            factoryMetadata.addProperty("interfaces", createList(context, interfaces));
        }

        Parser parser = getParser(context);
       
        // Parse elements
        List<RegistrationListener> listeners = new ArrayList<RegistrationListener>();
        NodeList nl = element.getChildNodes();
        for (int i = 0; i < nl.getLength(); i++) {
            Node node = nl.item(i);
            if (node instanceof Element) {
                Element e = (Element) node;
                if (isBlueprintNamespace(e.getNamespaceURI())) {
                    if (nodeNameEquals(e, INTERFACES_ELEMENT)) {
                        if (interfaces != null) {
                            throw new ComponentDefinitionException("Only one of " + Parser.INTERFACE_ATTRIBUTE + " attribute or " + INTERFACES_ELEMENT + " element must be used");
                        }
                        interfaces = parseInterfaceNames(e);
                        factoryMetadata.addProperty("interfaces", createList(context, interfaces));                   
                    } else if (nodeNameEquals(e, Parser.SERVICE_PROPERTIES_ELEMENT)) {
                        MapMetadata map = parser.parseServiceProperties(e, factoryMetadata);
                        factoryMetadata.addProperty("serviceProperties", map);
                    } else if (nodeNameEquals(e, Parser.REGISTRATION_LISTENER_ELEMENT)) {
                        listeners.add(parser.parseRegistrationListener(e, factoryMetadata));
                    }
                } else if (BLUEPRINT_CM_NAMESPACE.equals(e.getNamespaceURI())) {
                    if (nodeNameEquals(e, MANAGED_COMPONENT_ELEMENT)) {
                        MutableBeanMetadata managedComponent = context.parseElement(MutableBeanMetadata.class, null, e);
                        generateIdIfNeeded(context, managedComponent);
View Full Code Here

    }
   
    @Test
    public void testMultipleElements_100() throws Exception
    {
      Parser p = new Parser();
     
      URL bpxml = this.getClass().getResource("aries.xml");
      List<URL> bpxmlList = new LinkedList<URL>();
      bpxmlList.add(bpxml);
     
      p.parse(bpxmlList);
      Set<URI> nsuris = p.getNamespaces();
      NamespaceHandlerSet nshandlers = nhri.getNamespaceHandlers(nsuris, b);
      p.validate(nshandlers.getSchema());
     
      ComponentDefinitionRegistry cdr = new ComponentDefinitionRegistryImpl();
      p.populate(nshandlers, cdr);
     
      BeanMetadata comp = (BeanMetadata) cdr.getComponentDefinition("top");
     
      BeanMetadata anon = (BeanMetadata) ((BeanProperty) comp.getProperties().get(0)).getValue();
      BeanMetadata anonToo = (BeanMetadata) ((BeanProperty) comp.getProperties().get(1)).getValue();
View Full Code Here

    }
   
    @Test
    public void testMultipleElements_110() throws Exception
    {
      Parser p = new Parser();
     
      URL bpxml = this.getClass().getResource("aries4.xml");
      List<URL> bpxmlList = new LinkedList<URL>();
      bpxmlList.add(bpxml);
     
      p.parse(bpxmlList);
      Set<URI> nsuris = p.getNamespaces();
      NamespaceHandlerSet nshandlers = nhri.getNamespaceHandlers(nsuris, b);
      p.validate(nshandlers.getSchema());
     
      ComponentDefinitionRegistry cdr = new ComponentDefinitionRegistryImpl();
      p.populate(nshandlers, cdr);
     
      BeanMetadata comp = (BeanMetadata) cdr.getComponentDefinition("top");
     
      BeanMetadata anon = (BeanMetadata) ((BeanProperty) comp.getProperties().get(0)).getValue();
      BeanMetadata anonToo = (BeanMetadata) ((BeanProperty) comp.getProperties().get(1)).getValue();
View Full Code Here

    }
   
    @Test
    public void testOptionalMethodAttribute_100() throws Exception
    {
      Parser p = new Parser();
     
      URL bpxml = this.getClass().getResource("aries2.xml");
      List<URL> bpxmlList = new LinkedList<URL>();
      bpxmlList.add(bpxml);
     
      p.parse(bpxmlList);
      Set<URI> nsuris = p.getNamespaces();
      NamespaceHandlerSet nshandlers = nhri.getNamespaceHandlers(nsuris, b);
      p.validate(nshandlers.getSchema());
     
      ComponentDefinitionRegistry cdr = new ComponentDefinitionRegistryImpl();
      p.populate(nshandlers, cdr);
     
      BeanMetadata comp = (BeanMetadata) cdr.getComponentDefinition("top");
     
      BeanMetadata anon = (BeanMetadata) ((BeanProperty) comp.getProperties().get(0)).getValue();
      BeanMetadata anonToo = (BeanMetadata) ((BeanProperty) comp.getProperties().get(1)).getValue();
View Full Code Here

    }
   
    @Test
    public void testOptionalMethodAttribute_110() throws Exception
    {
      Parser p = new Parser();
     
      URL bpxml = this.getClass().getResource("aries5.xml");
      List<URL> bpxmlList = new LinkedList<URL>();
      bpxmlList.add(bpxml);
     
      p.parse(bpxmlList);
      Set<URI> nsuris = p.getNamespaces();
      NamespaceHandlerSet nshandlers = nhri.getNamespaceHandlers(nsuris, b);
      p.validate(nshandlers.getSchema());
     
      ComponentDefinitionRegistry cdr = new ComponentDefinitionRegistryImpl();
      p.populate(nshandlers, cdr);
     
      BeanMetadata comp = (BeanMetadata) cdr.getComponentDefinition("top");
     
      BeanMetadata anon = (BeanMetadata) ((BeanProperty) comp.getProperties().get(0)).getValue();
      BeanMetadata anonToo = (BeanMetadata) ((BeanProperty) comp.getProperties().get(1)).getValue();
View Full Code Here

    }
   
    @Test
    public void testOptionalValueAttribute_100() throws Exception
    {
      Parser p = new Parser();
     
      URL bpxml = this.getClass().getResource("aries3.xml");
      List<URL> bpxmlList = new LinkedList<URL>();
      bpxmlList.add(bpxml);
     
      p.parse(bpxmlList);
      Set<URI> nsuris = p.getNamespaces();
      NamespaceHandlerSet nshandlers = nhri.getNamespaceHandlers(nsuris, b);
      p.validate(nshandlers.getSchema());
     
      ComponentDefinitionRegistry cdr = new ComponentDefinitionRegistryImpl();
      p.populate(nshandlers, cdr);
     
      BeanMetadata comp = (BeanMetadata) cdr.getComponentDefinition("top");
     
      BeanMetadata anon = (BeanMetadata) ((BeanProperty) comp.getProperties().get(0)).getValue();
      BeanMetadata anonToo = (BeanMetadata) ((BeanProperty) comp.getProperties().get(1)).getValue();
View Full Code Here

    }
   
    @Test
    public void testOptionalValueAttribute_110() throws Exception
    {
      Parser p = new Parser();
     
      URL bpxml = this.getClass().getResource("aries6.xml");
      List<URL> bpxmlList = new LinkedList<URL>();
      bpxmlList.add(bpxml);
     
      p.parse(bpxmlList);
      Set<URI> nsuris = p.getNamespaces();
      NamespaceHandlerSet nshandlers = nhri.getNamespaceHandlers(nsuris, b);
      p.validate(nshandlers.getSchema());
     
      ComponentDefinitionRegistry cdr = new ComponentDefinitionRegistryImpl();
      p.populate(nshandlers, cdr);
     
      BeanMetadata comp = (BeanMetadata) cdr.getComponentDefinition("top");
     
      BeanMetadata anon = (BeanMetadata) ((BeanProperty) comp.getProperties().get(0)).getValue();
      BeanMetadata anonToo = (BeanMetadata) ((BeanProperty) comp.getProperties().get(1)).getValue();
View Full Code Here

TOP

Related Classes of org.apache.aries.blueprint.container.Parser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.