org.apache.felix.servicebinder
Interface InstanceReference

All Known Implementing Classes:
InstanceManager

public interface InstanceReference

This interface creates a level of indirection for the objects created by a factory. This is necessary because it might not be possible for a factory to create the actual object instance at the time of the call to Factory.createInstance() due to unfulfilled dependencies. In such a scenario, this interface can be used to listen for the object instance to become available.

Author:
Felix Project Team

Nested Class Summary
static interface InstanceReference.ValueHolder
          A simple interface that enabled deferred value creation for the InstanceReference.get() and InstanceReference.put() methods.
 
Field Summary
static String INSTANCE_BUNDLE
           
static String INSTANCE_DEPENDENCIES
           
static String INSTANCE_METADATA
           
static String INSTANCE_STATE
           
 
Method Summary
 void addInstanceReferenceListener(InstanceReferenceListener l)
          Adds an instance reference listener to listen for changes to the availability of the underlying object associated with this instance reference.
 Object get(String name)
          Get a property associated with this instance.
 Object getObject()
          Gets the actual object associated with this instance refernce.
 void put(String name, Object value)
          Associate a property with this instance.
 void removeInstanceReferenceListener(InstanceReferenceListener l)
          Removes an instance reference listener.
 

Field Detail

INSTANCE_STATE

static final String INSTANCE_STATE
See Also:
Constant Field Values

INSTANCE_METADATA

static final String INSTANCE_METADATA
See Also:
Constant Field Values

INSTANCE_BUNDLE

static final String INSTANCE_BUNDLE
See Also:
Constant Field Values

INSTANCE_DEPENDENCIES

static final String INSTANCE_DEPENDENCIES
See Also:
Constant Field Values
Method Detail

get

Object get(String name)
Get a property associated with this instance. For classes implementing this method, special care must be taken for values implementing InstanceReference.ValueHolder. In such cases, the value itself should not be returned, but the value of InstanceReference.ValueHolder.get() should be returned instead. This may be used to defer creating value objects in cases where creating the value object is expensive.

Parameters:
name - the name of the property to retrieve.
Returns:
the value of the associated property or null.

put

void put(String name,
         Object value)
Associate a property with this instance. For classes implementing this method, special care must be taken for values implementing InstanceReference.ValueHolder. In such cases, the value itself should not be returned, but the value of InstanceReference.ValueHolder.get() should be returned instead. This may be used to defer creating value objects in cases where creating the value object is expensive.

Parameters:
name - the name of the property to add.
value - the value of the property.

getObject

Object getObject()
Gets the actual object associated with this instance refernce.

Returns:
the object associated with this reference or null if the reference is not currently valid.

addInstanceReferenceListener

void addInstanceReferenceListener(InstanceReferenceListener l)
Adds an instance reference listener to listen for changes to the availability of the underlying object associated with this instance reference.

Parameters:
l - the listener to add.

removeInstanceReferenceListener

void removeInstanceReferenceListener(InstanceReferenceListener l)
Removes an instance reference listener.

Parameters:
l - the listener to remove.


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