Versions Compared

Key

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

...

  • pid: Returns the pid for a given service (by default, the pid is the service class name).
  • propagate: Returns true if the configuration properties must be published along with the service. Any additional service properties specified directly are merged with these.
  • heading: The label used to display the tab name (or section) where the properties are displayed. Example: "Printer Service".
  • description: A human readable description of the PID this annotation is associated with. Example: "Configuration for the PrinterService bundle".
  • Wiki Markup*metadata*: an array of PropertyMetadaData\[\] annotation describing property types (see the FactoryConfigurationAdapterService section in the "Writing Components" section.

Usage Examples

In the following example, the "Printer" component depends on a configuration whose PID name is "org.apache.felix.sample.Printer". This service will initialize its ip/port number from the provided configuration:

...

Code Block
     @Component
     public class SCR {
         @BundleDependency(required = false,
                           removed = "unloadServiceComponents",
                           filter = "(Service-Component=*)"
                           stateMask = Bundle.ACTIVE)
         void loadServiceComponents(Bundle b) {
             String descriptorPaths = (String) b.getHeaders().get("Service-Component");
             // load all service component specified in the XML descriptorPaths files ...
         }

         void unloadServiceComponents(Bundle b) {
             // unload all service component we loaded from our "loadServiceComponents" method.
         }
     }

...