org.apache.felix.ipojo.handler.temporal
Class TemporalDependency

java.lang.Object
  extended by org.apache.felix.ipojo.util.DependencyModel
      extended by org.apache.felix.ipojo.handler.temporal.TemporalDependency
All Implemented Interfaces:
FieldInterceptor, MethodInterceptor, TrackerCustomizer

public class TemporalDependency
extends DependencyModel
implements FieldInterceptor, MethodInterceptor

Temporal dependency. A temporal dependency waits (block) for the availability of the service. If no provider arrives in the specified among of time, a runtime exception is thrown.

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
TemporalDependency(Class spec, boolean agg, boolean collection, boolean proxy, Filter filter, BundleContext context, long timeout, int policy, String defaultImpl, TemporalHandler handler)
          Creates a temporal dependency.
 
Method Summary
 Object getService()
          Called by the proxy to get a service object to delegate a method.
 void onDependencyReconfiguration(ServiceReference[] arg0, ServiceReference[] arg1)
          The dependency has been reconfigured.
 void onEntry(Object pojo, Method method, Object[] args)
          A POJO method will be invoked.
 void onError(Object pojo, Method method, Throwable throwable)
          A POJO method has thrown an error.
 void onExit(Object pojo, Method method, Object returnedObj)
          A POJO method has returned.
 void onFinally(Object pojo, Method method)
          A POJO method is finished.
 Object onGet(Object arg0, String arg1, Object arg2)
          The code require a value of the monitored field.
 void onServiceArrival(ServiceReference ref)
          A provider arrives.
 void onServiceDeparture(ServiceReference arg0)
          A provider leaves.
 void onServiceModification(ServiceReference arg0)
          A provider is modified.
 void onSet(Object arg0, String arg1, Object arg2)
          The monitored field receives a value.
 void start()
          Start method.
 void stop()
          Stop method.
 
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, isFrozen, isOptional, loadSpecification, manageModification, match, modifiedService, removedService, setAggregate, setBindingPolicy, setBundleContext, setComparator, setFilter, setOptionality, setSpecification, unfreeze, ungetService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemporalDependency

public TemporalDependency(Class spec,
                          boolean agg,
                          boolean collection,
                          boolean proxy,
                          Filter filter,
                          BundleContext context,
                          long timeout,
                          int policy,
                          String defaultImpl,
                          TemporalHandler handler)
Creates a temporal dependency.

Parameters:
spec - the service specification
agg - is the dependency aggregate ?
collection - the dependency field is a collection
proxy - enable the proxy-mode
filter - the LDAP filter
context - service context
timeout - timeout
handler - Handler managing this dependency
defaultImpl - class used as default-implementation
policy - onTimeout policy
Method Detail

onDependencyReconfiguration

public void onDependencyReconfiguration(ServiceReference[] arg0,
                                        ServiceReference[] arg1)
The dependency has been reconfigured.

Specified by:
onDependencyReconfiguration in class DependencyModel
Parameters:
arg0 - new service references
arg1 - old service references
See Also:
DependencyModel.onDependencyReconfiguration(org.osgi.framework.ServiceReference[], org.osgi.framework.ServiceReference[])

onServiceArrival

public void onServiceArrival(ServiceReference ref)
A provider arrives.

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

onServiceDeparture

public void onServiceDeparture(ServiceReference arg0)
A provider leaves.

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

onServiceModification

public void onServiceModification(ServiceReference arg0)
A provider is modified.

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

onGet

public Object onGet(Object arg0,
                    String arg1,
                    Object arg2)
The code require a value of the monitored field. If providers are available, the method return service object(s) immediately. Else, the thread is blocked until an arrival. If no provider arrives during the among of time specified, the method throws a Runtime Exception.

Specified by:
onGet in interface FieldInterceptor
Parameters:
arg0 - POJO instance asking for the service
arg1 - field name
arg2 - previous value
Returns:
the object to inject.
See Also:
FieldInterceptor.onGet(java.lang.Object, java.lang.String, java.lang.Object)

onEntry

public void onEntry(Object pojo,
                    Method method,
                    Object[] args)
A POJO method will be invoked.

Specified by:
onEntry in interface MethodInterceptor
Parameters:
pojo - : Pojo object
method - : called method
args - : arguments
See Also:
MethodInterceptor.onEntry(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])

onError

public void onError(Object pojo,
                    Method method,
                    Throwable throwable)
A POJO method has thrown an error. This method does nothing and wait for the finally.

Specified by:
onError in interface MethodInterceptor
Parameters:
pojo - : POJO object.
method - : Method object.
throwable - : thrown error
See Also:
MethodInterceptor.onError(java.lang.Object, java.lang.reflect.Method, java.lang.Throwable)

onExit

public void onExit(Object pojo,
                   Method method,
                   Object returnedObj)
A POJO method has returned.

Specified by:
onExit in interface MethodInterceptor
Parameters:
pojo - : POJO object.
method - : Method object.
returnedObj - : returned object (null for void method)
See Also:
MethodInterceptor.onExit(java.lang.Object, java.lang.reflect.Method, java.lang.Object)

onFinally

public void onFinally(Object pojo,
                      Method method)
A POJO method is finished.

Specified by:
onFinally in interface MethodInterceptor
Parameters:
pojo - : POJO object.
method - : Method object.
See Also:
MethodInterceptor.onFinally(java.lang.Object, java.lang.reflect.Method)

getService

public Object getService()
Called by the proxy to get a service object to delegate a method. This methods manages the waited time and on timeout policies.

Returns:
a service object or a nullable/default-implmentation object.

start

public void start()
Start method. Initializes the nullable object.

Overrides:
start in class DependencyModel
See Also:
DependencyModel.start()

stop

public void stop()
Stop method. Just releases the reference on the nullable object.

Overrides:
stop in class DependencyModel
See Also:
DependencyModel.stop()

onSet

public void onSet(Object arg0,
                  String arg1,
                  Object arg2)
The monitored field receives a value. Nothing to do.

Specified by:
onSet in interface FieldInterceptor
Parameters:
arg0 - POJO setting the value.
arg1 - field name
arg2 - received value
See Also:
FieldInterceptor.onSet(java.lang.Object, java.lang.String, java.lang.Object)


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.