hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahue...@apache.org
Subject svn commit: r505210 - in /hivemind/hivemind2/trunk: annotations/src/java/org/apache/hivemind/annotations/ annotations/src/java/org/apache/hivemind/annotations/internal/ annotations/src/test/org/apache/hivemind/annotations/ framework/src/java/org/apache...
Date Fri, 09 Feb 2007 07:47:26 GMT
Author: ahuegen
Date: Thu Feb  8 23:47:25 2007
New Revision: 505210

URL: http://svn.apache.org/viewvc?view=rev&rev=505210
Log:
Submodule annotation added

Added:
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/Submodule.java
    hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/Submodule1.java
    hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/Supermodule.java
Modified:
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/Module.java
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleProcessor.java
    hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/TestAnnotatedModules.java
    hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParser.java
    hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParserConstructor.java
    hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParserDefinition.java
    hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java
    hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConstructionContext.java
    hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/Contribution.java
    hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ContributionContext.java
    hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ContributionDefinition.java
    hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ServicePointDefinition.java

Modified: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/Module.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/Module.java?view=diff&rev=505210&r1=505209&r2=505210
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/Module.java
(original)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/Module.java
Thu Feb  8 23:47:25 2007
@@ -8,6 +8,7 @@
 
 /**
  * Marks a class as an annotated module and assigns an id to it. 
+ * The class must be public, non final and must have a no arguments constructor.
  * 
  * @author Achim Huegen
  */

Added: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/Submodule.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/Submodule.java?view=auto&rev=505210
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/Submodule.java
(added)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/Submodule.java
Thu Feb  8 23:47:25 2007
@@ -0,0 +1,20 @@
+package org.apache.hivemind.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Defines a submodule of an annotated module. The return type of the annotated method
+ * defines the class of the submodule. This class must be an annotated module class itself.
+ *  
+ * @author Achim Huegen
+ */
+@Documented
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = ElementType.METHOD)
+public @interface Submodule {
+    String id();
+}

Modified: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleProcessor.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleProcessor.java?view=diff&rev=505210&r1=505209&r2=505210
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleProcessor.java
(original)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleProcessor.java
Thu Feb  8 23:47:25 2007
@@ -12,6 +12,7 @@
 import org.apache.hivemind.annotations.Configuration;
 import org.apache.hivemind.annotations.Module;
 import org.apache.hivemind.annotations.Service;
+import org.apache.hivemind.annotations.Submodule;
 import org.apache.hivemind.definition.Contribution;
 import org.apache.hivemind.definition.ImplementationConstructor;
 import org.apache.hivemind.definition.ImplementationDefinition;
@@ -50,15 +51,22 @@
         _classResolver = classResolver;
         _errorHandler = errorHandler;
     }
+    
+    public void processModule(Class moduleClass)
+    {
+        String moduleId = determineModuleId(moduleClass);
+        processModule(moduleClass, moduleId);
+    }
 
     /**
-     * Processes a module. Inspects the class
+     * Processes a module. Inspects the class.
+     * 
      * 
      * @param moduleClass
      */
-    public void processModule(Class moduleClass)
+    public void processModule(Class moduleClass, String moduleId)
     {
-        ModuleDefinitionImpl module = new ModuleDefinitionImpl(determineModuleId(moduleClass),
+        ModuleDefinitionImpl module = new ModuleDefinitionImpl(moduleId,
                 createModuleLocation(moduleClass), _classResolver, moduleClass.getPackage().getName());
 
         // processServices(moduleClass);
@@ -74,7 +82,7 @@
 
     }
 
-    public void processModuleMethods(Class moduleClass, ModuleDefinitionImpl module,
+    private void processModuleMethods(Class moduleClass, ModuleDefinitionImpl module,
             ModuleInstanceProvider instanceProvider)
     {
         Method[] methods = moduleClass.getMethods();
@@ -85,7 +93,7 @@
         }
     }
 
-    public void processMethod(Method method, ModuleDefinitionImpl module,
+    private void processMethod(Method method, ModuleDefinitionImpl module,
             ModuleInstanceProvider instanceProvider)
     {
         if (_log.isDebugEnabled())
@@ -122,6 +130,14 @@
                         module,
                         instanceProvider);
             }
+            else if (Submodule.class.equals(annotation.annotationType()))
+            {
+                processAnnotatedSubmoduleMethod(
+                        method,
+                        (Submodule) annotation,
+                        module,
+                        instanceProvider);
+            }
         }
 
     }
@@ -191,6 +207,25 @@
                 contribution.configurationId());
         module.addContribution(qualifiedConfigurationId, cd);
 
+    }
+    
+    /**
+     * Processes a method that is marked as submodule definition.
+     */
+    private void processAnnotatedSubmoduleMethod(Method method, Submodule submodule, ModuleDefinitionImpl
module, ModuleInstanceProvider instanceProvider)
+    {
+        if (_log.isDebugEnabled())
+        {
+            _log.debug("Method " + method.getName() + "classified as submodule.");
+        }
+        
+        String fullModuleId = IdUtils.qualify(
+                module.getId(),
+                submodule.id());
+        // TODO: Check if return type is defined
+        AnnotatedModuleProcessor submoduleProcessor = new AnnotatedModuleProcessor(_registryDefinition,
+                _classResolver, _errorHandler);
+        submoduleProcessor.processModule(method.getReturnType(), fullModuleId);
     }
     
     /**

Added: hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/Submodule1.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/Submodule1.java?view=auto&rev=505210
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/Submodule1.java
(added)
+++ hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/Submodule1.java
Thu Feb  8 23:47:25 2007
@@ -0,0 +1,16 @@
+package org.apache.hivemind.annotations;
+
+import hivemind.test.services.impl.StringHolderImpl;
+
+@Module(id = "theSubModule")
+public class Submodule1 extends AbstractAnnotatedModule
+{
+    @Service(id = "StringHolder")
+    public StringHolderImpl getStringHolderService()
+    {
+        StringHolderImpl result = new StringHolderImpl();
+        result.setValue("test");
+        return result;
+    }
+
+}

Added: hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/Supermodule.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/Supermodule.java?view=auto&rev=505210
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/Supermodule.java
(added)
+++ hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/Supermodule.java
Thu Feb  8 23:47:25 2007
@@ -0,0 +1,12 @@
+package org.apache.hivemind.annotations;
+
+@Module(id = "super")
+public class Supermodule extends AbstractAnnotatedModule
+{
+    @Submodule(id = "sub")
+    public Submodule1 getSubmodule()
+    {
+        return null;
+    }
+
+}

Modified: hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/TestAnnotatedModules.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/TestAnnotatedModules.java?view=diff&rev=505210&r1=505209&r2=505210
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/TestAnnotatedModules.java
(original)
+++ hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/TestAnnotatedModules.java
Thu Feb  8 23:47:25 2007
@@ -1,6 +1,7 @@
 package org.apache.hivemind.annotations;
 
 import hivemind.test.services.ServiceAutowireTarget;
+import hivemind.test.services.StringHolder;
 
 import org.apache.hivemind.Registry;
 
@@ -13,4 +14,11 @@
         assertNotNull(service.getStringHolder());
     }
     
+    public void testSubmodule()
+    {
+        Registry registry = constructRegistry(Supermodule.class);
+        StringHolder service = (StringHolder) registry.getService("super.sub.StringHolder",
StringHolder.class);
+        assertNotNull(service);
+    }
+
 }

Modified: hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParser.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParser.java?view=diff&rev=505210&r1=505209&r2=505210
==============================================================================
--- hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParser.java
(original)
+++ hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParser.java
Thu Feb  8 23:47:25 2007
@@ -2,7 +2,12 @@
 
 import java.io.InputStream;
 
-
+/**
+ * Parses configuration data that is provided in a textual format.
+ * A new instance is created for each parsing operation.
+ * 
+ * @author Huegen
+ */
 public interface ConfigurationParser
 {
     /**

Modified: hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParserConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParserConstructor.java?view=diff&rev=505210&r1=505209&r2=505210
==============================================================================
--- hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParserConstructor.java
(original)
+++ hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParserConstructor.java
Thu Feb  8 23:47:25 2007
@@ -1,7 +1,16 @@
 package org.apache.hivemind.definition;
 
-
+/**
+ * Factory for the creation of a {@link ConfigurationParser}.
+ * 
+ * @author Huegen
+ */
 public interface ConfigurationParserConstructor
 {
+    /**
+     * Constructs a parser instance.
+     * @param context  provides access to elements of the registry which are needed for the
construction.
+     * @return  the parser 
+     */
     public ConfigurationParser constructParser(ConstructionContext context);
 }

Modified: hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParserDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParserDefinition.java?view=diff&rev=505210&r1=505209&r2=505210
==============================================================================
--- hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParserDefinition.java
(original)
+++ hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationParserDefinition.java
Thu Feb  8 23:47:25 2007
@@ -1,9 +1,14 @@
 package org.apache.hivemind.definition;
 
-
 /**
  * Defines a parser for the processing of configuration data that is provided
- * in a textual format.
+ * in a textual format.  The parsed data is handled as {@link Contribution} to a 
+ * configuration point. Each parser is associated with a certain input format,
+ * which is specified by {@link #getInputFormat()}.
+ * The parsing is done by an instance of {@link ConfigurationParser}
+ * which is created by a {@link ConfigurationParserConstructor}.
+ * 
+ * @author Huegen
  */
 public interface ConfigurationParserDefinition extends ExtensionDefinition
 {

Modified: hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java?view=diff&rev=505210&r1=505209&r2=505210
==============================================================================
--- hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java
(original)
+++ hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java
Thu Feb  8 23:47:25 2007
@@ -4,27 +4,53 @@
 
 import org.apache.hivemind.ApplicationRuntimeException;
 
+/**
+ * Defines a configuration extension point.
+ * The definition includes the configuration type, contributions and parsers.
+ * 
+ * @author Achim Huegen
+ */
 public interface ConfigurationPointDefinition extends ExtensionPointDefinition
 {
+    /**
+     * @return  the fully qualified class name of the configuration type
+     */
     public String getConfigurationTypeName();
 
+    /**
+     * @return  the expected number of contributions to this configuration point
+     */
     public Occurances getExpectedContributions();
 
+    /**
+     * @return  the contributions to this configuration as instances of {@link ContributionDefinition}
+     */
     public Collection getContributions();
 
     /**
-     * @param contribution
+     * Adds a contribution.
+     * @param contribution  the contribution
      * @throws ApplicationRuntimeException  if this point is not visible from contribution
      */
     public void addContribution(ContributionDefinition contribution);
 
     /**
-     * @param parser
+     * Adds a parser definition.
+     * @param parser  the parser
      * @throws ApplicationRuntimeException  if this point is not visible from parser
+     *   or if a parser for the specified format is already defined
      */
     public void addParser(ConfigurationParserDefinition parser);
     
+    /**
+     * Returns the parsers which is responsible for processing the specified <code>inputFormat</code>.
+     * @param inputFormat  the input format
+     * @return the parser  
+     */
     public ConfigurationParserDefinition getParser(String inputFormat);
 
+    /**
+     * @return  returns all parsers as instances of {@link ConfigurationParserDefinition}
+     */
     public Collection getParsers();
 }

Modified: hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConstructionContext.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConstructionContext.java?view=diff&rev=505210&r1=505209&r2=505210
==============================================================================
--- hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConstructionContext.java
(original)
+++ hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ConstructionContext.java
Thu Feb  8 23:47:25 2007
@@ -37,5 +37,12 @@
      */
     public Object getConfiguration(String configurationId);
     
+    /**
+     * Returns a reference to the {@link RegistryInfrastructure}. 
+     * This allows access to services and configurations without the visibility checks
+     * performed by the other getter methods. 
+     * 
+     * @return  the registry 
+     */
     public RegistryInfrastructure getRegistry();
 }

Modified: hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/Contribution.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/Contribution.java?view=diff&rev=505210&r1=505209&r2=505210
==============================================================================
--- hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/Contribution.java
(original)
+++ hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/Contribution.java
Thu Feb  8 23:47:25 2007
@@ -16,7 +16,7 @@
 
 
 /**
- * Contributes data to a {@link org.apache.hivemind.definition.ConfigurationPointDefinition}.
+ * Contributes data to a {@link org.apache.hivemind.definition.ConfigurationPointDefinition
configuration point}.
  * 
  * @author Achim Huegen
  */
@@ -24,9 +24,10 @@
 {
     /**
      * Contributes to the configuration. The context provides methods to manipulate the
-     * configuration data. 
+     * configuration data, that is to merge with or override data already provided 
+     * by other contributions
      * 
-     * @returns   a configuration object whose type is assignable to the configuration type
+     * @param context  provides access to elements of the registry which are needed for the
contribution.
      */
     public void contribute(ContributionContext context);
 }

Modified: hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ContributionContext.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ContributionContext.java?view=diff&rev=505210&r1=505209&r2=505210
==============================================================================
--- hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ContributionContext.java
(original)
+++ hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ContributionContext.java
Thu Feb  8 23:47:25 2007
@@ -28,7 +28,7 @@
      * 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
+     * @param data  the data
      */
     public void setConfigurationData(Object data);
     

Modified: hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ContributionDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ContributionDefinition.java?view=diff&rev=505210&r1=505209&r2=505210
==============================================================================
--- hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ContributionDefinition.java
(original)
+++ hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ContributionDefinition.java
Thu Feb  8 23:47:25 2007
@@ -1,8 +1,16 @@
 package org.apache.hivemind.definition;
 
-
+/**
+ * Defines a contribution to a {@link ConfigurationPointDefinition}.
+ * The actual contribution is done by an instance of {@link Contribution}.
+ * 
+ * @author Huegen
+ */
 public interface ContributionDefinition extends ExtensionDefinition
 {
+    /**
+     * @return  the contribution implementation.
+     */
     public Contribution getContribution();
 
     /**

Modified: hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ServicePointDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ServicePointDefinition.java?view=diff&rev=505210&r1=505209&r2=505210
==============================================================================
--- hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ServicePointDefinition.java
(original)
+++ hivemind/hivemind2/trunk/framework/src/java/org/apache/hivemind/definition/ServicePointDefinition.java
Thu Feb  8 23:47:25 2007
@@ -4,8 +4,7 @@
 
 /**
  * Defines a service extension point.
- * The definition includes the service interface, implementations
- * and interceptors.
+ * The definition includes the service interface, implementations and interceptors.
  * 
  * @author Achim Huegen
  */



Mime
View raw message