hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahue...@apache.org
Subject svn commit: r509344 - 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/ examples/src/java/org/apache/...
Date Mon, 19 Feb 2007 21:45:45 GMT
Author: ahuegen
Date: Mon Feb 19 13:45:44 2007
New Revision: 509344

URL: http://svn.apache.org/viewvc?view=rev&rev=509344
Log:
Prerequisites for annotated modules and methods are checked
Expressive error messages
More tests

Added:
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/MethodCallContributionConstructor.java
      - copied, changed from r507225, hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/TemplateMethodContributionConstructor.java
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/MethodCallImplementationConstructor.java
      - copied, changed from r507225, hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodImplementationConstructor.java
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/TypedRegistryImpl.java
      - copied, changed from r507225, hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java
    hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/AbstractModule.java
    hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/FinalModule.java
    hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/NotPublicModule.java
    hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/calculator/
    hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/calculator/CalculatorMain.java
    hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/calculator/CalculatorModule.java
Removed:
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodImplementationConstructor.java
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/TemplateMethodContributionConstructor.java
Modified:
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotatedRegistryBuilder.java
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotationsMessages.java
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotationsStrings.properties
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/TypedRegistry.java
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleLocation.java
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleProcessor.java
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProvider.java
    hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProviderImpl.java
    hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/AnnotationTestCase.java
    hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/TestAnnotatedModuleReader.java
    hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/TestAnnotatedModules.java
    hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMain.java

Modified: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotatedRegistryBuilder.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotatedRegistryBuilder.java?view=diff&rev=509344&r1=509343&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotatedRegistryBuilder.java (original)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotatedRegistryBuilder.java Mon Feb 19 13:45:44 2007
@@ -18,12 +18,14 @@
 
 import org.apache.hivemind.ClassResolver;
 import org.apache.hivemind.ErrorHandler;
-import org.apache.hivemind.Registry;
+import org.apache.hivemind.annotations.internal.TypedRegistryImpl;
 import org.apache.hivemind.definition.RegistryDefinition;
 import org.apache.hivemind.definition.impl.RegistryDefinitionImpl;
+import org.apache.hivemind.events.RegistryInitializationListener;
 import org.apache.hivemind.impl.DefaultClassResolver;
 import org.apache.hivemind.impl.DefaultErrorHandler;
 import org.apache.hivemind.impl.RegistryBuilder;
+import org.apache.hivemind.internal.RegistryInfrastructure;
 
 /**
  * Helper class for defining hivemind registries that mainly base on
@@ -65,21 +67,21 @@
      * @param moduleClassNames  the annotated module class names 
      * @return  the registry
      */
-    public Registry constructRegistry(String ... moduleClassNames)
+    public TypedRegistry constructRegistry(String ... moduleClassNames)
     {
         RegistryDefinition definition = constructRegistryDefinition(moduleClassNames);
-        return RegistryBuilder.constructRegistry(definition, _errorHandler, _locale);
+        return constructRegistry(definition);
     }
-    
+
     /**
      * Constructs a registry from a couple of annotated module classes specified by their class definitions.
      * @param moduleClasses  the annotated module classes 
      * @return  the registry
      */
-   public Registry constructRegistry(Class ... moduleClasses)
+   public TypedRegistry constructRegistry(Class ... moduleClasses)
     {
         RegistryDefinition definition = constructRegistryDefinition(moduleClasses);
-        return RegistryBuilder.constructRegistry(definition, _errorHandler, _locale);
+        return constructRegistry(definition);
     }
     
     private RegistryDefinition constructRegistryDefinition(String ... moduleClassNames)
@@ -109,5 +111,32 @@
 
         return definition;
     }
+    
+    private TypedRegistry constructRegistry(RegistryDefinition definition)
+    {
+        // Register a listener that obtains a reference to RegistryInfrastructure
+        // which is not visible by other means. 
+        RegistryInfrastructureHolder infrastructureHolder = new RegistryInfrastructureHolder();
+            
+        definition.addRegistryInitializationListener(infrastructureHolder);
+        
+        RegistryBuilder.constructRegistry(definition, _errorHandler, _locale);
+        // Now the RegistryInfrastructureHolder has access to the registry
+        return new TypedRegistryImpl(null, infrastructureHolder.getInfrastructure());
+    }
+
+    final class RegistryInfrastructureHolder implements RegistryInitializationListener
+    {
+        private RegistryInfrastructure _infrastructure;
 
+        public void registryInitialized(RegistryInfrastructure registry)
+        {
+            _infrastructure = registry;   
+        }
+
+        public RegistryInfrastructure getInfrastructure()
+        {
+            return _infrastructure;
+        }
+    }
 }

Modified: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotationsMessages.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotationsMessages.java?view=diff&rev=509344&r1=509343&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotationsMessages.java (original)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotationsMessages.java Mon Feb 19 13:45:44 2007
@@ -14,8 +14,12 @@
 
 package org.apache.hivemind.annotations;
 
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
 import org.apache.hivemind.ClassResolver;
 import org.apache.hivemind.impl.MessageFormatter;
+import org.apache.hivemind.service.MethodSignature;
 
 
 /**
@@ -23,7 +27,7 @@
  * 
  * @author Achim Huegen
  */
-class AnnotationsMessages
+public class AnnotationsMessages
 {
     private static final MessageFormatter _formatter = new MessageFormatter(AnnotationsMessages.class,
             "AnnotationsStrings");
@@ -32,4 +36,29 @@
     {
         return _formatter.format("unable-to-find-module-class", resolver, moduleClassName);
     }
+    
+    public static String moduleClassHasInvalidModifiers(Class moduleClass, int invalidModifiers)
+    {
+        String modifierStr = Modifier.toString(invalidModifiers);
+        return _formatter.format("module-class-has-invalid-modifiers", moduleClass.getName(), modifierStr);
+    }
+    
+    public static String moduleClassIsPackagePrivate(Class moduleClass)
+    {
+        return _formatter.format("module-class-is-package-private", moduleClass.getName());
+    }
+
+    public static String annotatedMethodHasInvalidModifiers(Method method, String methodType, int invalidModifiers)
+    {
+        MethodSignature methodSig = new MethodSignature(method);
+        String modifierStr = Modifier.toString(invalidModifiers);
+        return _formatter.format("annotated-method-has-invalid-modifiers", methodSig.toString(), methodType, modifierStr);
+    }
+
+    public static String annotatedMethodIsProtectedAndNotAccessible(Method method, String methodType)
+    {
+        MethodSignature methodSig = new MethodSignature(method);
+        return _formatter.format("annotated-method-protected-not-accessible", methodSig.toString());
+    }
+
 }

Modified: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotationsStrings.properties
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotationsStrings.properties?view=diff&rev=509344&r1=509343&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotationsStrings.properties (original)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/AnnotationsStrings.properties Mon Feb 19 13:45:44 2007
@@ -13,3 +13,8 @@
 # limitations under the License.
 
 unable-to-find-module-class=Could not find module class {0} in {1}
+module-class-has-invalid-modifiers=Module class {0} has invalid modifiers: {1}
+module-class-is-package-private=Module class {0} has package-private access. It must be declared public.
+annotated-method-has-invalid-modifiers=Method ''{0}'' used as {1} has invalid modifiers: {2}
+annotated-method-protected-not-accessible=Method ''{0}'' is protected but not accessible by HiveMind. If a SecurityManager is used then HiveMind must be allowed to call Method#setAccessible.
+

Modified: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/TypedRegistry.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/TypedRegistry.java?view=diff&rev=509344&r1=509343&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/TypedRegistry.java (original)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/TypedRegistry.java Mon Feb 19 13:45:44 2007
@@ -17,7 +17,7 @@
 import org.apache.hivemind.service.Autowiring;
 
 /**
- * Specialized interface for the registry access from annotated modules.
+ * Specialized interface for the {@link org.apache.hivemind.Registry} access from annotated modules.
  * Implements typed access to services and configurations by use of Generics. 
  * 
  * @author Achim Huegen
@@ -59,4 +59,9 @@
      * Returns a reference to the {@link Autowiring} service.
      */
     public Autowiring getAutowiring();
+    
+    /**
+     * @see org.apache.hivemind.Registry#shutdown()
+     */
+    public void shutdown();
 }

Modified: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleLocation.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleLocation.java?view=diff&rev=509344&r1=509343&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleLocation.java (original)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/AnnotatedModuleLocation.java Mon Feb 19 13:45:44 2007
@@ -21,7 +21,7 @@
 
 /**
  * Implementation of the {@link org.apache.hivemind.Location} interface.
- * Uses a method name in a class as position.
+ * Uses a method name of a class as position.
  *
  * @author Achim Huegen
  */

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=509344&r1=509343&r2=509344
==============================================================================
--- 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 Mon Feb 19 13:45:44 2007
@@ -16,13 +16,16 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.ClassResolver;
 import org.apache.hivemind.ErrorHandler;
 import org.apache.hivemind.Location;
 import org.apache.hivemind.Resource;
+import org.apache.hivemind.annotations.AnnotationsMessages;
 import org.apache.hivemind.annotations.definition.Configuration;
 import org.apache.hivemind.annotations.definition.Module;
 import org.apache.hivemind.annotations.definition.Service;
@@ -45,6 +48,9 @@
  * Does the work for {@link org.apache.hivemind.annotations.AnnotatedModuleReader}. Processes an
  * annotated class and registers the defined extension and extension points in a registry
  * definition.
+ * The construction of extension points and extensions bases on reflective method calls
+ * to an instance of the module class. The module instance is created by a 
+ * {@link ModuleInstanceProvider} during registry construction. 
  * 
  * @author Achim Huegen
  */
@@ -75,11 +81,12 @@
     /**
      * Processes a module. Inspects the class.
      * 
-     * 
      * @param moduleClass
      */
     public void processModule(Class moduleClass, String moduleId)
     {
+        checkModuleClassPrerequisites(moduleClass);
+        
         ModuleDefinitionImpl module = new ModuleDefinitionImpl(moduleId,
                 createModuleLocation(moduleClass), _classResolver, moduleClass.getPackage().getName());
 
@@ -95,15 +102,43 @@
         _registryDefinition.addModule(module);
 
     }
+    
+    /**
+     * Ensures that a module class fulfills all prerequisites.
+     * 
+     * @param moduleClass
+     */
+    protected void checkModuleClassPrerequisites(Class moduleClass)
+    {
+        // These modifiers are allowed
+        final int validModifiers = Modifier.PUBLIC;
+        
+        int invalidModifiers = moduleClass.getModifiers() & ~validModifiers;
+        if (invalidModifiers > 0) {
+            throw new ApplicationRuntimeException(AnnotationsMessages.moduleClassHasInvalidModifiers(moduleClass, invalidModifiers));
+        }
+        
+        // Check for package-private access
+        if ((moduleClass.getModifiers() & (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE)) == 0) {
+            throw new ApplicationRuntimeException(AnnotationsMessages.moduleClassIsPackagePrivate(moduleClass));
+        }
+    }
 
     private void processModuleMethods(Class moduleClass, ModuleDefinitionImpl module,
             ModuleInstanceProvider instanceProvider)
     {
-        Method[] methods = moduleClass.getMethods();
+        // We need access to protected methods via getDeclaredMethods
+        // That means we must visit all superclasses manually
+        Method[] methods = moduleClass.getDeclaredMethods();
         for (int i = 0; i < methods.length; i++)
         {
             Method method = methods[i];
             processMethod(method, module, instanceProvider);
+            // Process superclass
+            Class superClass = moduleClass.getSuperclass();
+            if (!superClass.equals(Object.class)) {
+                processModuleMethods(superClass, module, instanceProvider);
+            }
         }
     }
 
@@ -155,10 +190,45 @@
         }
 
     }
+    
+    /**
+     * Ensures that an annotated method has only allowed modifiers.
+     * By default Modifier.PUBLIC and Modifier.PROTECTED are allowed.
+     * @param method  the method
+     * @param allowedModifiers  allowed {@link Modifier modifiers}. 
+     * @param methodType  used in error messages to describe what the method is used for
+     */
+    protected void checkMethodModifiers(Method method, int allowedModifiers, String methodType)
+    {
+        // These modifiers are allowed
+        final int validModifiers = Modifier.PUBLIC | Modifier.PROTECTED | allowedModifiers;
+        
+        int invalidModifiers = method.getModifiers() & ~validModifiers;
+        if (invalidModifiers > 0) {
+            throw new ApplicationRuntimeException(AnnotationsMessages.annotatedMethodHasInvalidModifiers(method, methodType, invalidModifiers));
+        }
+
+        // TODO: Check for package access
+        
+        // Check for setAccessible-Errors when Modifier.PROTECTED is used
+        if (Modifier.isProtected(method.getModifiers())) {
+            // Try to set method accessible
+            try
+            {
+                method.setAccessible(true);
+            }
+            catch (SecurityException e)
+            {
+                throw new ApplicationRuntimeException(AnnotationsMessages.annotatedMethodIsProtectedAndNotAccessible(method, methodType));
+            }
+        }
+    }
 
     private void processAnnotatedServiceMethod(Method method, Service service,
             ModuleDefinitionImpl module, ModuleInstanceProvider instanceProvider)
     {
+        checkMethodModifiers(method, 0, "service point");
+        
         if (_log.isDebugEnabled())
         {
             _log.debug("Method " + method.getName() + "classified as service point.");
@@ -167,11 +237,15 @@
         Location location = new AnnotatedModuleLocation(module.getLocation().getResource(), 
                 method.getDeclaringClass(), method);
 
+        Visibility visibility = Visibility.PUBLIC;
+        if (Modifier.isProtected(method.getModifiers())) {
+            visibility = Visibility.PRIVATE;
+        }
         ServicePointDefinitionImpl spd = new ServicePointDefinitionImpl(module, service.id(), location, 
-                Visibility.PUBLIC, method.getReturnType().getName());
+                visibility, method.getReturnType().getName());
         module.addServicePoint(spd);
 
-        ImplementationConstructor constructor = new FactoryMethodImplementationConstructor(location, 
+        ImplementationConstructor constructor = new MethodCallImplementationConstructor(location, 
                 method, instanceProvider);
 
         ImplementationDefinition sid = new ServiceImplementationDefinitionImpl(module, location, 
@@ -183,6 +257,8 @@
 
     private void processAnnotatedConfigurationMethod(Method method, Configuration configuration, ModuleDefinitionImpl module, ModuleInstanceProvider instanceProvider)
     {
+        checkMethodModifiers(method, 0, "configuration point");
+
         if (_log.isDebugEnabled())
         {
             _log.debug("Method " + method.getName() + "classified as configuration point.");
@@ -191,12 +267,16 @@
         Location location = new AnnotatedModuleLocation(module.getLocation().getResource(), 
                 method.getDeclaringClass(), method);
         
+        Visibility visibility = Visibility.PUBLIC;
+        if (Modifier.isProtected(method.getModifiers())) {
+            visibility = Visibility.PRIVATE;
+        }
         ConfigurationPointDefinitionImpl cpd = new ConfigurationPointDefinitionImpl(module, configuration.id(), 
-                location, Visibility.PUBLIC, method.getReturnType().getName(), Occurances.UNBOUNDED);
+                location, visibility, method.getReturnType().getName(), Occurances.UNBOUNDED);
         module.addConfigurationPoint(cpd);
         
         // Add method implementation as initial contribution
-        Contribution contribution = new TemplateMethodContributionConstructor(
+        Contribution contribution = new MethodCallContributionConstructor(
                 location, method, instanceProvider);
         ContributionDefinitionImpl cd = new ContributionDefinitionImpl(module, location, contribution, true);
         cpd.addContribution(cd);
@@ -204,6 +284,8 @@
 
     private void processAnnotatedContributionMethod(Method method, org.apache.hivemind.annotations.definition.Contribution contribution, ModuleDefinitionImpl module, ModuleInstanceProvider instanceProvider)
     {
+        checkMethodModifiers(method, 0, "contribution");
+
         if (_log.isDebugEnabled())
         {
             _log.debug("Method " + method.getName() + "classified as contribution.");
@@ -212,7 +294,7 @@
         Location location = new AnnotatedModuleLocation(module.getLocation().getResource(), 
                 method.getDeclaringClass(), method);
         
-        Contribution constructor = new TemplateMethodContributionConstructor(
+        Contribution constructor = new MethodCallContributionConstructor(
                 location, method, instanceProvider);
 
         ContributionDefinitionImpl cd = new ContributionDefinitionImpl(module, location, constructor, false);
@@ -228,6 +310,8 @@
      */
     private void processAnnotatedSubmoduleMethod(Method method, Submodule submodule, ModuleDefinitionImpl module, ModuleInstanceProvider instanceProvider)
     {
+        checkMethodModifiers(method, 0, "submodule");
+
         if (_log.isDebugEnabled())
         {
             _log.debug("Method " + method.getName() + "classified as submodule.");

Copied: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/MethodCallContributionConstructor.java (from r507225, hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/TemplateMethodContributionConstructor.java)
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/MethodCallContributionConstructor.java?view=diff&rev=509344&p1=hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/TemplateMethodContributionConstructor.java&r1=507225&p2=hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/MethodCallContributionConstructor.java&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/TemplateMethodContributionConstructor.java (original)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/MethodCallContributionConstructor.java Mon Feb 19 13:45:44 2007
@@ -27,7 +27,7 @@
  * 
  * @author Achim Huegen
  */
-public class TemplateMethodContributionConstructor implements
+public class MethodCallContributionConstructor implements
         Contribution
 {
     private Method _templateMethod;
@@ -36,7 +36,7 @@
 
     private Location _location;
 
-    public TemplateMethodContributionConstructor(Location location, Method factoryMethod,
+    public MethodCallContributionConstructor(Location location, Method factoryMethod,
             ModuleInstanceProvider moduleInstanceProvider)
     {
         _location = location;

Copied: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/MethodCallImplementationConstructor.java (from r507225, hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodImplementationConstructor.java)
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/MethodCallImplementationConstructor.java?view=diff&rev=509344&p1=hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodImplementationConstructor.java&r1=507225&p2=hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/MethodCallImplementationConstructor.java&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodImplementationConstructor.java (original)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/MethodCallImplementationConstructor.java Mon Feb 19 13:45:44 2007
@@ -29,14 +29,14 @@
  * 
  * @author Achim Huegen
  */
-public class FactoryMethodImplementationConstructor extends AbstractServiceImplementationConstructor implements
+public class MethodCallImplementationConstructor extends AbstractServiceImplementationConstructor implements
         ImplementationConstructor
 {
     private Method _factoryMethod;
 
     private ModuleInstanceProvider _moduleInstanceProvider;
 
-    public FactoryMethodImplementationConstructor(Location location, Method factoryMethod,
+    public MethodCallImplementationConstructor(Location location, Method factoryMethod,
             ModuleInstanceProvider moduleInstanceProvider)
     {
         super(location);

Modified: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProvider.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProvider.java?view=diff&rev=509344&r1=509343&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProvider.java (original)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProvider.java Mon Feb 19 13:45:44 2007
@@ -16,7 +16,16 @@
 
 import org.apache.hivemind.events.RegistryInitializationListener;
 
+/**
+ * Reponsible for the creation of the single instance of an annotated module class.
+ * Provides the module instance with a reference to the {@link org.apache.hivemind.internal.RegistryInfrastructure}.
+ * 
+ * @author Achim Huegen
+ */
 public interface ModuleInstanceProvider extends RegistryInitializationListener
 {
+    /**
+     * @return  the module instance
+     */
     public Object getModuleInstance();
 }

Modified: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProviderImpl.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProviderImpl.java?view=diff&rev=509344&r1=509343&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProviderImpl.java (original)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProviderImpl.java Mon Feb 19 13:45:44 2007
@@ -21,6 +21,11 @@
 import org.apache.hivemind.util.Defense;
 import org.apache.hivemind.util.PropertyUtils;
 
+/**
+ * Implementation of {@link ModuleInstanceProvider}.
+ * 
+ * @author Achim Huegen
+ */
 public class ModuleInstanceProviderImpl implements ModuleInstanceProvider
 {
     private static final String REGISTRY_PROPERTY_NAME = "registry";
@@ -43,7 +48,7 @@
         return _instance;
     }
     
-    public void createModuleInstance(RegistryInfrastructure _registry)
+    private void createModuleInstance(RegistryInfrastructure _registry)
     {
         try
         {
@@ -69,7 +74,7 @@
                 && PropertyUtils.getPropertyType(moduleInstance, REGISTRY_PROPERTY_NAME).equals(TypedRegistry.class)) {
             
             Module callingModule = _registry.getModule(_moduleId);
-            TypedRegistry annotatedRegistry = new RegistryImpl(callingModule, _registry);
+            TypedRegistry annotatedRegistry = new TypedRegistryImpl(callingModule, _registry);
             PropertyUtils.write(moduleInstance, REGISTRY_PROPERTY_NAME, annotatedRegistry);
         }
     }

Copied: hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/TypedRegistryImpl.java (from r507225, hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java)
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/TypedRegistryImpl.java?view=diff&rev=509344&p1=hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java&r1=507225&p2=hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/TypedRegistryImpl.java&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java (original)
+++ hivemind/hivemind2/trunk/annotations/src/java/org/apache/hivemind/annotations/internal/TypedRegistryImpl.java Mon Feb 19 13:45:44 2007
@@ -26,7 +26,7 @@
  * 
  * @author Huegen
  */
-public class RegistryImpl implements TypedRegistry
+public class TypedRegistryImpl implements TypedRegistry
 {
     private Module _callingModule;
 
@@ -35,9 +35,10 @@
     /**
      * @param callingModule  the module that gets access registry access by this instance.
      *                       Used for visibility checks when services and configurations are retrieved.
+     *                       Can be null, in this case only public extension points are visible.
      * @param delegate
      */
-    public RegistryImpl(Module callingModule, RegistryInfrastructure delegate)
+    public TypedRegistryImpl(Module callingModule, RegistryInfrastructure delegate)
     {
         _callingModule = callingModule;
         _delegate = delegate;
@@ -48,15 +49,24 @@
      */
     public <T> T getConfiguration(String configurationId, Class<T> configurationType)
     {
-        String qualifiedConfigurationId = IdUtils.qualify(
-                _callingModule.getModuleId(),
-                configurationId);
+        String qualifiedConfigurationId = qualifyExtensionPointId(configurationId);
         Object configuration = _delegate.getConfiguration(
                 qualifiedConfigurationId,
                 _callingModule);
         return (T) configuration;
     }
 
+    private String qualifyExtensionPointId(String extensionPointId)
+    {
+        if (_callingModule == null) {
+            return extensionPointId;
+        } else {
+            return IdUtils.qualify(
+                    _callingModule.getModuleId(),
+                    extensionPointId);
+        }
+    }
+
     /**
      * @see org.apache.hivemind.annotations.TypedRegistry#getConfiguration(java.lang.Class)
      */
@@ -71,9 +81,7 @@
      */
     public <T> T getService(String serviceId, Class<T> serviceInterface)
     {
-        String qualifiedServiceId = IdUtils.qualify(
-                _callingModule.getModuleId(),
-                serviceId);
+        String qualifiedServiceId = qualifyExtensionPointId(serviceId);
         Object service = _delegate.getService(qualifiedServiceId, serviceInterface, _callingModule);
         return (T) service;
     }
@@ -93,6 +101,15 @@
     public Autowiring getAutowiring()
     {
         return getService(Autowiring.class);
+    }
+
+    /**
+     * @see org.apache.hivemind.annotations.TypedRegistry#shutdown()
+     */
+    public void shutdown()
+    {
+        _delegate.shutdown();
+        
     }
 
 }

Added: hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/AbstractModule.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/AbstractModule.java?view=auto&rev=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/AbstractModule.java (added)
+++ hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/AbstractModule.java Mon Feb 19 13:45:44 2007
@@ -0,0 +1,22 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed 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.hivemind.annotations;
+
+import org.apache.hivemind.annotations.definition.Module;
+
+@Module(id = "AbstractModule")
+public abstract class AbstractModule
+{
+}

Modified: hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/AnnotationTestCase.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/AnnotationTestCase.java?view=diff&rev=509344&r1=509343&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/AnnotationTestCase.java (original)
+++ hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/AnnotationTestCase.java Mon Feb 19 13:45:44 2007
@@ -14,9 +14,6 @@
 
 package org.apache.hivemind.annotations;
 
-import org.apache.hivemind.Registry;
-import org.apache.hivemind.annotations.AnnotatedModuleReader;
-import org.apache.hivemind.annotations.AnnotatedRegistryBuilder;
 import org.apache.hivemind.definition.RegistryDefinition;
 import org.apache.hivemind.definition.impl.RegistryDefinitionImpl;
 import org.apache.hivemind.impl.DefaultErrorHandler;
@@ -24,13 +21,13 @@
 
 public class AnnotationTestCase extends HiveMindTestCase
 {
-    protected Registry constructRegistry(String ... moduleClassNames)
+    protected TypedRegistry constructRegistry(String ... moduleClassNames)
     {
         AnnotatedRegistryBuilder builder = new AnnotatedRegistryBuilder();
         return builder.constructRegistry(moduleClassNames);
     }
 
-    protected Registry constructRegistry(Class ... moduleClasses)
+    protected TypedRegistry constructRegistry(Class ... moduleClasses)
     {
         AnnotatedRegistryBuilder builder = new AnnotatedRegistryBuilder();
         return builder.constructRegistry(moduleClasses);

Added: hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/FinalModule.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/FinalModule.java?view=auto&rev=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/FinalModule.java (added)
+++ hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/FinalModule.java Mon Feb 19 13:45:44 2007
@@ -0,0 +1,22 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed 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.hivemind.annotations;
+
+import org.apache.hivemind.annotations.definition.Module;
+
+@Module(id = "FinalModule")
+public final class FinalModule
+{
+}

Added: hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/NotPublicModule.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/NotPublicModule.java?view=auto&rev=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/NotPublicModule.java (added)
+++ hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/NotPublicModule.java Mon Feb 19 13:45:44 2007
@@ -0,0 +1,22 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed 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.hivemind.annotations;
+
+import org.apache.hivemind.annotations.definition.Module;
+
+@Module(id = "NotPublicModule")
+class NotPublicModule
+{
+}

Modified: hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/TestAnnotatedModuleReader.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/TestAnnotatedModuleReader.java?view=diff&rev=509344&r1=509343&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/TestAnnotatedModuleReader.java (original)
+++ hivemind/hivemind2/trunk/annotations/src/test/org/apache/hivemind/annotations/TestAnnotatedModuleReader.java Mon Feb 19 13:45:44 2007
@@ -14,16 +14,20 @@
 
 package org.apache.hivemind.annotations;
 
-import org.apache.hivemind.Registry;
+import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.annotations.internal.AnnotatedModuleProcessor;
 import org.apache.hivemind.definition.ModuleDefinition;
 import org.apache.hivemind.definition.RegistryDefinition;
 import org.apache.hivemind.definition.ServicePointDefinition;
+import org.apache.hivemind.definition.impl.RegistryDefinitionImpl;
+import org.apache.hivemind.impl.DefaultClassResolver;
+import org.apache.hivemind.impl.DefaultErrorHandler;
 
 public class TestAnnotatedModuleReader extends AnnotationTestCase
 {
     public void testSimpleModule()
     {
-        Registry registry = constructRegistry(SimpleAnnotatedModule.class);
+        TypedRegistry registry = constructRegistry(SimpleAnnotatedModule.class);
         Runnable service = (Runnable) registry.getService("org.apache.hivemind.annotations.SimpleAnnotatedModule.Test", Runnable.class);
         service.run();
     }
@@ -33,17 +37,63 @@
      */
     public void testLocation()
     {
-        RegistryDefinition registry = constructRegistryDefinition((new Class[] {SimpleAnnotatedModule.class}));
+        RegistryDefinition registry = constructRegistryDefinition(SimpleAnnotatedModule.class);
         ModuleDefinition module = registry.getModule("org.apache.hivemind.annotations.SimpleAnnotatedModule");
         assertEquals("Class org.apache.hivemind.annotations.SimpleAnnotatedModule", module.getLocation().toString());
         ServicePointDefinition service = registry.getServicePoint("org.apache.hivemind.annotations.SimpleAnnotatedModule.Test");
         assertEquals("Class org.apache.hivemind.annotations.SimpleAnnotatedModule, method getRunnable", service.getLocation().toString());
     }
     
+    /**
+     * Checks that an explicitly defined id in the module annotation takes precedence
+     * over the package and class name.
+     */
     public void testModuleId()
     {
-        RegistryDefinition registry = constructRegistryDefinition((new Class[] {ModuleWithExplicitId.class}));
+        RegistryDefinition registry = constructRegistryDefinition(ModuleWithExplicitId.class);
         assertNotNull(registry.getModule("Test"));
     }
+  
+    public void testModuleClassNotFinal()
+    {
+        AnnotatedModuleProcessor processor = new AnnotatedModuleProcessor(new RegistryDefinitionImpl(),
+                new DefaultClassResolver(), new DefaultErrorHandler());
+        try
+        {
+            processor.processModule(FinalModule.class);
+            fail("Final class must not be allowed as module class");
+        }
+        catch (ApplicationRuntimeException expected)
+        {
+        }   
+    }
+    
+    public void testModuleClassNotAbstract()
+    {
+        AnnotatedModuleProcessor processor = new AnnotatedModuleProcessor(new RegistryDefinitionImpl(),
+                new DefaultClassResolver(), new DefaultErrorHandler());
+        try
+        {
+            processor.processModule(AbstractModule.class);
+            fail("Abstract class must not be allowed as module class");
+        }
+        catch (ApplicationRuntimeException expected)
+        {
+        }      
+    }
     
+    public void testModuleClassPublic()
+    {
+        AnnotatedModuleProcessor processor = new AnnotatedModuleProcessor(new RegistryDefinitionImpl(),
+                new DefaultClassResolver(), new DefaultErrorHandler());
+        try
+        {
+            processor.processModule(NotPublicModule.class);
+            fail("Protected class must not be allowed as module class");
+        }
+        catch (ApplicationRuntimeException expected)
+        {
+        }        
+    }
+
 }

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=509344&r1=509343&r2=509344
==============================================================================
--- 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 Mon Feb 19 13:45:44 2007
@@ -17,21 +17,19 @@
 import hivemind.test.services.ServiceAutowireTarget;
 import hivemind.test.services.StringHolder;
 
-import org.apache.hivemind.Registry;
-
 public class TestAnnotatedModules extends AnnotationTestCase
 {
     public void testAutowiring()
     {
-        Registry registry = constructRegistry(AutowiringModule.class);
-        ServiceAutowireTarget service = (ServiceAutowireTarget) registry.getService(ServiceAutowireTarget.class);
+        TypedRegistry registry = constructRegistry(AutowiringModule.class);
+        ServiceAutowireTarget service = registry.getService(ServiceAutowireTarget.class);
         assertNotNull(service.getStringHolder());
     }
     
     public void testSubmodule()
     {
-        Registry registry = constructRegistry(Supermodule.class);
-        StringHolder service = (StringHolder) registry.getService("super.sub.StringHolder", StringHolder.class);
+        TypedRegistry registry = constructRegistry(Supermodule.class);
+        StringHolder service = registry.getService("super.sub.StringHolder", StringHolder.class);
         assertNotNull(service);
     }
 

Added: hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/calculator/CalculatorMain.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/calculator/CalculatorMain.java?view=auto&rev=509344
==============================================================================
--- hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/calculator/CalculatorMain.java (added)
+++ hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/calculator/CalculatorMain.java Mon Feb 19 13:45:44 2007
@@ -0,0 +1,48 @@
+// Copyright 2005 The Apache Software Foundation
+//
+// Licensed 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.examples.annotations.calculator;
+
+import org.apache.examples.Calculator;
+import org.apache.hivemind.annotations.AnnotatedRegistryBuilder;
+import org.apache.hivemind.annotations.TypedRegistry;
+
+/**
+ * Builds the Registry for Calculator example based on annotations, then exits. 
+ * 
+ * @author Achim Huegen
+ */
+public class CalculatorMain
+{
+
+    public static void main(String[] args)
+    {
+        double arg0 = Double.parseDouble(args[0]);
+        double arg1 = Double.parseDouble(args[1]);
+
+        AnnotatedRegistryBuilder builder = new AnnotatedRegistryBuilder();
+        TypedRegistry registry = builder.constructRegistry(CalculatorModule.class);
+        
+        Calculator calculator = registry.getService(Calculator.class);
+
+        System.out.println("Inputs:   " + arg0 + " and " + arg1);
+        System.out.println("Add:      " + calculator.add(arg0, arg1));
+        System.out.println("Subtract: " + calculator.subtract(arg0, arg1));
+        System.out.println("Multiply: " + calculator.multiply(arg0, arg1));
+        System.out.println("Divide:   " + calculator.divide(arg0, arg1));
+
+
+        registry.shutdown();
+    }
+}

Added: hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/calculator/CalculatorModule.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/calculator/CalculatorModule.java?view=auto&rev=509344
==============================================================================
--- hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/calculator/CalculatorModule.java (added)
+++ hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/calculator/CalculatorModule.java Mon Feb 19 13:45:44 2007
@@ -0,0 +1,71 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed 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.examples.annotations.calculator;
+
+import org.apache.examples.Adder;
+import org.apache.examples.Calculator;
+import org.apache.examples.Divider;
+import org.apache.examples.Multiplier;
+import org.apache.examples.Subtracter;
+import org.apache.examples.impl.AdderImpl;
+import org.apache.examples.impl.CalculatorImpl;
+import org.apache.examples.impl.DividerImpl;
+import org.apache.examples.impl.MultiplierImpl;
+import org.apache.examples.impl.SubtracterImpl;
+import org.apache.hivemind.annotations.AbstractAnnotatedModule;
+import org.apache.hivemind.annotations.definition.Module;
+import org.apache.hivemind.annotations.definition.Service;
+
+/**
+ * Example of an annotated module that creates a calculator.
+ * 
+ * @author Huegen
+ */
+@Module( id="calculator" )
+public class CalculatorModule extends AbstractAnnotatedModule
+{
+
+    @Service( id="Adder" )
+    public Adder getAdderService()
+    {
+        return new AdderImpl();
+    }
+    
+    @Service( id="Subtracter" )
+    public Subtracter getSubtractorService()
+    {
+        return new SubtracterImpl();
+    }
+    
+    @Service( id="Multiplier" )
+    public Multiplier getMultiplierService()
+    {
+        return new MultiplierImpl();
+    }
+
+    @Service( id="Divider" )
+    public Divider getDividerService()
+    {
+        return new DividerImpl();
+    }
+
+    @Service( id="Calculator" )
+    public Calculator getCalculatorService()
+    {
+        CalculatorImpl result = new CalculatorImpl();
+        return autowireProperties(result);
+    }
+
+}

Modified: hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMain.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMain.java?view=diff&rev=509344&r1=509343&r2=509344
==============================================================================
--- hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMain.java (original)
+++ hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMain.java Mon Feb 19 13:45:44 2007
@@ -14,8 +14,8 @@
 
 package org.apache.examples.annotations.panorama;
 
-import org.apache.hivemind.Registry;
 import org.apache.hivemind.annotations.AnnotatedRegistryBuilder;
+import org.apache.hivemind.annotations.TypedRegistry;
 
 /**
  * Builds the Registry for Panorama example based on annotations, then exits. 
@@ -28,7 +28,7 @@
     public static void main(String[] args)
     {
         AnnotatedRegistryBuilder builder = new AnnotatedRegistryBuilder();
-        Registry registry = builder.constructRegistry(PanoramaModule.class);
+        TypedRegistry registry = builder.constructRegistry(PanoramaModule.class);
 
         registry.shutdown();
     }



Mime
View raw message