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/01 22:12:43 UTC
svn commit: r451799 - in /hivemind/branches/branch-2-0-annot:
framework/src/java/org/apache/hivemind/definition/
framework/src/java/org/apache/hivemind/impl/
framework/src/java/org/apache/hivemind/internal/
framework/src/test/hivemind/test/ framework/s...
Author: ahuegen
Date: Sun Oct 1 13:12:41 2006
New Revision: 451799
URL: http://svn.apache.org/viewvc?view=rev&rev=451799
Log:
Added ModuleDefinition to extension point constructors
Modified:
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ExtensionDefinition.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ExtensionPointDefinition.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinitionHelper.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ServicePointDefinition.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/AbstractExtensionPoint.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ExtensionPoint.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/FrameworkTestCase.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestMisc.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestServicesByInterface.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestShutdown.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestInterceptors.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructureConstructor.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestServicePoint.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestVisibility.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/TestLoggingInterceptorFactory.java
hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/parse/TestToString.java
hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/rules/TestServicePointTranslator.java
hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ConfigurationPointDefinition.java Sun Oct 1 13:12:41 2006
@@ -18,15 +18,16 @@
private List _contributions = new ArrayList();
- public ConfigurationPointDefinition()
+ public ConfigurationPointDefinition(ModuleDefinition module)
{
+ super(module);
}
- public ConfigurationPointDefinition(String id, Location location, Visibility visibility,
+ public ConfigurationPointDefinition(ModuleDefinition module, String id, Location location, Visibility visibility,
ConfigurationConstructor constructor, String containerClassName,
Occurances expectedContributions)
{
- super(id, location, visibility);
+ super(module, id, location, visibility);
_constructor = constructor;
_containerClassName = containerClassName;
_expectedContributions = expectedContributions;
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ExtensionDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ExtensionDefinition.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ExtensionDefinition.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ExtensionDefinition.java Sun Oct 1 13:12:41 2006
@@ -14,12 +14,13 @@
public ExtensionDefinition(ModuleDefinition module)
{
+ Defense.notNull(module, "module");
_module = module;
}
public ExtensionDefinition(ModuleDefinition module, Location location)
{
- _module = module;
+ this(module);
_location = location;
}
@@ -28,7 +29,6 @@
*/
public String getModuleId()
{
- Defense.fieldNotNull(_module, "module");
return _module.getId();
}
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ExtensionPointDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ExtensionPointDefinition.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ExtensionPointDefinition.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ExtensionPointDefinition.java Sun Oct 1 13:12:41 2006
@@ -5,9 +5,12 @@
import org.apache.hivemind.Location;
import org.apache.hivemind.internal.Visibility;
+import org.apache.hivemind.util.Defense;
public class ExtensionPointDefinition
{
+ private ModuleDefinition _module;
+
private String _id;
private Location _location;
@@ -16,15 +19,36 @@
private Map _natures = new HashMap();
- public ExtensionPointDefinition()
+ public ExtensionPointDefinition(ModuleDefinition module)
{
+ Defense.notNull(module, "module");
+ _module = module;
}
- public ExtensionPointDefinition(String id, Location location, Visibility visibility)
+ public ExtensionPointDefinition(ModuleDefinition module, String id, Location location, Visibility visibility)
{
+ this(module);
_id = id;
_location = location;
_visibility = visibility;
+ }
+
+ /**
+ * @return the id of the module that defined this extension point
+ */
+ public String getModuleId()
+ {
+ return _module.getId();
+ }
+
+ protected ModuleDefinition getModule()
+ {
+ return _module;
+ }
+
+ public String getFullyQualifiedId()
+ {
+ return getModuleId() + "." + _id;
}
public String getId()
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinitionHelper.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinitionHelper.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinitionHelper.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinitionHelper.java Sun Oct 1 13:12:41 2006
@@ -19,7 +19,7 @@
public ServicePointDefinition addServicePoint(String servicePointId, String serviceInterface)
{
- ServicePointDefinition result = new ServicePointDefinition(servicePointId, _module
+ ServicePointDefinition result = new ServicePointDefinition(_module, servicePointId, _module
.getLocation(), Visibility.PUBLIC, serviceInterface);
_module.addServicePoint(result);
@@ -57,7 +57,7 @@
public ConfigurationPointDefinition addConfigurationPoint(String configurationPointId,
ConfigurationConstructor constructor, String containerType)
{
- ConfigurationPointDefinition result = new ConfigurationPointDefinition(configurationPointId, _module
+ ConfigurationPointDefinition result = new ConfigurationPointDefinition(_module, configurationPointId, _module
.getLocation(), Visibility.PUBLIC, constructor, containerType, Occurances.UNBOUNDED);
_module.addConfigurationPoint(result);
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ServicePointDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ServicePointDefinition.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ServicePointDefinition.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ServicePointDefinition.java Sun Oct 1 13:12:41 2006
@@ -15,13 +15,14 @@
private List _interceptors = new ArrayList();
- public ServicePointDefinition()
+ public ServicePointDefinition(ModuleDefinition module)
{
+ super(module);
}
- public ServicePointDefinition(String id, Location location, Visibility visibility, String interfaceClassName)
+ public ServicePointDefinition(ModuleDefinition module, String id, Location location, Visibility visibility, String interfaceClassName)
{
- super(id, location, visibility);
+ super(module, id, location, visibility);
_interfaceClassName = interfaceClassName;
}
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/AbstractExtensionPoint.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/AbstractExtensionPoint.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/AbstractExtensionPoint.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/AbstractExtensionPoint.java Sun Oct 1 13:12:41 2006
@@ -14,12 +14,11 @@
package org.apache.hivemind.impl;
-import java.util.HashMap;
-import java.util.Map;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hivemind.ErrorLog;
+import org.apache.hivemind.Location;
+import org.apache.hivemind.definition.ExtensionPointDefinition;
import org.apache.hivemind.internal.ExtensionPoint;
import org.apache.hivemind.internal.Module;
import org.apache.hivemind.internal.Visibility;
@@ -35,24 +34,28 @@
*/
public abstract class AbstractExtensionPoint extends BaseLocatable implements ExtensionPoint
{
- private Module _module;
+ private ExtensionPointDefinition _definition;
- private String _extensionPointId;
-
- /** @since 1.1 */
- private Visibility _visibility;
+ private Module _module;
/** @since 1.1 */
private ErrorLog _errorLog;
- private Map _natures = new HashMap();
-
+ /**
+ * @param definition the definition of this extension point
+ */
+ public AbstractExtensionPoint(Module module, ExtensionPointDefinition definition)
+ {
+ _module = module;
+ _definition = definition;
+ }
+
public synchronized String toString()
{
ToStringBuilder builder = new ToStringBuilder(this);
- builder.append("extensionPointId", _extensionPointId);
- builder.append("visibility", _visibility);
+ builder.append("extensionPointId", getExtensionPointId());
+ builder.append("visibility", getVisibility());
extendDescription(builder);
@@ -64,19 +67,19 @@
*/
protected abstract void extendDescription(ToStringBuilder builder);
- public void setExtensionPointId(String extensionPointId)
+ public Visibility getVisibility()
{
- _extensionPointId = extensionPointId;
+ return _definition.getVisibility();
}
-
- public String getExtensionPointId()
+
+ public Location getLocation()
{
- return _extensionPointId;
+ return _definition.getLocation();
}
-
- public void setModule(Module module)
+
+ public String getExtensionPointId()
{
- _module = module;
+ return _module.getModuleId() + "." + _definition.getId();
}
public Module getModule()
@@ -85,14 +88,6 @@
}
/**
- * @since 1.1
- */
- public void setVisibility(Visibility visibility)
- {
- _visibility = visibility;
- }
-
- /**
* Returns true if the extension point is public, or the extgension point is visible to the
* module.
*
@@ -103,7 +98,7 @@
*/
public boolean visibleToModule(Module module)
{
- if (_visibility == Visibility.PUBLIC)
+ if (getVisibility() == Visibility.PUBLIC)
return true;
return _module.equals(module);
@@ -124,20 +119,15 @@
return _errorLog;
}
- /**
- * @see org.apache.hivemind.internal.ExtensionPoint#getNature(java.lang.Class)
- */
public Object getNature(Class natureType)
{
- return _natures.get(natureType);
+ return _definition.getNature(natureType);
}
- /**
- * @see org.apache.hivemind.internal.ExtensionPoint#addNature(java.lang.Class, java.lang.Object)
- */
- public void addNature(Class natureType, Object nature)
+ protected ExtensionPointDefinition getDefinition()
{
- _natures.put(natureType, nature);
- }
+ return _definition;
+ }
+
}
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java Sun Oct 1 13:12:41 2006
@@ -16,7 +16,6 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
-import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
@@ -25,11 +24,13 @@
import org.apache.hivemind.HiveMind;
import org.apache.hivemind.Occurances;
import org.apache.hivemind.ShutdownCoordinator;
+import org.apache.hivemind.definition.ConfigurationPointDefinition;
import org.apache.hivemind.definition.ContributionDefinition;
import org.apache.hivemind.impl.servicemodel.SingletonInnerProxy;
import org.apache.hivemind.internal.ConfigurationConstructor;
import org.apache.hivemind.internal.ConfigurationPoint;
import org.apache.hivemind.internal.Contribution;
+import org.apache.hivemind.internal.Module;
import org.apache.hivemind.service.BodyBuilder;
import org.apache.hivemind.service.ClassFab;
import org.apache.hivemind.service.InterfaceSynthesizer;
@@ -62,15 +63,26 @@
private ShutdownCoordinator _shutdownCoordinator;
- private ConfigurationConstructor _constructor;
-
- private String _containerClassName;
+ public ConfigurationPointImpl(Module module, ConfigurationPointDefinition definition)
+ {
+ super(module, definition);
+ }
+ public ConfigurationPointDefinition getConfigurationPointDefinition()
+ {
+ return (ConfigurationPointDefinition) super.getDefinition();
+ }
+
protected void extendDescription(ToStringBuilder builder)
{
builder.append("expectedCount", _expectedCount);
builder.append("contributions", _contributions);
}
+
+ public List getContributions()
+ {
+ return getConfigurationPointDefinition().getContributions();
+ }
/**
* Returns the number of contributions; it is expected that each top-level
@@ -80,30 +92,17 @@
*/
public int getContributionCount()
{
- if (_contributions == null)
+ if (getConfigurationPointDefinition() == null)
return 0;
- return _contributions.size();
- }
-
- public void addContribution(ContributionDefinition cd)
- {
- if (_contributions == null)
- _contributions = new ArrayList();
-
- _contributions.add(cd);
+ return getContributions().size();
}
public Occurances getExpectedCount()
{
- return _expectedCount;
+ return getConfigurationPointDefinition().getExpectedContributions();
}
- public void setExpectedCount(Occurances occurances)
- {
- _expectedCount = occurances;
- }
-
public boolean isLazy()
{
// TODO annotations: make configurable
@@ -183,6 +182,8 @@
if (LOG.isDebugEnabled())
LOG.debug("Constructing extension point " + getExtensionPointId());
+ List _contributions = getContributions();
+
int count = 0;
if (_contributions != null)
count = _contributions.size();
@@ -212,12 +213,12 @@
private Class lookupContainerClass()
{
- return getModule().resolveType(_containerClassName);
+ return getModule().resolveType(getContainerClassName());
}
private Object createContainerInstance()
{
- Object container = _constructor.constructConfigurationContainer(getModule());
+ Object container = getConfigurationConstructor().constructConfigurationContainer(getModule());
if (container == null)
// TODO annotations: i18n message
throw new ApplicationRuntimeException("configuration container is null");
@@ -237,12 +238,7 @@
public String getContainerClassName()
{
- return _containerClassName;
- }
-
- public void setContainerClassName(String containerClassName)
- {
- _containerClassName = containerClassName;
+ return getConfigurationPointDefinition().getContainerClassName();
}
/**
@@ -255,14 +251,9 @@
public ConfigurationConstructor getConfigurationConstructor()
{
- return _constructor;
+ return getConfigurationPointDefinition().getConstructor();
}
- public void setConfigurationConstructor(ConfigurationConstructor constructor)
- {
- _constructor = constructor;
- }
-
/**
* @return the interface of the configuration container. if the container class is an
* interface already it's returned instantly. If it is a pojo, then an interface
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java Sun Oct 1 13:12:41 2006
@@ -158,18 +158,7 @@
// whether the service is create-on-first-reference
// or create-on-first-use (deferred).
- ServicePointImpl point = new ServicePointImpl();
-
- point.setDefinition(sd);
- point.setExtensionPointId(pointId);
- point.setModule(module);
-
- // Copy natures from definition to point
- for (Iterator natures = sd.getNatures().entrySet().iterator(); natures.hasNext();)
- {
- Map.Entry natureEntry = (Entry) natures.next();
- point.addNature((Class) natureEntry.getKey(), natureEntry.getValue());
- }
+ ServicePointImpl point = new ServicePointImpl(module, sd);
point.setShutdownCoordinator(_shutdownCoordinator);
@@ -192,22 +181,7 @@
if (_log.isDebugEnabled())
_log.debug("Creating configuration point " + pointId);
- ConfigurationPointImpl point = new ConfigurationPointImpl();
-
- point.setExtensionPointId(pointId);
- point.setLocation(cpd.getLocation());
- point.setModule(module);
- point.setExpectedCount(cpd.getExpectedContributions());
- point.setVisibility(cpd.getVisibility());
- point.setConfigurationConstructor(cpd.getConstructor());
- point.setContainerClassName(cpd.getContainerClassName());
-
- // Copy natures from definition to point
- for (Iterator natures = cpd.getNatures().entrySet().iterator(); natures.hasNext();)
- {
- Map.Entry natureEntry = (Entry) natures.next();
- point.addNature((Class) natureEntry.getKey(), natureEntry.getValue());
- }
+ ConfigurationPointImpl point = new ConfigurationPointImpl(module, cpd);
point.setShutdownCoordinator(_shutdownCoordinator);
@@ -239,7 +213,6 @@
return;
}
- point.setDefinition(sd);
}
}
@@ -254,6 +227,7 @@
// String sourceModuleId = sourceModule.getModuleId();
+ // TODO annotations: move error handling to configuration point definition
if (!point.visibleToModule(sourceModule))
{
_errorHandler.error(_log, ImplMessages.configurationNotVisible(point.getExtensionPointId(), sourceModule), cpd
@@ -261,7 +235,6 @@
return;
}
- point.addContribution(cd);
}
}
@@ -279,14 +252,14 @@
// String sourceModuleId = sourceModule.getModuleId();
+ // TODO annotations: move error handling to service point definition
if (!point.visibleToModule(sourceModule))
{
_errorHandler.error(_log, ImplMessages.servicePointNotVisible(point, sourceModule), id
.getLocation(), null);
- return;
+ continue;
}
- point.addInterceptor(id);
}
}
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java Sun Oct 1 13:12:41 2006
@@ -14,7 +14,6 @@
package org.apache.hivemind.impl;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -28,6 +27,7 @@
import org.apache.hivemind.definition.ServiceInterceptorDefinition;
import org.apache.hivemind.definition.ServicePointDefinition;
import org.apache.hivemind.events.RegistryShutdownListener;
+import org.apache.hivemind.internal.Module;
import org.apache.hivemind.internal.ServiceImplementationConstructor;
import org.apache.hivemind.internal.ServiceModel;
import org.apache.hivemind.internal.ServiceModelFactory;
@@ -53,18 +53,18 @@
private Class _declaredInterface;
- private List _interceptorDefinitions;
+ private List _orderedInterceptorDefinitions;
private boolean _interceptorsOrdered;
- /**
- * The service point definition that describes this service point
- */
- private ServicePointDefinition _definition;
-
private ShutdownCoordinator _shutdownCoordinator;
private ServiceModel _serviceModelObject;
+
+ public ServicePointImpl(Module module, ServicePointDefinition definition)
+ {
+ super(module, definition);
+ }
protected void extendDescription(ToStringBuilder builder)
{
@@ -73,21 +73,13 @@
builder.append("serviceInterfaceName", getServiceInterfaceClassName());
builder.append("serviceConstructor", getServiceConstructor());
- builder.append("interceptorDefinitions", _interceptorDefinitions);
+ builder.append("interceptorDefinitions", getInterceptorDefinitions());
builder.append("serviceModel", getServiceModel());
if (_building)
builder.append("building", _building);
}
- public void addInterceptor(ServiceInterceptorDefinition definition)
- {
- if (_interceptorDefinitions == null)
- _interceptorDefinitions = new ArrayList();
-
- _interceptorDefinitions.add(definition);
- }
-
public synchronized Class getServiceInterface()
{
if (_serviceInterface == null)
@@ -108,10 +100,20 @@
public String getServiceInterfaceClassName()
{
- if (_definition == null)
+ // TODO: For toString tests. Remove?
+ if (getServicePointDefinition() == null)
return null;
- return _definition.getInterfaceClassName();
+ return getServicePointDefinition().getInterfaceClassName();
+ }
+
+ private Object getInterceptorDefinitions()
+ {
+ // TODO: For toString tests. Remove?
+ if (getServicePointDefinition() == null)
+ return null;
+
+ return getServicePointDefinition().getInterceptors();
}
private Class lookupDeclaredInterface()
@@ -199,7 +201,7 @@
public String getServiceModel()
{
- if (_definition == null)
+ if (getServicePointDefinition() == null)
return null;
return getImplementationDefinition().getServiceModel();
@@ -207,7 +209,7 @@
public void clearConstructorInformation()
{
- _interceptorDefinitions = null;
+ _orderedInterceptorDefinitions = null;
}
// Hm. Does this need to be synchronized?
@@ -219,11 +221,11 @@
{
if (!_interceptorsOrdered)
{
- _interceptorDefinitions = orderInterceptors();
+ _orderedInterceptorDefinitions = orderInterceptors();
_interceptorsOrdered = true;
}
- return _interceptorDefinitions;
+ return _orderedInterceptorDefinitions;
}
/**
@@ -231,7 +233,8 @@
*/
private List orderInterceptors()
{
- if (HiveMind.isEmpty(_interceptorDefinitions))
+ List interceptorDefinitions = getServicePointDefinition().getInterceptors();
+ if (HiveMind.isEmpty(interceptorDefinitions))
return null;
// Any error logging should go to the extension point
@@ -242,7 +245,7 @@
Orderer orderer = new Orderer(log, getModule().getErrorHandler(), ImplMessages
.interceptorContribution());
- Iterator i = _interceptorDefinitions.iterator();
+ Iterator i = interceptorDefinitions.iterator();
while (i.hasNext())
{
ServiceInterceptorDefinition sid = (ServiceInterceptorDefinition) i.next();
@@ -292,7 +295,8 @@
public ServiceImplementationConstructor getServiceConstructor()
{
- if (_definition == null)
+ // TODO: For toString tests. Remove?
+ if (getServicePointDefinition() == null)
return null;
return getImplementationDefinition().getServiceConstructor();
@@ -300,25 +304,16 @@
public ServiceImplementationDefinition getImplementationDefinition()
{
- return _definition.getDefaultImplementation();
+ return getServicePointDefinition().getDefaultImplementation();
}
/**
* @return the service point definition that describes this service point
*/
- public ServicePointDefinition getDefinition()
+ public ServicePointDefinition getServicePointDefinition()
{
- return _definition;
+ return (ServicePointDefinition) super.getDefinition();
}
- /**
- * Sets the service point definition that describes this service point
- * @param definition
- */
- public void setDefinition(ServicePointDefinition definition)
- {
- _definition = definition;
- setLocation(_definition.getLocation());
- setVisibility(_definition.getVisibility());
- }
+
}
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ExtensionPoint.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ExtensionPoint.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ExtensionPoint.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ExtensionPoint.java Sun Oct 1 13:12:41 2006
@@ -17,6 +17,7 @@
import org.apache.commons.logging.Log;
import org.apache.hivemind.ErrorLog;
import org.apache.hivemind.Locatable;
+import org.apache.hivemind.definition.ExtensionDefinition;
/**
* Base interface for service and configuration extension points.
@@ -62,14 +63,7 @@
public ErrorLog getErrorLog();
/**
- * Adds a new nature to the extension point (comparable to an eclipse project nature).
- * A nature is a decorator class which can store additional information and offer
- * specific functionality.
- */
- public void addNature(Class natureType, Object nature);
-
- /**
- * Retrieves a nature that has been added by {@link #addNature(Class, Object)}
+ * Retrieves a nature that has been added to the definition by {@link ExtensionDefinition#addNature(Class, Object)}
*/
public Object getNature(Class natureType);
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/FrameworkTestCase.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/FrameworkTestCase.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/FrameworkTestCase.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/FrameworkTestCase.java Sun Oct 1 13:12:41 2006
@@ -72,9 +72,9 @@
/**
* Convenience method for creating a {@link ServicePointDefinition}.
*/
- protected ServicePointDefinition createServicePointDefinition(String pointId, Class serviceInterface)
+ protected ServicePointDefinition createServicePointDefinition(ModuleDefinition module, String pointId, Class serviceInterface)
{
- ServicePointDefinition result = new ServicePointDefinition(pointId,
+ ServicePointDefinition result = new ServicePointDefinition(module, pointId,
newLocation(), Visibility.PUBLIC, serviceInterface.getName());
return result;
@@ -95,9 +95,9 @@
/**
* Convenience method for creating a {@link ConfigurationPointDefinition}.
*/
- protected ConfigurationPointDefinition createConfigurationPointDefinition(String pointId)
+ protected ConfigurationPointDefinition createConfigurationPointDefinition(ModuleDefinition module, String pointId)
{
- ConfigurationPointDefinition result = new ConfigurationPointDefinition(pointId,
+ ConfigurationPointDefinition result = new ConfigurationPointDefinition(module, pointId,
newLocation(), Visibility.PUBLIC, null, ArrayList.class.getName(),
Occurances.UNBOUNDED);
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestMisc.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestMisc.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestMisc.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestMisc.java Sun Oct 1 13:12:41 2006
@@ -73,10 +73,10 @@
public void testCreateClassServiceConstructorTwice()
{
- ServicePoint sp = new ServicePointImpl();
-
Module m = newModule();
+ ServicePoint sp = new ServicePointImpl(m, null);
+
replayControls();
CreateClassServiceConstructor c = new CreateClassServiceConstructor(newLocation(),
@@ -97,8 +97,8 @@
{
Module m = newModule();
- ServicePoint sp = new ServicePointImpl();
-
+ ServicePoint sp = new ServicePointImpl(m, null);
+
CreateClassServiceConstructor c = new CreateClassServiceConstructor(newLocation(),
SimpleBean.class.getName() + ",value=HiveMind");
@@ -111,7 +111,7 @@
{
Module m = newModule();
- ServicePoint sp = new ServicePointImpl();
+ ServicePoint sp = new ServicePointImpl(m, null);
CreateClassServiceConstructor c = new CreateClassServiceConstructor(newLocation(),
PrivateBean.class.getName());
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java Sun Oct 1 13:12:41 2006
@@ -60,20 +60,20 @@
{
ModuleDefinition testModule = createModuleDefinition("hivemind.test");
- testModule.addServicePoint(createServicePointDefinition("MyService", Comparable.class));
+ testModule.addServicePoint(createServicePointDefinition(testModule, "MyService", Comparable.class));
try
{
- testModule.addServicePoint(createServicePointDefinition("MyService", Comparable.class));
+ testModule.addServicePoint(createServicePointDefinition(testModule, "MyService", Comparable.class));
fail("duplicate service point not detected");
}
catch (ApplicationRuntimeException expected)
{
}
- testModule.addConfigurationPoint(createConfigurationPointDefinition("MyConfig"));
+ testModule.addConfigurationPoint(createConfigurationPointDefinition(testModule, "MyConfig"));
try
{
- testModule.addConfigurationPoint(createConfigurationPointDefinition("MyConfig"));
+ testModule.addConfigurationPoint(createConfigurationPointDefinition(testModule, "MyConfig"));
fail("duplicate configuration point not detected");
}
catch (ApplicationRuntimeException expected)
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestServicesByInterface.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestServicesByInterface.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestServicesByInterface.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestServicesByInterface.java Sun Oct 1 13:12:41 2006
@@ -35,19 +35,19 @@
ModuleDefinition module = createModuleDefinition("hivemind.tests.serviceByInterface");
- ServicePointDefinition sp1 = createServicePointDefinition("uniqueService", IUniqueService.class);
+ ServicePointDefinition sp1 = createServicePointDefinition(module, "uniqueService", IUniqueService.class);
ServiceImplementationDefinition impl1 = createServiceImplementationDefinition(module, UniqueServiceImpl.class);
sp1.addImplementation(impl1);
module.addServicePoint(sp1);
- ServicePointDefinition sp2 = createServicePointDefinition("multipleServiceOne", IMultipleService.class);
+ ServicePointDefinition sp2 = createServicePointDefinition(module, "multipleServiceOne", IMultipleService.class);
ServiceImplementationDefinition impl2 = createServiceImplementationDefinition(module, MultipleServiceImpl.class);
sp2.addImplementation(impl2);
module.addServicePoint(sp2);
- ServicePointDefinition sp3 = createServicePointDefinition("multipleServiceTwo", IMultipleService.class);
+ ServicePointDefinition sp3 = createServicePointDefinition(module, "multipleServiceTwo", IMultipleService.class);
sp3.addImplementation(impl2);
module.addServicePoint(sp3);
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?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- 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 Sun Oct 1 13:12:41 2006
@@ -155,7 +155,7 @@
{
ModuleDefinition module = createModuleDefinition("module1");
- ServicePointDefinition sp1 = createServicePointDefinition("Listener", Runnable.class);
+ ServicePointDefinition sp1 = createServicePointDefinition(module, "Listener", Runnable.class);
ServiceImplementationConstructor constructor = new AbstractServiceImplementationConstructor(newLocation()) {
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestInterceptors.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestInterceptors.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestInterceptors.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestInterceptors.java Sun Oct 1 13:12:41 2006
@@ -46,13 +46,10 @@
return result;
}
- private ServicePointImpl newServicePoint(Location l, Module module)
+ private ServicePointImpl newServicePoint(ModuleDefinition moduleDefinition, Location l, Module module)
{
- ServicePointImpl sp = new ServicePointImpl();
- ServicePointDefinition definition = new ServicePointDefinition("zip.zap", l, Visibility.PUBLIC, "foo.bar.Baz");
- sp.setDefinition(definition);
- sp.setModule(module);
- sp.setExtensionPointId("zip.zap");
+ ServicePointDefinition definition = new ServicePointDefinition(moduleDefinition, "zip.zap", l, Visibility.PUBLIC, "foo.bar.Baz");
+ ServicePointImpl sp = new ServicePointImpl(module, definition);
return sp;
}
@@ -63,16 +60,16 @@
replayControls();
- ServicePointImpl sp = newServicePoint(l, module);
-
ModuleDefinition moduleDef = createModuleDefinition("module");
+ ServicePointImpl sp = newServicePoint(moduleDef, l, module);
+
ServiceInterceptorDefinition interceptor1 = new OrderedServiceInterceptorDefinition(moduleDef, "Interceptor1", null, null,
null, null);
- sp.addInterceptor(interceptor1);
+ sp.getServicePointDefinition().addInterceptor(interceptor1);
ServiceInterceptorDefinition interceptor2 = new OrderedServiceInterceptorDefinition(moduleDef, "Interceptor2", null, null,
null, null);
- sp.addInterceptor(interceptor2);
- sp.setExtensionPointId("ExtensionPointId");
+ sp.getServicePointDefinition().addInterceptor(interceptor2);
+// sp.getServicePointDefinition()setExtensionPointId("ExtensionPointId");
final List ordered = sp.getOrderedInterceptorContributions();
assertNotNull(ordered);
assertEquals(2, ordered.size());
@@ -88,16 +85,15 @@
replayControls();
- ServicePointImpl sp = newServicePoint(l, module);
-
ModuleDefinition moduleDef = createModuleDefinition("module");
+ ServicePointImpl sp = newServicePoint(moduleDef, l, module);
+
ServiceInterceptorDefinition interceptor1 = new OrderedServiceInterceptorDefinition(moduleDef, "Interceptor1", null, null,
null, null);
- sp.addInterceptor(interceptor1);
+ sp.getServicePointDefinition().addInterceptor(interceptor1);
ServiceInterceptorDefinition interceptor2 = new OrderedServiceInterceptorDefinition(moduleDef, "Interceptor2", null, null,
null, "Interceptor1");
- sp.addInterceptor(interceptor2);
- sp.setExtensionPointId("ExtensionPointId");
+ sp.getServicePointDefinition().addInterceptor(interceptor2);
final List ordered = sp.getOrderedInterceptorContributions();
assertNotNull(ordered);
assertEquals(2, ordered.size());
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java Sun Oct 1 13:12:41 2006
@@ -14,14 +14,16 @@
package org.apache.hivemind.impl;
import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.definition.ModuleDefinition;
import org.apache.hivemind.definition.ServicePointDefinition;
import org.apache.hivemind.internal.ConfigurationPoint;
import org.apache.hivemind.internal.RegistryInfrastructure;
import org.apache.hivemind.internal.ServicePoint;
import org.apache.hivemind.internal.Visibility;
-import org.apache.hivemind.test.HiveMindTestCase;
import org.easymock.MockControl;
+import hivemind.test.FrameworkTestCase;
+
import java.sql.ResultSet;
import java.util.Arrays;
import java.util.Collections;
@@ -36,7 +38,7 @@
* @author Howard Lewis Ship
* @since 1.1
*/
-public class TestRegistryInfrastructure extends HiveMindTestCase
+public class TestRegistryInfrastructure extends FrameworkTestCase
{
public void testGetMissingExtensionPoint()
{
@@ -55,9 +57,10 @@
public void testGetUnqualifiedServicePoint()
{
RegistryInfrastructureImpl r = new RegistryInfrastructureImpl( null, null );
+ ModuleDefinition moduleDefinition = createModuleDefinition("module1");
final ModuleImpl module1 = new ModuleImpl();
module1.setModuleId( "module1" );
- r.addServicePoint( createServicePoint( module1, "module1.foo", ResultSet.class, Visibility.PUBLIC ) );
+ r.addServicePoint( createServicePoint(moduleDefinition, module1, "foo", ResultSet.class, Visibility.PUBLIC ) );
try
{
r.getServicePoint( "foo", null );
@@ -69,7 +72,7 @@
}
final ModuleImpl module2 = new ModuleImpl();
module2.setModuleId( "module2" );
- r.addServicePoint( createServicePoint( module2, "module2.foo", ResultSet.class, Visibility.PUBLIC ) );
+ r.addServicePoint( createServicePoint(moduleDefinition, module2, "foo", ResultSet.class, Visibility.PUBLIC ) );
try
{
r.getServicePoint( "foo", null );
@@ -93,23 +96,25 @@
{
RegistryInfrastructureImpl r = new RegistryInfrastructureImpl( null, null );
final ModuleImpl module1 = new ModuleImpl();
+ ModuleDefinition moduleDefinition = createModuleDefinition("module1");
module1.setClassResolver( new DefaultClassResolver() );
module1.setModuleId( "module1" );
- r.addServicePoint( createServicePoint( module1, "module1.foo", "com.evilsite.some.bogus.package.SomeBogusInterface.", Visibility.PUBLIC ) );
+ r.addServicePoint( createServicePoint(moduleDefinition, module1, "module1.foo", "com.evilsite.some.bogus.package.SomeBogusInterface.", Visibility.PUBLIC ) );
assertEquals( new HashSet(), new HashSet( r.getServiceIds( ResultSet.class ) ) );
}
public void testGetServiceIds()
{
RegistryInfrastructureImpl r = new RegistryInfrastructureImpl( null, null );
+ ModuleDefinition moduleDefinition = createModuleDefinition("module1");
assertTrue( r.getServiceIds( ResultSet.class ).isEmpty() );
final ModuleImpl module1 = new ModuleImpl();
module1.setClassResolver( new DefaultClassResolver() );
module1.setModuleId( "module1" );
- r.addServicePoint( createServicePoint( module1, "module1.foo", ResultSet.class, Visibility.PUBLIC ) );
- r.addServicePoint( createServicePoint( module1, "module1.bar", ResultSet.class, Visibility.PUBLIC ) );
- r.addServicePoint( createServicePoint( module1, "module1.baz", ResultSet.class, Visibility.PRIVATE ) );
- r.addServicePoint( createServicePoint( module1, "module1.string", String.class, Visibility.PUBLIC ) );
+ r.addServicePoint( createServicePoint(moduleDefinition, module1, "foo", ResultSet.class, Visibility.PUBLIC ) );
+ r.addServicePoint( createServicePoint(moduleDefinition, module1, "bar", ResultSet.class, Visibility.PUBLIC ) );
+ r.addServicePoint( createServicePoint(moduleDefinition, module1, "baz", ResultSet.class, Visibility.PRIVATE ) );
+ r.addServicePoint( createServicePoint(moduleDefinition, module1, "string", String.class, Visibility.PUBLIC ) );
assertEquals( new HashSet( Arrays.asList( new String[]{"module1.foo", "module1.bar"} ) ), new HashSet( r.getServiceIds( ResultSet.class ) ) );
assertEquals( new HashSet( Arrays.asList( new String[]{"module1.string"} ) ), new HashSet( r.getServiceIds( String.class ) ) );
List serviceIds = r.getServiceIds( null );
@@ -118,23 +123,17 @@
}
- private ServicePointImpl createServicePoint( final ModuleImpl module, String id, Class serviceInterface, Visibility visibility )
+ private ServicePointImpl createServicePoint(ModuleDefinition moduleDefinition, final ModuleImpl module, String id, Class serviceInterface, Visibility visibility)
{
- final ServicePointImpl servicePoint2 = new ServicePointImpl();
- ServicePointDefinition definition = new ServicePointDefinition(id, newLocation(), visibility, serviceInterface.getName());
- servicePoint2.setDefinition(definition);
- servicePoint2.setModule( module );
- servicePoint2.setExtensionPointId( id );
+ ServicePointDefinition definition = new ServicePointDefinition(moduleDefinition, id, newLocation(), visibility, serviceInterface.getName());
+ final ServicePointImpl servicePoint2 = new ServicePointImpl(module, definition);
return servicePoint2;
}
- private ServicePointImpl createServicePoint( final ModuleImpl module, String id, String serviceInterfaceName, Visibility visibility )
+ private ServicePointImpl createServicePoint(ModuleDefinition moduleDefinition, final ModuleImpl module, String id, String serviceInterfaceName, Visibility visibility )
{
- final ServicePointImpl servicePoint2 = new ServicePointImpl();
- ServicePointDefinition definition = new ServicePointDefinition(id, newLocation(), visibility, serviceInterfaceName);
- servicePoint2.setDefinition(definition);
- servicePoint2.setModule( module );
- servicePoint2.setExtensionPointId( id );
+ ServicePointDefinition definition = new ServicePointDefinition(moduleDefinition, id, newLocation(), visibility, serviceInterfaceName);
+ final ServicePointImpl servicePoint2 = new ServicePointImpl(module, definition);
return servicePoint2;
}
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructureConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructureConstructor.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructureConstructor.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructureConstructor.java Sun Oct 1 13:12:41 2006
@@ -41,13 +41,13 @@
ModuleDefinition fooBar = createModuleDefinition("foo.bar");
- ServicePointDefinition spd = createServicePointDefinition("sp1", Runnable.class);
+ ServicePointDefinition spd = createServicePointDefinition(fooBar, "sp1", Runnable.class);
fooBar.addServicePoint(spd);
ModuleDefinition zipZoop = createModuleDefinition("zip.zoop");
- ConfigurationPointDefinition cpd = createConfigurationPointDefinition("cp1");
+ ConfigurationPointDefinition cpd = createConfigurationPointDefinition(fooBar, "cp1");
zipZoop.addConfigurationPoint(cpd);
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestServicePoint.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestServicePoint.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestServicePoint.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestServicePoint.java Sun Oct 1 13:12:41 2006
@@ -30,7 +30,6 @@
import org.apache.hivemind.internal.ServiceModel;
import org.apache.hivemind.internal.ServiceModelFactory;
import org.apache.hivemind.internal.Visibility;
-import org.apache.hivemind.test.HiveMindTestCase;
import org.easymock.MockControl;
/**
@@ -45,7 +44,7 @@
private Module newModule()
{
ModuleImpl result = new ModuleImpl();
-
+ result.setModuleId("test");
result.setClassResolver(getClassResolver());
result.setPackageName("");
result.setRegistry(new RegistryInfrastructureImpl(new StrictErrorHandler(), Locale
@@ -60,11 +59,9 @@
replayControls();
- ServicePointImpl sp = new ServicePointImpl();
- ServicePointDefinition definition = new ServicePointDefinition("zip.zap", l, Visibility.PUBLIC, "foo.bar.Baz");
- sp.setDefinition(definition);
- sp.setModule(module);
- sp.setExtensionPointId("zip.zap");
+ ModuleDefinition moduleDefinition = createModuleDefinition("module");
+ ServicePointDefinition definition = new ServicePointDefinition(moduleDefinition, "zip.zap", l, Visibility.PUBLIC, "foo.bar.Baz");
+ ServicePointImpl sp = new ServicePointImpl(module, definition);
try
{
@@ -73,7 +70,7 @@
}
catch (ApplicationRuntimeException ex)
{
- assertEquals("Unable to find interface foo.bar.Baz (for service zip.zap).", ex
+ assertEquals("Unable to find interface foo.bar.Baz (for service test.zip.zap).", ex
.getMessage());
assertSame(l, ex.getLocation());
}
@@ -84,11 +81,15 @@
public void testResultNotAssignableToServiceInterface()
{
Location l = newLocation();
- ServicePointImpl sp = new ServicePointImpl();
MockControl modulec = newControl(Module.class);
Module module = (Module) modulec.getMock();
+ ModuleDefinition moduleDef = createModuleDefinition("foo");
+ ServicePointDefinition definition = new ServicePointDefinition(moduleDef, "bar", l, Visibility.PUBLIC, "java.util.List");
+ definition.addImplementation(new ServiceImplementationDefinition(moduleDef, l, null, "fred", true));
+ ServicePointImpl sp = new ServicePointImpl(module, definition);
+
Object service = new ArrayList();
MockControl factoryc = newControl(ServiceModelFactory.class);
@@ -106,19 +107,14 @@
model.getService();
modelc.setReturnValue(service);
+ module.getModuleId();
+ modulec.setReturnValue("test");
+
module.resolveType("java.util.List");
modulec.setReturnValue(List.class);
replayControls();
- sp.setExtensionPointId("foo.bar");
- sp.setModule(module);
-
- ModuleDefinition moduleDef = createModuleDefinition("foo");
- ServicePointDefinition definition = new ServicePointDefinition("bar", l, Visibility.PUBLIC, "java.util.List");
- definition.addImplementation(new ServiceImplementationDefinition(moduleDef, l, null, "fred", true));
- sp.setDefinition(definition);
-
try
{
sp.getService(Map.class);
@@ -127,7 +123,7 @@
catch (ApplicationRuntimeException ex)
{
assertEquals(
- "Service foo.bar does not implement the requested interface (java.util.Map). The declared service interface type is java.util.List.",
+ "Service test.bar does not implement the requested interface (java.util.Map). The declared service interface type is java.util.List.",
ex.getMessage());
assertSame(l, ex.getLocation());
}
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestVisibility.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestVisibility.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestVisibility.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestVisibility.java Sun Oct 1 13:12:41 2006
@@ -14,15 +14,17 @@
package org.apache.hivemind.impl;
+import hivemind.test.FrameworkTestCase;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.definition.ConfigurationPointDefinition;
import org.apache.hivemind.internal.ConfigurationPoint;
import org.apache.hivemind.internal.Module;
import org.apache.hivemind.internal.ServicePoint;
import org.apache.hivemind.internal.Visibility;
import org.apache.hivemind.service.ClassFactory;
-import org.apache.hivemind.test.HiveMindTestCase;
import org.easymock.MockControl;
/**
@@ -30,7 +32,7 @@
*
* @since 1.1
*/
-public class TestVisibility extends HiveMindTestCase
+public class TestVisibility extends FrameworkTestCase
{
private static final Log LOG = LogFactory.getLog(TestVisibility.class);
@@ -42,9 +44,9 @@
replayControls();
- ConfigurationPointImpl cp = new ConfigurationPointImpl();
- cp.setModule(m);
- cp.setVisibility(Visibility.PUBLIC);
+ ConfigurationPointDefinition cpd = new ConfigurationPointDefinition(createModuleDefinition("module"));
+ cpd.setVisibility(Visibility.PUBLIC);
+ ConfigurationPointImpl cp = new ConfigurationPointImpl(m, cpd);
assertEquals(true, cp.visibleToModule(om));
@@ -57,9 +59,9 @@
replayControls();
- ConfigurationPointImpl cp = new ConfigurationPointImpl();
- cp.setModule(m);
- cp.setVisibility(Visibility.PUBLIC);
+ ConfigurationPointDefinition cpd = new ConfigurationPointDefinition(createModuleDefinition("module"));
+ cpd.setVisibility(Visibility.PUBLIC);
+ ConfigurationPointImpl cp = new ConfigurationPointImpl(m, cpd);
assertEquals(true, cp.visibleToModule(null));
@@ -73,9 +75,9 @@
replayControls();
- ConfigurationPointImpl cp = new ConfigurationPointImpl();
- cp.setModule(m);
- cp.setVisibility(Visibility.PRIVATE);
+ ConfigurationPointDefinition cpd = new ConfigurationPointDefinition(createModuleDefinition("module"));
+ cpd.setVisibility(Visibility.PRIVATE);
+ ConfigurationPointImpl cp = new ConfigurationPointImpl(m, cpd);
assertEquals(false, cp.visibleToModule(om));
@@ -88,9 +90,9 @@
replayControls();
- ConfigurationPointImpl cp = new ConfigurationPointImpl();
- cp.setModule(m);
- cp.setVisibility(Visibility.PRIVATE);
+ ConfigurationPointDefinition cpd = new ConfigurationPointDefinition(createModuleDefinition("module"));
+ cpd.setVisibility(Visibility.PRIVATE);
+ ConfigurationPointImpl cp = new ConfigurationPointImpl(m, cpd);
assertEquals(false, cp.visibleToModule(null));
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/TestLoggingInterceptorFactory.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/TestLoggingInterceptorFactory.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/TestLoggingInterceptorFactory.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/TestLoggingInterceptorFactory.java Sun Oct 1 13:12:41 2006
@@ -127,7 +127,7 @@
ModuleDefinition module = createModuleDefinition("hivemind.tests.serviceByInterface");
definition.addModule(module);
- ServicePointDefinition sp1 = createServicePointDefinition("BeanInterface", BeanInterface.class);
+ ServicePointDefinition sp1 = createServicePointDefinition(module, "BeanInterface", BeanInterface.class);
ServiceImplementationDefinition impl = new ServiceImplementationDefinition(module, newLocation(),
constructor, ServiceModel.SINGLETON, true);
sp1.addImplementation(impl);
Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- 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 Sun Oct 1 13:12:41 2006
@@ -143,7 +143,8 @@
for (int i = 0; i < count; i++)
{
ServicePointDescriptor sd = (ServicePointDescriptor) services.get(i);
- ServicePointDefinition servicePoint = new ServicePointDefinition(sd.getId(), sd.getLocation(), sd.getVisibility(), sd.getInterfaceClassName());
+ ServicePointDefinition servicePoint = new ServicePointDefinition(module, sd.getId(), sd.getLocation(),
+ sd.getVisibility(), sd.getInterfaceClassName());
module.addServicePoint(servicePoint);
// Add the xml nature for the storage of the schema
@@ -254,7 +255,7 @@
cpd.getLocation());
ConfigurationPointDefinition configurationPoint = new ConfigurationPointDefinition(
- cpd.getId(), cpd.getLocation(), cpd.getVisibility(),
+ module, cpd.getId(), cpd.getLocation(), cpd.getVisibility(),
constructor, cpd.getContainerClassName(), cpd.getCount());
module.addConfigurationPoint(configurationPoint);
Modified: hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/parse/TestToString.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/parse/TestToString.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/parse/TestToString.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/parse/TestToString.java Sun Oct 1 13:12:41 2006
@@ -19,13 +19,11 @@
import java.util.Locale;
import org.apache.hivemind.impl.AttributeImpl;
-import org.apache.hivemind.impl.ConfigurationPointImpl;
import org.apache.hivemind.impl.DefaultErrorHandler;
import org.apache.hivemind.impl.ElementImpl;
import org.apache.hivemind.impl.InterceptorStackImpl;
import org.apache.hivemind.impl.ModuleImpl;
import org.apache.hivemind.impl.RegistryInfrastructureImpl;
-import org.apache.hivemind.impl.ServicePointImpl;
import org.apache.hivemind.internal.ServicePoint;
import org.apache.hivemind.parse.ConfigurationPointDescriptor;
import org.apache.hivemind.parse.ContributionDescriptor;
@@ -66,10 +64,8 @@
new InterceptorDescriptor().toString();
new ModuleImpl().toString();
new RegistryInfrastructureImpl(null, Locale.ENGLISH).toString();
- new ConfigurationPointImpl().toString();
new ElementImpl().toString();
new AttributeImpl("foo", "bar").toString();
- new ServicePointImpl().toString();
new InterceptorStackImpl(null, mockServicePoint, null).toString();
}
}
Modified: hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/rules/TestServicePointTranslator.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/rules/TestServicePointTranslator.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/rules/TestServicePointTranslator.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/rules/TestServicePointTranslator.java Sun Oct 1 13:12:41 2006
@@ -34,7 +34,7 @@
MockControl control = newControl(Module.class);
Module m = (Module) control.getMock();
- ServicePoint sp = new ServicePointImpl();
+ ServicePoint sp = new ServicePointImpl(m, null);
m.getServicePoint("Fred");
control.setReturnValue(sp);
Modified: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java?view=diff&rev=451799&r1=451798&r2=451799
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java Sun Oct 1 13:12:41 2006
@@ -28,8 +28,8 @@
{
public void testGetFirstParameter()
{
- final ServicePoint sp = new ServicePointImpl();
final Module m = new ModuleImpl();
+ final ServicePoint sp = new ServicePointImpl(m, null);
final ServiceImplementationFactoryParametersImpl params = new ServiceImplementationFactoryParametersImpl( sp, m, new LinkedList() );
assertNull( params.getFirstParameter() );
}