public abstract class DependencyModel extends Object implements org.apache.felix.ipojo.util.TrackerCustomizer
Modifier and Type | Field and Description |
---|---|
static int |
BROKEN
Dependency state : BROKEN.
|
static int |
DYNAMIC_BINDING_POLICY
Binding policy : Dynamic.
|
static int |
DYNAMIC_PRIORITY_BINDING_POLICY
Binding policy : Dynamic-Priority.
|
protected static org.slf4j.Logger |
logger |
static int |
RESOLVED
Dependency state : RESOLVED.
|
static int |
STATIC_BINDING_POLICY
Binding policy : Static.
|
static int |
UNRESOLVED
Dependency state : UNRESOLVED.
|
Constructor and Description |
---|
DependencyModel(Class specification,
boolean aggregate,
boolean optional,
org.osgi.framework.Filter filter,
Comparator comparator,
int policy,
org.osgi.framework.BundleContext context,
DependencyStateListener listener,
org.apache.felix.ipojo.ComponentInstance ci)
Creates a DependencyModel.
|
Modifier and Type | Method and Description |
---|---|
void |
addedService(org.osgi.framework.ServiceReference ref)
Service Tracker added service callback.
|
boolean |
addingService(org.osgi.framework.ServiceReference ref)
Service tracker adding service callback.
|
int |
getBindingPolicy()
Gets the used binding policy.
|
String |
getComparator()
Gets the used comparator name.
|
static Comparator |
getComparator(org.apache.felix.ipojo.metadata.Element dep,
org.osgi.framework.BundleContext context)
Helper method parsing the comparator attribute and returning the
comparator object.
|
String |
getFilter()
Returns the dependency filter (String form).
|
int |
getMaxServiceInjected() |
static int |
getPolicy(org.apache.felix.ipojo.metadata.Element dep)
Helper method parsing the binding policy.
|
static int |
getPolicy(String policy)
Helper method parsing the binding policy.
|
Object |
getService(org.osgi.framework.ServiceReference ref)
Gets a service object for the given reference.
|
org.osgi.framework.ServiceReference |
getServiceReference()
Gets the next matching service reference.
|
org.osgi.framework.ServiceReference[] |
getServiceReferences()
Gets matching service references.
|
int |
getSize()
Gets the number of actual matching references.
|
Class |
getSpecification()
Gets the tracked specification.
|
int |
getState()
Gets the actual state of the dependency.
|
List |
getUsedServiceReferences()
Gets the list of currently used service references.
|
boolean |
isAggregate() |
boolean |
isFrozen()
Is the reference set frozen (cannot change anymore)? This method must be
override by concrete dependency to support the static binding policy.
|
boolean |
isImmediate() |
boolean |
isOptional() |
boolean |
isServicesInWaitToInject() |
static Class |
loadSpecification(String specification,
org.osgi.framework.BundleContext context)
Loads the given specification class.
|
void |
manageModification(org.osgi.framework.ServiceReference ref)
This method can be override by the concrete dependency to be notified of
service modification.
|
boolean |
match(org.osgi.framework.ServiceReference ref)
Does the service reference match ? This method must be override by
concrete dependencies if they need advanced testing on service reference
(that cannot be expressed in the LDAP filter).
|
void |
modifiedService(org.osgi.framework.ServiceReference ref,
Object arg1)
Service tracker modified service callback.
|
abstract void |
onDependencyReconfiguration(org.osgi.framework.ServiceReference[] departs,
org.osgi.framework.ServiceReference[] arrivals)
Concrete dependency callback.
|
abstract void |
onServiceArrival(org.osgi.framework.ServiceReference ref)
Concrete dependency callback.
|
abstract void |
onServiceDeparture(org.osgi.framework.ServiceReference ref)
Concrete dependency callback.
|
abstract void |
onServiceModification(org.osgi.framework.ServiceReference ref)
Concrete dependency callback.
|
void |
removedService(org.osgi.framework.ServiceReference ref,
Object arg1)
Service tracker removed service callback.
|
void |
setAggregate(boolean isAggregate)
Sets the aggregate attribute of the current dependency.
|
void |
setBindingPolicy()
Sets the binding policy.
|
void |
setBundleContext(org.osgi.framework.BundleContext context)
Sets the bundle context used by this dependency.
|
void |
setComparator(Comparator cmp) |
void |
setFilter(org.osgi.framework.Filter filter)
Sets the filter of the dependency.
|
void |
setOptionality(boolean isOptional)
Sets the optionality attribute of the current dependency.
|
void |
setSpecification(Class specification)
Sets the required specification of this service dependency.
|
void |
start()
Opens the tracking.
|
void |
stop()
Closes the tracking.
|
void |
unfreeze()
Unfreezes the dependency.
|
void |
ungetService(org.osgi.framework.ServiceReference ref)
Ungets a used service reference.
|
protected static org.slf4j.Logger logger
public static final int BROKEN
public static final int UNRESOLVED
public static final int RESOLVED
public static final int DYNAMIC_BINDING_POLICY
public static final int STATIC_BINDING_POLICY
BROKEN
. The
instance needs to be recreated.public static final int DYNAMIC_PRIORITY_BINDING_POLICY
public DependencyModel(Class specification, boolean aggregate, boolean optional, org.osgi.framework.Filter filter, Comparator comparator, int policy, org.osgi.framework.BundleContext context, DependencyStateListener listener, org.apache.felix.ipojo.ComponentInstance ci)
DYNAMIC_PRIORITY_BINDING_POLICY
policy the OSGi Service Reference Comparator is used.specification
- the required specificationaggregate
- is the dependency aggregate ?optional
- is the dependency optional ?filter
- the LDAP filtercomparator
- the comparator object to sort referencespolicy
- the binding policycontext
- the bundle context (or service context)listener
- the dependency lifecycle listener to notify from dependencyci
- instance managing the dependency state changes.public void start()
computeDependencyState()
public void stop()
UNRESOLVED
at the end of this method.public boolean isFrozen()
false
by
default. The method must always return false
for non-static
dependencies.true
if the reference set is frozen.public boolean isImmediate()
public int getMaxServiceInjected()
public boolean isServicesInWaitToInject()
public void unfreeze()
public boolean match(org.osgi.framework.ServiceReference ref)
true
.ref
- the tested reference.true
if the service reference matches.public boolean addingService(org.osgi.framework.ServiceReference ref)
addingService
in interface org.apache.felix.ipojo.util.TrackerCustomizer
ref
- the arriving service reference.true
if the reference must be tracked.TrackerCustomizer.addingService(org.osgi.framework.ServiceReference)
public void addedService(org.osgi.framework.ServiceReference ref)
match(ServiceReference)
,
manages the provider arrival.addedService
in interface org.apache.felix.ipojo.util.TrackerCustomizer
ref
- : new references.TrackerCustomizer.addedService(org.osgi.framework.ServiceReference)
public void removedService(org.osgi.framework.ServiceReference ref, Object arg1)
removedService
in interface org.apache.felix.ipojo.util.TrackerCustomizer
ref
- the leaving service referencearg1
- the service object if the service was already getTrackerCustomizer.removedService(org.osgi.framework.ServiceReference,
java.lang.Object)
public void modifiedService(org.osgi.framework.ServiceReference ref, Object arg1)
modifiedService
in interface org.apache.felix.ipojo.util.TrackerCustomizer
ref
- the modified referencearg1
- the service object if already get.TrackerCustomizer.modifiedService(org.osgi.framework.ServiceReference,
java.lang.Object)
public org.osgi.framework.ServiceReference getServiceReference()
null
if no more provider is available, else returns
the first reference from the matching set.public org.osgi.framework.ServiceReference[] getServiceReferences()
null
if no references are available.public List getUsedServiceReferences()
null
public int getSize()
public abstract void onServiceArrival(org.osgi.framework.ServiceReference ref)
ref
- the service reference to inject.public abstract void onServiceDeparture(org.osgi.framework.ServiceReference ref)
ref
- the leaving service reference.public abstract void onServiceModification(org.osgi.framework.ServiceReference ref)
ref
- the modified service reference.public void manageModification(org.osgi.framework.ServiceReference ref)
ref
- the modified service reference.public abstract void onDependencyReconfiguration(org.osgi.framework.ServiceReference[] departs, org.osgi.framework.ServiceReference[] arrivals)
departs
- the service leaving the matching set.arrivals
- the service arriving in the matching set.public int getState()
public Class getSpecification()
public void setSpecification(Class specification)
specification
- the required specification.public void setFilter(org.osgi.framework.Filter filter)
filter
- the new LDAP filter.public String getFilter()
null
if not set.public void setAggregate(boolean isAggregate)
isAggregate
- the new aggregate attribute value.public boolean isAggregate()
public void setOptionality(boolean isOptional)
isOptional
- the new optional attribute value.public boolean isOptional()
public int getBindingPolicy()
public void setBindingPolicy()
public void setComparator(Comparator cmp)
public String getComparator()
Null
if no comparator (i.e.
the OSGi one is used).null
if the dependency
doesn't use a comparator.public void setBundleContext(org.osgi.framework.BundleContext context)
context
- the bundle context or service context to usepublic Object getService(org.osgi.framework.ServiceReference ref)
ref
- the wanted service referencepublic void ungetService(org.osgi.framework.ServiceReference ref)
ref
- the reference to unget.public static Comparator getComparator(org.apache.felix.ipojo.metadata.Element dep, org.osgi.framework.BundleContext context) throws org.apache.felix.ipojo.ConfigurationException
dep
- the Element describing the dependencycontext
- the bundle context (to load the comparator class)null
if not set.org.apache.felix.ipojo.ConfigurationException
- the comparator class cannot be load or the comparator cannot
be instantiated correctly.public static Class loadSpecification(String specification, org.osgi.framework.BundleContext context) throws org.apache.felix.ipojo.ConfigurationException
specification
- the specification class name to loadcontext
- the bundle contextorg.apache.felix.ipojo.ConfigurationException
- if the class cannot be loaded correctly.public static int getPolicy(org.apache.felix.ipojo.metadata.Element dep) throws org.apache.felix.ipojo.ConfigurationException
dep
- the Element describing the dependencyorg.apache.felix.ipojo.ConfigurationException
- if an unknown binding policy was described.public static int getPolicy(String policy) throws org.apache.felix.ipojo.ConfigurationException
String
- policy the Element describing the dependencyorg.apache.felix.ipojo.ConfigurationException
- if an unknown binding policy was described.Copyright © 2012-2013 Adele Team | LIG. All Rights Reserved.