org.apache.felix.cm.impl
Class ConfigurationAdapter

java.lang.Object
  extended by org.apache.felix.cm.impl.ConfigurationAdapter
All Implemented Interfaces:
Configuration

public class ConfigurationAdapter
extends Object
implements Configuration

The ConfigurationAdapter is just an adapter to the internal configuration object. Instances of this class are returned as Configuration objects to the client, where each caller gets a fresh instance of this class while internal Configuration objects are shared.


Method Summary
 void delete()
          Delete this Configuration object.
 boolean equals(Object obj)
          Equality is defined to have equal PIDs Two Configuration objects are equal when their PIDs are equal.
 String getBundleLocation()
          Get the bundle location.
 String getFactoryPid()
          For a factory configuration return the PID of the corresponding Managed Service Factory, else return null.
 String getPid()
          Get the PID for this Configuration object.
 Dictionary getProperties()
          Return the properties of this Configuration object.
 int hashCode()
          Hash code is based on PID.
 void setBundleLocation(String bundleLocation)
          Bind this Configuration object to the specified bundle location.
 String toString()
           
 void update()
          Update the Configuration object with the current properties.
 void update(Dictionary properties)
          Update the properties of this Configuration object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getPid

public String getPid()
Description copied from interface: Configuration
Get the PID for this Configuration object.

Specified by:
getPid in interface Configuration
Returns:
the PID for this Configuration object.
See Also:
ConfigurationImpl.getPid()

getFactoryPid

public String getFactoryPid()
Description copied from interface: Configuration
For a factory configuration return the PID of the corresponding Managed Service Factory, else return null.

Specified by:
getFactoryPid in interface Configuration
Returns:
factory PID or null
See Also:
ConfigurationImpl.getFactoryPid()

getBundleLocation

public String getBundleLocation()
Description copied from interface: Configuration
Get the bundle location. Returns the bundle location to which this configuration is bound, or null if it is not yet bound to a bundle location.

Specified by:
getBundleLocation in interface Configuration
Returns:
location to which this configuration is bound, or null.
See Also:
ConfigurationBase.getBundleLocation()

setBundleLocation

public void setBundleLocation(String bundleLocation)
Description copied from interface: Configuration
Bind this Configuration object to the specified bundle location. If the bundleLocation parameter is null then the Configuration object will not be bound to a location. It will be set to the bundle's location before the first time a Managed Service/Managed Service Factory receives this Configuration object via the updated method and before any plugins are called. The bundle location will be set persistently.

Specified by:
setBundleLocation in interface Configuration
Parameters:
bundleLocation -
See Also:
org.apache.felix.cm.impl.ConfigurationImpl#setBundleLocation(java.lang.String)

update

public void update()
            throws IOException
Description copied from interface: Configuration
Update the Configuration object with the current properties. Initiate the updated callback to the Managed Service or Managed Service Factory with the current properties asynchronously.

This is the only way for a bundle that uses a Configuration Plugin service to initiate a callback. For example, when that bundle detects a change that requires an update of the Managed Service or Managed Service Factory via its ConfigurationPlugin object.

Specified by:
update in interface Configuration
Throws:
IOException
See Also:
ConfigurationImpl.update()

update

public void update(Dictionary properties)
            throws IOException
Description copied from interface: Configuration
Update the properties of this Configuration object. Stores the properties in persistent storage after adding or overwriting the following properties: These system properties are all of type String.

If the corresponding Managed Service/Managed Service Factory is registered, its updated method must be called asynchronously. Else, this callback is delayed until aforementioned registration occurs.

Also initiates an asynchronous call to all ConfigurationListeners with a ConfigurationEvent.CM_UPDATED event.

Specified by:
update in interface Configuration
Parameters:
properties -
Throws:
IOException
See Also:
ConfigurationImpl.update(java.util.Dictionary)

getProperties

public Dictionary getProperties()
Description copied from interface: Configuration
Return the properties of this Configuration object. The Dictionary object returned is a private copy for the caller and may be changed without influencing the stored configuration. The keys in the returned dictionary are case insensitive and are always of type String.

If called just after the configuration is created and before update has been called, this method returns null.

Specified by:
getProperties in interface Configuration
Returns:
A private copy of the properties for the caller or null. These properties must not contain the "service.bundleLocation" property. The value of this property may be obtained from the getBundleLocation method.
See Also:
org.apache.felix.cm.impl.ConfigurationImpl#getProperties()

delete

public void delete()
            throws IOException
Description copied from interface: Configuration
Delete this Configuration object. Removes this configuration object from the persistent store. Notify asynchronously the corresponding Managed Service or Managed Service Factory. A ManagedService object is notified by a call to its updated method with a null properties argument. A ManagedServiceFactory object is notified by a call to its deleted method.

Also initiates an asynchronous call to all ConfigurationListeners with a ConfigurationEvent.CM_DELETED event.

Specified by:
delete in interface Configuration
Throws:
IOException
See Also:
ConfigurationImpl.delete()

hashCode

public int hashCode()
Description copied from interface: Configuration
Hash code is based on PID. The hashcode for two Configuration objects must be the same when the Configuration PID's are the same.

Specified by:
hashCode in interface Configuration
Overrides:
hashCode in class Object
Returns:
hash code for this Configuration object
See Also:
ConfigurationImpl.hashCode()

equals

public boolean equals(Object obj)
Description copied from interface: Configuration
Equality is defined to have equal PIDs Two Configuration objects are equal when their PIDs are equal.

Specified by:
equals in interface Configuration
Overrides:
equals in class Object
Parameters:
obj -
Returns:
true if equal, false if not a Configuration object or one with a different PID.
See Also:
ConfigurationImpl.equals(java.lang.Object)

toString

public String toString()
Overrides:
toString in class Object
See Also:
ConfigurationImpl.toString()


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