org.apache.felix.ipojo.api

## Class Dependency

- java.lang.Object
- - org.apache.felix.ipojo.api.Dependency

All Implemented Interfaces:
  HandlerConfiguration

    public class Dependency
    extends java.lang.Object
    implements HandlerConfiguration

Allows configuring a service dependencies.

Author:
  Felix Project Team

### Field Summary

Fields
`static int` `DYNAMIC` The dynamic binding policy.
`static int` `DYNAMIC_PRIORITY` The dynamic-priority binding policy.
`static int` `STATIC` The static binding policy.

### Constructor Summary

Constructors
Constructor and Description
`Dependency()`

### Method Summary

All Methods Instance Methods Concrete Methods
`DependencyDescription` `getDependencyDescription(ComponentInstance instance)` Gets the dependency description object attached to this dependency.
`org.apache.felix.ipojo.metadata.Element` `getElement()` Gets the dependency metadata.
`Dependency` `setAggregate(boolean agg)` Sets the dependency cardinality.
`Dependency` `setBindingPolicy(int policy)` Sets the dependency binding policy.
`Dependency` `setBindMethod(java.lang.String bind)` Sets the dependency bind method.
`Dependency` `setComparator(java.lang.String cmp)` Sets the dependency comparator.
`Dependency` `setConstructorParameter(int index)` Sets the constructor parameter index of the dependency.
`Dependency` `setDefaultImplementation(java.lang.String di)` Sets the dependency default-implementation.
`Dependency` `setField(java.lang.String field)` Sets the field attached to the dependency.
`Dependency` `setFilter(java.lang.String filter)` Sets the dependency filter.
`Dependency` `setFrom(java.lang.String from)` Sets the dependency 'from' attribute.
`Dependency` `setId(java.lang.String id)` Sets the dependency id.
`Dependency` `setModifiedMethod(java.lang.String modified)` Sets the dependency modified method.
`Dependency` `setNullable(boolean nullable)` Sets if the dependency supports nullable objects.
`Dependency` `setOptional(boolean opt)` Sets the dependency optionality.
`Dependency` `setProxy(boolean proxy)` Sets if the dependency injects proxies.
`Dependency` `setSpecification(java.lang.String spec)` Sets the required service specification.
`Dependency` `setUnbindMethod(java.lang.String unbind)` Sets the dependency unbind method.

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

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

### Field Detail

#### DYNAMIC

    public static final int DYNAMIC

The dynamic binding policy.

See Also:
  Constant Field Values

#### STATIC

    public static final int STATIC

The static binding policy.

See Also:
  Constant Field Values

#### DYNAMIC_PRIORITY

    public static final int DYNAMIC_PRIORITY

The dynamic-priority binding policy.

See Also:
  Constant Field Values

### Constructor Detail

#### Dependency

    public Dependency()

### Method Detail

#### getElement

    public org.apache.felix.ipojo.metadata.Element getElement()

Gets the dependency metadata.

Specified by:
  `getElement` in interface `HandlerConfiguration`
Returns:
  the 'requires' element describing the current dependency.

#### setSpecification

    public Dependency setSpecification(java.lang.String spec)

Sets the required service specification.

Parameters:
  `spec` - the specification
Returns:
  the current dependency object.

#### setFilter

    public Dependency setFilter(java.lang.String filter)

Sets the dependency filter.

Parameters:
  `filter` - the LDAP filter
Returns:
  the current dependency object

#### setField

    public Dependency setField(java.lang.String field)

Sets the field attached to the dependency.

Parameters:
  `field` - the implementation class field name.
Returns:
  the current dependency object

#### setConstructorParameter

    public Dependency setConstructorParameter(int index)

Sets the constructor parameter index of the dependency.

Parameters:
  `index` - the parameter index
Returns:
  the current dependency object

#### setOptional

    public Dependency setOptional(boolean opt)

Sets the dependency optionality.

Parameters:
  `opt` - `true` to set the dependency to optional.
Returns:
  the current dependency object.

#### setAggregate

    public Dependency setAggregate(boolean agg)

Sets the dependency cardinality.

Parameters:
  `agg` - `true` to set the dependency to aggregate.
Returns:
  the current dependency object.

#### setNullable

    public Dependency setNullable(boolean nullable)

Sets if the dependency supports nullable objects.

Parameters:
  `nullable` - `false` if the dependency does not support the nullable object injection
Returns:
  the current dependency object.

#### setProxy

    public Dependency setProxy(boolean proxy)

Sets if the dependency injects proxies.

Parameters:
  `proxy` - `false` if the dependency does not inject proxies but uses direct references.
Returns:
  the current dependency object.

#### setBindMethod

    public Dependency setBindMethod(java.lang.String bind)

Sets the dependency bind method.

Parameters:
  `bind` - the bind method name
Returns:
  the current dependency object.

#### setUnbindMethod

    public Dependency setUnbindMethod(java.lang.String unbind)

Sets the dependency unbind method.

Parameters:
  `unbind` - the unbind method
Returns:
  the current dependency object.

#### setModifiedMethod

    public Dependency setModifiedMethod(java.lang.String modified)

Sets the dependency modified method.

Parameters:
  `modified` - the modified method
Returns:
  the current dependency object.

#### setBindingPolicy

    public Dependency setBindingPolicy(int policy)

Sets the dependency binding policy.

Parameters:
  `policy` - the binding policy
Returns:
  the current dependency object

#### setComparator

    public Dependency setComparator(java.lang.String cmp)

Sets the dependency comparator.

Parameters:
  `cmp` - the comparator class name
Returns:
  the current dependency object

#### setDefaultImplementation

    public Dependency setDefaultImplementation(java.lang.String di)

Sets the dependency default-implementation.

Parameters:
  `di` - the default-implementation class name
Returns:
  the current dependency object

#### setFrom

    public Dependency setFrom(java.lang.String from)

Sets the dependency 'from' attribute.

Parameters:
  `from` - the name of the service provider.
Returns:
  the current dependency object

#### setId

    public Dependency setId(java.lang.String id)

Sets the dependency id.

Parameters:
  `id` - the dependency id.
Returns:
  the current dependency object.

#### getDependencyDescription

    public DependencyDescription getDependencyDescription(ComponentInstance instance)

Gets the dependency description object attached to this dependency.

Parameters:
  `instance` - the instance on which searching the dependency
Returns:
  the dependency description attached to this dependency or `null` if the dependency cannot be found.