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/08/10 08:02:28 UTC
svn commit: r430271 - in /hivemind/branches/branch-2-0-annot:
framework/src/java/org/apache/hivemind/definition/
framework/src/java/org/apache/hivemind/impl/
framework/src/test/hivemind/test/
framework/src/test/hivemind/test/services/ framework/src/tes...
Author: ahuegen
Date: Wed Aug 9 23:02:27 2006
New Revision: 430271
URL: http://svn.apache.org/viewvc?rev=430271&view=rev
Log:
Moved unresolved extensions from registry to module definition
Added:
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CreateClassConfigurationConstructor.java
Modified:
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/RegistryDefinition.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/ModuleDefinitionHelper.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/EagerLoadPooled.xml
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestEagerLoader.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestShutdown.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/impl/LoudRunner.java
hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml
hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java?rev=430271&r1=430270&r2=430271&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java Wed Aug 9 23:02:27 2006
@@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.apache.hivemind.ClassResolver;
@@ -24,6 +25,12 @@
private Collection _dependencies = new ArrayList();
+ private List _unresolvedImplementations = new ArrayList();
+
+ private List _unresolvedContributions = new ArrayList();
+
+ private List _unresolvedInterceptors = new ArrayList();
+
public ModuleDefinition()
{
}
@@ -128,5 +135,27 @@
_dependencies.add(dependsOnModuleId);
}
-
+ public void addServiceImplementation(String qualifiedServicePointId,
+ ServiceImplementationDefinition implementation)
+ {
+ UnresolvedExtension unresolvedExtension = new UnresolvedExtension(implementation,
+ qualifiedServicePointId);
+ _unresolvedImplementations.add(unresolvedExtension);
+ }
+
+ public void addServiceInterceptor(String qualifiedServicePointId,
+ ServiceInterceptorDefinition interceptor)
+ {
+ UnresolvedExtension unresolvedExtension = new UnresolvedExtension(interceptor,
+ qualifiedServicePointId);
+ _unresolvedInterceptors.add(unresolvedExtension);
+ }
+
+ public void addContribution(String qualifiedConfigurationPointId,
+ ContributionDefinition contribution)
+ {
+ UnresolvedExtension unresolvedExtension = new UnresolvedExtension(contribution,
+ qualifiedConfigurationPointId);
+ _unresolvedContributions.add(unresolvedExtension);
+ }
}
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/RegistryDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/RegistryDefinition.java?rev=430271&r1=430270&r2=430271&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/RegistryDefinition.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/RegistryDefinition.java Wed Aug 9 23:02:27 2006
@@ -33,12 +33,6 @@
private Map _natures = new HashMap();
- private List _unresolvedImplementations = new ArrayList();
-
- private List _unresolvedContributions = new ArrayList();
-
- private List _unresolvedInterceptors = new ArrayList();
-
private List _postProcessors = new ArrayList();
public RegistryDefinition()
@@ -131,54 +125,6 @@
configurationPoint = module.getConfigurationPoint(configurationPointId);
}
return configurationPoint;
- }
-
- public void addServiceImplementation(String qualifiedServicePointId,
- ServiceImplementationDefinition implementation)
- {
- ServicePointDefinition servicePoint = getServicePoint(qualifiedServicePointId);
- if (servicePoint != null)
- {
- servicePoint.addImplementation(implementation);
- }
- else
- {
- UnresolvedExtension unresolvedExtension = new UnresolvedExtension(implementation,
- qualifiedServicePointId);
- _unresolvedImplementations.add(unresolvedExtension);
- }
- }
-
- public void addServiceInterceptor(String qualifiedServicePointId,
- ServiceInterceptorDefinition interceptor)
- {
- ServicePointDefinition servicePoint = getServicePoint(qualifiedServicePointId);
- if (servicePoint != null)
- {
- servicePoint.addInterceptor(interceptor);
- }
- else
- {
- UnresolvedExtension unresolvedExtension = new UnresolvedExtension(interceptor,
- qualifiedServicePointId);
- _unresolvedInterceptors.add(unresolvedExtension);
- }
- }
-
- public void addContribution(String qualifiedConfigurationPointId,
- ContributionDefinition contribution)
- {
- ConfigurationPointDefinition configurationPoint = getConfigurationPoint(qualifiedConfigurationPointId);
- if (configurationPoint != null)
- {
- configurationPoint.addContribution(contribution);
- }
- else
- {
- UnresolvedExtension unresolvedExtension = new UnresolvedExtension(contribution,
- qualifiedConfigurationPointId);
- _unresolvedContributions.add(unresolvedExtension);
- }
}
/**
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java?rev=430271&r1=430270&r2=430271&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java Wed Aug 9 23:02:27 2006
@@ -1,5 +1,9 @@
package org.apache.hivemind.impl;
+import hivemind.test.ModuleDefinitionHelper;
+
+import java.util.ArrayList;
+import java.util.List;
import java.util.Locale;
import org.apache.hivemind.ErrorHandler;
@@ -14,13 +18,13 @@
import org.apache.hivemind.internal.ServiceImplementationConstructor;
import org.apache.hivemind.internal.ServiceModel;
import org.apache.hivemind.internal.ServicePoint;
-import org.apache.hivemind.internal.Visibility;
import org.apache.hivemind.service.ClassFactory;
import org.apache.hivemind.service.InterfaceSynthesizer;
import org.apache.hivemind.service.ThreadEventNotifier;
import org.apache.hivemind.service.ThreadLocalStorage;
import org.apache.hivemind.service.ThreadLocale;
import org.apache.hivemind.service.impl.ClassFactoryImpl;
+import org.apache.hivemind.service.impl.EagerLoader;
import org.apache.hivemind.service.impl.InterfaceSynthesizerImpl;
import org.apache.hivemind.service.impl.ThreadEventNotifierImpl;
import org.apache.hivemind.service.impl.ThreadLocalStorageImpl;
@@ -33,6 +37,7 @@
*/
public class CoreServicesProvider implements RegistryProvider
{
+ private ModuleDefinitionHelper helper;
public void process(RegistryDefinition registryDefinition, ErrorHandler errorHandler)
@@ -52,6 +57,7 @@
registryDefinition.addModule(md);
}
+ helper = new ModuleDefinitionHelper(md);
addClassFactory(md);
@@ -61,6 +67,8 @@
addThreadLocale(md);
+ addEagerLoad(md);
+
addShutdownCoordinator(md);
addInterfaceSynthesizer(md);
@@ -71,8 +79,8 @@
*/
private void addClassFactory(ModuleDefinition md)
{
- ServicePointDefinition spd = addServicePoint(md, "ClassFactory", ClassFactory.class);
- addSimpleServiceImplementation(md, spd, ClassFactoryImpl.class, ServiceModel.PRITIMIVE);
+ ServicePointDefinition spd = helper.addServicePoint("ClassFactory", ClassFactory.class.getName());
+ helper.addSimpleServiceImplementation(spd, ClassFactoryImpl.class.getName(), ServiceModel.PRITIMIVE);
}
/**
@@ -81,14 +89,12 @@
*/
private void addThreadEventNotifier(ModuleDefinition md)
{
- ServicePointDefinition spd = addServicePoint(
- md,
+ ServicePointDefinition spd = helper.addServicePoint(
"ThreadEventNotifier",
- ThreadEventNotifier.class);
- addSimpleServiceImplementation(
- md,
+ ThreadEventNotifier.class.getName());
+ helper.addSimpleServiceImplementation(
spd,
- ThreadEventNotifierImpl.class,
+ ThreadEventNotifierImpl.class.getName(),
ServiceModel.SINGLETON);
}
@@ -100,11 +106,10 @@
*/
private void addThreadLocalStorage(ModuleDefinition md)
{
- ServicePointDefinition spd = addServicePoint(
- md,
+ ServicePointDefinition spd = helper.addServicePoint(
"ThreadLocalStorage",
- ThreadLocalStorage.class);
- addSimpleServiceImplementation(md, spd, ThreadLocalStorageImpl.class, ServiceModel.THREADED);
+ ThreadLocalStorage.class.getName());
+ helper.addSimpleServiceImplementation(spd, ThreadLocalStorageImpl.class.getName(), ServiceModel.THREADED);
}
/**
@@ -113,7 +118,7 @@
*/
private void addThreadLocale(ModuleDefinition md)
{
- ServicePointDefinition spd = addServicePoint(md, "ThreadLocale", ThreadLocale.class);
+ ServicePointDefinition spd = helper.addServicePoint("ThreadLocale", ThreadLocale.class.getName());
// Define inline implementation constructor
ServiceImplementationConstructor constructor = new AbstractServiceImplementationConstructor(md.getLocation(),
@@ -140,30 +145,39 @@
*/
private void addShutdownCoordinator(ModuleDefinition md)
{
- ServicePointDefinition spd = addServicePoint(md, "ShutdownCoordinator", ShutdownCoordinator.class);
- addSimpleServiceImplementation(md, spd, ShutdownCoordinatorImpl.class, ServiceModel.SINGLETON);
+ ServicePointDefinition spd = helper.addServicePoint("ShutdownCoordinator", ShutdownCoordinator.class.getName());
+ helper.addSimpleServiceImplementation(spd, ShutdownCoordinatorImpl.class.getName(), ServiceModel.SINGLETON);
}
-
- public static ServicePointDefinition addServicePoint(ModuleDefinition module,
- String servicePointId, Class serviceInterface)
+ /**
+ * Service that performs eager loading of other services. This service is contributed into the hivemind.Startup configuration.
+ */
+ private void addEagerLoad(ModuleDefinition md)
{
- ServicePointDefinition result = new ServicePointDefinition(servicePointId, module
- .getLocation(), Visibility.PUBLIC, serviceInterface.getName());
+ ServicePointDefinition spd = helper.addServicePoint("EagerLoad", Runnable.class.getName());
- module.addServicePoint(result);
- return result;
- }
+ // Define inline implementation constructor, that wires the EagerLoad configuration
+ ServiceImplementationConstructor constructor = new AbstractServiceImplementationConstructor(md.getLocation(),
+ md.getId())
+ {
+ public Object constructCoreServiceImplementation(ServicePoint servicePoint,
+ Module contributingModule)
+ {
+ EagerLoader result = new EagerLoader();
+ result.setServicePoints((List) contributingModule.getConfiguration("EagerLoad"));
+ return result;
+ }
+ };
+ ServiceImplementationDefinition sid = new ServiceImplementationDefinition(md.getLocation(),
+ constructor, ServiceModel.PRITIMIVE, true);
+ spd.addImplementation(sid);
+
+ // Configuration to which services may be contributed. The corresponding services are instantiated eagerly, as the Registry is started.
+ // The order in which services are instantiated is not specified.
- public static ServiceImplementationDefinition addSimpleServiceImplementation(
- ModuleDefinition module, ServicePointDefinition servicePoint,
- Class serviceImplementationClass, String serviceModel)
- {
- ServiceImplementationDefinition result = new ServiceImplementationDefinition(module
- .getLocation(), new CreateClassServiceConstructor(module.getLocation(), module.getId(),
- serviceImplementationClass.getName()), serviceModel, true);
- servicePoint.addImplementation(result);
- return result;
+ helper.addConfigurationPoint("EagerLoad",
+ new CreateClassConfigurationConstructor(md.getLocation(), ArrayList.class.getName()),
+ List.class.getName());
}
/**
@@ -171,13 +185,12 @@
*/
private void addInterfaceSynthesizer(ModuleDefinition md)
{
- ServicePointDefinition spd = addServicePoint(md, "InterfaceSynthesizer", InterfaceSynthesizer.class);
+ ServicePointDefinition spd = helper.addServicePoint("InterfaceSynthesizer", InterfaceSynthesizer.class.getName());
// Define inline implementation constructor
ServiceImplementationConstructor constructor = new AbstractServiceImplementationConstructor(md.getLocation(),
md.getId())
{
-
public Object constructCoreServiceImplementation(ServicePoint servicePoint,
Module contributingModule)
{
@@ -186,7 +199,6 @@
result.setClassFactory((ClassFactory) contributingModule.getService(ClassFactory.class));
return result;
}
-
};
ServiceImplementationDefinition sid = new ServiceImplementationDefinition(md.getLocation(),
Added: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CreateClassConfigurationConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CreateClassConfigurationConstructor.java?rev=430271&view=auto
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CreateClassConfigurationConstructor.java (added)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CreateClassConfigurationConstructor.java Wed Aug 9 23:02:27 2006
@@ -0,0 +1,55 @@
+// Copyright 2004, 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.hivemind.impl;
+
+import org.apache.hivemind.Location;
+import org.apache.hivemind.internal.ConfigurationConstructor;
+import org.apache.hivemind.internal.Module;
+import org.apache.hivemind.util.InstanceCreationUtils;
+
+/**
+ * Constructs a configuration container by instantiating a class.
+ *
+ * @author Achim Huegen
+ */
+public final class CreateClassConfigurationConstructor extends BaseLocatable implements ConfigurationConstructor
+{
+ private String _containerClassName;
+
+ public CreateClassConfigurationConstructor(Location location, String instanceClassName)
+ {
+ super(location);
+ _containerClassName = instanceClassName;
+ }
+
+ public String getContainerClassName()
+ {
+ return _containerClassName;
+ }
+
+ public void setContainerClassName(String string)
+ {
+ _containerClassName = string;
+ }
+
+ public Object constructConfigurationContainer(Module contributingModule)
+ {
+ return InstanceCreationUtils.createInstance(
+ contributingModule,
+ _containerClassName,
+ getLocation());
+ }
+
+}
\ No newline at end of file
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/ModuleDefinitionHelper.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/ModuleDefinitionHelper.java?rev=430271&r1=430270&r2=430271&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/ModuleDefinitionHelper.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/ModuleDefinitionHelper.java Wed Aug 9 23:02:27 2006
@@ -1,9 +1,14 @@
package hivemind.test;
+import org.apache.hivemind.Occurances;
+import org.apache.hivemind.definition.ConfigurationPointDefinition;
+import org.apache.hivemind.definition.ContributionDefinition;
import org.apache.hivemind.definition.ModuleDefinition;
import org.apache.hivemind.definition.ServiceImplementationDefinition;
import org.apache.hivemind.definition.ServicePointDefinition;
import org.apache.hivemind.impl.CreateClassServiceConstructor;
+import org.apache.hivemind.internal.ConfigurationConstructor;
+import org.apache.hivemind.internal.Contribution;
import org.apache.hivemind.internal.ServiceModel;
import org.apache.hivemind.internal.Visibility;
@@ -16,19 +21,19 @@
_module = module;
}
- public ServicePointDefinition addServicePoint(String servicePointId, Class serviceInterface)
+ public ServicePointDefinition addServicePoint(String servicePointId, String serviceInterface)
{
ServicePointDefinition result = new ServicePointDefinition(servicePointId, _module
- .getLocation(), Visibility.PUBLIC, serviceInterface.getName());
+ .getLocation(), Visibility.PUBLIC, serviceInterface);
_module.addServicePoint(result);
return result;
}
- public ServicePointDefinition addServicePointWithDefaultImplementation(String servicePointId, Class serviceInterface)
+ public ServicePointDefinition addServicePointWithDefaultImplementation(String servicePointId, String serviceInterface)
{
ServicePointDefinition result = addServicePoint(servicePointId, serviceInterface);
- String defaultImplementationName = serviceInterface.getName() + "Impl";
+ String defaultImplementationName = serviceInterface + "Impl";
addSimpleServiceImplementation(result, defaultImplementationName, ServiceModel.SINGLETON);
return result;
}
@@ -41,6 +46,32 @@
.getLocation(), new CreateClassServiceConstructor(_module.getLocation(), _module.getId(),
serviceImplementationClass), serviceModel, true);
servicePoint.addImplementation(result);
+ return result;
+ }
+
+ public ConfigurationPointDefinition addConfigurationPoint(String configurationPointId,
+ ConfigurationConstructor constructor, String containerType)
+ {
+ ConfigurationPointDefinition result = new ConfigurationPointDefinition(configurationPointId, _module
+ .getLocation(), Visibility.PUBLIC, constructor, containerType, Occurances.UNBOUNDED);
+
+ _module.addConfigurationPoint(result);
+ return result;
+ }
+
+ public ContributionDefinition addContributionDefinition(ConfigurationPointDefinition configurationPoint,
+ Contribution contributionConstructor)
+ {
+ ContributionDefinition result = new ContributionDefinition(_module.getLocation(), contributionConstructor);
+ configurationPoint.addContribution(result);
+ return result;
+ }
+
+ public ContributionDefinition addContributionDefinition(String fullyQualifiedConfigurationPointId,
+ Contribution contributionConstructor)
+ {
+ ContributionDefinition result = new ContributionDefinition(_module.getLocation(), contributionConstructor);
+ _module.addContribution(fullyQualifiedConfigurationPointId, result);
return result;
}
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/EagerLoadPooled.xml
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/EagerLoadPooled.xml?rev=430271&r1=430270&r2=430271&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/EagerLoadPooled.xml (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/EagerLoadPooled.xml Wed Aug 9 23:02:27 2006
@@ -18,8 +18,7 @@
<module id="hivemind.test.services" version="1.0.0">
<service-point id="Loud" interface="java.lang.Runnable">
<invoke-factory model="pooled" service-id="hivemind.BuilderFactory">
- <construct class="hivemind.test.services.impl.LoudRunner"
- initialize-method="run" log-property="log"/>
+ <construct class="hivemind.test.services.impl.LoudRunner" />
</invoke-factory>
</service-point>
<contribution configuration-id="hivemind.EagerLoad">
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java?rev=430271&r1=430270&r2=430271&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java Wed Aug 9 23:02:27 2006
@@ -18,7 +18,7 @@
super("hivemind.test.services", null, new DefaultClassResolver(), null);
ModuleDefinitionHelper helper = new ModuleDefinitionHelper(this);
- ServicePointDefinition sp = helper.addServicePoint("Simple", SimpleService.class);
+ ServicePointDefinition sp = helper.addServicePoint("Simple", SimpleService.class.getName());
helper.addSimpleServiceImplementation(sp, SimpleServiceImpl.class.getName(), ServiceModel.SINGLETON);
}
}
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestEagerLoader.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestEagerLoader.java?rev=430271&r1=430270&r2=430271&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestEagerLoader.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestEagerLoader.java Wed Aug 9 23:02:27 2006
@@ -15,10 +15,18 @@
package hivemind.test.services;
import hivemind.test.FrameworkTestCase;
+import hivemind.test.ModuleDefinitionHelper;
+import hivemind.test.services.impl.LoudRunner;
import java.util.ArrayList;
import java.util.List;
+import org.apache.hivemind.Registry;
+import org.apache.hivemind.definition.ModuleDefinition;
+import org.apache.hivemind.definition.ServicePointDefinition;
+import org.apache.hivemind.internal.ConfigurationPoint;
+import org.apache.hivemind.internal.Contribution;
+import org.apache.hivemind.internal.ServiceModel;
import org.apache.hivemind.internal.ServicePoint;
import org.apache.hivemind.service.impl.EagerLoader;
@@ -80,8 +88,32 @@
{
interceptLogging("hivemind.test.services.Loud");
- buildFrameworkRegistry("EagerLoadPooled.xml");
+ createEagerLoadModule(ServiceModel.POOLED);
assertLoggedMessage("Instantiated.");
}
+
+ /**
+ *
+ */
+ private Registry createEagerLoadModule(final String serviceModel)
+ {
+ ModuleDefinition module = createModuleDefinition("hivemind.test.services");
+ ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);
+
+ ServicePointDefinition sp1 = helper.addServicePoint("Loud", Runnable.class.getName());
+ helper.addSimpleServiceImplementation(sp1, LoudRunner.class.getName(), serviceModel);
+
+ // Add service point "Loud" to EagerLoad configuration point
+ helper.addContributionDefinition("hivemind.EagerLoad", new Contribution()
+ {
+ public void contribute(ConfigurationPoint configurationPoint, Object container)
+ {
+ ((List) container).add(configurationPoint.getModule().getServicePoint("hivemind.test.services.Loud"));
+ }
+ });
+
+ return buildFrameworkRegistry(module);
+ }
+
}
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestShutdown.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestShutdown.java?rev=430271&r1=430270&r2=430271&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestShutdown.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestShutdown.java Wed Aug 9 23:02:27 2006
@@ -20,11 +20,9 @@
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.Registry;
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.events.RegistryShutdownListener;
-import org.apache.hivemind.impl.CreateClassServiceConstructor;
import org.apache.hivemind.internal.AbstractServiceImplementationConstructor;
import org.apache.hivemind.internal.Module;
import org.apache.hivemind.internal.ServiceImplementationConstructor;
@@ -155,10 +153,7 @@
*/
private Registry createModuleWithShutdownListener(final String serviceModel)
{
- RegistryDefinition definition = new RegistryDefinition();
-
ModuleDefinition module = createModuleDefinition("module1");
- definition.addModule(module);
ServicePointDefinition sp1 = createServicePointDefinition("Listener", Runnable.class);
@@ -175,8 +170,7 @@
constructor, serviceModel, true);
sp1.addImplementation(impl);
module.addServicePoint(sp1);
- Registry reg = buildFrameworkRegistry(module);
- return reg;
+ return buildFrameworkRegistry(module);
}
}
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/impl/LoudRunner.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/impl/LoudRunner.java?rev=430271&r1=430270&r2=430271&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/impl/LoudRunner.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/impl/LoudRunner.java Wed Aug 9 23:02:27 2006
@@ -15,19 +15,18 @@
package hivemind.test.services.impl;
import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
public class LoudRunner implements Runnable
{
- private Log _log;
-
- public void run()
+ private static final Log _log = LogFactory.getLog("hivemind.test.services.Loud");
+
{
_log.info("Instantiated.");
}
- public void setLog(Log log)
+ public void run()
{
- _log = log;
}
}
Modified: hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml?rev=430271&r1=430270&r2=430271&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml Wed Aug 9 23:02:27 2006
@@ -562,12 +562,7 @@
</invoke-factory>
</service-point>
- <configuration-point id="EagerLoad">
-
- Configuration to which services may be contributed. The corresponding services are instantiated eagerly, as the Registry is started.
- The order in which services are instantiated is not specified.
-
- <schema>
+ <schema id="EagerLoad">
<element name="load">
Identifies a service that will be eagerly loaded.
@@ -579,18 +574,6 @@
</rules>
</element>
</schema>
- </configuration-point>
-
- <service-point id="EagerLoad" interface="java.lang.Runnable">
-
- Service that performs eager loading of other services. This service is contributed into the hivemind.Startup configuration.
-
- <invoke-factory model="primitive">
- <construct class="service.impl.EagerLoader">
- <set-configuration configuration-id="EagerLoad" property="servicePoints"/>
- </construct>
- </invoke-factory>
- </service-point>
<contribution configuration-id="Startup">
<startup object="service:EagerLoad"/>
Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java?rev=430271&r1=430270&r2=430271&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java Wed Aug 9 23:02:27 2006
@@ -194,7 +194,7 @@
ServiceImplementationDefinition implementation = new ServiceImplementationDefinition(
builder.getLocation(), builder.createConstructor(sourceModule.getId()),
builder.getServiceModel(), false);
- _registryDefinition.addServiceImplementation(qualifiedPointId, implementation);
+ sourceModule.addServiceImplementation(qualifiedPointId, implementation);
}
int count = size(interceptors);
@@ -202,7 +202,7 @@
{
InterceptorDescriptor ind = (InterceptorDescriptor) interceptors.get(i);
- addInterceptor(sourceModule.getId(), qualifiedPointId, ind);
+ addInterceptor(sourceModule, qualifiedPointId, ind);
}
}
@@ -235,7 +235,7 @@
{
InterceptorDescriptor id = (InterceptorDescriptor) interceptors.get(i);
String qualifiedId = IdUtils.qualify(module.getId(), pointId);
- addInterceptor(module.getId(), qualifiedId, id);
+ addInterceptor(module, qualifiedId, id);
}
}
@@ -288,26 +288,26 @@
ContributionDefinition contribution = new ContributionDefinition(cd.getLocation(),
new ContributionImpl(moduleId, cd.getElements()));
- _registryDefinition.addContribution(qualifiedId, contribution);
+ module.addContribution(qualifiedId, contribution);
}
}
- private void addInterceptor(String contributingModuleId, String qualifiedPointId, InterceptorDescriptor id)
+ private void addInterceptor(ModuleDefinition module, String qualifiedPointId, InterceptorDescriptor id)
{
if (_log.isDebugEnabled())
_log.debug("Adding " + id + " to service extension point " + qualifiedPointId);
// TODO annotations: generic container for parameter
InvokeFactoryInterceptorConstructor constructor = new InvokeFactoryInterceptorConstructor(id.getLocation(),
- contributingModuleId, id.getName());
+ module.getId(), id.getName());
constructor.setFactoryServiceId(id.getFactoryServiceId());
constructor.setParameters(id.getParameters());
constructor.setPrecedingInterceptorIds(id.getAfter());
constructor.setFollowingInterceptorIds(id.getBefore());
ServiceInterceptorDefinition interceptor = new ServiceInterceptorDefinition(
id.getLocation(), constructor);
- _registryDefinition.addServiceInterceptor(qualifiedPointId, interceptor);
+ module.addServiceInterceptor(qualifiedPointId, interceptor);
}
/**