directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gokt...@apache.org
Subject svn commit: r1222995 - in /directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component: ./ hub/ instance/ utilities/
Date Sat, 24 Dec 2011 16:10:16 GMT
Author: gokturk
Date: Sat Dec 24 16:10:16 2011
New Revision: 1222995

URL: http://svn.apache.org/viewvc?rev=1222995&view=rev
Log:
* ComponentInstance classname is changed to ADSComponentInstance to prevent name clashes with
...ipojo.util.ComponentInstance
* IPojo instance creation in DefaultComponentInstanceGenerator is handled without IPojoHelper
for potential performance gain.
* License Header is addition to some files.


Added:
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ADSComponentInstance.java
      - copied, changed from r1222990, directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstance.java
Removed:
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstance.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/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/ConfigurationManager.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/instance/DefaultComponentInstanceGenerator.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSComponentHelper.java
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/LdifConfigHelper.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=1222995&r1=1222994&r2=1222995&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
Sat Dec 24 16:10:16 2011
@@ -26,7 +26,7 @@ import java.util.Properties;
 
 import org.apache.directory.server.component.hub.ComponentManager;
 import org.apache.directory.server.component.instance.CachedComponentInstance;
-import org.apache.directory.server.component.instance.ComponentInstance;
+import org.apache.directory.server.component.instance.ADSComponentInstance;
 import org.apache.directory.server.component.schema.ADSComponentSchema;
 import org.apache.felix.ipojo.Factory;
 
@@ -62,7 +62,7 @@ public class ADSComponent
     /*
      * List holding all the created instances.
      */
-    private List<ComponentInstance> activeInstances;
+    private List<ADSComponentInstance> activeInstances;
 
     /*
      * List holding all the cached instances.
@@ -84,7 +84,7 @@ public class ADSComponent
     {
         this.componentManager = componentManager;
 
-        activeInstances = new ArrayList<ComponentInstance>();
+        activeInstances = new ArrayList<ADSComponentInstance>();
     }
 
 
@@ -93,7 +93,7 @@ public class ADSComponent
      *
      * @param instance instance reference to add to a list
      */
-    public void addInstance( ComponentInstance instance )
+    public void addInstance( ADSComponentInstance instance )
     {
         activeInstances.add( instance );
     }
@@ -104,7 +104,7 @@ public class ADSComponent
      *
      * @param instance to remove from the list
      */
-    public void removeInstance( ComponentInstance instance )
+    public void removeInstance( ADSComponentInstance instance )
     {
         activeInstances.remove( instance );
     }
@@ -135,11 +135,11 @@ public class ADSComponent
     /**
      * Gets the current instances of the component
      *
-     * @return Cloned ComponentInstance list.
+     * @return Cloned ADSComponentInstance list.
      */
-    public List<ComponentInstance> getInstances()
+    public List<ADSComponentInstance> getInstances()
     {
-        return new ArrayList<ComponentInstance>( activeInstances );
+        return new ArrayList<ADSComponentInstance>( activeInstances );
     }
 
 

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=1222995&r1=1222994&r2=1222995&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
Sat Dec 24 16:10:16 2011
@@ -108,7 +108,7 @@ public class ComponentHub
     /*
      * Used to manage config partition interactions.
      */
-    private ConfigurationManager configManager = new ConfigurationManager( configPartition,componentSchemaManager
);
+    private ConfigurationManager configManager = new ConfigurationManager( configPartition,
componentSchemaManager );
 
     /*
      * Used to manage instances' DIT hooks.
@@ -174,10 +174,10 @@ public class ComponentHub
 
         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() );
     }
 
@@ -387,6 +387,8 @@ public class ComponentHub
         component.setComponentName( ADSComponentHelper.getComponentName( component.getFactory()
) );
         component.setComponentVersion( ADSComponentHelper.getComponentVersion( component.getFactory()
) );
 
+        configManager.pairWithComponent( component );
+
         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=1222995&r1=1222994&r2=1222995&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
Sat Dec 24 16:10:16 2011
@@ -28,7 +28,7 @@ import java.util.Properties;
 
 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.ADSComponentInstance;
 import org.apache.directory.server.component.instance.ComponentInstanceGenerator;
 import org.apache.directory.server.component.utilities.ADSConstants;
 import org.slf4j.Logger;
@@ -89,7 +89,7 @@ public class ComponentManager
      * @param component ADSComponent reference create new instance for.
      * @return created instance
      */
-    public ComponentInstance createInstance( ADSComponent component )
+    public ADSComponentInstance createInstance( ADSComponent component )
     {
         if ( component.getDefaultConfiguration() == null )
         {
@@ -111,7 +111,7 @@ public class ComponentManager
             }
         }
 
-        ComponentInstance instance = generateInstance( component, component.getDefaultConfiguration()
);
+        ADSComponentInstance instance = generateInstance( component, component.getDefaultConfiguration()
);
 
         component.addInstance( instance );
         configManager.injectInstance( instance );
@@ -126,9 +126,9 @@ public class ComponentManager
      *
      * @param component ADSComponent reference to instantiate
      * @param properties Configuration to create instance under.
-     * @return created ComponentInstance reference
+     * @return created ADSComponentInstance reference
      */
-    public ComponentInstance generateInstance( ADSComponent component, Properties properties
)
+    public ADSComponentInstance generateInstance( ADSComponent component, Properties properties
)
     {
         if ( properties.get( ADSConstants.ADS_COMPONENT_INSTANCE_PROP_NAME ) == null )
         {
@@ -138,7 +138,7 @@ public class ComponentManager
         ComponentInstanceGenerator generator = instanceGenerators.get( component.getComponentType()
);
         if ( generator != null )
         {
-            ComponentInstance instance = generator.createInstance( component, properties
);
+            ADSComponentInstance instance = generator.createInstance( component, properties
);
 
             return instance;
         }
@@ -157,13 +157,13 @@ public class ComponentManager
      * @param component ADSComponent reference to load its cached instances.
      * @return loaded instances.
      */
-    public List<ComponentInstance> loadCachedInstances( ADSComponent component )
+    public List<ADSComponentInstance> loadCachedInstances( ADSComponent component )
     {
-        List<ComponentInstance> loadedInstances = new ArrayList<ComponentInstance>();
+        List<ADSComponentInstance> loadedInstances = new ArrayList<ADSComponentInstance>();
 
         for ( CachedComponentInstance cachedConf : component.getCachedInstances() )
         {
-            ComponentInstance instance = loadInstance( component, cachedConf );
+            ADSComponentInstance instance = loadInstance( component, cachedConf );
             if ( instance != null )
             {
                 loadedInstances.add( instance );
@@ -179,11 +179,11 @@ public class ComponentManager
      *
      * @param component ADSComponent reference owning cached instance
      * @param cachedInstance cached instance reference
-     * @return ComponentInstance which is loaded from cache.
+     * @return ADSComponentInstance which is loaded from cache.
      */
-    public ComponentInstance loadInstance( ADSComponent component, CachedComponentInstance
cachedInstance )
+    public ADSComponentInstance loadInstance( ADSComponent component, CachedComponentInstance
cachedInstance )
     {
-        ComponentInstance instance = generateInstance( component, cachedInstance.getCachedConfiguration()
);
+        ADSComponentInstance instance = generateInstance( component, cachedInstance.getCachedConfiguration()
);
 
         if ( instance == null )
         {
@@ -229,7 +229,7 @@ public class ComponentManager
 
         }
 
-        for ( ComponentInstance ins : component.getInstances() )
+        for ( ADSComponentInstance ins : component.getInstances() )
         {
             String instanceName = ins.getInstanceConfiguration().getProperty(
                 ADSConstants.ADS_COMPONENT_INSTANCE_PROP_NAME );

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ConfigurationManager.java?rev=1222995&r1=1222994&r2=1222995&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ConfigurationManager.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ConfigurationManager.java
Sat Dec 24 16:10:16 2011
@@ -28,7 +28,7 @@ import javax.naming.directory.SearchCont
 
 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.ADSComponentInstance;
 import org.apache.directory.server.component.utilities.ADSComponentHelper;
 import org.apache.directory.server.component.utilities.ADSConstants;
 import org.apache.directory.server.component.utilities.ADSSchemaConstants;
@@ -148,9 +148,9 @@ public class ConfigurationManager
     /**
      * Injects an instance's configuration into config partition.
      *
-     * @param instance ComponentInstance to set in config partition.
+     * @param instance ADSComponentInstance to set in config partition.
      */
-    public void injectInstance( ComponentInstance instance )
+    public void injectInstance( ADSComponentInstance instance )
     {
         LdifEntry instanceEntry = LdifConfigHelper.instanceToLdif( instance );
 

Copied: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ADSComponentInstance.java
(from r1222990, 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/ADSComponentInstance.java?p2=directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ADSComponentInstance.java&p1=directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/ComponentInstance.java&r1=1222990&r2=1222995&rev=1222995&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/ADSComponentInstance.java
Sat Dec 24 16:10:16 2011
@@ -31,7 +31,7 @@ import org.apache.directory.server.compo
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ComponentInstance
+public class ADSComponentInstance
 {
     /*
      * Actual instance reference.
@@ -56,13 +56,13 @@ public class ComponentInstance
 
     /**
      * 
-     * Creates a new instance of ComponentInstance.
+     * Creates a new instance of ADSComponentInstance.
      *
      * @param component Parent component of the component instance
      * @param pojo Underlying Pojo object if the component instance
      * @param configuration Configuration of the Pojo
      */
-    public ComponentInstance( ADSComponent component, Object pojo, Properties configuration
)
+    public ADSComponentInstance( ADSComponent component, Object pojo, Properties configuration
)
     {
         this.parentComponent = component;
         this.instance = pojo;

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=1222995&r1=1222994&r2=1222995&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
Sat Dec 24 16:10:16 2011
@@ -35,7 +35,7 @@ public interface ComponentInstanceGenera
      * @param component ADSComponent reference to be instantiated
      * @return ADSInstance reference created from ADSComponent
      */
-    public ComponentInstance createInstance( ADSComponent component, Properties properties
);
+    public ADSComponentInstance createInstance( ADSComponent component, Properties properties
);
 
 
     /**

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/DefaultComponentInstanceGenerator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/DefaultComponentInstanceGenerator.java?rev=1222995&r1=1222994&r2=1222995&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/DefaultComponentInstanceGenerator.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/instance/DefaultComponentInstanceGenerator.java
Sat Dec 24 16:10:16 2011
@@ -25,7 +25,12 @@ import java.util.Properties;
 import org.apache.directory.server.component.ADSComponent;
 import org.apache.directory.server.component.schema.DefaultComponentSchemaGenerator;
 import org.apache.directory.shared.ipojo.helpers.IPojoHelper;
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ConfigurationException;
 import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.InstanceManager;
+import org.apache.felix.ipojo.MissingHandlerException;
+import org.apache.felix.ipojo.UnacceptableConfiguration;
 import org.apache.felix.ipojo.architecture.PropertyDescription;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -47,7 +52,7 @@ public class DefaultComponentInstanceGen
      * @see org.apache.directory.server.component.instance.ComponentInstanceGenerator#createInstance(org.apache.directory.server.component.ADSComponent)
      */
     @Override
-    public ComponentInstance createInstance( ADSComponent component, Properties properties
)
+    public ADSComponentInstance createInstance( ADSComponent component, Properties properties
)
     {
         if ( properties == null && component.getDefaultConfiguration() == null )
         {
@@ -57,15 +62,41 @@ public class DefaultComponentInstanceGen
 
         // We create the IPojo instance using supplied configuration, 
         // configuration have instance.name property at that point.
-        Object pojo = IPojoHelper.createIPojoComponent( component.getFactory().getName(),
null, properties );
+        try
+        {
+            ComponentInstance comp = component.getFactory().createComponentInstance( properties
);
+            Object pojo = ( ( InstanceManager ) comp ).getPojoObject();
 
-        //Create the ComponentInstance reference using the pojo just created.
-        ComponentInstance instance = new ComponentInstance( component, pojo, properties );
+            //Create the ADSComponentInstance reference using the pojo just created.
+            ADSComponentInstance instance = new ADSComponentInstance( component, pojo, properties
);
 
-        return instance;
+            return instance;
+        }
+        catch ( UnacceptableConfiguration e )
+        {
+            LOG.info( "Configuration is not valid to create instance of component:" + component
);
+            e.printStackTrace();
+            return null;
+        }
+        catch ( MissingHandlerException e )
+        {
+            LOG.info( "Instance creation is lacking an IPojo handler for component" + component
);
+            e.printStackTrace();
+            return null;
+        }
+        catch ( ConfigurationException e )
+        {
+            LOG.info( "Instance configuration failed for component:" + component );
+            e.printStackTrace();
+            return null;
+        }
     }
 
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.directory.server.component.instance.ComponentInstanceGenerator#extractDefaultConfiguration(org.apache.directory.server.component.ADSComponent)
+     */
     @Override
     public Properties extractDefaultConfiguration( ADSComponent component )
     {

Modified: 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=1222995&r1=1222994&r2=1222995&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSComponentHelper.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/utilities/ADSComponentHelper.java
Sat Dec 24 16:10:16 2011
@@ -1,3 +1,22 @@
+/*
+ *  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.utilities;
 
 

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=1222995&r1=1222994&r2=1222995&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
Sat Dec 24 16:10:16 2011
@@ -23,7 +23,7 @@ package org.apache.directory.server.comp
 import java.util.Properties;
 
 import org.apache.directory.server.component.ADSComponent;
-import org.apache.directory.server.component.instance.ComponentInstance;
+import org.apache.directory.server.component.instance.ADSComponentInstance;
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
 
 
@@ -33,10 +33,10 @@ public class LdifConfigHelper
     /**
      * Transforms a component instance into its corresponding entry in ldif format.
      *
-     * @param instance ComponentInstance to transform into Ldif entry.
+     * @param instance ADSComponentInstance to transform into Ldif entry.
      * @return Generated Ldif entry.
      */
-    public static LdifEntry instanceToLdif( ComponentInstance instance )
+    public static LdifEntry instanceToLdif( ADSComponentInstance instance )
     {
         return null;
     }



Mime
View raw message