com.buglabs.osgi.cm.impl
Class ConfigurationImpl

java.lang.Object
  extended by com.buglabs.osgi.cm.impl.ConfigurationImpl
All Implemented Interfaces:
java.io.Serializable, Configuration

public class ConfigurationImpl
extends java.lang.Object
implements Configuration, java.io.Serializable

Implementation of Configuration

See Also:
Serialized Form

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

Constructor Detail

ConfigurationImpl

public ConfigurationImpl(java.lang.String pid)
Constructor

Parameters:
pid - PID that identifies this Configuration
Method Detail

delete

public void delete()
            throws java.io.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.

Specified by:
delete in interface Configuration
Throws:
java.io.IOException - If delete fails

getBundleLocation

public java.lang.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.

This call requires AdminPermission.

Specified by:
getBundleLocation in interface Configuration
Returns:
location to which this configuration is bound, or null.

getFactoryPid

public java.lang.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

getPid

public java.lang.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.

getProperties

public java.util.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.

setBundleLocation

public void setBundleLocation(java.lang.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.

This method requires AdminPermission.

Specified by:
setBundleLocation in interface Configuration
Parameters:
bundleLocation - a bundle location or null

update

public void update()
            throws java.io.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 initate 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:
java.io.IOException - if update cannot access the properties in persistent storage
See Also:
ConfigurationPlugin

update

public void update(java.util.Dictionary properties)
            throws java.io.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.

Specified by:
update in interface Configuration
Parameters:
properties - the new set of properties for this configuration
Throws:
java.io.IOException - if update cannot be made persistent

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 java.lang.Object
Returns:
hash code for this Configuration object

equals

public boolean equals(java.lang.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 java.lang.Object
Parameters:
obj - Configuration object to compare against
Returns:
true if equal, false if not a Configuration object or one with a different PID.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object