/
Working with Settings

Working with Settings

DDF provides the ability to obtain DDF Settings/Properties. For a list of DDF Settings view the Catalog API and Global Settings in the Integrator's Guide. The DdfConfigurationWatcher will provide an update of properties to watchers. For example, if the Port number changes, the DDF_PORT property value will be propagated to the watcher(s) in the form of a Map.

To obtain the property values follow these steps:

  1. Import and Implement the ddf.catalog.util.DdfConfigurationWatcher Interface.

    Implement DdfConfigurationWatcher
    public class SettingsWatcher implements DdfConfigurationWatcher
  2. Get properties map and search for the property.

    Handle Properties
    public void ddfConfigurationUpdated( Map properties )
    {
      //Get property by name
      Object value = properties.get( DdfConfigurationManager.DDF_HOME_DIR );
      if ( value != null )
      {
        this.ddfHomeDir = value.toString();
        logger.debug( "ddfHomeDir = " + this.ddfHomeDir );
      }
    }
  3. Export the Watcher Class as a Service in the OSGi Registry. The example below uses the Blueprint dependency injection framework to add this Watcher to the OSGi Registry. The ddf.catalog.DdfConfigurationManager will search for ConfigurationWatcher(s) to send properties updates.

    Blueprint Example of Export
    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
    
     <!-- create the bean -->
     <bean id="SettingsWatcher" class="ddf.catalog.SettingsWatcher">
       <cm:managed-properties
         persistent-id="ddf.catalog.SettingsWatcher"
         update-strategy="container-managed" />
     </bean>
    
     <!-- export the bean in the service registry as a DdfConfigurationWatcher -->
     <service ref="SettingsWatcher" interface="ddf.catalog.util.DdfConfigurationWatcher">
     </service>
    
    </blueprint>
    
    
  4. Import the

    DDF

    packages to the bundle's manifest for run-time (in addition to any other required packages):
    Import-Package: ddf.catalog, ddf.catalog.util, ddf.catalog.*
  5. Deploy the packaged service to

    DDF

    .