org.apache.felix.ipojo.handlers.dependency

## Class DependencyCallback

- java.lang.Object
- - org.apache.felix.ipojo.util.Callback
  - - org.apache.felix.ipojo.handlers.dependency.DependencyCallback

    public class DependencyCallback
    extends Callback

This class allwos the creation of callback when service dependency arrives or disappear.

Author:
  Felix Project Team

### Field Summary

Fields
`static int` `BIND` Bind method (called when a service arrives).
`static int` `MODIFIED` Updated method (called when a service is modified).
`static int` `UNBIND` Unbind method (called when a service disappears).

### Fields inherited from class org.apache.felix.ipojo.util.Callback

`m_methodObj`

### Constructor Summary

Constructors
Constructor and Description
`DependencyCallback(Dependency dep, java.lang.String method, int methodType)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `call(org.osgi.framework.ServiceReference ref, java.lang.Object obj)` Call the callback method with a service reference.
`protected void` `callOnInstance(java.lang.Object instance, org.osgi.framework.ServiceReference ref, java.lang.Object obj)` Call the callback on the given instance with the given argument.
`java.lang.String` `getMethodName()`
`int` `getMethodType()`
`protected void` `searchMethod()` Search the method object in the POJO by analyzing present method.
`void` `setArgument(java.lang.String[] arg)` Set the argument type (Empty or the class name).

### Methods inherited from class org.apache.felix.ipojo.util.Callback

`call, call, call, call, getArguments, getMethod`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### BIND

    public static final int BIND

Bind method (called when a service arrives).

See Also:
  Constant Field Values

#### UNBIND

    public static final int UNBIND

Unbind method (called when a service disappears).

See Also:
  Constant Field Values

#### MODIFIED

    public static final int MODIFIED

Updated method (called when a service is modified).

See Also:
  Constant Field Values

### Constructor Detail

#### DependencyCallback

    public DependencyCallback(Dependency dep,
                              java.lang.String method,
                              int methodType)

Constructor.

Parameters:
  `dep` - : the dependency attached to this dependency callback
  `method` - : the method to call
  `methodType` - : is the method to call a bind method or an unbind method

### Method Detail

#### getMethodType

    public int getMethodType()

#### getMethodName

    public java.lang.String getMethodName()

#### setArgument

    public void setArgument(java.lang.String[] arg)

Set the argument type (Empty or the class name).

Parameters:
  `arg` - : the array of argument types.

#### searchMethod

    protected void searchMethod()

Search the method object in the POJO by analyzing present method. If not found in the pojo it tests the parent classes. The name of the method and the argument type are checked.

Overrides:
  `searchMethod` in class `Callback`

#### call

    protected void call(org.osgi.framework.ServiceReference ref,
                        java.lang.Object obj)
                 throws java.lang.NoSuchMethodException,
                        java.lang.IllegalAccessException,
                        java.lang.reflect.InvocationTargetException

Call the callback method with a service reference.

Parameters:
  `ref` - : the service reference to send to the method
  `obj` - : the service object
Throws:
  `java.lang.NoSuchMethodException` - : Method is not found in the class
  `java.lang.reflect.InvocationTargetException` - : The method is not static
  `java.lang.IllegalAccessException` - : The method can not be invoked

#### callOnInstance

    protected void callOnInstance(java.lang.Object instance,
                                  org.osgi.framework.ServiceReference ref,
                                  java.lang.Object obj)
                           throws java.lang.NoSuchMethodException,
                                  java.lang.IllegalAccessException,
                                  java.lang.reflect.InvocationTargetException

Call the callback on the given instance with the given argument.

Parameters:
  `instance` - : the instance on which call the callback
  `ref` - : the service reference to send to the callback
  `obj` - : the service object
Throws:
  `java.lang.NoSuchMethodException` - : the method is not found
  `java.lang.IllegalAccessException` - : the method could not be called
  `java.lang.reflect.InvocationTargetException` - : an error happens in the called method