Package org.apache.felix.ipojo.metadata

Examples of org.apache.felix.ipojo.metadata.Attribute


    public Element getHandlerInfo() {
        Element root = super.getHandlerInfo();
        for (int i = 0; i < m_publishersDescriptions.size(); i++) {
            PublisherDescription p = (PublisherDescription) m_publishersDescriptions.get(i);
            Element publisher = new Element("Publisher", "");
            publisher.addAttribute(new Attribute("name", p.getName()));
            publisher.addAttribute(new Attribute("synchronous", String.valueOf(p.isSynchronous())));
            publisher.addAttribute(new Attribute("data_key", p.getDataKey()));
            Element topics = new Element("Topics", "");
            if (p.getTopics() != null) {
                for (int j = 0; j < p.getTopics().length; j++) {
                    String topic = p.getTopics()[j];
                    Element e_topic = new Element("topic","");
                    topics.addElement(e_topic);
                    e_topic.addAttribute(new Attribute("name",topic));
                }
            }
            publisher.addElement(topics);
            root.addElement(publisher);
        }
View Full Code Here


          String method = definition.getCallback();
          String value = instance.getApamComponent() != null ? instance.getApamComponent().getProperty(name) : null;

          Element property = new Element("property", ApamComponentFactory.APAM_NAMESPACE);
         
          property.addAttribute(new Attribute("name",  ApamComponentFactory.APAM_NAMESPACE,  name));
          property.addAttribute(new Attribute("field", ApamComponentFactory.APAM_NAMESPACE, field != null ? field : ""));
          property.addAttribute(new Attribute("method",ApamComponentFactory.APAM_NAMESPACE, method != null ? method : ""));
          property.addAttribute(new Attribute("value", ApamComponentFactory.APAM_NAMESPACE, value != null ? value : ""));

          root.addElement(property);
        }
      }
      return root;
View Full Code Here

            if (getFactory().declaration != null) {

                ComponentDeclaration declaration = getFactory().declaration;

                Element componentDescription = new Element(COMPONENT_DECLARATION_PROPERTY, APAM_NAMESPACE);
                componentDescription.addAttribute(new Attribute("name",declaration.getName()));
                componentDescription.addAttribute(new Attribute("type",declaration.getClass().getSimpleName()));

                if (declaration instanceof ImplementationDeclaration) {
                    ImplementationDeclaration implementation = (ImplementationDeclaration) declaration;
                    if (implementation.getSpecification() != null ) {
                        componentDescription.addAttribute(new Attribute("specification",implementation.getSpecification().getName()));
                    }
                }

                if (declaration instanceof CompositeDeclaration) {
                    CompositeDeclaration composite = (CompositeDeclaration) declaration;
                    if (composite.getSpecification() != null && composite.getMainComponent() != null) {
                        componentDescription.addAttribute(new Attribute("main",composite.getMainComponent().getName()));
                    }
                }

                if (declaration instanceof InstanceDeclaration) {
                    InstanceDeclaration instance = (InstanceDeclaration) declaration;
                    if (instance.getImplementation() != null ) {
                        componentDescription.addAttribute(new Attribute("implementation",instance.getImplementation().getName()));
                    }
                }

                Element providesDescription = new Element("provides", APAM_NAMESPACE);;
                for (ResourceReference resource : declaration.getProvidedResources()) {
                    Element provideDescription = new Element("provides", APAM_NAMESPACE);
                    provideDescription.addAttribute(new Attribute("resource", resource.toString()));
                    providesDescription.addElement(provideDescription);
                }
                componentDescription.addElement(providesDescription);

                Element relationsDescription = new Element("dependencies", APAM_NAMESPACE);;
                for (RelationDeclaration relationDeclaration : declaration.getRelations()) {
                    Element relationDescription = new Element("relation", APAM_NAMESPACE);
                    relationDescription.addAttribute(new Attribute("id", relationDeclaration.getIdentifier()));
                    relationDescription.addAttribute(new Attribute("resource", relationDeclaration.getTarget().toString()));
                    relationDescription.addAttribute(new Attribute("multiple", Boolean.toString(relationDeclaration.isMultiple())));


                    Element injectionsDescription = new Element("instrumentations", APAM_NAMESPACE);
                    for (RequirerInstrumentation injectionDeclaration : relationDeclaration.getInstrumentations()) {
                        Element injectionDescription = new Element("instrumentation", APAM_NAMESPACE);
                        injectionDescription.addAttribute(new Attribute("name", injectionDeclaration.getName()));
                        injectionDescription.addAttribute(new Attribute("resource", injectionDeclaration.getRequiredResource().toString()));
                        injectionDescription.addAttribute(new Attribute("multiple", Boolean.toString(injectionDeclaration.acceptMultipleProviders())));
                        injectionsDescription.addElement(injectionDescription);
                    }
                    relationDescription.addElement(injectionsDescription);

                    Element constraintsDescription = new Element("constraints", APAM_NAMESPACE);
                    for (String constraint : relationDeclaration.getImplementationConstraints()) {
                        Element constraintDescription = new Element("implementation", APAM_NAMESPACE);
                        constraintDescription.addAttribute(new Attribute("filter", constraint));
                        constraintsDescription.addElement(constraintDescription);
                    }
                    for (String constraint : relationDeclaration.getInstanceConstraints()) {
                        Element constraintDescription = new Element("instance", APAM_NAMESPACE);
                        constraintDescription.addAttribute(new Attribute("filter", constraint));
                        constraintsDescription.addElement(constraintDescription);
                    }
                    relationDescription.addElement(constraintsDescription);

                    Element preferencesDescription = new Element("preferences", APAM_NAMESPACE);
                    int priority=0;
                    for ( String preference : relationDeclaration.getImplementationPreferences()) {
                        Element preferenceDescription = new Element("implementation", APAM_NAMESPACE);
                        preferenceDescription.addAttribute(new Attribute("filter", preference));
                        preferenceDescription.addAttribute(new Attribute("priority", Integer.toString(priority++)));
                        preferencesDescription.addElement(preferenceDescription);
                    }

                    priority=0;
                    for (String preference : relationDeclaration.getInstancePreferences()) {
                        Element preferenceDescription = new Element("instance", APAM_NAMESPACE);
                        preferenceDescription.addAttribute(new Attribute("filter", preference));
                        preferenceDescription.addAttribute(new Attribute("priority", Integer.toString(priority++)));
                        preferencesDescription.addElement(preferenceDescription);
                    }
                    relationDescription.addElement(preferencesDescription);

                    relationsDescription.addElement(relationDescription);
                }
                componentDescription.addElement(relationsDescription);

                Element definitionsDescription = new Element("definitions", APAM_NAMESPACE);;
                for (PropertyDefinition propertyDeclaration : declaration.getPropertyDefinitions()) {
                    Element definitionDescription = new Element("property", APAM_NAMESPACE);
                    definitionDescription.addAttribute(new Attribute("name", propertyDeclaration.getName()));
                    definitionDescription.addAttribute(new Attribute("type", propertyDeclaration.getType()));
                    if (propertyDeclaration.hasDefaultValue())
                        definitionDescription.addAttribute(new Attribute("value", propertyDeclaration.getDefaultValue().toString()));
                    definitionsDescription.addElement(definitionDescription);
                }
                componentDescription.addElement(definitionsDescription);

                Element propertiesDescription = new Element("properties", APAM_NAMESPACE);;
                for (Entry<String,String> propertyEntry : declaration.getProperties().entrySet()) {
                    Element propertyDescription = new Element("property", APAM_NAMESPACE);
                    propertyDescription.addAttribute(new Attribute("name", propertyEntry.getKey()));
                    if (propertyEntry.getValue() != null)
                        propertyDescription.addAttribute(new Attribute("value", propertyEntry.getValue().toString()));
                    propertiesDescription.addElement(propertyDescription);
                }
                componentDescription.addElement(propertiesDescription);

                description.addElement(componentDescription);
View Full Code Here

     */
    @Override
    public Element getDescription() {

    Element relationDescription = new Element("injection",  ApamComponentFactory.APAM_NAMESPACE);
    relationDescription.addAttribute(new Attribute("relation", relation.getIdentifier()));
    relationDescription.addAttribute(new Attribute("target", relation.getTarget().toString()));
    relationDescription.addAttribute(new Attribute("name", injection.getName()));
    relationDescription.addAttribute(new Attribute("type", injection.getRequiredResource().toString()));
    relationDescription.addAttribute(new Attribute("isAggregate", Boolean.toString(injection.acceptMultipleProviders())));
 
    /*
     * show the current state of resolution. To avoid unnecessary
     * synchronization overhead make a copy of the current target services
     * and do not use directly the field that can be concurrently modified
     */
    Set<Component> resolutions = new HashSet<Component>();
    synchronized (this) {
        resolutions.addAll(targetServices);
    }
 
    relationDescription.addAttribute(new Attribute("resolved", Boolean.toString(!resolutions.isEmpty())));
    for (Component target : resolutions) {
        Element bindingDescription = new Element("binding",ApamComponentFactory.APAM_NAMESPACE);
        bindingDescription.addAttribute(new Attribute("target", target.getName()));
        relationDescription.addElement(bindingDescription);
    }
 
    return relationDescription;

View Full Code Here

   */
    @Override
  public Element getDescription() {

        Element consumerDescription = new Element("injection", ApamComponentFactory.APAM_NAMESPACE);
    consumerDescription.addAttribute(new Attribute("relation", relation.getIdentifier()));
        consumerDescription.addAttribute(new Attribute("target", relation.getTarget().toString()));
        consumerDescription.addAttribute(new Attribute("method", injection.getName()));
        consumerDescription.addAttribute(new Attribute("type", injection.getRequiredResource().toString()));
        consumerDescription.addAttribute(new Attribute("isAggregate",   Boolean.toString(injection.acceptMultipleProviders())));

        /*
         * show the current state of resolution. To avoid unnecessary synchronization overhead make a copy of the
         * current target services and do not use directly the field that can be concurrently modified
         */
        List<Wire> resolutions = new ArrayList<Wire>();
        synchronized (this) {
            resolutions.addAll(wires.values());
        }

           
        consumerDescription.addAttribute(new Attribute("resolved",Boolean.toString(!resolutions.isEmpty())));
        consumerDescription.addAttribute(new Attribute("consumer.id",consumerId));
        consumerDescription.addAttribute(new Attribute("flavors",Arrays.toString(messageFlavors)));
        consumerDescription.addAttribute(new Attribute("buffered",Integer.toString(buffer.size())));

        for (Wire wire : resolutions) {
           
            Element wireInfo = new Element("wire",ApamComponentFactory.APAM_NAMESPACE);
            wireInfo.addAttribute(new Attribute("producer.id",(String)wire.getProperties().get(WireConstants.WIREADMIN_PRODUCER_PID)));
            wireInfo.addAttribute(new Attribute("flavors",Arrays.toString(wire.getFlavors())));
            consumerDescription.addElement(wireInfo);
        }
       

       
View Full Code Here

    }
   
    @Override
    public Element getHandlerInfo() {
      Element info = super.getHandlerInfo();
      info.addAttribute(new Attribute("producer.id",producerId));
      info.addAttribute(new Attribute("session.id",sessionId));
      info.addAttribute(new Attribute("flavors",Arrays.toString(messageFlavors)));
      info.addAttribute(new Attribute("isRegistered",Boolean.toString(isRegisteredProducer)));
 
          /*
           * show the current state of resolution. To avoid unnecessary synchronization overhead make a copy of the
           * current target services and do not use directly the field that can be concurrently modified
           */
          List<Wire> resolutions = new ArrayList<Wire>();
          synchronized (this) {
              resolutions.addAll(wires.values());
          }

      for (Wire wire : resolutions) {
        Element wireInfo = new Element("wire",ApamComponentFactory.APAM_NAMESPACE);
        wireInfo.addAttribute(new Attribute("consumer.id",(String)wire.getProperties().get(WireConstants.WIREADMIN_CONSUMER_PID)));
        wireInfo.addAttribute(new Attribute("flavors",Arrays.toString(wire.getFlavors())));
        info.addElement(wireInfo);
      }
      return info;
    }
View Full Code Here

    // Finally we can add definitions
    for (PropertyDefinition def : mapAddedDefinitions.values()) {
      Element toAdd = new Element(ComponentParser.DEFINITION,
          ComponentParser.APAM);

      toAdd.addAttribute(new Attribute(ComponentParser.ATT_NAME, def
          .getName()));
     
      if(def.getType()!= null) {
      toAdd.addAttribute(new Attribute(ComponentParser.ATT_TYPE, def
          .getType()));
      }
     
      if(def.hasDefaultValue()) {
      toAdd.addAttribute(new Attribute(ComponentParser.ATT_DEFAULT,
          def.getDefaultValue()));
      }
     
      if(def.getField()!=null) {
      toAdd.addAttribute(new Attribute(ComponentParser.ATT_FIELD, def
          .getField()));
      }
     
      if(def.getCallback()!=null) {
        toAdd.addAttribute(new Attribute(ComponentParser.ATT_METHOD, def
          .getCallback()));
      }
     
      if (def.getInjected() != null) {
        toAdd.addAttribute(new Attribute(
            ComponentParser.ATT_INJECTED, def.getInjected()
                .toString()));
      }

      element.addElement(toAdd);
    }

    // And add the properties
    for (String name : addedProperties.keySet()) {
      Element prop = new Element(ComponentParser.PROPERTY,
          ComponentParser.APAM);
      prop.addAttribute(new Attribute(ComponentParser.ATT_NAME, name));
      prop.addAttribute(new Attribute(ComponentParser.ATT_VALUE,
          addedProperties.get(name)));

      element.addElement(prop);
    }
View Full Code Here

        /**
         * Initialize the standard publishing component (based on the
         * asynchronous donut provider).
         */
        m_provider = new Element("component", "");
        m_provider.addAttribute(new Attribute("className",
                "org.apache.felix.ipojo.test.donut.DonutProviderImpl"));
        m_provider.addAttribute(new Attribute("name",
                "standard donut provider for bad tests"));

        // The provided service of the publisher
        Element providesDonutProvider = new Element("provides", "");
        providesDonutProvider.addAttribute(new Attribute("interface",
                "org.apache.felix.ipojo.test.donut.DonutProvider"));
        Element providesDonutProviderProperty = new Element("property", "");
        providesDonutProviderProperty
                .addAttribute(new Attribute("name", "name"));
        providesDonutProviderProperty.addAttribute(new Attribute("field",
                "m_name"));
        providesDonutProviderProperty.addAttribute(new Attribute("value",
                "Unknown donut vendor"));
        providesDonutProvider.addElement(providesDonutProviderProperty);
        m_provider.addElement(providesDonutProvider);

        // The event publisher, corresponding to the following description :
        // <ev:publisher name="donut-publisher" field="m_publisher"
        // topics="food/donuts" data-key="food" synchronous="false"/>
        m_publisher = new Element("publisher", NAMESPACE);
        m_publisherName = new Attribute("name", "donut-publisher");
        m_publisherField = new Attribute("field", "m_publisher");
        m_publisherTopics = new Attribute("topics", "food/donuts");
        m_publisherDataKey = new Attribute("data-key", "food");
        m_publisherSynchronous = new Attribute("synchronous", "false");
        m_publisher.addAttribute(m_publisherName);
        m_publisher.addAttribute(m_publisherField);
        m_publisher.addAttribute(m_publisherTopics);
        m_publisher.addAttribute(m_publisherDataKey);
        m_publisher.addAttribute(m_publisherSynchronous);
        m_provider.addElement(m_publisher);

        m_provider.addElement(getManipulationForComponent("donut-provider"));

        /**
         * Initialize the standard subscribing component (based on the donut
         * consumer).
         */
        m_consumer = new Element("component", "");
        m_consumer.addAttribute(new Attribute("className",
                "org.apache.felix.ipojo.test.donut.DonutConsumerImpl"));
        m_consumer.addAttribute(new Attribute("name",
                "standard donut consumer for bad tests"));

        // The provided service of the publisher
        Element providesDonutConsumer = new Element("provides", "");
        providesDonutConsumer.addAttribute(new Attribute("interface",
                "org.apache.felix.ipojo.test.donut.DonutConsumer"));
        Element providesDonutConsumerNameProperty = new Element("property", "");
        providesDonutConsumerNameProperty.addAttribute(new Attribute("name",
                "name"));
        providesDonutConsumerNameProperty.addAttribute(new Attribute("field",
                "m_name"));
        providesDonutConsumerNameProperty.addAttribute(new Attribute("value",
                "Unknown donut consumer"));
        providesDonutConsumer.addElement(providesDonutConsumerNameProperty);
        Element providesDonutConsumerSlowProperty = new Element("property", "");
        providesDonutConsumerSlowProperty.addAttribute(new Attribute("name",
                "slow"));
        providesDonutConsumerSlowProperty.addAttribute(new Attribute("field",
                "m_isSlow"));
        providesDonutConsumerSlowProperty.addAttribute(new Attribute("value",
                "false"));
        providesDonutConsumer.addElement(providesDonutConsumerSlowProperty);
        m_consumer.addElement(providesDonutConsumer);

        // The event publisher, corresponding to the following description :
        // <ev:subscriber name="donut-subscriber" callback="receiveDonut"
        // topics="food/donuts" data-key="food"
        // data-type="org.apache.felix.ipojo.test.donut.Donut"/>
        m_subscriber = new Element("subscriber", NAMESPACE);
        m_subscriberName = new Attribute("name", "donut-subscriber");
        m_subscriberCallback = new Attribute("callback", "receiveDonut");
        m_subscriberTopics = new Attribute("topics", "food/donuts");
        m_subscriberDataKey = new Attribute("data-key", "food");
        m_subscriberDataType = new Attribute("data-type",
                "org.apache.felix.ipojo.test.donut.Donut");
        m_subscriber.addAttribute(m_subscriberName);
        m_subscriber.addAttribute(m_subscriberCallback);
        m_subscriber.addAttribute(m_subscriberTopics);
        m_subscriber.addAttribute(m_subscriberDataKey);
View Full Code Here

        UnacceptableConfiguration {

        // Remove the name attribute of the publisher and replace with an
        // unexisting field name
        m_publisher.removeAttribute(m_publisherField);
        Attribute unexistingField = new Attribute("field", "m_unexistingField");
        m_publisher.addAttribute(unexistingField);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
        try {
View Full Code Here

        UnacceptableConfiguration {

        // Remove the name attribute of the publisher and replace with an
        // bad typed field name
        m_publisher.removeAttribute(m_publisherField);
        Attribute badTypedField = new Attribute("field", "m_name");
        m_publisher.addAttribute(badTypedField);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
        try {
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.metadata.Attribute

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.