You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemind.apache.org by ah...@apache.org on 2006/10/05 09:29:26 UTC
svn commit: r453128 - in /hivemind/branches/branch-2-0-annot/annotations/src:
java/org/apache/hivemind/annotations/
java/org/apache/hivemind/annotations/internal/
test/org/apache/hivemind/annotations/
Author: ahuegen
Date: Thu Oct 5 00:29:25 2006
New Revision: 453128
URL: http://svn.apache.org/viewvc?view=rev&rev=453128
Log:
annotated modules can get registry reference injected
support for configuration points
Added:
hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Configuration.java
hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodConfigurationConstructor.java
Modified:
hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Registry.java
hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Service.java
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/FactoryMethodImplementationConstructor.java
hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProvider.java
hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProviderImpl.java
hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java
hivemind/branches/branch-2-0-annot/annotations/src/test/org/apache/hivemind/annotations/SimpleAnnotatedModule.java
Added: hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Configuration.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Configuration.java?view=auto&rev=453128
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Configuration.java (added)
+++ hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Configuration.java Thu Oct 5 00:29:25 2006
@@ -0,0 +1,21 @@
+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;
+
+/**
+ * Marks a method in an annotated module as configuration point.
+ * The return type of the method defines the configuration type.
+ * The method is used factory method for the construction of the configuration container.
+ *
+ * @author Achim Huegen
+ */
+@Documented
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = ElementType.METHOD)
+public @interface Configuration {
+ String id();
+}
Modified: hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Registry.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Registry.java?view=diff&rev=453128&r1=453127&r2=453128
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Registry.java (original)
+++ hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Registry.java Thu Oct 5 00:29:25 2006
@@ -1,5 +1,11 @@
package org.apache.hivemind.annotations;
+/**
+ * Specialized interface for the registry access from annotated modules.
+ * Implements typed access to services and configurations by use of Generics.
+ *
+ * @author Achim Huegen
+ */
public interface Registry
{
public <T> T getService(String serviceId, Class<T> serviceInterface);
Modified: hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Service.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Service.java?view=diff&rev=453128&r1=453127&r2=453128
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Service.java (original)
+++ hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Service.java Thu Oct 5 00:29:25 2006
@@ -8,6 +8,13 @@
import org.apache.hivemind.internal.ServiceModel;
+/**
+ * Marks a method in an annotated module as service point.
+ * The return type of the method defines the service interface.
+ * The method is used factory method for the construction of service implementations.
+ *
+ * @author Achim Huegen
+ */
@Documented
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = ElementType.METHOD)
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=453128&r1=453127&r2=453128
==============================================================================
--- 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 Thu Oct 5 00:29:25 2006
@@ -8,24 +8,25 @@
import org.apache.hivemind.ClassResolver;
import org.apache.hivemind.ErrorHandler;
import org.apache.hivemind.Location;
+import org.apache.hivemind.Occurances;
import org.apache.hivemind.Resource;
-import org.apache.hivemind.annotations.Registry;
+import org.apache.hivemind.annotations.Configuration;
import org.apache.hivemind.annotations.Service;
+import org.apache.hivemind.definition.ConfigurationPointDefinition;
import org.apache.hivemind.definition.ModuleDefinition;
import org.apache.hivemind.definition.RegistryDefinition;
import org.apache.hivemind.definition.ServiceImplementationDefinition;
import org.apache.hivemind.definition.ServicePointDefinition;
+import org.apache.hivemind.definition.construction.ConfigurationConstructor;
import org.apache.hivemind.definition.construction.ImplementationConstructor;
import org.apache.hivemind.impl.LocationImpl;
import org.apache.hivemind.internal.Visibility;
import org.apache.hivemind.util.ClasspathResource;
/**
- * Does the work for
- * {@link org.apache.hivemind.annotations.AnnotatedModuleReader}.
- *
- * Process an annotated class and registers the defined extension and extension points
- * in a registry definition.
+ * 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.
*
* @author Achim Huegen
*/
@@ -39,8 +40,8 @@
private RegistryDefinition _registryDefinition;
- public AnnotatedModuleProcessor(RegistryDefinition registryDefinition, ClassResolver classResolver,
- ErrorHandler errorHandler)
+ public AnnotatedModuleProcessor(RegistryDefinition registryDefinition,
+ ClassResolver classResolver, ErrorHandler errorHandler)
{
_registryDefinition = registryDefinition;
_classResolver = classResolver;
@@ -54,69 +55,117 @@
*/
public void processModule(Class moduleClass)
{
- ModuleDefinition module = new ModuleDefinition(determineModuleId(moduleClass), createLocation(moduleClass),
- _classResolver, moduleClass.getPackage().getName());
-
-// processServices(moduleClass);
-
- Registry registry = null; // new RegistryImpl(null, )
- ModuleInstanceProvider instanceProvider = new ModuleInstanceProviderImpl(moduleClass, null);
+ ModuleDefinition module = new ModuleDefinition(determineModuleId(moduleClass),
+ createLocation(moduleClass), _classResolver, moduleClass.getPackage().getName());
+
+ // processServices(moduleClass);
+
+ ModuleInstanceProvider instanceProvider = new ModuleInstanceProviderImpl(moduleClass,
+ module.getId());
+ // Register provider as initialization provider so it can acquire a reference to the
+ // registry
+ _registryDefinition.addRegistryInitializationListener(instanceProvider);
+
processModuleMethods(moduleClass, module, instanceProvider);
_registryDefinition.addModule(module);
}
-// /**
-// * Detects all services defined in the module class.
-// *
-// * @param moduleClass
-// */
-// private void processServices(Class moduleClass)
-// {
-// // TODO Auto-generated method stub
-//
-// }
- public void processModuleMethods(Class moduleClass, ModuleDefinition module, ModuleInstanceProvider instanceProvider)
+ // /**
+ // * Detects all services defined in the module class.
+ // *
+ // * @param moduleClass
+ // */
+ // private void processServices(Class moduleClass)
+ // {
+ // // TODO Auto-generated method stub
+ //
+ // }
+ public void processModuleMethods(Class moduleClass, ModuleDefinition module,
+ ModuleInstanceProvider instanceProvider)
{
Method[] methods = moduleClass.getMethods();
- for (int i = 0; i < methods.length; i++) {
+ for (int i = 0; i < methods.length; i++)
+ {
Method method = methods[i];
processMethod(method, module, instanceProvider);
}
}
-
- public void processMethod(Method method, ModuleDefinition module, ModuleInstanceProvider instanceProvider)
+
+ public void processMethod(Method method, ModuleDefinition module,
+ ModuleInstanceProvider instanceProvider)
{
+ if (_log.isDebugEnabled())
+ {
+ _log.debug("Checking method " + method.getName() + " for annotations");
+ }
+
Annotation[] annotations = method.getAnnotations();
- for (int j = 0; j < annotations.length; j++) {
+ for (int j = 0; j < annotations.length; j++)
+ {
Annotation annotation = annotations[j];
-
- if (Service.class.isAssignableFrom(annotation.annotationType())) {
- processAnnotatedServiceMethod(method, (Service) annotation, module, instanceProvider);
+
+ if (Service.class.isAssignableFrom(annotation.annotationType()))
+ {
+ processAnnotatedServiceMethod(
+ method,
+ (Service) annotation,
+ module,
+ instanceProvider);
}
- }
-
+ else if (Configuration.class.isAssignableFrom(annotation.annotationType()))
+ {
+ processAnnotatedConfigurationMethod(
+ method,
+ (Configuration) annotation,
+ module,
+ instanceProvider);
+ }
+ }
+
}
- private void processAnnotatedServiceMethod(Method method, Service service, ModuleDefinition module, ModuleInstanceProvider instanceProvider)
+ private void processAnnotatedServiceMethod(Method method, Service service,
+ ModuleDefinition module, ModuleInstanceProvider instanceProvider)
{
- ServicePointDefinition spd = new ServicePointDefinition(module, service.id(),
- module.getLocation(), Visibility.PUBLIC, method.getReturnType().getName());
+ if (_log.isDebugEnabled())
+ {
+ _log.debug("Method " + method.getName() + "classified as service point.");
+ }
+
+ ServicePointDefinition spd = new ServicePointDefinition(module, service.id(), module
+ .getLocation(), Visibility.PUBLIC, method.getReturnType().getName());
module.addServicePoint(spd);
-
- ImplementationConstructor constructor = new FactoryMethodImplementationConstructor(
- module.getLocation(), method, instanceProvider);
-
- ServiceImplementationDefinition sid = new ServiceImplementationDefinition(module,
- module.getLocation(), constructor, service.serviceModel(), true);
-
+
+ ImplementationConstructor constructor = new FactoryMethodImplementationConstructor(module
+ .getLocation(), method, instanceProvider);
+
+ ServiceImplementationDefinition sid = new ServiceImplementationDefinition(module, module
+ .getLocation(), constructor, service.serviceModel(), true);
+
spd.addImplementation(sid);
+
+ }
+
+ private void processAnnotatedConfigurationMethod(Method method, Configuration configuration, ModuleDefinition module, ModuleInstanceProvider instanceProvider)
+ {
+ if (_log.isDebugEnabled())
+ {
+ _log.debug("Method " + method.getName() + "classified as configuration point.");
+ }
+ ConfigurationConstructor constructor = new FactoryMethodConfigurationConstructor(module
+ .getLocation(), method, instanceProvider);
+
+ ConfigurationPointDefinition cpd = new ConfigurationPointDefinition(module, configuration.id(), module
+ .getLocation(), Visibility.PUBLIC, constructor, method.getReturnType().getName(), Occurances.UNBOUNDED);
+ module.addConfigurationPoint(cpd);
+
}
/**
- * Creates a location pointing at the module class. The location contains a fixed
- * line number 1.
+ * Creates a location pointing at the module class. The location contains a fixed line number 1.
+ *
* @param moduleClass
* @return the location
*/
Added: hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodConfigurationConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodConfigurationConstructor.java?view=auto&rev=453128
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodConfigurationConstructor.java (added)
+++ hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodConfigurationConstructor.java Thu Oct 5 00:29:25 2006
@@ -0,0 +1,52 @@
+package org.apache.hivemind.annotations.internal;
+
+import java.lang.reflect.Method;
+
+import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.Location;
+import org.apache.hivemind.annotations.Configuration;
+import org.apache.hivemind.definition.construction.ConfigurationConstructionContext;
+import org.apache.hivemind.definition.construction.ConfigurationConstructor;
+
+/**
+ * Constructs a configuration container by calling a factory method defined in
+ * an annotated module by use of the {@link Configuration} annotation.
+ *
+ * @author Achim Huegen
+ */
+public class FactoryMethodConfigurationConstructor implements
+ ConfigurationConstructor
+{
+ private Method _factoryMethod;
+
+ private ModuleInstanceProvider _moduleInstanceProvider;
+
+ private Location _location;
+
+ public FactoryMethodConfigurationConstructor(Location location, Method factoryMethod,
+ ModuleInstanceProvider moduleInstanceProvider)
+ {
+ _location = location;
+ _factoryMethod = factoryMethod;
+ _moduleInstanceProvider = moduleInstanceProvider;
+ }
+
+ public Object constructConfigurationContainer(ConfigurationConstructionContext context)
+ {
+ try
+ {
+ Object result = _factoryMethod.invoke(_moduleInstanceProvider.getModuleInstance(), (Object[]) null);
+ return result;
+ }
+ catch (Exception ex)
+ {
+ throw new ApplicationRuntimeException(ex.getMessage(), getLocation(), ex);
+ }
+ }
+
+ public Location getLocation()
+ {
+ return _location;
+ }
+
+}
Modified: hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodImplementationConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodImplementationConstructor.java?view=diff&rev=453128&r1=453127&r2=453128
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodImplementationConstructor.java (original)
+++ hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/FactoryMethodImplementationConstructor.java Thu Oct 5 00:29:25 2006
@@ -4,10 +4,17 @@
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.Location;
+import org.apache.hivemind.annotations.Service;
import org.apache.hivemind.definition.construction.ImplementationConstructionContext;
import org.apache.hivemind.definition.construction.ImplementationConstructor;
import org.apache.hivemind.internal.AbstractServiceImplementationConstructor;
+/**
+ * Constructs a service implementation by calling a factory method defined in
+ * an annotated module by use of the {@link Service} annotation.
+ *
+ * @author Achim Huegen
+ */
public class FactoryMethodImplementationConstructor extends AbstractServiceImplementationConstructor implements
ImplementationConstructor
{
Modified: hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProvider.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProvider.java?view=diff&rev=453128&r1=453127&r2=453128
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProvider.java (original)
+++ hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProvider.java Thu Oct 5 00:29:25 2006
@@ -1,6 +1,8 @@
package org.apache.hivemind.annotations.internal;
-public interface ModuleInstanceProvider
+import org.apache.hivemind.events.RegistryInitializationListener;
+
+public interface ModuleInstanceProvider extends RegistryInitializationListener
{
public Object getModuleInstance();
}
Modified: hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProviderImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProviderImpl.java?view=diff&rev=453128&r1=453127&r2=453128
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProviderImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/ModuleInstanceProviderImpl.java Thu Oct 5 00:29:25 2006
@@ -2,6 +2,9 @@
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.annotations.Registry;
+import org.apache.hivemind.internal.Module;
+import org.apache.hivemind.internal.RegistryInfrastructure;
+import org.apache.hivemind.util.Defense;
import org.apache.hivemind.util.PropertyUtils;
public class ModuleInstanceProviderImpl implements ModuleInstanceProvider
@@ -11,31 +14,33 @@
private Class _moduleClass;
private Object _instance;
-
- private Registry _registry;
- public ModuleInstanceProviderImpl(Class moduleClass, Registry registry)
+ private String _moduleId;
+
+ public ModuleInstanceProviderImpl(Class moduleClass, String moduleId)
{
_moduleClass = moduleClass;
- _registry = registry;
+ _moduleId = moduleId;
}
- public synchronized Object getModuleInstance()
+ public Object getModuleInstance()
+ {
+ Defense.fieldNotNull(_instance, "instance");
+ return _instance;
+ }
+
+ public void createModuleInstance(RegistryInfrastructure _registry)
{
- if (_instance == null)
+ try
{
- try
- {
- _instance = _moduleClass.newInstance();
- injectRegistry(_instance);
- }
- catch (Exception ex)
- {
- // TODO: more expressive error message
- throw new ApplicationRuntimeException(ex.getMessage(), ex);
- }
+ _instance = _moduleClass.newInstance();
+ injectRegistry(_instance, _registry);
+ }
+ catch (Exception ex)
+ {
+ // TODO: more expressive error message
+ throw new ApplicationRuntimeException(ex.getMessage(), ex);
}
- return _instance;
}
/**
@@ -44,12 +49,28 @@
*
* @param moduleInstance
*/
- private void injectRegistry(Object moduleInstance)
+ private void injectRegistry(Object moduleInstance, RegistryInfrastructure _registry)
{
if (PropertyUtils.isWritable(moduleInstance, REGISTRY_PROPERTY_NAME)
&& PropertyUtils.getPropertyType(moduleInstance, REGISTRY_PROPERTY_NAME).equals(Registry.class)) {
- PropertyUtils.write(moduleInstance, REGISTRY_PROPERTY_NAME, _registry);
+
+ Module callingModule = _registry.getModule(_moduleId);
+ Registry annotatedRegistry = new RegistryImpl(callingModule, _registry);
+ PropertyUtils.write(moduleInstance, REGISTRY_PROPERTY_NAME, annotatedRegistry);
}
+ }
+
+ /**
+ * Called after initialization of the registry infrastructure.
+ * This is a good moment to create the module instance. If any service defined in the module
+ * is initialized during startup (by the EagerLoad service) it will find the registry
+ * reference in place.
+ *
+ * @see org.apache.hivemind.events.RegistryInitializationListener#registryInitialized(org.apache.hivemind.internal.RegistryInfrastructure)
+ */
+ public void registryInitialized(RegistryInfrastructure registry)
+ {
+ createModuleInstance(registry);
}
}
Modified: hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java?view=diff&rev=453128&r1=453127&r2=453128
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java Thu Oct 5 00:29:25 2006
@@ -3,12 +3,14 @@
import org.apache.hivemind.annotations.Registry;
import org.apache.hivemind.internal.Module;
import org.apache.hivemind.internal.RegistryInfrastructure;
+import org.apache.hivemind.util.IdUtils;
public class RegistryImpl implements Registry
{
private Module _callingModule;
+
private RegistryInfrastructure _delegate;
-
+
public RegistryImpl(Module callingModule, RegistryInfrastructure delegate)
{
_callingModule = callingModule;
@@ -22,25 +24,36 @@
public <T> T getConfiguration(String configurationId, Class<T> configurationType)
{
- Object configuration = _delegate.getConfiguration(configurationId, _callingModule);
+ String fullyQualifiedConfigurationId = IdUtils.qualify(
+ _callingModule.getModuleId(),
+ configurationId);
+ Object configuration = _delegate.getConfiguration(
+ fullyQualifiedConfigurationId,
+ _callingModule);
return (T) configuration;
}
public <T> T getConfiguration(Class<T> configurationType)
{
-// Object configuration = _delegate.getConfiguration(configurationId, _callingModule);
-// throw new UnsupportedOperationException();
+ // Object configuration = _delegate.getConfiguration(configurationId, _callingModule);
+ // throw new UnsupportedOperationException();
return null;
}
public Object getConfiguration(String configurationId)
{
- return _delegate.getConfiguration(configurationId, _callingModule);
+ String fullyQualifiedConfigurationId = IdUtils.qualify(
+ _callingModule.getModuleId(),
+ configurationId);
+ return _delegate.getConfiguration(fullyQualifiedConfigurationId, _callingModule);
}
public <T> T getService(String serviceId, Class<T> serviceInterface)
{
- Object service = _delegate.getService(serviceId, serviceInterface, _callingModule);
+ String fullyQualifiedServiceId = IdUtils.qualify(
+ _callingModule.getModuleId(),
+ serviceId);
+ Object service = _delegate.getService(fullyQualifiedServiceId, serviceInterface, _callingModule);
return (T) service;
}
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=453128&r1=453127&r2=453128
==============================================================================
--- 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 Thu Oct 5 00:29:25 2006
@@ -1,5 +1,6 @@
package org.apache.hivemind.annotations;
+import java.util.ArrayList;
import java.util.List;
import org.apache.hivemind.impl.ServiceModelContribution;
@@ -20,17 +21,31 @@
{
System.out.println(model.getName());
}
- System.out.println("working!!!");
+
+ List<String> demoList = (List<String>) getRegistry().getConfiguration("Demo", List.class);
+ for (String entry : demoList)
+ {
+ System.out.println(entry);
+ }
+
}
};
}
+
+ @Configuration(id="Demo")
+ public List<String> getDemo()
+ {
+ List<String> result = new ArrayList<String>();
+ result.add("data");
+ return result;
+ }
- protected Registry getRegistry()
+ public Registry getRegistry()
{
return _registry;
}
- protected void setRegistry(Registry registry)
+ public void setRegistry(Registry registry)
{
_registry = registry;
}