hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahue...@apache.org
Subject svn commit: r483921 - in /hivemind/branches/branch-2-0-annot: annotations/src/java/org/apache/hivemind/annotations/internal/ annotations/src/test/org/apache/hivemind/annotations/ framework/src/java/org/apache/hivemind/definition/ framework/src/java/org...
Date Fri, 08 Dec 2006 10:46:53 GMT
Author: ahuegen
Date: Fri Dec  8 02:46:51 2006
New Revision: 483921

URL: http://svn.apache.org/viewvc?view=rev&rev=483921
Log:
Reworked configuration and contributions.
Removed ConfigurationConstructor, everything is a contribution now.

Added:
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/Contribution.java   (contents, props changed)
      - copied, changed from r480519, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionConstructor.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionContext.java
      - copied, changed from r480519, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionConstructionContext.java
Removed:
    hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodConfigurationConstructor.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ConfigurationConstructionContext.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ConfigurationConstructor.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionConstructionContext.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionConstructor.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CreateClassConfigurationConstructor.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationConstructionContextImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlConfigurationConstructor.java
Modified:
    hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleProcessor.java
    hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/TemplateMethodContributionConstructor.java
    hivemind/branches/branch-2-0-annot/annotations/src/test/org/apache/hivemind/annotations/SimpleAnnotatedModule.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ContributionDefinition.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinitionHelper.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/impl/ConfigurationPointDefinitionImpl.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/impl/ContributionDefinitionImpl.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationPoint.java
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/FrameworkTestCase.java
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestEagerLoader.java
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestStartup.java
    hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlContributionImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlCoreServicesProvider.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/SchemaProcessor.java

Modified: hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleProcessor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleProcessor.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleProcessor.java (original)
+++ hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleProcessor.java Fri Dec  8 02:46:51 2006
@@ -10,7 +10,6 @@
 import org.apache.hivemind.Location;
 import org.apache.hivemind.Resource;
 import org.apache.hivemind.annotations.Configuration;
-import org.apache.hivemind.annotations.Contribution;
 import org.apache.hivemind.annotations.Module;
 import org.apache.hivemind.annotations.Service;
 import org.apache.hivemind.definition.ModuleDefinition;
@@ -18,15 +17,13 @@
 import org.apache.hivemind.definition.RegistryDefinition;
 import org.apache.hivemind.definition.ServiceImplementationDefinition;
 import org.apache.hivemind.definition.Visibility;
-import org.apache.hivemind.definition.construction.ConfigurationConstructor;
-import org.apache.hivemind.definition.construction.ContributionConstructor;
+import org.apache.hivemind.definition.construction.Contribution;
 import org.apache.hivemind.definition.construction.ImplementationConstructor;
 import org.apache.hivemind.definition.impl.ConfigurationPointDefinitionImpl;
 import org.apache.hivemind.definition.impl.ContributionDefinitionImpl;
 import org.apache.hivemind.definition.impl.ModuleDefinitionImpl;
 import org.apache.hivemind.definition.impl.ServiceImplementationDefinitionImpl;
 import org.apache.hivemind.definition.impl.ServicePointDefinitionImpl;
-import org.apache.hivemind.impl.LocationImpl;
 import org.apache.hivemind.util.ClasspathResource;
 import org.apache.hivemind.util.IdUtils;
 
@@ -102,7 +99,7 @@
         {
             Annotation annotation = annotations[j];
 
-            if (Service.class.isAssignableFrom(annotation.annotationType()))
+            if (Service.class.equals(annotation.annotationType()))
             {
                 processAnnotatedServiceMethod(
                         method,
@@ -110,7 +107,7 @@
                         module,
                         instanceProvider);
             }
-            else if (Configuration.class.isAssignableFrom(annotation.annotationType()))
+            else if (Configuration.class.equals(annotation.annotationType()))
             {
                 processAnnotatedConfigurationMethod(
                         method,
@@ -118,11 +115,11 @@
                         module,
                         instanceProvider);
             }
-            else if (Contribution.class.isAssignableFrom(annotation.annotationType()))
+            else if (org.apache.hivemind.annotations.Contribution.class.equals(annotation.annotationType()))
             {
                 processAnnotatedContributionMethod(
                         method,
-                        (Contribution) annotation,
+                        (org.apache.hivemind.annotations.Contribution) annotation,
                         module,
                         instanceProvider);
             }
@@ -145,11 +142,11 @@
                 Visibility.PUBLIC, method.getReturnType().getName());
         module.addServicePoint(spd);
 
-        ImplementationConstructor constructor = new FactoryMethodImplementationConstructor(module
-                .getLocation(), method, instanceProvider);
+        ImplementationConstructor constructor = new FactoryMethodImplementationConstructor(location, 
+                method, instanceProvider);
 
-        ServiceImplementationDefinition sid = new ServiceImplementationDefinitionImpl(module, module
-                .getLocation(), constructor, service.serviceModel(), true);
+        ServiceImplementationDefinition sid = new ServiceImplementationDefinitionImpl(module, location, 
+                constructor, service.serviceModel(), true);
 
         spd.addImplementation(sid);
 
@@ -165,16 +162,18 @@
         Location location = new AnnotatedModuleLocation(module.getLocation().getResource(), 
                 method.getDeclaringClass(), method);
         
-        ConfigurationConstructor constructor = new FactoryMethodConfigurationConstructor(location
-                , method, instanceProvider);
-
-        ConfigurationPointDefinitionImpl cpd = new ConfigurationPointDefinitionImpl(module, configuration.id(), module
-                .getLocation(), Visibility.PUBLIC, constructor, method.getReturnType().getName(), Occurances.UNBOUNDED);
+        ConfigurationPointDefinitionImpl cpd = new ConfigurationPointDefinitionImpl(module, configuration.id(), 
+                location, Visibility.PUBLIC, method.getReturnType().getName(), Occurances.UNBOUNDED);
         module.addConfigurationPoint(cpd);
-
+        
+        // Add method implementation as initial contribution
+        Contribution contribution = new TemplateMethodContributionConstructor(
+                location, method, instanceProvider);
+        ContributionDefinitionImpl cd = new ContributionDefinitionImpl(module, location, contribution, true);
+        cpd.addContribution(cd);
     }
 
-    private void processAnnotatedContributionMethod(Method method, Contribution contribution, ModuleDefinition module, ModuleInstanceProvider instanceProvider)
+    private void processAnnotatedContributionMethod(Method method, org.apache.hivemind.annotations.Contribution contribution, ModuleDefinition module, ModuleInstanceProvider instanceProvider)
     {
         if (_log.isDebugEnabled())
         {
@@ -184,11 +183,10 @@
         Location location = new AnnotatedModuleLocation(module.getLocation().getResource(), 
                 method.getDeclaringClass(), method);
         
-        ContributionConstructor constructor = new TemplateMethodContributionConstructor(
+        Contribution constructor = new TemplateMethodContributionConstructor(
                 location, method, instanceProvider);
 
-        ContributionDefinitionImpl cd = new ContributionDefinitionImpl(module, module
-                .getLocation(), constructor);
+        ContributionDefinitionImpl cd = new ContributionDefinitionImpl(module, location, constructor, false);
         String qualifiedConfigurationId = IdUtils.qualify(
                 module.getId(),
                 contribution.configurationId());

Modified: hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/TemplateMethodContributionConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/TemplateMethodContributionConstructor.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/TemplateMethodContributionConstructor.java (original)
+++ hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/TemplateMethodContributionConstructor.java Fri Dec  8 02:46:51 2006
@@ -4,9 +4,8 @@
 
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.Location;
-import org.apache.hivemind.annotations.Contribution;
-import org.apache.hivemind.definition.construction.ContributionConstructionContext;
-import org.apache.hivemind.definition.construction.ContributionConstructor;
+import org.apache.hivemind.definition.construction.Contribution;
+import org.apache.hivemind.definition.construction.ContributionContext;
 
 /**
  * Contributes to a configuration point by passing the configuration container
@@ -15,7 +14,7 @@
  * @author Achim Huegen
  */
 public class TemplateMethodContributionConstructor implements
-        ContributionConstructor
+        Contribution
 {
     private Method _templateMethod;
 
@@ -36,12 +35,23 @@
         return _location;
     }
 
-    public void contribute(ContributionConstructionContext context, Object container)
+    public void contribute(ContributionContext context)
     {
         try
         {
-            Object[] params = new Object[] {container}; 
-            _templateMethod.invoke(_moduleInstanceProvider.getModuleInstance(), params);
+            if (_templateMethod.getParameterTypes().length == 0) {
+                Object result = _templateMethod.invoke(_moduleInstanceProvider.getModuleInstance());
+                // a null contribution means: nothing to contribute. This happens for example
+                // in configuration point definitions 
+                if (result != null) {
+                    context.mergeContribution(result);
+                }
+            } else if (_templateMethod.getParameterTypes().length == 1) {
+                Object[] params = new Object[] {context.getConfigurationData()}; 
+                _templateMethod.invoke(_moduleInstanceProvider.getModuleInstance(), params);
+            } else {
+                // TODO: Throw Exception
+            }
         }
         catch (Exception ex)
         {

Modified: hivemind/branches/branch-2-0-annot/annotations/src/test/org/apache/hivemind/annotations/SimpleAnnotatedModule.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/test/org/apache/hivemind/annotations/SimpleAnnotatedModule.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/test/org/apache/hivemind/annotations/SimpleAnnotatedModule.java (original)
+++ hivemind/branches/branch-2-0-annot/annotations/src/test/org/apache/hivemind/annotations/SimpleAnnotatedModule.java Fri Dec  8 02:46:51 2006
@@ -1,5 +1,8 @@
 package org.apache.hivemind.annotations;
 
+import hivemind.test.services.StringHolder;
+import hivemind.test.services.impl.StringHolderImpl;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -18,6 +21,13 @@
                 {
                     System.out.println(entry);
                 }
+                String one = (String) getRegistry().getConfiguration("SingleElement", String.class);
+                System.out.println(one);
+                StringHolderImpl holder = (StringHolderImpl) getRegistry().getConfiguration("StringHolder", StringHolderImpl.class);
+                System.out.println(holder.getValue());
+                
+                StringHolderImpl holderService = (StringHolderImpl) getRegistry().getService("StringHolder", StringHolderImpl.class);
+                System.out.println(holderService.getValue());
             }
         };
     }
@@ -35,7 +45,43 @@
     {
         container.add("contributed-data");
     }
+
+    @Contribution(configurationId = "Demo")
+    public List<String> contributeData2()
+    {
+        List<String> data = new ArrayList<String>(); 
+        data.add("contributed-data-2");
+        return data;
+    }
     
+    @Configuration(id = "SingleElement")
+    public String getSingleElementConfig()
+    {
+        return null;
+    }
+
+    @Contribution(configurationId = "SingleElement")
+    public String contributeSingleElement()
+    {
+        return "The One and Only";
+    }
+    
+    @Configuration(id = "StringHolder")
+    public StringHolderImpl getStringHolder()
+    {
+        StringHolderImpl result = new StringHolderImpl();
+        result.setValue("test");
+        return result;
+    }
+    
+    @Service(id = "StringHolder")
+    public StringHolderImpl getStringHolderService()
+    {
+        StringHolderImpl result = new StringHolderImpl();
+        result.setValue("test");
+        return result;
+    }
+
 //    @Contribution(configurationId = "hivemind.ApplicationDefaults")
 //    public void contributeDefaults(HashMap<String,FactoryDefault> container)
 //    {

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java Fri Dec  8 02:46:51 2006
@@ -2,18 +2,11 @@
 
 import java.util.List;
 
-import org.apache.hivemind.definition.construction.ConfigurationConstructor;
-
 public interface ConfigurationPointDefinition extends ExtensionPointDefinition
 {
+    public String getConfigurationTypeName();
 
-    public ConfigurationConstructor getConstructor();
-
-    public void setConstructor(ConfigurationConstructor constructor);
-
-    public String getContainerClassName();
-
-    public void setContainerClassName(String containerClassName);
+    public void setConfigurationTypeName(String typeName);
 
     public Occurances getExpectedContributions();
 

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ContributionDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ContributionDefinition.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ContributionDefinition.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ContributionDefinition.java Fri Dec  8 02:46:51 2006
@@ -1,12 +1,16 @@
 package org.apache.hivemind.definition;
 
-import org.apache.hivemind.definition.construction.ContributionConstructor;
+import org.apache.hivemind.definition.construction.Contribution;
 
 public interface ContributionDefinition extends ExtensionDefinition
 {
+    public Contribution getContributionConstructor();
 
-    public ContributionConstructor getContributionConstructor();
-
-    public void setContributionConstructor(ContributionConstructor contributionConstructor);
+    public void setContributionConstructor(Contribution contributionConstructor);
 
+    /**
+     * @return  true if the contribution is the initial one to be processed first. Only one
+     *          contribution of a configuration point is allowed to return true here. 
+     */
+    public boolean isInitalContribution();
 }

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinitionHelper.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinitionHelper.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinitionHelper.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinitionHelper.java Fri Dec  8 02:46:51 2006
@@ -1,7 +1,6 @@
 package org.apache.hivemind.definition;
 
-import org.apache.hivemind.definition.construction.ConfigurationConstructor;
-import org.apache.hivemind.definition.construction.ContributionConstructor;
+import org.apache.hivemind.definition.construction.Contribution;
 import org.apache.hivemind.definition.construction.ImplementationConstructor;
 import org.apache.hivemind.definition.impl.ConfigurationPointDefinitionImpl;
 import org.apache.hivemind.definition.impl.ContributionDefinitionImpl;
@@ -56,28 +55,27 @@
                 serviceModel);
     }
     
-    public ConfigurationPointDefinition addConfigurationPoint(String configurationPointId, 
-            ConfigurationConstructor constructor, String containerType)
+    public ConfigurationPointDefinition addConfigurationPoint(String configurationPointId, String containerType)
     {
         ConfigurationPointDefinitionImpl result = new ConfigurationPointDefinitionImpl(_module, configurationPointId, _module
-                .getLocation(), Visibility.PUBLIC, constructor, containerType, Occurances.UNBOUNDED);
+                .getLocation(), Visibility.PUBLIC, containerType, Occurances.UNBOUNDED);
 
         _module.addConfigurationPoint(result);
         return result;
     }
     
     public ContributionDefinition addContributionDefinition(ConfigurationPointDefinition configurationPoint,
-            ContributionConstructor contributionConstructor)
+            Contribution contributionConstructor)
     {
-        ContributionDefinition result = new ContributionDefinitionImpl(_module, _module.getLocation(), contributionConstructor);
+        ContributionDefinition result = new ContributionDefinitionImpl(_module, _module.getLocation(), contributionConstructor, false);
         configurationPoint.addContribution(result);
         return result;
     }
     
     public ContributionDefinition addContributionDefinition(String fullyQualifiedConfigurationPointId, 
-            ContributionConstructor contributionConstructor)
+            Contribution contributionConstructor)
     {
-        ContributionDefinitionImpl result = new ContributionDefinitionImpl(_module, _module.getLocation(), contributionConstructor);
+        ContributionDefinitionImpl result = new ContributionDefinitionImpl(_module, _module.getLocation(), contributionConstructor, false);
         _module.addContribution(fullyQualifiedConfigurationPointId, result);
         return result;
     }

Copied: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/Contribution.java (from r480519, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionConstructor.java)
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/Contribution.java?view=diff&rev=483921&p1=hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionConstructor.java&r1=480519&p2=hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/Contribution.java&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionConstructor.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/Contribution.java Fri Dec  8 02:46:51 2006
@@ -20,11 +20,13 @@
  * 
  * @author Achim Huegen
  */
-public interface ContributionConstructor
+public interface Contribution
 {
     /**
-     * Contributes to the Configuration. A container is handed in to which new 
-     * entries can be added.
+     * Contributes to the configuration. The context provides methods to manipulate the
+     * configuration data. 
+     * 
+     * @returns   a configuration object whose type is assignable to the configuration type
      */
-    public void contribute(ContributionConstructionContext context, Object container);
+    public void contribute(ContributionContext context);
 }

Propchange: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/Contribution.java
------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.5

Propchange: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/Contribution.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/Contribution.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionContext.java (from r480519, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionConstructionContext.java)
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionContext.java?view=diff&rev=483921&p1=hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionConstructionContext.java&r1=480519&p2=hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionContext.java&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionConstructionContext.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ContributionContext.java Fri Dec  8 02:46:51 2006
@@ -2,10 +2,42 @@
 
 import org.apache.hivemind.internal.ConfigurationPoint;
 
-public interface ContributionConstructionContext extends ConstructionContext
+/**
+ * Context for execution of a {@link Contribution}.
+ * 
+ * Allows to manipulate a configuration from a {@link Contribution}.
+ * The new contribution can be merged with the existing configuration data or
+ * the data may be changed or replaced. 
+ * 
+ * @author Huegen
+ */
+public interface ContributionContext extends ConstructionContext
 {
     /**
      * @return  the configuration point that is currently constructed
      */
     public ConfigurationPoint getConfigurationPoint();
+    
+    /**
+     * @return  the configuration data already provided by other contributions that were processed before.
+     *          Null, if no data has be contributed before.
+     */
+    public Object getConfigurationData();
+    
+    /**
+     * Replaces all configuration data with <code>data</code>. Overrides data provided by other contributions
+     * so should only be called when getConfigurationData() returns null.
+     *  
+     * @param data
+     */
+    public void setConfigurationData(Object data);
+    
+    /**
+     * Merges contribution data with the data already provided by other contributions.
+     * Automatic merging works for standard collections only. 
+     * Handles the case that no data has been provided before (getConfigurationData() returns null)
+     * 
+     * @param contributionData  the data to merge. Must be compatible with the type of the configuration.
+     */
+    public void mergeContribution(Object contributionData);
 }

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/impl/ConfigurationPointDefinitionImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/impl/ConfigurationPointDefinitionImpl.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/impl/ConfigurationPointDefinitionImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/impl/ConfigurationPointDefinitionImpl.java Fri Dec  8 02:46:51 2006
@@ -9,12 +9,9 @@
 import org.apache.hivemind.definition.ModuleDefinition;
 import org.apache.hivemind.definition.Occurances;
 import org.apache.hivemind.definition.Visibility;
-import org.apache.hivemind.definition.construction.ConfigurationConstructor;
 
 public class ConfigurationPointDefinitionImpl extends ExtensionPointDefinitionImpl implements ConfigurationPointDefinition
 {
-    private ConfigurationConstructor _constructor;
-
     private String _containerClassName;
 
     private Occurances _expectedContributions;
@@ -27,43 +24,25 @@
     }
 
     public ConfigurationPointDefinitionImpl(ModuleDefinition module, String id, Location location, Visibility visibility,
-            ConfigurationConstructor constructor, String containerClassName,
-            Occurances expectedContributions)
+            String containerClassName, Occurances expectedContributions)
     {
         super(module, id, location, visibility);
-        _constructor = constructor;
         _containerClassName = containerClassName;
         _expectedContributions = expectedContributions;
     }
 
     /**
-     * @see org.apache.hivemind.definition.ConfigurationPointDefinition#getConstructor()
-     */
-    public ConfigurationConstructor getConstructor()
-    {
-        return _constructor;
-    }
-
-    /**
-     * @see org.apache.hivemind.definition.ConfigurationPointDefinition#setConstructor(org.apache.hivemind.definition.construction.ConfigurationConstructor)
-     */
-    public void setConstructor(ConfigurationConstructor constructor)
-    {
-        _constructor = constructor;
-    }
-
-    /**
-     * @see org.apache.hivemind.definition.ConfigurationPointDefinition#getContainerClassName()
+     * @see org.apache.hivemind.definition.ConfigurationPointDefinition#getConfigurationTypeName()
      */
-    public String getContainerClassName()
+    public String getConfigurationTypeName()
     {
         return _containerClassName;
     }
 
     /**
-     * @see org.apache.hivemind.definition.ConfigurationPointDefinition#setContainerClassName(java.lang.String)
+     * @see org.apache.hivemind.definition.ConfigurationPointDefinition#setConfigurationTypeName(java.lang.String)
      */
-    public void setContainerClassName(String containerClassName)
+    public void setConfigurationTypeName(String containerClassName)
     {
         _containerClassName = containerClassName;
     }

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/impl/ContributionDefinitionImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/impl/ContributionDefinitionImpl.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/impl/ContributionDefinitionImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/impl/ContributionDefinitionImpl.java Fri Dec  8 02:46:51 2006
@@ -3,11 +3,12 @@
 import org.apache.hivemind.Location;
 import org.apache.hivemind.definition.ContributionDefinition;
 import org.apache.hivemind.definition.ModuleDefinition;
-import org.apache.hivemind.definition.construction.ContributionConstructor;
+import org.apache.hivemind.definition.construction.Contribution;
 
 public class ContributionDefinitionImpl extends ExtensionDefinitionImpl implements ContributionDefinition
 {
-    private ContributionConstructor _contributionConstructor;
+    private Contribution _contributionConstructor;
+    private boolean _initial;
 
     public ContributionDefinitionImpl(ModuleDefinition module)
     {
@@ -15,25 +16,34 @@
     }
 
     public ContributionDefinitionImpl(ModuleDefinition module, Location location,
-            ContributionConstructor contributionConstructor)
+            Contribution contributionConstructor, boolean initial)
     {
         super(module, location);
         _contributionConstructor = contributionConstructor;
+        _initial = initial;
     }
 
     /**
      * @see org.apache.hivemind.definition.ContributionDefinition#getContributionConstructor()
      */
-    public ContributionConstructor getContributionConstructor()
+    public Contribution getContributionConstructor()
     {
         return _contributionConstructor;
     }
 
     /**
-     * @see org.apache.hivemind.definition.ContributionDefinition#setContributionConstructor(org.apache.hivemind.definition.construction.ContributionConstructor)
+     * @see org.apache.hivemind.definition.ContributionDefinition#setContributionConstructor(org.apache.hivemind.definition.construction.Contribution)
      */
-    public void setContributionConstructor(ContributionConstructor contributionConstructor)
+    public void setContributionConstructor(Contribution contributionConstructor)
     {
         _contributionConstructor = contributionConstructor;
+    }
+
+    /**
+     * @see org.apache.hivemind.definition.ContributionDefinition#isInitalContribution()
+     */
+    public boolean isInitalContribution()
+    {
+        return _initial;
     }
 }

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java Fri Dec  8 02:46:51 2006
@@ -25,27 +25,24 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.hivemind.HiveMind;
 import org.apache.hivemind.ShutdownCoordinator;
 import org.apache.hivemind.definition.ConfigurationPointDefinition;
 import org.apache.hivemind.definition.ContributionDefinition;
 import org.apache.hivemind.definition.Occurances;
-import org.apache.hivemind.definition.construction.ContributionConstructionContext;
-import org.apache.hivemind.definition.construction.ContributionConstructor;
-import org.apache.hivemind.definition.construction.ContributionHandler;
+import org.apache.hivemind.definition.construction.Contribution;
+import org.apache.hivemind.definition.construction.ContributionContext;
 import org.apache.hivemind.impl.servicemodel.SingletonInnerProxy;
-import org.apache.hivemind.internal.ConfigurationConstructionContextImpl;
+import org.apache.hivemind.internal.AbstractConstructionContext;
 import org.apache.hivemind.internal.ConfigurationPoint;
 import org.apache.hivemind.internal.Module;
 import org.apache.hivemind.service.BodyBuilder;
 import org.apache.hivemind.service.ClassFab;
-import org.apache.hivemind.service.InterfaceSynthesizer;
 import org.apache.hivemind.service.MethodSignature;
 import org.apache.hivemind.util.ToStringBuilder;
 
 /**
  * Implementation of the {@link org.apache.hivemind.internal.ConfigurationPoint} interface; a
- * container for {@link org.apache.hivemind.definition.construction.ContributionConstructor}s.
+ * container for {@link org.apache.hivemind.definition.construction.Contribution}s.
  * 
  * @author Howard Lewis Ship
  */
@@ -69,8 +66,6 @@
 
     private ShutdownCoordinator _shutdownCoordinator;
 
-    private Class _declaredInterface;
-    
     public ConfigurationPointImpl(Module module, ConfigurationPointDefinition definition)
     {
         super(module, definition);
@@ -94,7 +89,7 @@
 
     /**
      * Returns the number of contributions; it is expected that each top-level
-     * {@link org.apache.hivemind.Element} in each {@link ContributionConstructor} will convert to one element
+     * {@link org.apache.hivemind.Element} in each {@link Contribution} will convert to one element
      * instance; the value returned is the total number of top-level elements in all contributed
      * Extensions.
      */
@@ -120,8 +115,8 @@
         // exclude ServiceModels, otherwise a cycle occurs because the proxy generation
         // requires the {@link ClassFactory service}
         return !getExtensionPointId().equals("hivemind.ServiceModels") && 
-          getDeclaredInterface().isInterface() &&
-          !Modifier.isFinal(getDeclaredInterface().getModifiers());
+          getConfigurationType().isInterface() &&
+          !Modifier.isFinal(getConfigurationType().getModifiers());
     }
 
     /**
@@ -205,8 +200,8 @@
             {
                 ContributionDefinition cd = (ContributionDefinition) contributions.get(i);
                 Module definingModule = getModule().getRegistry().getModule(cd.getModuleId());
-                ContributionConstructionContext context = new ConfigurationConstructionContextImpl(definingModule, this);
-                cd.getContributionConstructor().contribute(context, new ContributionHandlerImpl());
+                ContributionContext context = new ContributionContextImpl(definingModule, this);
+                cd.getContributionConstructor().contribute(context);
             }
             // For backward compatibility create empty collections if nothing was contributed
             if (_configuration == null) {
@@ -222,8 +217,19 @@
 
     }
     
-    class ContributionHandlerImpl implements ContributionHandler
+    /**
+     * Implementation of {@link ContributionContext}.
+     * Currently defined inline since it needs access to private methods of the outer configuration point. 
+     */
+    class ContributionContextImpl extends AbstractConstructionContext implements ContributionContext 
     {
+        private ConfigurationPoint _configurationPoint;
+
+        public ContributionContextImpl(Module definingModule, ConfigurationPoint configurationPoint)
+        {
+            super(definingModule);
+            _configurationPoint = configurationPoint;
+        }
 
         public Object getConfigurationData()
         {
@@ -239,6 +245,11 @@
         {
             _configuration = data;
         }
+
+        public ConfigurationPoint getConfigurationPoint()
+        {
+            return _configurationPoint;
+        }
     }
     
     private void initEmptyCollection()
@@ -254,9 +265,14 @@
         }
     }
 
+    /**
+     * Merges a contribution with the configuration data already present in the field _configuration.
+     * TODO: Refactor as configurable service
+     * @param contribution
+     */
     private void mergeContribution(Object contribution)
     {
-        if (!getDeclaredInterface().isAssignableFrom(contribution.getClass())) {
+        if (!getConfigurationType().isAssignableFrom(contribution.getClass())) {
             throw new ApplicationRuntimeException("contribution of of type " +
                     contribution.getClass().getName() + " is not compatible to configuration type " + 
                     getConfigurationType().getName());
@@ -275,19 +291,6 @@
         
     }
 
-    public synchronized Class getDeclaredInterface()
-    {
-        if (_declaredInterface == null)
-            _declaredInterface = lookupDeclaredInterface();
-
-        return _declaredInterface;
-    }
-    
-    private Class lookupDeclaredInterface()
-    {
-        return getModule().resolveType(getConfigurationTypeName());
-    }
-    
     public void setShutdownCoordinator(ShutdownCoordinator coordinator)
     {
         _shutdownCoordinator = coordinator;
@@ -304,33 +307,12 @@
     public Class getConfigurationType()
     {
         if (_configurationInterface == null)
-            _configurationInterface = lookupConfigurationInterface();
+            _configurationInterface = getModule().resolveType(getConfigurationTypeName());
 
         return _configurationInterface;
     }
 
     /**
-     * @return  the interface of the configuration container. if the container class is an
-     *          interface already it's returned instantly. If it is a pojo, then an interface
-     *          is generated by {@link InterfaceSynthesizer}.
-     */
-    private Class lookupConfigurationInterface()
-    {
-        Class declaredInterface = getDeclaredInterface();
-
-        if (declaredInterface.isInterface() || !isLazy())
-            return declaredInterface;
-
-        // Not an interface ... a class. Synthesize an interface from the class itself.
-
-        InterfaceSynthesizer is = (InterfaceSynthesizer) getModule().getService(
-                HiveMind.INTERFACE_SYNTHESIZER_SERVICE,
-                InterfaceSynthesizer.class);
-
-        return is.synthesizeInterface(declaredInterface);
-    }
-
-    /**
      * Creates a proxy class for the service and then construct the class itself.
      */
     private Object createSingletonProxy()
@@ -409,7 +391,7 @@
     private Class createSingletonProxyClass()
     {
         ProxyBuilder proxyBuilder = new ProxyBuilder("LazyConstructionProxy", getModule(), getConfigurationType(), 
-                getDeclaredInterface(), true);
+                getConfigurationType(), true);
 
         ClassFab classFab = proxyBuilder.getClassFab();
 
@@ -457,7 +439,7 @@
     private Class createInnerProxyClass(Class deferredProxyClass)
     {
         ProxyBuilder builder = new ProxyBuilder("InnerProxy", getModule(), getConfigurationType(), 
-                getDeclaredInterface(), false);
+                getConfigurationType(), false);
 
         ClassFab classFab = builder.getClassFab();
 

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java Fri Dec  8 02:46:51 2006
@@ -14,8 +14,8 @@
 import org.apache.hivemind.definition.ModuleDefinitionHelper;
 import org.apache.hivemind.definition.RegistryDefinition;
 import org.apache.hivemind.definition.ServicePointDefinition;
-import org.apache.hivemind.definition.construction.ContributionConstructionContext;
-import org.apache.hivemind.definition.construction.ContributionConstructor;
+import org.apache.hivemind.definition.construction.Contribution;
+import org.apache.hivemind.definition.construction.ContributionContext;
 import org.apache.hivemind.definition.construction.ImplementationConstructionContext;
 import org.apache.hivemind.definition.construction.ImplementationConstructor;
 import org.apache.hivemind.definition.impl.ModuleDefinitionImpl;
@@ -187,9 +187,7 @@
         // Configuration to which services may be contributed. The corresponding services are instantiated eagerly, as the Registry is started. 
         // The order in which services are instantiated is not specified.
 
-        helper.addConfigurationPoint("EagerLoad", 
-                new CreateClassConfigurationConstructor(md.getLocation(), ArrayList.class.getName()), 
-                List.class.getName());
+        helper.addConfigurationPoint("EagerLoad", List.class.getName());
     }
 
     /**
@@ -216,20 +214,20 @@
         // A configuration to which startup objects may be contributed (as objects or services). 
         // Startup objects must implement the java.lang.Runnable interface. Order of execution is expliclitly NOT defined.
 
-        ConfigurationPointDefinition cpd = helper.addConfigurationPoint("Startup", 
-                new CreateClassConfigurationConstructor(md.getLocation(), ArrayList.class.getName()), 
-                List.class.getName());
+        ConfigurationPointDefinition cpd = helper.addConfigurationPoint("Startup", List.class.getName());
         
         final List services = getDefaultStartupServices();
-        helper.addContributionDefinition(cpd, new ContributionConstructor() {
+        helper.addContributionDefinition(cpd, new Contribution() {
 
-            public void contribute(ContributionConstructionContext context, Object container)
+            public void contribute(ContributionContext context)
             {
+                List contribution = new ArrayList(); 
                 for (Iterator iterServices = services.iterator(); iterServices.hasNext();)
                 {
                     String serviceName = (String) iterServices.next();
-                    ((List) container).add(context.getService(serviceName, Runnable.class));
+                    contribution.add(context.getService(serviceName, Runnable.class));
                 }
+                context.mergeContribution(contribution);
             }});
     }
     
@@ -240,15 +238,16 @@
     {
 
         ConfigurationPointDefinition cpd = helper.addConfigurationPoint("ServiceModels", 
-                new CreateClassConfigurationConstructor(helper.getModule().getLocation(), ArrayList.class.getName()), 
                 List.class.getName());
         
         final List serviceModels = getDefaultServiceModels();
-        helper.addContributionDefinition(cpd, new ContributionConstructor() {
+        helper.addContributionDefinition(cpd, new Contribution() {
 
-            public void contribute(ContributionConstructionContext context, Object container)
+            public void contribute(ContributionContext context)
             {
-                ((List) container).addAll(serviceModels);
+                List contribution = new ArrayList(); 
+                contribution.addAll(serviceModels);
+                context.mergeContribution(contribution);
             }});
     }
     
@@ -324,16 +323,16 @@
     private void addAutowiringStrategiesConfiguration()
     {
 
-        ConfigurationPointDefinition cpd = helper.addConfigurationPoint("AutowiringStrategies", 
-                new CreateClassConfigurationConstructor(helper.getModule().getLocation(), ArrayList.class.getName()), 
-                List.class.getName());
+        ConfigurationPointDefinition cpd = helper.addConfigurationPoint("AutowiringStrategies", List.class.getName());
         
         final List serviceModels = getDefaultAutowiringStrategies();
-        helper.addContributionDefinition(cpd, new ContributionConstructor() {
+        helper.addContributionDefinition(cpd, new Contribution() {
 
-            public void contribute(ContributionConstructionContext context, Object container)
+            public void contribute(ContributionContext context)
             {
-                ((List) container).addAll(serviceModels);
+                List contribution = new ArrayList(); 
+                contribution.addAll(serviceModels);
+                context.mergeContribution(contribution);
             }});
     }
 

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java Fri Dec  8 02:46:51 2006
@@ -268,7 +268,7 @@
     {
         ConfigurationPoint point = getConfigurationPoint(configurationId, module);
 
-        return point.getContainer();
+        return point.getConfiguration();
     }
 
     public String toString()

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationPoint.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationPoint.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationPoint.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationPoint.java Fri Dec  8 02:46:51 2006
@@ -27,11 +27,11 @@
      * return a proxy to the actual data (which is constructed only as needed), but user code
      * shouldn't care about that.
      */
-    public Object getContainer();
+    public Object getConfiguration();
     
     /**
      * @return  the type of the container that holds the configuration data
      */
-    public Class getContainerType();
+    public Class getConfigurationType();
 
 }

Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/FrameworkTestCase.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/FrameworkTestCase.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/FrameworkTestCase.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/FrameworkTestCase.java Fri Dec  8 02:46:51 2006
@@ -101,7 +101,7 @@
     protected ConfigurationPointDefinition createConfigurationPointDefinition(ModuleDefinition module, String pointId)
     {
         ConfigurationPointDefinitionImpl result = new ConfigurationPointDefinitionImpl(module, pointId,
-                newLocation(), Visibility.PUBLIC, null, ArrayList.class.getName(),
+                newLocation(), Visibility.PUBLIC, ArrayList.class.getName(),
                 Occurances.UNBOUNDED);
 
         return result;

Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestEagerLoader.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestEagerLoader.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestEagerLoader.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestEagerLoader.java Fri Dec  8 02:46:51 2006
@@ -24,8 +24,8 @@
 import org.apache.hivemind.definition.ModuleDefinition;
 import org.apache.hivemind.definition.ModuleDefinitionHelper;
 import org.apache.hivemind.definition.ServicePointDefinition;
-import org.apache.hivemind.definition.construction.ContributionConstructionContext;
-import org.apache.hivemind.definition.construction.ContributionConstructor;
+import org.apache.hivemind.definition.construction.Contribution;
+import org.apache.hivemind.definition.construction.ContributionContext;
 import org.apache.hivemind.internal.ServiceModel;
 import org.apache.hivemind.internal.ServicePoint;
 import org.apache.hivemind.service.impl.EagerLoader;
@@ -106,11 +106,13 @@
         helper.addSimpleServiceImplementation(sp1, LoudRunner.class.getName(), serviceModel);
 
         // Add service point "Loud" to EagerLoad configuration point
-        helper.addContributionDefinition("hivemind.EagerLoad", new ContributionConstructor()
+        helper.addContributionDefinition("hivemind.EagerLoad", new Contribution()
         {
-            public void contribute(ContributionConstructionContext context, Object container)
+            public void contribute(ContributionContext context)
             {
-                ((List) container).add(context.getDefiningModule().getServicePoint("hivemind.test.services.Loud"));
+                List contribution = new ArrayList();
+                contribution.add(context.getDefiningModule().getServicePoint("hivemind.test.services.Loud"));
+                context.mergeContribution(contribution);
             }
         });
 

Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestStartup.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestStartup.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestStartup.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestStartup.java Fri Dec  8 02:46:51 2006
@@ -24,8 +24,8 @@
 import org.apache.hivemind.definition.ModuleDefinition;
 import org.apache.hivemind.definition.ModuleDefinitionHelper;
 import org.apache.hivemind.definition.ServicePointDefinition;
-import org.apache.hivemind.definition.construction.ContributionConstructionContext;
-import org.apache.hivemind.definition.construction.ContributionConstructor;
+import org.apache.hivemind.definition.construction.Contribution;
+import org.apache.hivemind.definition.construction.ContributionContext;
 import org.apache.hivemind.impl.StartupImpl;
 import org.apache.hivemind.internal.ServiceModel;
 
@@ -77,11 +77,13 @@
         helper.addSimpleServiceImplementation(sp1, StartupRunnableFixtureImpl.class.getName(), ServiceModel.SINGLETON);
 
         // Add service point "StartupRunnableFixture" to Startup configuration point
-        helper.addContributionDefinition("hivemind.Startup", new ContributionConstructor()
+        helper.addContributionDefinition("hivemind.Startup", new Contribution()
         {
-            public void contribute(ContributionConstructionContext context, Object container)
+            public void contribute(ContributionContext context)
             {
-                ((List) container).add(context.getService(StartupRunnableFixture.class));
+                List contribution = new ArrayList(); 
+                contribution.add(context.getService(StartupRunnableFixture.class));
+                context.mergeContribution(contribution);
             }
         });
 

Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java Fri Dec  8 02:46:51 2006
@@ -184,7 +184,7 @@
         cpc.setReturnValue( "hivemind.ServiceModels" );
         cp.visibleToModule( null );
         cpc.setReturnValue( true );
-        cp.getContainer();
+        cp.getConfiguration();
         cpc.setReturnValue( Collections.EMPTY_LIST );
         replayControls();
         RegistryInfrastructureImpl r = new RegistryInfrastructureImpl( null, null );

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlContributionImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlContributionImpl.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlContributionImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlContributionImpl.java Fri Dec  8 02:46:51 2006
@@ -19,24 +19,26 @@
 import java.util.List;
 
 import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.hivemind.definition.construction.ContributionConstructionContext;
-import org.apache.hivemind.definition.construction.ContributionConstructor;
+import org.apache.hivemind.definition.construction.Contribution;
+import org.apache.hivemind.definition.construction.ContributionContext;
 import org.apache.hivemind.impl.natures.XmlConfigurationPointNature;
 import org.apache.hivemind.internal.Module;
 import org.apache.hivemind.schema.Schema;
+import org.apache.hivemind.util.Defense;
+import org.apache.hivemind.util.InstanceCreationUtils;
 
 /**
- * Implements the {@link org.apache.hivemind.definition.construction.ContributionConstructor} interface, a wrapper
- * around objects that can provide values that plug into an extension point.
+ * Implements the {@link org.apache.hivemind.definition.construction.Contribution}
+ * interface, a wrapper around objects that can provide values that plug into an extension point.
  * 
  * @author Howard Lewis Ship
  */
-public final class XmlContributionImpl implements ContributionConstructor
+public final class XmlContributionImpl implements Contribution
 {
     private String _contributingModuleId;
 
     private List _elements;
-    
+
     public XmlContributionImpl(String moduleId, List elements)
     {
         _contributingModuleId = moduleId;
@@ -64,37 +66,52 @@
         return _elements;
     }
 
-    public void contribute(ContributionConstructionContext context, Object container)
+    public void contribute(ContributionContext context)
     {
         // Retrieve xml nature
-        XmlConfigurationPointNature xmlNature = (XmlConfigurationPointNature) context.getConfigurationPoint().getNature(XmlConfigurationPointNature.class);
-        if (xmlNature == null) {
-            // TODO:
-            throw new ApplicationRuntimeException("Configuration point has no associated xml schema. You can define one with a schema element that uses the configuration-id attribute");
+        XmlConfigurationPointNature xmlNature = (XmlConfigurationPointNature) context
+                .getConfigurationPoint().getNature(XmlConfigurationPointNature.class);
+        if (xmlNature == null)
+        {
+            // TODO: Enhance Exception-Handling
+            throw new ApplicationRuntimeException(
+                    "Configuration point has no associated xml schema. You can define one with a schema element that uses the configuration-id attribute");
         }
-        
+
         Module contributingModule = context.getDefiningModule();
 
         Schema contributionsSchema = xmlNature.getSchema();
-        if (contributionsSchema != null) {
-            SchemaProcessorImpl processor = new SchemaProcessorImpl(context.getConfigurationPoint().getErrorLog(), contributionsSchema);
-            processor.process(container, getElements(), contributingModule);
+        if (contributionsSchema != null)
+        {
+            SchemaProcessorImpl processor = new SchemaProcessorImpl(context.getConfigurationPoint()
+                    .getErrorLog(), contributionsSchema);
+            Object contributionObject = constructContributionObject(contributionsSchema, context.getDefiningModule());
+            processor.process(contributionObject, getElements(), contributingModule);
+            context.mergeContribution(contributionObject);
         } else {
-            // Expect a list that was created by {@link XmlConfigurationConstructor} for
-            // backward compatibility reasons
-            ((List) container).addAll(getElements());
+            // It's perfectly valid that a configuration point has no schema  
+            // In that case the unparsed elements should be returned
+            context.mergeContribution(getElements());
         }
 
         // After constructing the result, if the result
         // will be cached, then there's no need to keep
         // the schema and extensions (used to build the
         // result); it can all be released to the GC.
-        
+
         // TODO schema can not be deleted here since there are still other contributions
         // that need the schema
         // configurationPoint.putMetaData("schema", null);
 
-        
     }
 
+    public Object constructContributionObject(Schema contributionsSchema, Module definingModule)
+    {
+        Defense.notNull(contributionsSchema.getRootElementClassName(), "schema.rootElementClassName");
+
+        return InstanceCreationUtils.createInstance(
+                definingModule,
+                contributionsSchema.getRootElementClassName(),
+                contributionsSchema.getLocation());
+    }
 }

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlCoreServicesProvider.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlCoreServicesProvider.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlCoreServicesProvider.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlCoreServicesProvider.java Fri Dec  8 02:46:51 2006
@@ -1,7 +1,6 @@
 package org.apache.hivemind.impl;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -17,8 +16,8 @@
 import org.apache.hivemind.definition.ModuleDefinitionHelper;
 import org.apache.hivemind.definition.RegistryDefinition;
 import org.apache.hivemind.definition.ServicePointDefinition;
-import org.apache.hivemind.definition.construction.ContributionConstructionContext;
-import org.apache.hivemind.definition.construction.ContributionConstructor;
+import org.apache.hivemind.definition.construction.Contribution;
+import org.apache.hivemind.definition.construction.ContributionContext;
 import org.apache.hivemind.definition.construction.ImplementationConstructionContext;
 import org.apache.hivemind.definition.construction.ImplementationConstructor;
 import org.apache.hivemind.internal.AbstractServiceImplementationConstructor;
@@ -87,28 +86,30 @@
      */
     private void addSymbolSourcesConfiguration(ModuleDefinition md)
     {
-        ConfigurationPointDefinition cpd = helper.addConfigurationPoint("SymbolSources",
-                new CreateClassConfigurationConstructor(md.getLocation(), ArrayList.class.getName()), List.class
-                        .getName());
+        ConfigurationPointDefinition cpd = helper.addConfigurationPoint("SymbolSources", List.class.getName());
 
-        helper.addContributionDefinition(cpd, new ContributionConstructor()
+        helper.addContributionDefinition(cpd, new Contribution()
         {
 
-            public void contribute(ContributionConstructionContext context, Object container)
+            public void contribute(ContributionContext context)
             {
+                List contribution = new ArrayList();
+                
                 // Add the default symbol sources FactoryDefaults and
                 // ApplicationDefaults
                 SymbolSource factoryDefaults = (SymbolSource) context.getService(
                         "FactoryDefaultsSymbolSource", SymbolSource.class);
                 SymbolSourceContribution factoryDefaultsContrib = new SymbolSourceContribution(factoryDefaults,
                         "hivemind.FactoryDefaults", null, null);
-                ((List) container).add(factoryDefaultsContrib);
+                contribution.add(factoryDefaultsContrib);
 
                 SymbolSource applicationDefaults = (SymbolSource) context.getService(
                         "ApplicationDefaultsSymbolSource", SymbolSource.class);
                 SymbolSourceContribution applicationDefaultsContrib = new SymbolSourceContribution(applicationDefaults,
                         "hivemind.ApplicationDefaults", null, "hivemind.FactoryDefaults");
-                ((List) container).add(applicationDefaultsContrib);
+                contribution.add(applicationDefaultsContrib);
+                
+                context.mergeContribution(contribution);
             }
         });
     }
@@ -136,9 +137,7 @@
         
         // Configuration point for setting defaults for symbol values.
 
-        helper.addConfigurationPoint(configurationId, 
-                new CreateClassConfigurationConstructor(md.getLocation(), HashMap.class.getName()), 
-                Map.class.getName());
+        helper.addConfigurationPoint(configurationId, Map.class.getName());
     }    
     /**
      * @see SymbolExpander

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java Fri Dec  8 02:46:51 2006
@@ -252,12 +252,9 @@
         {
             ConfigurationPointDescriptor cpd = (ConfigurationPointDescriptor) points.get(i);
 
-            XmlConfigurationConstructor constructor = new XmlConfigurationConstructor(
-                    cpd.getLocation());
-            
             ConfigurationPointDefinitionImpl configurationPoint = new ConfigurationPointDefinitionImpl(
                     module, cpd.getId(), cpd.getLocation(), cpd.getVisibility(), 
-                    constructor, cpd.getContainerClassName(), cpd.getCount());
+                    cpd.getContainerClassName(), cpd.getCount());
             module.addConfigurationPoint(configurationPoint);
             
             // Add the xml nature
@@ -270,10 +267,9 @@
                 // TODO: compare container class name and rootElementClassName
                 if (HashMap.class.getName().equals(cpd.getContributionsSchema().getRootElementClassName())
                     || UniqueHashMap.class.getName().equals(cpd.getContributionsSchema().getRootElementClassName())) {
-                    configurationPoint.setContainerClassName(Map.class.getName());
+                    configurationPoint.setConfigurationTypeName(Map.class.getName());
                 }
 
-                constructor.setContainerClassName(cpd.getContributionsSchema().getRootElementClassName());
                 xmlNature.setSchema(cpd.getContributionsSchema());
             }
         }
@@ -297,7 +293,7 @@
             String qualifiedId = IdUtils.qualify(moduleId, pointId);
             
             ContributionDefinitionImpl contribution = new ContributionDefinitionImpl(module, cd.getLocation(),
-                    new XmlContributionImpl(moduleId, cd.getElements())); 
+                    new XmlContributionImpl(moduleId, cd.getElements()), false); 
             module.addContribution(qualifiedId, contribution);
 
         }
@@ -358,14 +354,11 @@
                 } else {
                     // TODO: check if schema has already been set (by resolveSubsequentSchemaAssociations)
                     xmlNature.setSchema(schema);
-                    XmlConfigurationConstructor constructor = (XmlConfigurationConstructor) point.getConstructor();
 
                     if (HashMap.class.getName().equals(schema.getRootElementClassName())
                        || UniqueHashMap.class.getName().equals(schema.getRootElementClassName())) {
-                        point.setContainerClassName(Map.class.getName());
+                        point.setConfigurationTypeName(Map.class.getName());
                     }
-                    // store the root-element-classname in the constructor
-                    constructor.setContainerClassName(schema.getRootElementClassName());
                 }
             }
         }

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/SchemaProcessor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/SchemaProcessor.java?view=diff&rev=483921&r1=483920&r2=483921
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/SchemaProcessor.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/SchemaProcessor.java Fri Dec  8 02:46:51 2006
@@ -19,7 +19,7 @@
 
 /**
  * Object used when processing the elements contributed in an
- * {@link org.apache.hivemind.definition.construction.ContributionConstructor}.
+ * {@link org.apache.hivemind.definition.construction.Contribution}.
  * 
  * @author Howard Lewis Ship
  */



Mime
View raw message