directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gokt...@apache.org
Subject svn commit: r1203705 - in /directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component: ./ hub/ hub/listener/ instance/ schema/
Date Fri, 18 Nov 2011 15:39:24 GMT
Author: gokturk
Date: Fri Nov 18 15:39:23 2011
New Revision: 1203705

URL: http://svn.apache.org/viewvc?rev=1203705&view=rev
Log: (empty)

Added:
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentCacheHandle.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentCacheManager.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentEventManager.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ADSComponentInstanceGenerator.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/UserComponentInstanceGenerator.java
Modified:
    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/ADSComponentInstance.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/listener/AbstractHubListener.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/schema/ADSComponentSchema.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java

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=1203705&r1=1203704&r2=1203705&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
Fri Nov 18 15:39:23 2011
@@ -19,10 +19,13 @@
  */
 package org.apache.directory.server.component;
 
+
+import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.directory.shared.ldap.model.ldif.LdifReader;
-import org.apache.felix.ipojo.ComponentFactory;
+import org.apache.directory.server.component.schema.ADSComponentSchema;
+import org.apache.felix.ipojo.Factory;
+
 
 /**
  * Class that represents a component for ApacheDS use.
@@ -31,19 +34,114 @@ import org.apache.felix.ipojo.ComponentF
  */
 public class ADSComponent
 {
-    private ComponentFactory factory;
-    
+    private Factory factory;
+
     private String componentType = "user";
-    
-    private String componentSchemaDn;
-    
+
     private List<ADSComponentInstance> instances;
-    
-    private LdifReader cacheHandle;
 
-    public ComponentFactory getFactory()
+    private ADSComponentCacheHandle cacheHandle;
+
+    private ADSComponentSchema schema;
+
+
+    public ADSComponent()
+    {
+        instances = new ArrayList<ADSComponentInstance>();
+    }
+
+
+    /**
+     * Adds an instance to a instances list
+     *
+     * @param instance instance reference to add to a list
+     */
+    public void addInstance( ADSComponentInstance instance )
+    {
+        instances.add( instance );
+    }
+
+
+    /**
+     * Removes an instance from instances list
+     *
+     * @param instance to remove from the list
+     */
+    public void removeInstance( ADSComponentInstance instance )
+    {
+        instances.remove( instance );
+    }
+
+
+    /**
+     * @return the cacheHandle
+     */
+    public ADSComponentCacheHandle getCacheHandle()
+    {
+        return cacheHandle;
+    }
+
+
+    /**
+     * @param cacheHandle the cacheHandle to set
+     */
+    public void setCacheHandle( ADSComponentCacheHandle cacheHandle )
+    {
+        this.cacheHandle = cacheHandle;
+    }
+
+
+    /**
+     * @return the factory
+     */
+    public Factory getFactory()
     {
         return factory;
     }
-    
+
+
+    /**
+     * @param factory the factory to set
+     */
+    public void setFactory( Factory factory )
+    {
+        this.factory = factory;
+    }
+
+
+    /**
+     * @return the componentType
+     */
+    public String getComponentType()
+    {
+        return componentType;
+    }
+
+
+    /**
+     * @param componentType the componentType to set
+     */
+    public void setComponentType( String componentType )
+    {
+        this.componentType = componentType;
+    }
+
+
+    /**
+     * @return the schema
+     */
+    public ADSComponentSchema getSchema()
+    {
+        return schema;
+    }
+
+
+    /**
+     * @param schema the schema to set
+     */
+    public void setSchema( ADSComponentSchema schema )
+    {
+        this.schema = schema;
+    }
+
 }

Added: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentCacheHandle.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentCacheHandle.java?rev=1203705&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentCacheHandle.java
(added)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentCacheHandle.java
Fri Nov 18 15:39:23 2011
@@ -0,0 +1,66 @@
+package org.apache.directory.server.component;
+
+
+import org.apache.directory.shared.ldap.model.ldif.LdifReader;
+
+
+public class ADSComponentCacheHandle
+{
+    /*
+     * LdifReader pointing to a ldif file holding cached schema of the component.
+     */
+    private LdifReader cachedSchemaHandle;
+
+    /*
+     * LdifReader pointing to a ldif file holding previously created component instance entries.

+     */
+    private LdifReader cachedInstancesHandle;
+
+    /*
+     * Component version of the cache. Used for validating of invalidating the cache in case
of
+     * component updates.
+     */
+    private String cachedVersion;
+
+
+    public ADSComponentCacheHandle( LdifReader schema, LdifReader instances, String version
)
+    {
+        cachedSchemaHandle = schema;
+        cachedInstancesHandle = instances;
+        cachedVersion = version;
+    }
+
+
+    /**
+     * Getter for cached schema handle
+     *
+     * @return LdifReader pointing to a ldif file of schema.
+     */
+    public LdifReader getCachedSchemaHandle()
+    {
+        return cachedSchemaHandle;
+    }
+
+
+    /**
+     * Getter for cached instances handle
+     *
+     * @return LdifReader pointing to a ldif file of instance entries.
+     */
+    public LdifReader getCachedInstancesHandle()
+    {
+        return cachedInstancesHandle;
+    }
+
+
+    /**
+     * Getter for cached version of cache
+     *
+     * @return version of cache.
+     */
+    public String getCachedVersion()
+    {
+        return cachedVersion;
+    }
+
+}

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java?rev=1203705&r1=1203704&r2=1203705&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java
Fri Nov 18 15:39:23 2011
@@ -19,8 +19,10 @@
  */
 package org.apache.directory.server.component;
 
+
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
 
+
 /**
  * Class that represents an individual instance of an ADSComponent
  *
@@ -28,12 +30,96 @@ import org.apache.directory.shared.ldap.
  */
 public class ADSComponentInstance
 {
-    private LdifEntry instanceEntry;
-    
-    private String configHookDn;
-    
+    /*
+     * Actual instance reference.
+     */
     private Object instance;
-    
+
+    /*
+     * The parent component of this spesific instance
+     */
     private ADSComponent parentComponent;
-    
+
+    /*
+     * LdifEntry of configuration hook.
+     */
+    private LdifEntry instanceEntry;
+
+    /*
+     * Dn value shows where the configuration hook is set on DIT.
+     */
+    private String configHookDn;
+
+
+    /**
+     * @return the instance
+     */
+    public Object getInstance()
+    {
+        return instance;
+    }
+
+
+    /**
+     * @param instance the instance to set
+     */
+    public void setInstance( Object instance )
+    {
+        this.instance = instance;
+    }
+
+
+    /**
+     * @return the parentComponent
+     */
+    public ADSComponent getParentComponent()
+    {
+        return parentComponent;
+    }
+
+
+    /**
+     * @param parentComponent the parentComponent to set
+     */
+    public void setParentComponent( ADSComponent parentComponent )
+    {
+        this.parentComponent = parentComponent;
+    }
+
+
+    /**
+     * @return the instanceEntry
+     */
+    public LdifEntry getInstanceEntry()
+    {
+        return instanceEntry;
+    }
+
+
+    /**
+     * @param instanceEntry the instanceEntry to set
+     */
+    public void setInstanceEntry( LdifEntry instanceEntry )
+    {
+        this.instanceEntry = instanceEntry;
+    }
+
+
+    /**
+     * @return the configHookDn
+     */
+    public String getConfigHookDn()
+    {
+        return configHookDn;
+    }
+
+
+    /**
+     * @param configHookDn the configHookDn to set
+     */
+    public void setConfigHookDn( String configHookDn )
+    {
+        this.configHookDn = configHookDn;
+    }
+
 }

Added: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentCacheManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentCacheManager.java?rev=1203705&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentCacheManager.java
(added)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentCacheManager.java
Fri Nov 18 15:39:23 2011
@@ -0,0 +1,36 @@
+/*
+ *  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.hub;
+
+
+import org.apache.directory.server.component.ADSComponent;
+import org.apache.directory.server.component.ADSComponentCacheHandle;
+
+
+/*
+ * Class to manage schema and instance cache locations for ADSComponents.
+ */
+public class ComponentCacheManager
+{
+    public ADSComponentCacheHandle getCacheHandle( ADSComponent component )
+    {
+        return null;
+    }
+}

Added: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentEventManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentEventManager.java?rev=1203705&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentEventManager.java
(added)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentEventManager.java
Fri Nov 18 15:39:23 2011
@@ -0,0 +1,202 @@
+/*
+ *  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.hub;
+
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.apache.directory.server.component.ADSComponent;
+import org.apache.directory.server.component.hub.listener.HubListener;
+
+
+/**
+ * Manages component install, uninstall events for listeners.
+ * Provides listeners an ability to get passed events by holding an event cache.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ComponentEventManager
+{
+
+    /*
+     * Map to keep "component type" -> "listeners" mapping
+     */
+    private Dictionary<String, List<HubListener>> listenersMap;
+
+    /*
+     * Map to keep all passed events.
+     */
+    private Dictionary<String, List<ADSComponent>> eventCache;
+
+
+    public ComponentEventManager()
+    {
+        listenersMap = new Hashtable<String, List<HubListener>>();
+        eventCache = new Hashtable<String, List<ADSComponent>>();
+    }
+
+
+    /**
+     * Registers a HubListener for specified component type.
+     *
+     * @param componentType component type to get notifications for.
+     * @param listener HubListener implementation
+     */
+    public synchronized void registerListener( String componentType, HubListener listener
)
+    {
+        List<HubListener> listenersForComp = listenersMap.get( componentType );
+        if ( listenersForComp == null )
+        {
+            ArrayList<HubListener> list = new ArrayList<HubListener>();
+            list.add( listener );
+            listenersMap.put( componentType, list );
+        }
+        else
+        {
+            if ( !listenersForComp.contains( listener ) )
+            {
+                listenersForComp.add( listener );
+            }
+        }
+
+        // Make listener receive the passed creation events.
+        List<ADSComponent> passedCreations = eventCache.get( componentType );
+        if ( passedCreations != null )
+        {
+            for ( ADSComponent comp : passedCreations )
+            {
+                listener.onComponentCreation( comp );
+            }
+        }
+    }
+
+
+    /**
+     * Removes the specified listener from the notification chain.
+     *
+     * @param listener HubListener implementation
+     */
+    public synchronized void removeListener( HubListener listener )
+    {
+        Enumeration<List<HubListener>> it = listenersMap.elements();
+        while ( it.hasMoreElements() )
+        {
+            List<HubListener> list = it.nextElement();
+            if ( list.contains( listener ) )
+            {
+                list.remove( listener );
+            }
+        }
+    }
+
+
+    /**
+     * Iterates through listeners for specified ADSComponent's component type.
+     * Calls their onComponentCreation() method. 
+     * 
+     * Reference is passed without cloning. So individual listeners can change
+     * the provided ADSComponent. It will affect the all component hub.
+     *
+     * @param component ADSComponent reference to be used for notification
+     */
+    public synchronized void fireComponentCreated( ADSComponent component )
+    {
+        List<HubListener> listenersByType = listenersMap.get( component.getComponentType()
);
+
+        // Iterate over listeners for 'component created' event. Apply the changes applied
by them.
+        if ( listenersByType != null )
+        {
+            for ( HubListener listener : listenersByType )
+            {
+                listener.onComponentCreation( component );
+            }
+        }
+
+        cacheCreation( component );
+    }
+
+
+    /**
+     * Iterates through listeners for specified ADSComponent's component type.
+     * Calls their onComponentDeletion() method.
+     * 
+     * In the time callbacks are executed, the ADSComponent's existence on ApacheDS
+     * is terminated. So use the reference just for statistical purposes.
+     *
+     * @param component ADSComponent reference to be used for notification
+     */
+    public synchronized void fireComponentDeleted( ADSComponent component )
+    {
+        List<HubListener> listenersByType = listenersMap.get( component.getComponentType()
);
+
+        // Iterate over listeners for 'component deleting' event.
+        if ( listenersByType != null )
+        {
+            for ( HubListener listener : listenersByType )
+            {
+                listener.onComponentDeletion( component );
+            }
+        }
+
+        unCacheCreation( component );
+    }
+
+
+    /**
+     * Caches ADSComponent to notify late-coming listeners.
+     *
+     * @param comp ADSComponent reference to cache
+     */
+    private void cacheCreation( ADSComponent component )
+    {
+        String compType = component.getComponentType();
+        List<ADSComponent> passedEvents = eventCache.get( compType );
+        if ( passedEvents == null )
+        {
+            passedEvents = new ArrayList<ADSComponent>();
+            passedEvents.add( component );
+        }
+        else
+        {
+            passedEvents.add( component );
+        }
+    }
+
+
+    /**
+     * Removes ADSComponent from the cache. So late-coming listeners
+     * won't be notified.
+     *
+     * @param comp ADSComponent reference to cache
+     */
+    private void unCacheCreation( ADSComponent component )
+    {
+        String compType = component.getComponentType();
+        List<ADSComponent> passedEvents = eventCache.get( compType );
+        if ( passedEvents != null && passedEvents.contains( component ) )
+        {
+            passedEvents.remove( component );
+        }
+    }
+}

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=1203705&r1=1203704&r2=1203705&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
Fri Nov 18 15:39:23 2011
@@ -29,6 +29,9 @@ import java.util.List;
 import org.apache.directory.server.component.ADSComponent;
 import org.apache.directory.server.component.ADSConstants;
 import org.apache.directory.server.component.hub.listener.HubListener;
+import org.apache.directory.server.component.instance.ADSComponentInstanceGenerator;
+import org.apache.directory.server.component.instance.UserComponentInstanceGenerator;
+import org.apache.directory.server.component.schema.ADSComponentSchema;
 import org.apache.directory.server.component.schema.ComponentSchemaGenerator;
 import org.apache.directory.server.component.schema.UserComponentSchemaGenerator;
 import org.apache.felix.ipojo.Factory;
@@ -90,9 +93,19 @@ public class ComponentHub
     private Dictionary<String, ComponentSchemaGenerator> schemaGenerators;
 
     /*
-     * Map to keep "component type" -> "listeners" mapping
+     * Map to keep "component type" -> "instance generator" mapping.
      */
-    private Dictionary<String, List<HubListener>> listenersMap;
+    private Dictionary<String, ADSComponentInstanceGenerator> instanceGenerators;
+
+    /*
+     * Used to manage listeners.
+     */
+    private ComponentEventManager eventManager = new ComponentEventManager();
+
+    /*
+     * Used to manage component caches.
+     */
+    private ComponentCacheManager cacheManager = new ComponentCacheManager();
 
     /*
      * OSGI Logger
@@ -109,7 +122,8 @@ public class ComponentHub
         schemaGenerators = new Hashtable<String, ComponentSchemaGenerator>();
         schemaGenerators.put( ADSConstants.ADS_COMPONENT_TYPE_USER, new UserComponentSchemaGenerator()
);
 
-        listenersMap = new Hashtable<String, List<HubListener>>();
+        instanceGenerators = new Hashtable<String, ADSComponentInstanceGenerator>();
+        instanceGenerators.put( ADSConstants.ADS_COMPONENT_TYPE_USER, new UserComponentInstanceGenerator()
);
     }
 
 
@@ -152,32 +166,10 @@ public class ComponentHub
         {
             String componentType = parseComponentType( arrivingFactory );
 
-            List<HubListener> listenersByType = listenersMap.get( componentType );
-
-            // Fire the 'factory arrived' event on listeners.
-            if ( listenersByType != null )
-            {
-                for ( HubListener listener : listenersByType )
-                {
-                    listener.onFactoryArrival( arrivingFactory );
-                }
-            }
-
             //Actual ADSComponent creation
             ADSComponent component = generateADSComponent( componentType, arrivingFactory
);
 
-            // Iterate over listeners for 'component created' event. Apply the changes applied
by them.
-            if ( listenersByType != null )
-            {
-                for ( HubListener listener : listenersByType )
-                {
-                    ADSComponent _comp = listener.onComponentCreation( component );
-                    if ( _comp != null )
-                    {
-                        component = _comp;
-                    }
-                }
-            }
+            eventManager.fireComponentCreated( component );
 
             //Keep the newly created ADSComponent reference.
             components.add( component );
@@ -220,17 +212,6 @@ public class ComponentHub
         {
             String componentType = parseComponentType( leavingFactory );
 
-            List<HubListener> listenersByType = listenersMap.get( componentType );
-
-            // Fire the 'factory leaving' event on listeners.
-            if ( listenersByType != null )
-            {
-                for ( HubListener listener : listenersByType )
-                {
-                    listener.onFactoryDeparture( leavingFactory );
-                }
-            }
-
             ADSComponent associatedComp = null;
             for ( ADSComponent _comp : components )
             {
@@ -248,18 +229,12 @@ public class ComponentHub
                 return;
             }
 
-            // Iterate over listeners for 'component deleting' event.
-            if ( listenersByType != null )
-            {
-                for ( HubListener listener : listenersByType )
-                {
-                    listener.onComponentDeletion( associatedComp );
-                }
-            }
-
             // All clients are notified now cache and delete the ADSComponent existence on
ApacheDS
             cacheAndReleaseADSComponent( associatedComp );
 
+            // Fire "Component Deleted" event
+            eventManager.fireComponentDeleted( associatedComp );
+
         }
         catch ( ParseException e )
         {
@@ -358,7 +333,23 @@ public class ComponentHub
      */
     private ADSComponent generateADSComponent( String componentType, Factory factory )
     {
-        return null;
+        ADSComponent component = new ADSComponent();
+
+        ComponentSchemaGenerator schemaGenerator = schemaGenerators.get( componentType );
+        if ( schemaGenerator == null )
+        {
+            logger.log( LogService.LOG_INFO, "Schema generator not present for component
type:" + componentType );
+            return null;
+        }
+
+        ADSComponentSchema schema = schemaGenerator.generateOrGetSchemaElements( factory
);
+        component.setSchema( schema );
+
+        component.setFactory( factory );
+        component.setComponentType( componentType );
+        component.setCacheHandle( cacheManager.getCacheHandle( component ) );
+
+        return component;
     }
 
 
@@ -381,20 +372,7 @@ public class ComponentHub
      */
     public void registerListener( String componentType, HubListener listener )
     {
-        List<HubListener> listenersForComp = listenersMap.get( componentType );
-        if ( listenersForComp == null )
-        {
-            ArrayList<HubListener> list = new ArrayList<HubListener>();
-            list.add( listener );
-            listenersMap.put( componentType, list );
-        }
-        else
-        {
-            if ( !listenersForComp.contains( listener ) )
-            {
-                listenersForComp.add( listener );
-            }
-        }
+        eventManager.registerListener( componentType, listener );
     }
 
 
@@ -405,14 +383,6 @@ public class ComponentHub
      */
     public void removeListener( HubListener listener )
     {
-        Enumeration<List<HubListener>> it = listenersMap.elements();
-        while ( it.hasMoreElements() )
-        {
-            List<HubListener> list = it.nextElement();
-            if ( list.contains( listener ) )
-            {
-                list.remove( listener );
-            }
-        }
+        eventManager.removeListener( listener );
     }
 }

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/AbstractHubListener.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/AbstractHubListener.java?rev=1203705&r1=1203704&r2=1203705&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/AbstractHubListener.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/listener/AbstractHubListener.java
Fri Nov 18 15:39:23 2011
@@ -34,33 +34,11 @@ public abstract class AbstractHubListene
 
     /*
      * (non-Javadoc)
-     * @see org.apache.directory.server.component.hub.listener.HubListener#onFactoryArrival(org.apache.felix.ipojo.Factory)
-     */
-    @Override
-    public void onFactoryArrival( Factory factory )
-    {
-    }
-
-
-    /*
-     * (non-Javadoc)
-     * @see org.apache.directory.server.component.hub.listener.HubListener#onFactoryDeparture(org.apache.felix.ipojo.Factory)
-     */
-    @Override
-    public void onFactoryDeparture( Factory factory )
-    {
-
-    }
-
-
-    /*
-     * (non-Javadoc)
      * @see org.apache.directory.server.component.hub.listener.HubListener#onComponentCreation(org.apache.directory.server.component.ADSComponent)
      */
     @Override
-    public ADSComponent onComponentCreation( ADSComponent component )
+    public void onComponentCreation( ADSComponent component )
     {
-        return null;
     }
 
 

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=1203705&r1=1203704&r2=1203705&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
Fri Nov 18 15:39:23 2011
@@ -35,30 +35,15 @@ import org.apache.felix.ipojo.architectu
  */
 public interface HubListener
 {
-    /**
-     * Notified when a new factory is sniffed by Hub.
-     *
-     * @param factory arriving factory
-     */
-    public void onFactoryArrival( Factory factory );
-
-
-    /**
-     * Notified when a factory leaving the container.
-     *
-     * @param factory departuring factory
-     */
-    public void onFactoryDeparture( Factory factory );
-
 
     /**
      * Notified when a new ADSComponent is created.
-     * Listener can change the newly created ADSComponent by returning changed ADSComponent.(Be
cautious)
+     * Listener can change the newly created ADSComponent by modifying the suppliad argument.
      *
      * @param component newly created ADSComponent
      * @return the overrided version of the ADSComponent or null if no change is intended.
      */
-    public ADSComponent onComponentCreation( ADSComponent component );
+    public void onComponentCreation( ADSComponent component );
 
 
     /**

Added: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ADSComponentInstanceGenerator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ADSComponentInstanceGenerator.java?rev=1203705&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ADSComponentInstanceGenerator.java
(added)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ADSComponentInstanceGenerator.java
Fri Nov 18 15:39:23 2011
@@ -0,0 +1,38 @@
+/*
+ *  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.instance;
+
+
+import org.apache.directory.server.component.ADSComponent;
+import org.apache.directory.server.component.ADSComponentInstance;
+
+
+public interface ADSComponentInstanceGenerator
+{
+    /**
+     * Creates an instance of a supplied ADSComponent.
+     * Generates actual java object an LdifEntry describing it.
+     *
+     * @param component ADSComponent reference to be instantiated
+     * @return ADSInstance reference created from ADSComponent
+     */
+    public ADSComponentInstance createInstance( ADSComponent component );
+
+}

Added: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/UserComponentInstanceGenerator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/UserComponentInstanceGenerator.java?rev=1203705&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/UserComponentInstanceGenerator.java
(added)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/UserComponentInstanceGenerator.java
Fri Nov 18 15:39:23 2011
@@ -0,0 +1,46 @@
+/*
+ *  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.instance;
+
+
+import org.apache.directory.server.component.ADSComponent;
+import org.apache.directory.server.component.ADSComponentInstance;
+
+
+/**
+ * Class that generates an instances of "user" typed components.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class UserComponentInstanceGenerator implements ADSComponentInstanceGenerator
+{
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.directory.server.component.instance.ADSComponentInstanceGenerator#createInstance(org.apache.directory.server.component.ADSComponent)
+     */
+    @Override
+    public ADSComponentInstance createInstance( ADSComponent component )
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/ADSComponentSchema.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/ADSComponentSchema.java?rev=1203705&r1=1203704&r2=1203705&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/ADSComponentSchema.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/ADSComponentSchema.java
Fri Nov 18 15:39:23 2011
@@ -21,6 +21,7 @@ package org.apache.directory.server.comp
 
 
 import java.util.ArrayList;
+import java.util.Dictionary;
 import java.util.List;
 
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
@@ -48,6 +49,11 @@ public class ADSComponentSchema
      */
     private String parentSchemaDn = null;
 
+    /*
+     * The default attribute/property values for this schemas associated component to be
instantiated
+     */
+    private Dictionary defaultConf = null;
+
 
     public ADSComponentSchema( String name, List<LdifEntry> elements )
     {
@@ -100,4 +106,26 @@ public class ADSComponentSchema
         return new ArrayList<LdifEntry>( schemaElements );
     }
 
+
+    /**
+     * Setter for default configuration
+     *
+     * @param conf Dictionary containing property name -> value mapping
+     */
+    public void setDefaultConf( Dictionary conf )
+    {
+        defaultConf = conf;
+    }
+
+
+    /**
+     * Getter for default configuration
+     *
+     * @param conf Dictionary containing property name -> value mapping
+     */
+    public Dictionary getDefaultConf()
+    {
+        return defaultConf;
+    }
+
 }

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java?rev=1203705&r1=1203704&r2=1203705&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java
Fri Nov 18 15:39:23 2011
@@ -21,6 +21,8 @@ package org.apache.directory.server.comp
 
 
 import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
 import java.util.List;
 
 import org.apache.directory.server.component.ADSConstants;
@@ -59,6 +61,9 @@ public class UserComponentSchemaGenerato
         //Will hold the m-must attributes while iterating over properties of the component
         List<String> ocAttribs = new ArrayList<String>();
 
+        //Will hold default values for factory proeprties.
+        Dictionary defaultConf = new Hashtable<String, Object>();
+
         // Creating schema elements with proper order and pushing them into the list
         try
         {
@@ -68,9 +73,10 @@ public class UserComponentSchemaGenerato
             for ( PropertyDescription prop : componentFactory.getComponentDescription().getProperties()
)
             {
 
-                //Must be lower case, alphanumeric only
+                //Must be lower case, alphanumeric+'-' only
                 String propname = prop.getName();
 
+                String propvalue = prop.getValue();
                 String proptype = prop.getType();
                 String propoid = ComponentOIDGenerator.generateAttribOID( componentBaseOID
);
                 String propdn = "m-oid=" + propoid + "," + attribsDn;
@@ -111,6 +117,8 @@ public class UserComponentSchemaGenerato
                     ocAttribs.add( "m-may:" + propname );
                 }
 
+                defaultConf.put( propname, propvalue );
+
             }
 
             schemaElements.add( new LdifEntry( ocsDn,
@@ -151,7 +159,11 @@ public class UserComponentSchemaGenerato
                 + componentFactory );
         }
 
-        return new ADSComponentSchema( ADSConstants.ADS_USER_COMPONENTS_SCHEMA_DN, schemaElements
);
+        ADSComponentSchema compSchema = new ADSComponentSchema( ADSConstants.ADS_USER_COMPONENTS_SCHEMA_DN,
+            schemaElements );
+        compSchema.setDefaultConf( defaultConf );
+
+        return compSchema;
     }
 
 }



Mime
View raw message