Interface FactoryPidAdapterBuilder
- All Superinterfaces:
ComponentBuilder<FactoryPidAdapterBuilder>
For each new Config Admin factory configuration matching a given factory pid,
an adapter will be created based on the adapter implementation class. The adapter will be registered with the specified interface,
and with the specified adapter service properties. Depending on the propagate parameter, every public factory configuration properties
(which don't start with ".") will be propagated along with the adapter service properties.
This builded supports type safe configuration types. For a given factory configuration, you can specify an interface of your choice,
and DM will implement it using a dynamic proxy that converts interface methods to lookups in the actual factory configuration dictionary.
For more information about configuration types, please refer to ConfigurationDependencyBuilder.
Example that defines a factory configuration adapter service for the "foo.bar" factory pid. For each factory pid instance, an instance of the DictionaryImpl component will be created.
public class Activator extends DependencyManagerActivator {
public void init(BundleContext ctx, DependencyManager dm) throws Exception {
factoryPidAdapter(adapter -> adapter
.impl(DictionaryImpl.class)
.factoryPid("foo.bar")
.update(ServiceImpl::updated)
.propagate()
.withSvc(LogService.class, log -> log.optional()));
}
}
Example that defines a factory configuration adapter using a user defined configuration type (the pid is by default assumed to match the fqdn of the configuration type):
public interface DictionaryConfiguration {
public String getLanguage();
public List<String> getWords();
}
public class Activator extends DependencyManagerActivator {
public void init(BundleContext ctx, DependencyManager dm) throws Exception {
factoryPidAdapter(adapter -> adapter
.impl(DictionaryImpl.class)
.factoryPid("foo.bar")
.update(DictionaryConfiguration.class, ServiceImpl::updated)
.propagate()
.withSvc(LogService.class, log -> log.optional()));
}
}
-
Method Summary
Modifier and TypeMethodDescriptionfactoryPid(String pid) Specifies the factory pid used by the adapter.Specifies if the public properties (not starting with a dot) should be propagated to the adapter service properties (false by default).propagate(boolean propagate) Specifies if the public properties (not starting with a dot) should be propagated to the adapter service properties (false by default).Specifies a callback instance method that will be called on a given object instance when the configuration is injected.Sets a callback method to call on the component implementation when the configuration is updated.update(Class<T> configType, InstanceCbConfiguration<T> callback) Specifies a method reference that will be called on a given object instance when the configuration is injected.update(Class<T> configType, InstanceCbConfigurationComponent<T> callback) Specifies a method reference that will be called on a given object instance when the configuration is injected.<T,U> FactoryPidAdapterBuilder update(Class<U> configType, CbConfiguration<T, U> callback) Specifies a method reference that will be called on one of the component classes when the configuration is injected.<T,U> FactoryPidAdapterBuilder update(Class<U> configType, CbConfigurationComponent<T, U> callback) Specifies a method reference that will be called on one of the component classes when the configuration is injected.Specifies a callback instance method that will be called on a given object instance when the configuration is injected.Specifies a callback method that will be called on the component implementation when the configuration is injected.update(CbDictionary<T> callback) Specifies a method reference that will be called on one of the component classes when the configuration is injected.update(CbDictionaryComponent<T> callback) Specifies a method reference that will be called on one of the component classes when the configuration is injectedupdate(InstanceCbDictionary callback) Specifies a method reference that will be called on a given object instance when the configuration is injectedupdate(InstanceCbDictionaryComponent callback) Specifies a method reference that will be called on a given object instance when the configuration is injected.Methods inherited from interface org.apache.felix.dm.lambda.ComponentBuilder
autoAdd, autoConfig, autoConfig, build, composition, composition, composition, debug, destroy, destroy, destroy, destroy, factory, factory, factory, factory, factory, impl, init, init, init, init, listener, properties, properties, properties, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, scope, start, start, start, start, stop, stop, stop, stop, withBundle, withCnf, withCnf, withCnf, withDep, withFuture, withSvc, withSvc, withSvc, withSvc, withSvc, withSvc
-
Method Details
-
factoryPid
Specifies the factory pid used by the adapter.- Parameters:
pid- the factory pid.- Returns:
- this builder
-
propagate
FactoryPidAdapterBuilder propagate()Specifies if the public properties (not starting with a dot) should be propagated to the adapter service properties (false by default).- Returns:
- this builder.
-
propagate
Specifies if the public properties (not starting with a dot) should be propagated to the adapter service properties (false by default).- Parameters:
propagate- true if the public properties should be propagated to the adapter service properties (false by default).- Returns:
- this builder.
-
update
Specifies a callback method that will be called on the component implementation when the configuration is injected.- Parameters:
updateMethod- the method to call on the component implementation when the configuration is available ("updated" by default).The following method signatures are supported:
- method(Dictionary properties)
- method(Component component, Dictionary properties)
- Returns:
- this builder
-
update
Sets a callback method to call on the component implementation when the configuration is updated. The callback is invoked with a configuration type argument.The following callback signatures are supported and searched in the following order:
- method(Dictionary)
- method(Component, Dictionary)
- method(Configuration) // same type as the one specified in the "configType" argument
- method(Component, Configuration) // Configuration has the same type as the one specified in the "configType" argument
- Parameters:
configType- the type of a configuration that is passed as argument to the callbackupdateMethod- the callback to call on the component implementation when the configuration is updated.- Returns:
- this builder
-
update
Specifies a callback instance method that will be called on a given object instance when the configuration is injected.- Parameters:
callbackInstance- the Object instance on which the updated callback will be invoked.updateMethod- the method to call on the given object instance when the configuration is available ("updated" by default). The following method signatures are supported:method(Dictionary properties) method(Component component, Dictionary properties)- Returns:
- this builder
-
update
Specifies a callback instance method that will be called on a given object instance when the configuration is injected. The callback is invoked with a configuration type argument.The following callback signatures are supported and searched in the following order:
- method(Dictionary)
- method(Component, Dictionary)
- method(Configuration) // same type as the one specified in the "configType" argument
- method(Component, Configuration) // Configuration has the same type as the one specified in the "configType" argument
- Parameters:
configType- the type of a configuration that is passed as argument to the callbackcallbackInstance- the Object instance on which the updated callback will be invoked.updateMethod- the method to call on the given object instance when the configuration is available. The callback is invoked with a configuration type argument (matching the configType you have specified.- Returns:
- this builder
-
update
Specifies a method reference that will be called on one of the component classes when the configuration is injected. The callback is invoked with a Dictionary argument.- Type Parameters:
T- the type of the component implementation class on which the callback is invoked on.- Parameters:
callback- the method to call on one of the component classes when the configuration is available.- Returns:
- this builder
-
update
Specifies a method reference that will be called on one of the component classes when the configuration is injected. The callback is invoked with a configuration type argument.- Type Parameters:
T- the type of the component implementation class on which the callback is invoked on.U- the configuration type accepted by the callback method.- Parameters:
configType- the type of a configuration that is passed as argument to the callbackcallback- the method to call on one of the component classes when the configuration is available.- Returns:
- this builder
-
update
Specifies a method reference that will be called on one of the component classes when the configuration is injected- Type Parameters:
T- the type of the component implementation class on which the callback is invoked on.- Parameters:
callback- the reference to a method on one of the component classes. The method may takes as arguments a Dictionary and a Component.- Returns:
- this builder
-
update
Specifies a method reference that will be called on one of the component classes when the configuration is injected. The callback is invoked with the following arguments: a configuration type, and a Component object.- Type Parameters:
T- the type of the component implementation class on which the callback is invoked on.U- the configuration type accepted by the callback method.- Parameters:
configType- the type of a configuration that is passed as argument to the callbackcallback- the reference to a method on one of the component classes. The method may takes as arguments a configuration type and a Component.- Returns:
- this builder
-
update
Specifies a method reference that will be called on a given object instance when the configuration is injected- Parameters:
callback- the method to call on a given object instance when the configuration is available. The callback takes as argument a a Dictionary parameter.- Returns:
- this builder
-
update
Specifies a method reference that will be called on a given object instance when the configuration is injected. The callback is invoked with a type-safe configuration type argument.- Type Parameters:
T- the configuration type accepted by the callback method.- Parameters:
configType- the type of a configuration that is passed as argument to the callbackcallback- the method to call on a given object instance when the configuration is available. The callback takes as argument a a configuration type parameter.- Returns:
- this builder
-
update
Specifies a method reference that will be called on a given object instance when the configuration is injected.- Parameters:
callback- the method to call on a given object instance when the configuration is available. The callback takes as argument a Dictionary, and a Component parameter.- Returns:
- this builder
-
update
<T> FactoryPidAdapterBuilder update(Class<T> configType, InstanceCbConfigurationComponent<T> callback) Specifies a method reference that will be called on a given object instance when the configuration is injected.- Type Parameters:
T- the configuration type accepted by the callback method.- Parameters:
configType- the type of a configuration that is passed as argument to the callbackcallback- the method to call on a given object instance when the configuration is available. The callback takes as arguments a configuration type, and a Component parameter.- Returns:
- this builder
-