You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by go...@apache.org on 2011/12/21 13:26:54 UTC

svn commit: r1221697 - in /directory/apacheds/branches/apacheds-osgi: ./ component-hub/ component-hub/src/main/java/org/apache/directory/server/component/ component-hub/src/main/java/org/apache/directory/server/component/hub/ component-hub/src/main/jav...

Author: gokturk
Date: Wed Dec 21 12:26:53 2011
New Revision: 1221697

URL: http://svn.apache.org/viewvc?rev=1221697&view=rev
Log:
* Utility methods are reorganied in more meaningful way.(Some removed, some merged ...)
* ComponentSchema information is removed from ADSComponent, thus reflecting later changes on schema management.
* HubListener signature is changed. It also receives new configurations crated under DIT now.

* + Some minor code changes....


Added:
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentOIDGenerator.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSComponentHelper.java   (with props)
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/resources/
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/resources/org/
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/resources/org/apache/
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/resources/org/apache/directory/
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/resources/org/apache/directory/server/
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/resources/org/apache/directory/server/component/
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/resources/org/apache/directory/server/component/schema/
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/resources/org/apache/directory/server/component/schema/componenthub.ldif
Removed:
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/AvlPartitionOperationsHelper.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/IPojoFactoryHelper.java
Modified:
    directory/apacheds/branches/apacheds-osgi/component-hub/pom.xml
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentManager.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/InstanceManager.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/HubListener.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstance.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstanceGenerator.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSConstants.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/LdifConfigHelper.java
    directory/apacheds/branches/apacheds-osgi/pom.xml

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/pom.xml?rev=1221697&r1=1221696&r2=1221697&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/pom.xml (original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/pom.xml Wed Dec 21 12:26:53 2011
@@ -49,11 +49,21 @@
     </dependency>
     
     <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ipojo-manager</artifactId>
+    </dependency>
+    
+    <dependency>
       <groupId>org.apache.directory.server</groupId>
       <artifactId>apacheds-ldif-partition</artifactId>
     </dependency>
     
     <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-xdbm-partition</artifactId>
+    </dependency>
+    
+    <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.ipojo.annotations</artifactId>
       <version>1.8.0</version>

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java?rev=1221697&r1=1221696&r2=1221697&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java (original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java Wed Dec 21 12:26:53 2011
@@ -46,7 +46,7 @@ public class ADSComponent
     /*
      * Component's type
      */
-    private String componentType = "user";
+    private String componentType = "";
 
     /*
      * Name of the component(Its IPojo factory name in normalized form).
@@ -70,14 +70,9 @@ public class ADSComponent
     private List<CachedComponentInstance> cachedInstances;
 
     /*
-     * Generated/Choosed schema information
-     */
-    private ADSComponentSchema schema;
-
-    /*
      * Default configuration to instantiate instances of that component.
      */
-    private Properties defaultConfiguration;
+    private Properties defaultConfiguration = null;
 
     /*
      * internal component manager
@@ -127,6 +122,17 @@ public class ADSComponent
 
 
     /**
+     * Adds a CachedInstance to list
+     *
+     * @param cachedInstance CachedComponentReference to add.
+     */
+    public void addCachedInstance( CachedComponentInstance cachedInstance )
+    {
+        cachedInstances.add( cachedInstance );
+    }
+
+
+    /**
      * Gets the current instances of the component
      *
      * @return Cloned ComponentInstance list.
@@ -138,6 +144,17 @@ public class ADSComponent
 
 
     /**
+     * Gets the current cached instances of the component
+     *
+     * @return Cloned CachedComponentInstance list.
+     */
+    public List<CachedComponentInstance> getCachedInstances()
+    {
+        return new ArrayList<CachedComponentInstance>( cachedInstances );
+    }
+
+
+    /**
      * @return the factory
      */
     public Factory getFactory()
@@ -174,24 +191,6 @@ public class ADSComponent
 
 
     /**
-     * @return the schema
-     */
-    public ADSComponentSchema getSchema()
-    {
-        return schema;
-    }
-
-
-    /**
-     * @param schema the schema to set
-     */
-    public void setSchema( ADSComponentSchema schema )
-    {
-        this.schema = schema;
-    }
-
-
-    /**
      * @return the componentName
      */
     public String getComponentName()

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java?rev=1221697&r1=1221696&r2=1221697&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java (original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java Wed Dec 21 12:26:53 2011
@@ -22,20 +22,27 @@ package org.apache.directory.server.comp
 
 import java.util.ArrayList;
 import java.util.Dictionary;
+import java.util.Properties;
 
 import java.util.Hashtable;
 import java.util.List;
 
 import org.apache.directory.server.component.ADSComponent;
 import org.apache.directory.server.component.hub.listener.HubListener;
+import org.apache.directory.server.component.instance.DefaultComponentInstanceGenerator;
 import org.apache.directory.server.component.schema.DefaultComponentSchemaGenerator;
-import org.apache.directory.server.component.utilities.IPojoFactoryHelper;
+import org.apache.directory.server.component.utilities.ADSComponentHelper;
+import org.apache.directory.server.component.utilities.ADSConstants;
+import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.interceptor.Interceptor;
+import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.core.api.schema.SchemaPartition;
 import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
+import org.apache.directory.shared.ipojo.helpers.IPojoHelper;
 import org.apache.felix.ipojo.Factory;
 import org.apache.felix.ipojo.annotations.Component;
 import org.apache.felix.ipojo.annotations.Invalidate;
+import org.apache.felix.ipojo.annotations.Property;
 import org.apache.felix.ipojo.annotations.Requires;
 import org.apache.felix.ipojo.annotations.Validate;
 import org.apache.felix.ipojo.whiteboard.Wbp;
@@ -51,7 +58,7 @@ import org.osgi.service.log.LogService;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-@Component
+@Component(name = ADSConstants.ADS_HUB_FACTORY_NAME)
 @Whiteboards(whiteboards =
     {
         @Wbp(onArrival = "onFactoryArrival",
@@ -64,6 +71,11 @@ import org.osgi.service.log.LogService;
 public class ComponentHub
 {
     /*
+     * DirectoryService reference
+     */
+    private DirectoryService ads;
+
+    /*
      * Schema Partition reference.
      */
     private SchemaPartition schemaPartition;
@@ -91,12 +103,12 @@ public class ComponentHub
     /*
      * Used to manage component's schemas.
      */
-    private ComponentSchemaManager compSchemaManager = new ComponentSchemaManager( schemaPartition );
+    private ComponentSchemaManager componentSchemaManager = new ComponentSchemaManager( schemaPartition );
 
     /*
      * Used to manage config partition interactions.
      */
-    private ConfigurationManager configManager = new ConfigurationManager( configPartition );
+    private ConfigurationManager configManager = new ConfigurationManager( configPartition,componentSchemaManager );
 
     /*
      * Used to manage instances' DIT hooks.
@@ -106,7 +118,7 @@ public class ComponentHub
     /*
      * Used to manage components.
      */
-    private ComponentManager componentManager = new ComponentManager( configManager, instanceManager );
+    private ComponentManager componentManager = new ComponentManager( configManager );
 
     /*
      * Allowed interfaces for components.
@@ -128,19 +140,56 @@ public class ComponentHub
      * @param configPartition config partition reference
      * @return reference to a wrapped ComponentHub IPojo component
      */
-    public static ComponentHub createComponentHub( SchemaPartition schemaPartition,
+    public static ComponentHub createIPojoInstance( DirectoryService ads, SchemaPartition schemaPartition,
         SingleFileLdifPartition configPartition )
     {
-        return null;
+        String adsInstance = ads.getInstanceId();
+        String hubInstanceId = ADSConstants.ADS_HUB_FACTORY_NAME + "-" + adsInstance;
+        Properties conf = new Properties();
+
+        conf.put( "ads-hub-arg-ads", ads );
+        conf.put( "ads-hub-arg-schpart", schemaPartition );
+        conf.put( "ads-hub-arg-confpart", configPartition );
+
+        ComponentHub componentHubInstance = ( ComponentHub ) IPojoHelper.createIPojoComponent(
+            ADSConstants.ADS_HUB_FACTORY_NAME, hubInstanceId, null );
+
+        return componentHubInstance;
     }
 
 
-    public ComponentHub()
+    public ComponentHub(
+        @Property(name = "ads-hub-arg-ads") DirectoryService ads,
+
+        @Property(name = "ads-hub-arg-schpart") SchemaPartition schemaPartition,
+
+        @Property(name = "ads-hub-arg-confpart") SingleFileLdifPartition configPartition )
     {
+        this.ads = ads;
+        this.schemaPartition = schemaPartition;
+        this.configPartition = configPartition;
+
         componentMap = new Hashtable<String, List<ADSComponent>>();
         components = new ArrayList<ADSComponent>();
 
-        compSchemaManager.addSchemaGenerator( Interceptor.class.getName(), new DefaultComponentSchemaGenerator() );
+        componentSchemaManager.addSchemaGenerator( Interceptor.class.getName(), new DefaultComponentSchemaGenerator() );
+        componentSchemaManager.addSchemaGenerator( Partition.class.getName(), new DefaultComponentSchemaGenerator() );
+        
+        componentManager.addInstanceGenerator( Interceptor.class.getName(), new DefaultComponentInstanceGenerator() );
+        componentManager.addInstanceGenerator( Partition.class.getName(), new DefaultComponentInstanceGenerator() );
+        
+        //compSchemaManager.addSchemaGenerator( DirectoryBackedService.class.getName(), new DefaultComponentSchemaGenerator() );
+    }
+
+
+    /**
+     * Register the DirectoryListener of InstanceManager with ADS
+     *
+     * @param ads DirectoryService reference to register listener with.
+     */
+    public void RegisterWithDS( DirectoryService ads )
+    {
+        // TODO implement
     }
 
 
@@ -335,8 +384,8 @@ public class ComponentHub
 
         component.setFactory( factory );
         component.setComponentType( componentType );
-        component.setComponentName( IPojoFactoryHelper.getComponentName( component.getFactory() ) );
-        component.setComponentVersion( IPojoFactoryHelper.getComponentVersion( component.getFactory() ) );
+        component.setComponentName( ADSComponentHelper.getComponentName( component.getFactory() ) );
+        component.setComponentVersion( ADSComponentHelper.getComponentVersion( component.getFactory() ) );
 
         return component;
     }

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentManager.java?rev=1221697&r1=1221696&r2=1221697&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentManager.java (original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentManager.java Wed Dec 21 12:26:53 2011
@@ -21,23 +21,15 @@ package org.apache.directory.server.comp
 
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Properties;
-import java.util.Queue;
-import java.util.concurrent.LinkedBlockingQueue;
 
 import org.apache.directory.server.component.ADSComponent;
+import org.apache.directory.server.component.instance.CachedComponentInstance;
 import org.apache.directory.server.component.instance.ComponentInstance;
 import org.apache.directory.server.component.instance.ComponentInstanceGenerator;
-import org.apache.directory.server.component.schema.ComponentSchemaGenerator;
-import org.apache.directory.server.core.api.LdapCoreSessionConnection;
-import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
-import org.apache.directory.shared.ldap.model.message.AddRequest;
-import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -64,18 +56,12 @@ public class ComponentManager
      */
     private ConfigurationManager configManager;
 
-    /*
-     * Instance Manager reference to pair with created instances.
-     */
-    private InstanceManager instanceManager;
-
 
-    public ComponentManager( ConfigurationManager configManager, InstanceManager instanceManager )
+    public ComponentManager( ConfigurationManager configManager )
     {
         instanceGenerators = new Hashtable<String, ComponentInstanceGenerator>();
 
         this.configManager = configManager;
-        this.instanceManager = instanceManager;
     }
 
 
@@ -96,26 +82,58 @@ public class ComponentManager
 
 
     /**
-     * Create and return the instance of the given component
+     * Creates the new instance based from its factory's default configuration.
+     * And hook its instance with the DIT.
+     *
+     * @param component ADSComponent reference create new instance for.
+     * @return created instance
+     */
+    public ComponentInstance createInstance( ADSComponent component )
+    {
+        if ( component.getDefaultConfiguration() == null )
+        {
+            ComponentInstanceGenerator generator = instanceGenerators.get( component.getComponentType() );
+            if ( generator != null )
+            {
+                Properties defaultConf = generator.extractDefaultConfiguration( component );
+                if ( defaultConf == null )
+                {
+                    LOG.info( "instance generator failed to extract default configuration for component:" + component );
+                    return null;
+                }
+                component.setDefaultConfiguration( defaultConf );
+            }
+            else
+            {
+                LOG.info( "No instance generator found to extract default configuration for component:" + component );
+                return null;
+            }
+        }
+
+        ComponentInstance instance = generateInstance( component, component.getDefaultConfiguration() );
+
+        component.addInstance( instance );
+        configManager.injectInstance( instance );
+
+        return instance;
+    }
+
+
+    /**
+     * Generate and return the instance of the given component
      * using ComponentInstanceGenerator registered for its type.
      *
      * @param component ADSComponent reference to instantiate
+     * @param properties Configuration to create instance under.
      * @return created ComponentInstance reference
      */
-    public ComponentInstance createInstance( ADSComponent component, Properties properties )
+    public ComponentInstance generateInstance( ADSComponent component, Properties properties )
     {
         ComponentInstanceGenerator generator = instanceGenerators.get( component.getComponentType() );
         if ( generator != null )
         {
             ComponentInstance instance = generator.createInstance( component, properties );
 
-            instance.setInstanceManager( instanceManager );
-
-            if ( instance != null )
-            {
-                component.addInstance( instance );
-            }
-
             return instance;
         }
         else
@@ -135,7 +153,40 @@ public class ComponentManager
      */
     public List<ComponentInstance> loadCachedInstances( ADSComponent component )
     {
-        return null;
+        List<ComponentInstance> loadedInstances = new ArrayList<ComponentInstance>();
+
+        for ( CachedComponentInstance cachedConf : component.getCachedInstances() )
+        {
+            ComponentInstance instance = loadInstance( component, cachedConf );
+            if ( instance != null )
+            {
+                loadedInstances.add( instance );
+            }
+        }
+
+        return loadedInstances;
+    }
+
+
+    /**
+     * Loads the cached component instance.
+     *
+     * @param component ADSComponent reference owning cached instance
+     * @param cachedInstance cached instance reference
+     * @return ComponentInstance which is loaded from cache.
+     */
+    public ComponentInstance loadInstance( ADSComponent component, CachedComponentInstance cachedInstance )
+    {
+        ComponentInstance instance = generateInstance( component, cachedInstance.getCachedConfiguration() );
+
+        if ( instance == null )
+        {
+            return null;
+        }
+
+        component.addInstance( instance );
+
+        return instance;
     }
 
 }

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/InstanceManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/InstanceManager.java?rev=1221697&r1=1221696&r2=1221697&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/InstanceManager.java (original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/InstanceManager.java Wed Dec 21 12:26:53 2011
@@ -19,7 +19,120 @@
  */
 package org.apache.directory.server.component.hub;
 
+
+import org.apache.directory.server.component.ADSComponent;
+import org.apache.directory.server.core.api.DirectoryService;
+import org.apache.directory.server.core.api.event.DirectoryListener;
+import org.apache.directory.server.core.api.event.NotificationCriteria;
+import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.MoveAndRenameOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.MoveOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext;
+import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.message.SearchRequest;
+import org.apache.directory.shared.ldap.model.message.SearchRequestImpl;
+import org.apache.directory.shared.ldap.model.message.SearchScope;
+import org.apache.directory.shared.ldap.model.name.Dn;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
 public class InstanceManager
 {
 
+    /*
+     * Logger
+     */
+    private final Logger LOG = LoggerFactory.getLogger( InstanceManager.class );
+
+
+    public void registerComponent( ADSComponent component )
+    {
+        
+    }
+
+
+    /**
+     * Register inner DirectoryListener class with DirectoryService
+     * DirectoryService reference must have its EventService set by EventInterceptor initialization.
+     *
+     * @param ads DirectoryService reference to register listener.
+     */
+    public void registerWithDirectoryService( DirectoryService ads )
+    {
+        try
+        {
+            SearchRequest sr = new SearchRequestImpl()
+                .setBase( new Dn( "ou=config" ) )
+                .setScope( SearchScope.SUBTREE )
+                .setFilter( "(objectClass=*)" );
+
+            NotificationCriteria nfCriteria = new NotificationCriteria( sr );
+            ads.getEventService().addListener( listener, nfCriteria );
+        }
+        catch ( LdapException e )
+        {
+            LOG.info( "Ldap exception while creating SearchRequest" );
+            e.printStackTrace();
+        }
+        catch ( Exception e )
+        {
+            LOG.info( "Exception while registering with EventService" );
+            e.printStackTrace();
+        }
+
+    }
+
+    private DirectoryListener listener = new DirectoryListener()
+    {
+
+        @Override
+        public void entryRenamed( RenameOperationContext renameContext )
+        {
+            // TODO Auto-generated method stub
+
+        }
+
+
+        @Override
+        public void entryMovedAndRenamed( MoveAndRenameOperationContext moveAndRenameContext )
+        {
+            // TODO Auto-generated method stub
+
+        }
+
+
+        @Override
+        public void entryMoved( MoveOperationContext moveContext )
+        {
+            // TODO Auto-generated method stub
+
+        }
+
+
+        @Override
+        public void entryModified( ModifyOperationContext modifyContext )
+        {
+            // TODO Auto-generated method stub
+
+        }
+
+
+        @Override
+        public void entryDeleted( DeleteOperationContext deleteContext )
+        {
+            // TODO Auto-generated method stub
+
+        }
+
+
+        @Override
+        public void entryAdded( AddOperationContext addContext )
+        {
+            // TODO Auto-generated method stub
+
+        }
+    };
 }

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/HubListener.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/HubListener.java?rev=1221697&r1=1221696&r2=1221697&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/HubListener.java (original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/HubListener.java Wed Dec 21 12:26:53 2011
@@ -21,6 +21,7 @@ package org.apache.directory.server.comp
 
 
 import org.apache.directory.server.component.ADSComponent;
+import org.apache.directory.server.component.instance.CachedComponentInstance;
 import org.apache.felix.ipojo.Factory;
 import org.apache.felix.ipojo.architecture.Architecture;
 
@@ -55,4 +56,7 @@ public interface HubListener
      */
     public void onComponentDeletion( ADSComponent component );
 
+
+    public void onNewInstanceConfiguration( ADSComponent component, CachedComponentInstance createdConf );
+
 }

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstance.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstance.java?rev=1221697&r1=1221696&r2=1221697&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstance.java (original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstance.java Wed Dec 21 12:26:53 2011
@@ -53,21 +53,6 @@ public class ComponentInstance
      */
     private String DITHookDn;
 
-    /*
-     * ConfigurationManager to manage instance's DIT hooks.
-     */
-    private InstanceManager instanceManager;
-
-    /*
-     * Specifies whether this instance's DIT hook will be watched for changes.
-     */
-    private boolean isReconfigurable;
-
-    /*
-     * Specifies whether instance is avtive or cached
-     */
-    private boolean isActive = false;
-
 
     /**
      * @return the instance
@@ -140,49 +125,4 @@ public class ComponentInstance
         this.DITHookDn = DITHookDn;
     }
 
-
-    /**
-     * @param configManager the configManager to set
-     */
-    public void setInstanceManager( InstanceManager instanceManager )
-    {
-        this.instanceManager = instanceManager;
-    }
-
-
-    /**
-     * @return the isActive
-     */
-    public boolean isActive()
-    {
-        return isActive;
-    }
-
-
-    /**
-     * Sets the instance active.
-     */
-    public void setActive()
-    {
-        this.isActive = true;
-    }
-
-
-    /**
-     * @return the isReconfigurable
-     */
-    public boolean isReconfigurable()
-    {
-        return isReconfigurable;
-    }
-
-
-    /**
-     * @param isReconfigurable the isReconfigurable to set
-     */
-    public void setReconfigurable( boolean isReconfigurable )
-    {
-        this.isReconfigurable = isReconfigurable;
-    }
-
 }

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstanceGenerator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstanceGenerator.java?rev=1221697&r1=1221696&r2=1221697&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstanceGenerator.java (original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstanceGenerator.java Wed Dec 21 12:26:53 2011
@@ -41,6 +41,8 @@ public interface ComponentInstanceGenera
     /**
      * Extract default configuration from factory. This configuration is 
      * the map of default values of the published properties of a IPojo component.
+     * 
+     * If some mandatory property has no default value, then this method returns null !
      *
      * @param factory Factory reference to extract default configuration to instantiate it.
      * @return Default configuration

Added: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentOIDGenerator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentOIDGenerator.java?rev=1221697&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentOIDGenerator.java (added)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/ComponentOIDGenerator.java Wed Dec 21 12:26:53 2011
@@ -0,0 +1,87 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.component.schema;
+
+
+import org.apache.directory.server.component.utilities.ADSConstants;
+
+
+/**
+ * This is a simple incremental generator for OID assignments of custom generated schemas.
+ * Ensuring consistency among different servers on the cluster will be replication layer's duty.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ComponentOIDGenerator
+{
+    /*
+     * Base OID to generate sequential OIDs against.
+     */
+    private static String baseOID = null;
+
+    /*
+     * Counters to keep track.
+     */
+    private static int componentCounter;
+    private static int ocCounter;
+    private static int attribCounter;
+
+    static
+    {
+        baseOID = ADSConstants.ADS_COMPONENT_BASE_OID;
+
+        componentCounter = 0;
+        ocCounter = 0;
+        attribCounter = 0;
+    }
+
+
+    /**
+     * Returns OID for component
+     *
+     * @return oid for component
+     */
+    public static synchronized String generateComponentOID()
+    {
+        return baseOID + "." + ( ++componentCounter );
+    }
+
+
+    /**
+     * Returns OID for object class under specified component base OID.
+     *
+     * @return oid for object class
+     */
+    public static synchronized String generateOCOID( String componentBase )
+    {
+        return componentBase + ".1." + ( ++ocCounter );
+    }
+
+
+    /**
+     * Returns OID for attribute under specified component base OID.
+     *
+     * @return oid for attribute
+     */
+    public static synchronized String generateAttribOID( String componentBase )
+    {
+        return componentBase + ".2." + ( ++attribCounter );
+    }
+}

Added: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSComponentHelper.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSComponentHelper.java?rev=1221697&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSComponentHelper.java (added)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSComponentHelper.java Wed Dec 21 12:26:53 2011
@@ -0,0 +1,134 @@
+package org.apache.directory.server.component.utilities;
+
+
+import org.apache.directory.server.component.ADSComponent;
+import org.apache.felix.ipojo.Factory;
+
+
+public class ADSComponentHelper
+{
+    /**
+     * Gets the component name of an IPojo Component. If IPojo Component does not define its factory name
+     * its default factory name is the class name that implements that component. In this case this method leaves out
+     * the package name and only takes the class name.
+     *
+     * @param componentFactory An IPojo Component Factory reference
+     * @return component name of an IPojo Component
+     */
+    public static String getComponentName( Factory componentFactory )
+    {
+        String factoryName = componentFactory.getName();
+        if ( factoryName.contains( "." ) )
+        {
+            return factoryName.substring( factoryName.lastIndexOf( '.' ) + 1 );
+        }
+        else
+        {
+            return factoryName;
+        }
+    }
+
+
+    /**
+     * Gets the version of the component. This version is the bundle version of the bundle that
+     * contains specified component. 
+     *
+     * @param componentFactory An IPojo Component Factory reference
+     * @return version of an IPojo Component
+     */
+    public static String getComponentVersion( Factory componentFactory )
+    {
+        return ( String ) componentFactory.getBundleContext().getBundle().getHeaders().get( "Bundle-Version" );
+
+    }
+
+
+    /**
+     * Gets the base schema name which will hold this component's schema
+     *
+     * @param component ADSComponent reference to generate base schema name
+     * @return generated base schema name for ADSComponent
+     */
+    public static String getSchemaBaseName( ADSComponent component )
+    {
+        //return component.getComponentType() + "components";
+        return ADSConstants.ADS_COMPONENT_BASE_SCHEMA_NAME;
+    }
+
+
+    /**
+     * Gets the base schema Dn which will hold this component's schema
+     *
+     * @param component ADSComponent reference to generate base schema Dn
+     * @return generated base schema Dn for ADSComponent
+     */
+    public static String getSchemaBaseDn( ADSComponent component )
+    {
+        return "cn=" + getSchemaBaseName( component ) + ",ou=schema";
+    }
+
+
+    /**
+     * Gets the LDAP Object Class name which will represent this component's instances.
+     *
+     * @param component ADSComponent reference to generate objectClass name.
+     * @return generated Object Class name for component.
+     */
+    public static String getComponentObjectClass( ADSComponent component )
+    {
+        return component.getComponentName().toLowerCase();
+    }
+
+
+    /**
+     * Gets the parent entry holding supplied component's types.
+     *
+     * @param component ADSComponent reference
+     * @return Parent Dn on DIT which holds component type's instances.
+     */
+    public static String getComponentParentRdn( ADSComponent component )
+    {
+        if ( component.getComponentType().equals( ADSConstants.ADS_COMPONENT_TYPE_INTERCEPTOR ) )
+        {
+            return "ou=interceptors,ou=config";
+        }
+        else if ( component.getComponentType().equals( ADSConstants.ADS_COMPONENT_TYPE_PARTITION ) )
+        {
+            return "ou=partitions,ou=config";
+        }
+        else if ( component.getComponentType().equals( ADSConstants.ADS_COMPONENT_TYPE_SERVER ) )
+        {
+            return "ou=servers,ou=config";
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * Gets the Dn of the component's entry in DIT.
+     *
+     * @param component ADSComponent reference
+     * @return Dn of the component's entry in config partition.
+     */
+    public static String getComponentDn( ADSComponent component )
+    {
+        String base = getComponentParentRdn( component );
+        return "ou=" + component.getComponentName().toLowerCase() + "," + base;
+    }
+
+
+    /**
+     * Gets the Dn of the parent of the instances for component
+     *
+     * @param component ADSComponent reference
+     * @return Dn of the instances parent in DIT
+     */
+    public static String getComponentInstancesDn( ADSComponent component )
+    {
+        String componentDn = getComponentDn( component );
+        return "ou=instances," + componentDn;
+    }
+}

Propchange: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSComponentHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSConstants.java?rev=1221697&r1=1221696&r2=1221697&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSConstants.java (original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSConstants.java Wed Dec 21 12:26:53 2011
@@ -31,6 +31,10 @@ import java.util.Hashtable;
  */
 public class ADSConstants
 {
+    /*
+     * Component Hub factory name
+     */
+    public static final String ADS_HUB_FACTORY_NAME = "ADSComponentHub";
 
     /*
      * base directory path for component cache
@@ -53,34 +57,54 @@ public class ADSConstants
     public static final String ADS_CACHE_VERSION_FILE = "version";
 
     /*
-     * IPojo Handler name for ADSComponent annotation.
+     * Base OID value for ApacheDS component schemas.
      */
-    public static final String ADS_COMPONENT_HANDLER_NS = "org.apache.directory.server.component.handler";
+    public static final String ADS_COMPONENT_BASE_OID = "1.3.6.1.4.1.18060.0.4.4";
 
     /*
-     * IPojo Handler name for ADSComponent annotation.
+     * Base schema name for holding component's elements
      */
-    public static final String ADS_COMPONENT_HANDLER_NAME = "ADSComponentHandler";
+    public static final String ADS_COMPONENT_BASE_SCHEMA_NAME = "componenthub";
 
     /*
-     * IPojo Handler name for ADSComponent annotation.
+     * OC name of the component OC.
      */
-    public static final String ADS_COMPONENT_HANDLER_FULLNAME = "org.apache.directory.server.component.handler:ADSComponentHandler";
+    public static final String ADS_COMPONENT_OC_NAME = "ads-component";
 
     /*
-     * iPOJO Component Type and Instance declaration header.
+     * Attribute name of component name
      */
-    public static final String IPOJO_HEADER = "iPOJO-Components";
+    public static final String ADS_COMPONENT_ATTRIB_NAME = "ads-componetname";
 
     /*
-     * Base OID value for ApacheDS component schemas.
+     * Attribute name of component type
      */
-    public static final String ADS_COMPONENT_BASE_OID = "1.3.6.1.4.1.18060.0.4.4";
+    public static final String ADS_COMPONENT_ATTRIB_TYPE = "ads-componenttype";
+
+    /*
+     * Attribute name of component object class
+     */
+    public static final String ADS_COMPONENT_ATTRIB_OC = "ads-ocname";
+
+    /*
+     * Attribute name of component purge count
+     */
+    public static final String ADS_COMPONENT_ATTRIB_PURGE = "ads-componentpurgecount";
+
+    /*
+     * Component type name of interceptors
+     */
+    public static final String ADS_COMPONENT_TYPE_INTERCEPTOR = "interceptor";
+
+    /*
+     * Component type name of partitions
+     */
+    public static final String ADS_COMPONENT_TYPE_PARTITION = "partition";
 
     /*
-     * Component type name of user defined components.
+     * Component type name of servers
      */
-    public static final String ADS_COMPONENT_TYPE_USER = "user";
+    public static final String ADS_COMPONENT_TYPE_SERVER = "server";
 
     /*
      * Hash table for mapping property type name to its syntax in ApacheDS

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/LdifConfigHelper.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/LdifConfigHelper.java?rev=1221697&r1=1221696&r2=1221697&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/LdifConfigHelper.java (original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/LdifConfigHelper.java Wed Dec 21 12:26:53 2011
@@ -19,25 +19,29 @@
  */
 package org.apache.directory.server.component.utilities;
 
+
 import java.util.Properties;
 
 import org.apache.directory.server.component.ADSComponent;
 import org.apache.directory.server.component.instance.ComponentInstance;
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
 
+
 public class LdifConfigHelper
 {
-    public LdifEntry componentToLdifEntry(ADSComponent component)
+    public static LdifEntry componentToLdifEntry( ADSComponent component )
     {
         return null;
     }
-    
-    public LdifEntry instanceToLdif(ComponentInstance instance)
+
+
+    public static LdifEntry instanceToLdif( ComponentInstance instance )
     {
         return null;
     }
-    
-    public Properties instanceEntryToConfiguration(LdifEntry entry)
+
+
+    public static Properties instanceEntryToConfiguration( LdifEntry entry )
     {
         return null;
     }

Added: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/resources/org/apache/directory/server/component/schema/componenthub.ldif
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/resources/org/apache/directory/server/component/schema/componenthub.ldif?rev=1221697&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/resources/org/apache/directory/server/component/schema/componenthub.ldif (added)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/resources/org/apache/directory/server/component/schema/componenthub.ldif Wed Dec 21 12:26:53 2011
@@ -0,0 +1,144 @@
+# Generated by Apache Directory Studio on December 21, 2011 10:03:16 AM
+
+# SCHEMA "COMPONENTHUB"
+dn: cn=componenthub, ou=schema
+objectclass: metaSchema
+objectclass: top
+cn: componenthub
+m-dependencies: core
+
+dn: ou=attributeTypes, cn=componenthub, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: attributetypes
+
+dn: m-oid=1.3.6.1.4.1.18060.0.4.3.1.1, ou=attributeTypes, cn=componenthub, ou=sc
+ hema
+objectclass: metaAttributeType
+objectclass: metaTop
+objectclass: top
+m-oid: 1.3.6.1.4.1.18060.0.4.3.1.1
+m-name: ads-componentname
+m-description: The normalized factory name of an IPojo component
+m-equality: caseIgnoreMatch
+m-ordering: caseExactOrderingMatch
+m-substr: caseIgnoreSubstringsMatch
+m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
+m-length: 0
+m-singleValue: TRUE
+m-usage: directoryOperation
+
+dn: m-oid=1.3.6.1.4.1.18060.0.4.3.1.2, ou=attributeTypes, cn=componenthub, ou=sc
+ hema
+objectclass: metaAttributeType
+objectclass: metaTop
+objectclass: top
+m-oid: 1.3.6.1.4.1.18060.0.4.3.1.2
+m-name: ads-componenttype
+m-description: Describes the type of a IPojo component(eg: interceptor,partition
+ ,...)
+m-equality: caseIgnoreMatch
+m-ordering: caseIgnoreOrderingMatch
+m-substr: caseIgnoreSubstringsMatch
+m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
+m-length: 0
+m-singleValue: TRUE
+m-usage: directoryOperation
+
+dn: m-oid=1.3.6.1.4.1.18060.0.4.3.1.3, ou=attributeTypes, cn=componenthub, ou=sc
+ hema
+objectclass: metaAttributeType
+objectclass: metaTop
+objectclass: top
+m-oid: 1.3.6.1.4.1.18060.0.4.3.1.3
+m-name: ads-ocname
+m-description: Object Class name which will be used to represent a component.
+m-equality: caseIgnoreMatch
+m-ordering: caseIgnoreOrderingMatch
+m-substr: caseIgnoreSubstringsMatch
+m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
+m-length: 0
+m-singleValue: TRUE
+m-usage: directoryOperation
+
+dn: m-oid=1.3.6.1.4.1.18060.0.4.3.1.4, ou=attributeTypes, cn=componenthub, ou=sc
+ hema
+objectclass: metaAttributeType
+objectclass: metaTop
+objectclass: top
+m-oid: 1.3.6.1.4.1.18060.0.4.3.1.4
+m-name: ads-componentpurgecount
+m-description: The count which will be used as a feedback to house keeping proce
+ dure for component.
+m-equality: integerMatch
+m-ordering: integerOrderingMatch
+m-substr: numericStringSubstringsMatch
+m-syntax: 1.3.6.1.4.1.1466.115.121.1.27
+m-length: 0
+m-singleValue: TRUE
+m-usage: directoryOperation
+
+dn: ou=comparators, cn=componenthub, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: comparators
+
+dn: ou=ditContentRules, cn=componenthub, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: ditcontentrules
+
+dn: ou=ditStructureRules, cn=componenthub, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: ditstructurerules
+
+dn: ou=matchingRules, cn=componenthub, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: matchingrules
+
+dn: ou=matchingRuleUse, cn=componenthub, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: matchingruleuse
+
+dn: ou=nameForms, cn=componenthub, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: nameforms
+
+dn: ou=normalizers, cn=componenthub, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: normalizers
+
+dn: ou=objectClasses, cn=componenthub, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: objectClasses
+
+dn: m-oid=1.3.6.1.4.1.18060.0.4.3.2.1, ou=objectClasses, cn=componenthub, ou=sch
+ ema
+objectclass: metaObjectClass
+objectclass: metaTop
+objectclass: top
+m-oid: 1.3.6.1.4.1.18060.0.4.3.2.1
+m-name: ads-component
+m-description: Describes the IPojo component extension to the ApacheDS
+m-supObjectClass: organizationalUnit
+m-must: ads-componentname
+m-must: ads-componenttype
+m-must: ads-ocname
+m-may: ads-componentpurgecount
+
+dn: ou=syntaxCheckers, cn=componenthub, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: syntaxcheckers
+
+dn: ou=syntaxes, cn=componenthub, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: syntaxes
+

Modified: directory/apacheds/branches/apacheds-osgi/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/pom.xml?rev=1221697&r1=1221696&r2=1221697&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/pom.xml (original)
+++ directory/apacheds/branches/apacheds-osgi/pom.xml Wed Dec 21 12:26:53 2011
@@ -981,6 +981,13 @@
         <version>${org.apache.directory.shared.version}</version>
       </dependency>
       
+      <dependency>
+        <groupId>org.apache.directory.shared</groupId>
+        <artifactId>shared-ipojo-manager</artifactId>
+        <version>${org.apache.directory.shared.version}</version>
+      </dependency>
+      
+      
       <!-- Mina dependencies -->
       
       <dependency>