Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Here are some examples:

Code Block
java
java
titleContained instancesjava
 PrimitiveComponentType prov = createAProvider(); // Create a primitive type
 PrimitiveComponentType cons = createAConsumer(); // Create another primitive type
       
       CompositeComponentType type = new CompositeComponentType()
           .setBundleContext(context)
           .setComponentTypeName("comp1")
           .addInstance(new Instance(prov.getFactory().getName())) // Create an instance in the composite
           .addInstance(new Instance(cons.getFactory().getName())); 
       
       ComponentInstance ci = type.createInstance();
Code Block
java
java
titleImporting servicesjava
 CompositeComponentType type = new CompositeComponentType()
           .setBundleContext(context)
           .setComponentTypeName("comp3")
           .addSubService(new InstantiatedService() // Importation
              .setSpecification(Foo.class.getName())
              .setOptional(true));
Code Block
java
java
titleInstantiated sub-servicesjava
  CompositeComponentType type = new CompositeComponentType()
           .setBundleContext(context)
           .setComponentTypeName("comp2")
           .addSubService(new InstantiatedService()  // Instantiated service
              .setSpecification(Foo.class.getName()))
           .addInstance(new Instance(cons.getFactory().getName()));
Code Block
java
java
titleExported Servicesjava
CompositeComponentType type = new CompositeComponentType()
           .setBundleContext(context)
           .setComponentTypeName("compExport")
           .addSubService(new InstantiatedService().setSpecification(Foo.class.getName()))
           .addService(new ExportedService()
                .setSpecification(Foo.class.getName())); // Exports a service

...