org.apache.felix.ipojo.composite.service.instantiator
Class SvcInstance

java.lang.Object
  extended by org.apache.felix.ipojo.util.DependencyModel
      extended by org.apache.felix.ipojo.composite.service.instantiator.SvcInstance
All Implemented Interfaces:
TrackerCustomizer

public class SvcInstance
extends DependencyModel

Manage a service instantiation. This service create component instance providing the required service specification.

Author:
Felix Project Team

Field Summary
 
Fields inherited from class org.apache.felix.ipojo.util.DependencyModel
BROKEN, DYNAMIC_BINDING_POLICY, DYNAMIC_PRIORITY_BINDING_POLICY, RESOLVED, STATIC_BINDING_POLICY, UNRESOLVED
 
Constructor Summary
SvcInstance(ServiceDependencyHandler handler, String spec, Dictionary conf, boolean isAgg, boolean isOpt, Filter filt, Comparator cmp, int policy)
          Constructor.
 
Method Summary
 void freeze()
          Freeze the set of used provider.
protected  Map getMatchingFactories()
          Get the map of used references [reference, component instance].
 String getServiceSpecification()
          Get the required specification.
 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 match(ServiceReference fact)
          Does the service instance match with the given factory ?
 void onDependencyReconfiguration(ServiceReference[] departs, ServiceReference[] arrivals)
          On Dependency Reconfiguration notification method.
 void onServiceArrival(ServiceReference ref)
          A new service is injected.
 void onServiceDeparture(ServiceReference ref)
          A used service is leaving.
 void onServiceModification(ServiceReference arg0)
          A factory is modified.
 void stop()
          Stop the service instance.
 void unfreeze()
          Unfreezes.
 
Methods inherited from class org.apache.felix.ipojo.util.DependencyModel
addedService, addingService, getBindingPolicy, getComparator, getComparator, getFilter, getPolicy, getService, getServiceReference, getServiceReferences, getSize, getSpecification, getState, getUsedServiceReferences, isAggregate, isOptional, loadSpecification, manageModification, modifiedService, removedService, setAggregate, setBindingPolicy, setBundleContext, setComparator, setFilter, setOptionality, setSpecification, start, ungetService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SvcInstance

public SvcInstance(ServiceDependencyHandler handler,
                   String spec,
                   Dictionary conf,
                   boolean isAgg,
                   boolean isOpt,
                   Filter filt,
                   Comparator cmp,
                   int policy)
            throws ConfigurationException
Constructor.

Parameters:
handler - : the handler.
spec - : required specification.
conf - : instance configuration.
isAgg - : is the service instance an aggregate service ?
isOpt - : is the service instance optional ?
filt - : LDAP filter
cmp - : comparator to use for the tracking
policy - : binding policy
Throws:
ConfigurationException - : an attribute cannot be parsed correctly, or is incorrect.
Method Detail

stop

public void stop()
Stop the service instance.

Overrides:
stop in class DependencyModel

isFrozen

public boolean isFrozen()
Description copied from class: DependencyModel
Is the reference set frozen (cannot change anymore)? This method must be override by concrete dependency to support the static binding policy. In fact, this method allows optimizing the static dependencies to become frozen only when needed. This method returns false by default. The method must always return false for non-static dependencies.

Overrides:
isFrozen in class DependencyModel
Returns:
true if the reference set is frozen.

freeze

public void freeze()
Freeze the set of used provider. This method is when the static binding policy is applied.


unfreeze

public void unfreeze()
Unfreezes.

Overrides:
unfreeze in class DependencyModel

match

public boolean match(ServiceReference fact)
Does the service instance match with the given factory ?

Overrides:
match in class DependencyModel
Parameters:
fact - : the factory to test.
Returns:
true if the factory match, false otherwise.

getServiceSpecification

public String getServiceSpecification()
Get the required specification.

Returns:
the required specification.

getMatchingFactories

protected Map getMatchingFactories()
Get the map of used references [reference, component instance].

Returns:
the map of used references.

onDependencyReconfiguration

public void onDependencyReconfiguration(ServiceReference[] departs,
                                        ServiceReference[] arrivals)
On Dependency Reconfiguration notification method.

Specified by:
onDependencyReconfiguration in class DependencyModel
Parameters:
departs - : leaving service references.
arrivals - : new injected service references.
See Also:
DependencyModel.onDependencyReconfiguration(org.osgi.framework.ServiceReference[], org.osgi.framework.ServiceReference[])

onServiceArrival

public void onServiceArrival(ServiceReference ref)
A new service is injected. This method create the sub-service instance in the composite.

Specified by:
onServiceArrival in class DependencyModel
Parameters:
ref - : service reference.
See Also:
DependencyModel.onServiceArrival(org.osgi.framework.ServiceReference)

onServiceDeparture

public void onServiceDeparture(ServiceReference ref)
A used service is leaving. This method dispose the created instance.

Specified by:
onServiceDeparture in class DependencyModel
Parameters:
ref - : leaving service reference.
See Also:
DependencyModel.onServiceDeparture(org.osgi.framework.ServiceReference)

onServiceModification

public void onServiceModification(ServiceReference arg0)
A factory is modified. This should not happen.

Specified by:
onServiceModification in class DependencyModel
Parameters:
arg0 - the service reference
See Also:
DependencyModel.onServiceModification(org.osgi.framework.ServiceReference)


Copyright © 2011 Apache Software Foundation. All Rights Reserved.