Package org.apache.felix.dm.lambda
Interface BundleDependencyBuilder
- All Superinterfaces:
DependencyBuilder<org.apache.felix.dm.BundleDependency>
public interface BundleDependencyBuilder
extends DependencyBuilder<org.apache.felix.dm.BundleDependency>
Builds a Dependency Manager Bundle Dependency.
Example of a Pojo Component which tracks a started bundle having a given bundle symbolic name:
public class Activator extends DependencyManagerActivator {
public void init(BundleContext ctx, DependencyManager dm) throws Exception {
String BSN = "org.apache.felix.dependencymanager";
component(comp -> comp
.impl(Pojo.class)
.withBundle(b -> b.mask(Bundle.ACTIVE).filter("(Bundle-SymbolicName=" + BSN + ")").add(Pojo::add).remove(Pojo::remove)));
}
}
- Author:
- Felix Project Team
-
Method Summary
Modifier and TypeMethodDescriptionSets a "add"callbackmethod to invoke on the component implementation instance(s).Sets acallbackmethod reference which is invoked when a bundle is added.add(CbBundleComponent<T> add) Sets acallbackmethod reference which is invoked when a bundle is added.add(InstanceCbBundle add) Sets a method reference on an Object instance which is invoked when a bundle is added.Sets acallback instancemethod reference which is invoked when a bundle is added.Enables auto configuration for this dependency.autoConfig(boolean autoConfig) Enables auto configuration for this dependency.bundle(org.osgi.framework.Bundle bundle) Sets the bundle to depend on directly.callbackInstance(Object callbackInstance) Specifies a callback instance used to invoke the reflection based callbacks on it.Sets a "change"callbackmethod to invoke on the component implementation instance(s).Sets acallbackmethod reference which is invoked when a bundle is changed.change(CbBundleComponent<T> change) Sets acallbackmethod reference which is invoked when a bundle is changed.change(InstanceCbBundle change) Sets a method reference on an Object instance which is invoked when a bundle is changed.change(InstanceCbBundleComponent change) Sets acallback instancemethod reference which is invoked when a bundle is changed.Sets the filter condition to depend on.mask(int mask) Sets the bundle state mask to depend on.optional()Sets the dependency to be optional.Sets property propagation.propagate(boolean propagate) Sets property propagation.Sets an Object instance and a callback method used to propagate some properties to the provided service properties.propagate(Function<org.osgi.framework.Bundle, Dictionary<?, ?>> propagate) Sets a reference to a method on an Object instance used to propagate some bundle properties to the provided service properties.Sets a "remove"callbackmethod to invoke on the component implementation instance(s).Sets acallbackmethod reference which is invoked when a bundle is removed.remove(CbBundleComponent<T> remove) Sets acallbackmethod reference which is invoked when a bundle is removed.remove(InstanceCbBundle remove) Sets a method reference on an Object instance which is invoked when a bundle is removed.remove(InstanceCbBundleComponent remove) Sets acallback instancemethod reference which is invoked when a bundle is removed.required()Sets the dependency to be required.required(boolean required) Sets the dependency to be required.Methods inherited from interface org.apache.felix.dm.lambda.DependencyBuilder
build
-
Method Details
-
autoConfig
Enables auto configuration for this dependency. This means the component implementation class fields will be injected with this bundle dependency automatically.- Parameters:
autoConfig-trueto enable auto configuration- Returns:
- the bundle dependency builder
-
autoConfig
BundleDependencyBuilder autoConfig()Enables auto configuration for this dependency. This means the component implementation class fields will be injected with this bundle dependency automatically.- Returns:
- the bundle dependency builder
-
required
Sets the dependency to be required.- Parameters:
required-trueif this bundle dependency is required.- Returns:
- the bundle dependency builder
-
required
BundleDependencyBuilder required()Sets the dependency to be required.- Returns:
- the bundle dependency builder
-
optional
BundleDependencyBuilder optional()Sets the dependency to be optional.- Returns:
- the bundle dependency builder
-
bundle
Sets the bundle to depend on directly.- Parameters:
bundle- the bundle to depend on- Returns:
- the bundle dependency builder
-
filter
Sets the filter condition to depend on. Filters are matched against the full manifest of a bundle.- Parameters:
filter- the filter condition- Returns:
- the bundle dependency builder
-
mask
Sets the bundle state mask to depend on. The OSGi BundleTracker explains this mask in more detail, but it is basically a mask with flags for each potential state a bundle can be in.- Parameters:
mask- the mask to use- Returns:
- the bundle dependency builder
-
propagate
Sets property propagation. If set totrueany bundle manifest properties will be added to the service properties of the component that declares this dependency (if it provides a service).- Parameters:
propagate-trueto propagate the bundle manifest properties- Returns:
- the bundle dependency builder
-
propagate
BundleDependencyBuilder propagate()Sets property propagation. any bundle manifest properties will be added to the service properties of the component that has this dependency (if it registers as a service).- Returns:
- the bundle dependency builder
-
propagate
Sets an Object instance and a callback method used to propagate some properties to the provided service properties. The method will be invoked on the specified object instance and must have one of the following signatures:- Dictionary callback(Bundle bundle)
- Parameters:
instance- the Object instance which is used to retrieve propagated service propertiesmethod- the method to invoke for retrieving the properties to be propagated to the service properties.- Returns:
- this service dependency. builder
-
propagate
Sets a reference to a method on an Object instance used to propagate some bundle properties to the provided service properties.- Parameters:
propagate- a function which accepts a Bundle argument and which returns some properties that will be propagated to the provided component service properties.- Returns:
- this service dependency. builder
-
add
Sets a "add"callbackmethod to invoke on the component implementation instance(s). The callback is invoked when the bundle is added, and the following signatures are supported:- method(Bundle)
- method(Component, Bundle)
- Parameters:
callback- the add callback- Returns:
- this builder
-
change
Sets a "change"callbackmethod to invoke on the component implementation instance(s). The callback is invoked when the bundle state has changed, and the following signatures are supported:- method(Bundle)
- method(Component, Bundle)
- Parameters:
callback- the change callback- Returns:
- this builder
-
remove
Sets a "remove"callbackmethod to invoke on the component implementation instance(s). The callback is invoked when the bundle is removed, and the following signatures are supported:- method(Bundle)
- method(Component, Bundle)
- Parameters:
callback- the remove callback- Returns:
- this builder
-
callbackInstance
Specifies a callback instance used to invoke the reflection based callbacks on it.- Parameters:
callbackInstance- the instance to invoke the reflection based callbacks on- Returns:
- this builder
- See Also:
-
add
Sets acallbackmethod reference which is invoked when a bundle is added. The method reference must point to a Component implementation class method, and takes as argument a Bundle.- Type Parameters:
T- the type of the component implementation class on which the callback is invoked on.- Parameters:
add- the method reference invoked when a bundle is added.- Returns:
- this builder
-
change
Sets acallbackmethod reference which is invoked when a bundle is changed. The method reference must point to a Component implementation class method, and takes as argument a Bundle.- Type Parameters:
T- the type of the component implementation class on which the callback is invoked on.- Parameters:
change- the method reference invoked when a bundle has changed.- Returns:
- this builder
-
remove
Sets acallbackmethod reference which is invoked when a bundle is removed. The method reference must point to a Component implementation class method, and takes as argument a Bundle.- Type Parameters:
T- the type of the component implementation class on which the callback is invoked on.- Parameters:
remove- the method reference invoked when a bundle is removed.- Returns:
- this builder
-
add
Sets acallbackmethod reference which is invoked when a bundle is added. The method reference must point to a Component implementation class method, and takes as argument a Bundle and a Component.- Type Parameters:
T- the type of the component implementation class on which the callback is invoked on.- Parameters:
add- the method reference invoked when a bundle is added.- Returns:
- this builder
-
change
Sets acallbackmethod reference which is invoked when a bundle is changed. The method reference must point to a Component implementation class method, and takes as argument a Bundle and a Component.- Type Parameters:
T- the type of the component implementation class on which the callback is invoked on.- Parameters:
change- the method reference invoked when a bundle has changed.- Returns:
- this builder
-
remove
Sets acallbackmethod reference which is invoked when a bundle is removed. The method reference must point to a Component implementation class method, and takes as argument a Bundle and a Component.- Type Parameters:
T- the type of the component implementation class on which the callback is invoked on.- Parameters:
remove- the method reference invoked when a bundle is removed.- Returns:
- this builder
-
add
Sets a method reference on an Object instance which is invoked when a bundle is added. The method reference must point to an Object instance method, and takes as argument a Bundle parameter.- Parameters:
add- the method reference invoked when a bundle is added.- Returns:
- this builder
-
change
Sets a method reference on an Object instance which is invoked when a bundle is changed. The method reference must point to an Object instance method, and takes as argument a Bundle parameter.- Parameters:
change- the method reference invoked when a bundle is changed.- Returns:
- this builder
-
remove
Sets a method reference on an Object instance which is invoked when a bundle is removed. The method reference must point to an Object instance method, and takes as argument a Bundle parameter.- Parameters:
remove- the method reference invoked when a bundle is removed.- Returns:
- this builder
-
add
Sets acallback instancemethod reference which is invoked when a bundle is added. The method reference must point to an Object instance method, and takes as arguments a Bundle and a Component.- Parameters:
add- the method reference invoked when a bundle is added.- Returns:
- this builder
-
change
Sets acallback instancemethod reference which is invoked when a bundle is changed. The method reference must point to an Object instance method, and takes as argument a Bundle and a Component.- Parameters:
change- the method reference invoked when a bundle is changed.- Returns:
- this builder
-
remove
Sets acallback instancemethod reference which is invoked when a bundle is removed. The method reference must point to an Object instance method, and takes as argument a Bundle and a Component.- Parameters:
remove- the method reference invoked when a bundle is removed.- Returns:
- this builder
-