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/06/12 23:44:58 UTC
svn commit: r413747 [2/4] - in /jakarta/hivemind/branches/branch-2-0-annot:
./ examples/src/java/org/apache/examples/
framework/src/descriptor/META-INF/ framework/src/java/org/apache/hivemind/
framework/src/java/org/apache/hivemind/ant/ framework/src/j...
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java Mon Jun 12 14:44:52 2006
@@ -15,18 +15,16 @@
package org.apache.hivemind.impl;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.hivemind.*;
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.Occurances;
+import org.apache.hivemind.ShutdownCoordinator;
+import org.apache.hivemind.internal.ConfigurationConstructor;
import org.apache.hivemind.internal.ConfigurationPoint;
import org.apache.hivemind.internal.Contribution;
-import org.apache.hivemind.schema.Schema;
import org.apache.hivemind.util.ToStringBuilder;
/**
@@ -43,15 +41,9 @@
/**
* The cached elements for the extension point (if caching is enabled).
*/
- private List _elements;
+ private Object _container;
- private List _elementsProxy;
-
- private Map _mappedElements;
-
- private Map _mappedElementsProxy;
-
- private boolean _canElementsBeMapped = false;
+ private Object _containerProxy;
private Occurances _expectedCount;
@@ -59,15 +51,16 @@
private boolean _building;
- private Schema _contributionsSchema;
-
private ShutdownCoordinator _shutdownCoordinator;
+
+ private ConfigurationConstructor _constructor;
+
+ private String _containerClassName;
protected void extendDescription(ToStringBuilder builder)
{
builder.append("expectedCount", _expectedCount);
builder.append("contributions", _contributions);
- builder.append("schema", _contributionsSchema);
}
/**
@@ -81,16 +74,7 @@
if (_contributions == null)
return 0;
- int total = 0;
-
- int count = _contributions.size();
- for (int i = 0; i < count; i++)
- {
- Contribution c = (Contribution) _contributions.get(i);
- total += c.getElements().size();
- }
-
- return total;
+ return _contributions.size();
}
public void addContribution(Contribution c)
@@ -112,65 +96,29 @@
}
/**
- * Returns the contributed elements as an unmodifiable {@link List}. Internally, a proxy to the
- * real list is returned, such that the real list may not be constructed until actually needed.
+ * @see org.apache.hivemind.internal.ConfigurationPoint#getContainer()
*/
- public synchronized List getElements()
+ public synchronized Object getContainer()
{
- if (_elements != null)
- return _elements;
-
- if (_elementsProxy == null)
- {
- ElementsProxyList outerProxy = new ElementsProxyList();
-
- new ElementsInnerProxyList(this, outerProxy);
+ if (_container != null)
+ return _container;
- _shutdownCoordinator.addRegistryShutdownListener(outerProxy);
+ // TODO: implement generic proxy for all kind of containers
+// if (_containerProxy == null)
+// {
+// ElementsProxyList outerProxy = new ElementsProxyList();
+//
+// new ElementsInnerProxyList(this, outerProxy);
+//
+// _shutdownCoordinator.addRegistryShutdownListener(outerProxy);
+//
+// _containerProxy = outerProxy;
+// }
- _elementsProxy = outerProxy;
- }
-
- return _elementsProxy;
- }
-
- public boolean areElementsMappable()
- {
- return _canElementsBeMapped;
+ return constructContainer();
}
- /**
- * Returns the contributed elements as an unmodifiable {@link Map}. Internally, a proxy to the
- * real map is returned, such that the real map may not be constructed until actually needed.
- */
- public synchronized Map getElementsAsMap()
- {
- if (!areElementsMappable())
- throw new ApplicationRuntimeException(ImplMessages.unableToMapConfiguration(this));
-
- if (_mappedElements != null)
- return _mappedElements;
-
- if (_mappedElementsProxy == null)
- {
- ElementsProxyMap outerProxy = new ElementsProxyMap();
-
- new ElementsInnerProxyMap(this, outerProxy);
-
- _shutdownCoordinator.addRegistryShutdownListener(outerProxy);
-
- _mappedElementsProxy = outerProxy;
- }
-
- return _mappedElementsProxy;
- }
-
- /**
- * Invoked by {@link ElementsInnerProxyList} when the actual list is needed. Returns the List
- * (which is modifiable, but that's OK because ElementsInnerProxyList is unmodifiable) created
- * by calling {@link #processContributionElements()}.
- */
- synchronized List constructElements()
+ synchronized Object constructContainer()
{
// It's nice to have this protection, but (unlike services), you
// would really have to go out of your way to provoke
@@ -182,53 +130,20 @@
try
{
- if (_elements == null)
+ if (_container == null)
{
_building = true;
+
+ _container = createContainerInstance();
processContributionElements();
}
// Now that we have the real list, we don't need the proxy anymore, either.
- _elementsProxy = null;
-
- return _elements;
- }
- finally
- {
- _building = false;
- }
- }
-
- /**
- * Analoguously to {@link #constructElements()} this method will be called by
- * {@link ElementsInnerProxyMap} to construct the actual map.
- */
- synchronized Map constructMapElements()
- {
- // It's nice to have this protection, but (unlike services), you
- // would really have to go out of your way to provoke
- // a recursive configuration.
-
- if (_building)
- throw new ApplicationRuntimeException(ImplMessages
- .recursiveConfiguration(getExtensionPointId()));
+ _containerProxy = null;
- try
- {
- if (_mappedElements == null)
- {
- _building = true;
-
- processContributionElements();
- }
-
- // Now that we have the real map, we don't need the proxy anymore, either.
-
- _mappedElementsProxy = null;
-
- return _mappedElements;
+ return _container;
}
finally
{
@@ -237,27 +152,16 @@
}
/**
- * Processes the contribution elements using the
- * {@link org.apache.hivemind.schema.SchemaProcessor}. The processed contributions will be
- * stored as an immutable list (in {@link #_elements}) and as an immutable map (in
- * {@link #_mappedElements}) if applicable (see {@link #areElementsMappable()}).
+ * Adds all contributions to the configuration container.
*/
private void processContributionElements()
{
if (LOG.isDebugEnabled())
LOG.debug("Constructing extension point " + getExtensionPointId());
- if (_contributions == null)
- {
- _elements = Collections.EMPTY_LIST;
- _mappedElements = Collections.EMPTY_MAP;
-
- return;
- }
-
- SchemaProcessorImpl processor = new SchemaProcessorImpl(getErrorLog(), _contributionsSchema);
-
- int count = _contributions.size();
+ int count = 0;
+ if (_contributions != null)
+ count = _contributions.size();
try
{
@@ -265,7 +169,7 @@
{
Contribution extension = (Contribution) _contributions.get(i);
- processor.process(extension.getElements(), extension.getContributingModule());
+ extension.contribute(this, _container);
}
}
catch (Exception ex)
@@ -275,41 +179,65 @@
ex), ex);
}
- if (areElementsMappable())
- _mappedElements = Collections.unmodifiableMap(processor.getMappedElements());
-
- _elements = Collections.unmodifiableList(processor.getElements());
-
// After constructing the result, if the result
// will be cached, then there's no need to keep
- // the schema and extensions (used to build the
+ // the extensions (used to build the
// result); it can all be released to the GC.
- _contributionsSchema = null;
_contributions = null;
}
+
+ private Class lookupContainerClass()
+ {
+ return getModule().resolveType(_containerClassName);
+ }
+
+ private Object createContainerInstance()
+ {
+ Object container = _constructor.constructConfigurationContainer(getModule());
+ if (container == null)
+ // TODO AH: better exception
+ throw new ApplicationRuntimeException("configuration container is null");
+
+ if (!lookupContainerClass().isAssignableFrom(container.getClass()))
+ throw new ApplicationRuntimeException("configuration container of type " +
+ container.getClass().getName() + " is not assignable to " +
+ lookupContainerClass().getName());
+
+ return container;
+ }
+
+ public void setShutdownCoordinator(ShutdownCoordinator coordinator)
+ {
+ _shutdownCoordinator = coordinator;
+ }
- public Schema getSchema()
+ public String getContainerClassName()
{
- return _contributionsSchema;
+ return _containerClassName;
}
- public void setContributionsSchema(Schema schema)
+ public void setContainerClassName(String containerClassName)
{
- _contributionsSchema = schema;
+ _containerClassName = containerClassName;
+ }
- _canElementsBeMapped = _contributionsSchema != null
- && _contributionsSchema.canInstancesBeKeyed();
+ /**
+ * @see org.apache.hivemind.internal.ConfigurationPoint#getContainerType()
+ */
+ public Class getContainerType()
+ {
+ return lookupContainerClass();
}
- public Schema getContributionsSchema()
+ public ConfigurationConstructor getConfigurationConstructor()
{
- return _contributionsSchema;
+ return _constructor;
}
- public void setShutdownCoordinator(ShutdownCoordinator coordinator)
+ public void setConfigurationConstructor(ConfigurationConstructor constructor)
{
- _shutdownCoordinator = coordinator;
+ _constructor = constructor;
}
}
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ElementsInnerProxyList.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ElementsInnerProxyList.java?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ElementsInnerProxyList.java (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ElementsInnerProxyList.java Mon Jun 12 14:44:52 2006
@@ -43,7 +43,7 @@
{
if (_inner == null)
{
- _inner = _point.constructElements();
+// _inner = _point.constructElements();
// Replace ourselves in the outer proxy with the actual list.
_outer.setInner(_inner);
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java Mon Jun 12 14:44:52 2006
@@ -28,10 +28,9 @@
import org.apache.hivemind.internal.ConfigurationPoint;
import org.apache.hivemind.internal.ExtensionPoint;
import org.apache.hivemind.internal.Module;
-import org.apache.hivemind.internal.ServiceInterceptorContribution;
+import org.apache.hivemind.internal.ServiceInterceptorConstructor;
import org.apache.hivemind.internal.ServicePoint;
import org.apache.hivemind.parse.ContributionDescriptor;
-import org.apache.hivemind.parse.DependencyDescriptor;
import org.apache.hivemind.schema.SchemaProcessor;
/**
@@ -99,18 +98,18 @@
return _formatter.format("unable-to-load-class", name, loader, cause);
}
- static String nullInterceptor(ServiceInterceptorContribution contribution,
+ static String nullInterceptor(ServiceInterceptorConstructor constructor,
ServicePoint point)
{
- return _formatter.format("null-interceptor", contribution.getFactoryServiceId(), point
+ return _formatter.format("null-interceptor", constructor.getName(), point
.getExtensionPointId());
}
static String interceptorDoesNotImplementInterface(Object interceptor,
- ServiceInterceptorContribution contribution, ServicePoint point, Class serviceInterface)
+ ServiceInterceptorConstructor constructor, ServicePoint point, Class serviceInterface)
{
return _formatter.format("interceptor-does-not-implement-interface", new Object[]
- { interceptor, contribution.getFactoryServiceId(), point.getExtensionPointId(),
+ { interceptor, constructor.getName(), point.getExtensionPointId(),
serviceInterface.getName() });
}
@@ -128,6 +127,16 @@
{
return _formatter.format("unable-to-find-modules", resolver, cause);
}
+
+ static String unableToFindProviders(ClassResolver resolver, Throwable cause)
+ {
+ return _formatter.format("unable-to-find-providers", resolver, cause);
+ }
+
+ static String unableToReadManifest(URL url, Throwable cause)
+ {
+ return _formatter.format("unable-to-read-manifest", url.toString(), cause);
+ }
static String duplicateModuleId(String moduleId, Location locationOfExisting,
Location locationOfDuplicate)
@@ -168,7 +177,7 @@
ServicePointImpl existing)
{
return _formatter.format("duplicate-factory", sourceModule.getModuleId(), pointId, existing
- .getServiceConstructor().getContributingModule().getModuleId());
+ .getServiceConstructor().getContributingModuleId());
}
static String wrongNumberOfContributions(ConfigurationPoint point, int actualCount,
@@ -332,17 +341,9 @@
return _formatter.format("sub-module-does-not-exist", subModuleDescriptor);
}
- static String dependencyOnUnknownModule(DependencyDescriptor dependency)
- {
- return _formatter.format("dependency-on-unknown-module", dependency.getModuleId());
- }
-
- static String dependencyVersionMismatch(DependencyDescriptor dependency)
+ static String dependencyOnUnknownModule(String toModuleId)
{
- return _formatter.format(
- "dependency-version-mismatch",
- dependency.getModuleId(),
- dependency.getVersion());
+ return _formatter.format("dependency-on-unknown-module", toModuleId);
}
private static String convertModule(Module module)
@@ -401,5 +402,15 @@
static String unableToConvertType(String type, String packageName)
{
return _formatter.format("unable-to-convert-type", type, packageName);
+ }
+
+ public static String unableToCreateProvider(String providerClassName, Exception cause)
+ {
+ return _formatter.format("unable-to-create-provider", providerClassName, cause);
+ }
+
+ public static String providerWrongType(String providerClassName, Class requiredInterface)
+ {
+ return _formatter.format("provider-wrong-type", providerClassName, requiredInterface.getName());
}
}
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties Mon Jun 12 14:44:52 2006
@@ -85,4 +85,9 @@
service-point-not-visible=Service point {0} is not visible to module {1}.
unable-to-map-configuration=Unable to map the contributions to configuration point {0}. All top-level schema elements must define a key attribute.
-unable-to-convert-type=Unable to convert type ''{0}'' to a Java class, either as is, or in package {1}.
\ No newline at end of file
+unable-to-convert-type=Unable to convert type ''{0}'' to a Java class, either as is, or in package {1}.
+
+unable-to-find-providers=Unable to locate manifest files in {0}: {1}
+unable-to-read-manifest=Unable to read manifest file {0}: {1}
+unable-to-create-provider=Unable to create provider of type {0}: {1}
+provider-wrong-type=Registry provider class {0} must implement interface {1}
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/InterceptorStackImpl.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/InterceptorStackImpl.java?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/InterceptorStackImpl.java (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/InterceptorStackImpl.java Mon Jun 12 14:44:52 2006
@@ -18,7 +18,7 @@
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.InterceptorStack;
import org.apache.hivemind.internal.Module;
-import org.apache.hivemind.internal.ServiceInterceptorContribution;
+import org.apache.hivemind.internal.ServiceInterceptorConstructor;
import org.apache.hivemind.internal.ServicePoint;
import org.apache.hivemind.util.ToStringBuilder;
@@ -32,7 +32,7 @@
{
private final Log _log;
- private ServiceInterceptorContribution _contribution;
+ private ServiceInterceptorConstructor _constructor;
private ServicePoint _sep;
private Class _interfaceClass;
private Object _top;
@@ -48,7 +48,7 @@
public String toString()
{
ToStringBuilder builder = new ToStringBuilder(this);
- builder.append("contribution", _contribution);
+ builder.append("contribution", _constructor);
builder.append("interfaceClass", _interfaceClass);
builder.append("top", _top);
@@ -79,18 +79,18 @@
{
if (interceptor == null)
throw new ApplicationRuntimeException(
- ImplMessages.nullInterceptor(_contribution, _sep),
- _contribution.getLocation(),
+ ImplMessages.nullInterceptor(_constructor, _sep),
+ _constructor.getLocation(),
null);
if (!_interfaceClass.isAssignableFrom(interceptor.getClass()))
throw new ApplicationRuntimeException(
ImplMessages.interceptorDoesNotImplementInterface(
interceptor,
- _contribution,
+ _constructor,
_sep,
_interfaceClass),
- _contribution.getLocation(),
+ _constructor.getLocation(),
null);
_top = interceptor;
@@ -102,22 +102,21 @@
*
*/
- public void process(ServiceInterceptorContribution contribution)
+ public void process(ServiceInterceptorConstructor constructor)
{
if (_log.isDebugEnabled())
- _log.debug("Applying interceptor factory " + contribution.getFactoryServiceId());
+ _log.debug("Applying interceptor factory " + constructor.getName());
// And now we can finally do this!
-
try
{
- _contribution = contribution;
-
- contribution.createInterceptor(this);
+ _constructor = constructor;
+ Module contributingModule = getServiceModule().getModule(constructor.getContributingModuleId());
+ _constructor.constructServiceInterceptor(this, contributingModule);
}
finally
{
- _contribution = null;
+ _constructor = null;
}
}
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ModuleImpl.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ModuleImpl.java?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ModuleImpl.java (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ModuleImpl.java Mon Jun 12 14:44:52 2006
@@ -15,7 +15,6 @@
package org.apache.hivemind.impl;
import java.util.HashMap;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -30,7 +29,6 @@
import org.apache.hivemind.internal.RegistryInfrastructure;
import org.apache.hivemind.internal.ServiceModelFactory;
import org.apache.hivemind.internal.ServicePoint;
-import org.apache.hivemind.schema.Translator;
import org.apache.hivemind.service.ThreadLocale;
import org.apache.hivemind.util.IdUtils;
import org.apache.hivemind.util.ToStringBuilder;
@@ -60,27 +58,13 @@
*/
private final Map _typeCache = new HashMap();
- public List getConfiguration(String extensionPointId)
+ public Object getConfiguration(String extensionPointId)
{
String qualifiedId = IdUtils.qualify(_moduleId, extensionPointId);
return _registry.getConfiguration(qualifiedId, this);
}
- public boolean isConfigurationMappable(String configurationId)
- {
- String qualifiedId = IdUtils.qualify(_moduleId, configurationId);
-
- return _registry.getConfigurationPoint(qualifiedId, this).areElementsMappable();
- }
-
- public Map getConfigurationAsMap(String configurationId)
- {
- String qualifiedId = IdUtils.qualify(_moduleId, configurationId);
-
- return _registry.getConfigurationPoint(qualifiedId, this).getElementsAsMap();
- }
-
public String getModuleId()
{
return _moduleId;
@@ -174,11 +158,6 @@
return _registry.getServiceModelFactory(name);
}
- public Translator getTranslator(String translator)
- {
- return _registry.getTranslator(translator);
- }
-
public Locale getLocale()
{
return _registry.getLocale();
@@ -222,4 +201,18 @@
return result;
}
+
+ /**
+ * @see org.apache.hivemind.internal.Module#getRegistryNature(java.lang.Class)
+ */
+ public Object getRegistryNature(Class natureType)
+ {
+ return _registry.getNature(natureType);
+ }
+
+ public Module getModule(String moduleId)
+ {
+ return _registry.getModule(moduleId);
+ }
+
}
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryBuilder.java?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryBuilder.java (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryBuilder.java Mon Jun 12 14:44:52 2006
@@ -14,25 +14,21 @@
package org.apache.hivemind.impl;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
-import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hivemind.ErrorHandler;
import org.apache.hivemind.ModuleDescriptorProvider;
import org.apache.hivemind.Registry;
+import org.apache.hivemind.definition.RegistryDefinition;
import org.apache.hivemind.internal.RegistryInfrastructure;
-import org.apache.hivemind.parse.ModuleDescriptor;
/**
* Class used to build a {@link org.apache.hivemind.Registry} from individual
- * {@link org.apache.hivemind.parse.ModuleDescriptor}. The descriptors are provided by the
- * {@link ModuleDescriptorProvider}parameter passed to {@link #constructRegistry(Locale)} method.
- * <p>
+ * {@link org.apache.hivemind.definition.RegistryDefinition}.
* A note about threadsafety: The assumption is that a single thread will access the RegistryBuilder
* at one time (typically, a startup class within some form of server or application). Code here and
* in many of the related classes is divided into construction-time logic and runtime logic. Runtime
@@ -80,27 +76,7 @@
private ErrorHandler _errorHandler;
- /**
- * RegistryAssembly used by the module descriptor parser(s).
- */
-
- private RegistryAssemblyImpl _registryAssembly;
-
- /**
- * A set of all {@link ModuleDescriptorProvider} objects used to construct the Registry.
- *
- * @since 1.1
- */
-
- private Set _moduleDescriptorProviders;
-
- /**
- * Contains most of the logic for actually creating the registry.
- *
- * @since 1.1
- */
-
- private RegistryInfrastructureConstructor _constructor;
+ private RegistryDefinition _registryDefinition;
public RegistryBuilder()
{
@@ -110,78 +86,55 @@
public RegistryBuilder(ErrorHandler handler)
{
_errorHandler = handler;
-
- _registryAssembly = new RegistryAssemblyImpl();
-
- _moduleDescriptorProviders = new HashSet();
-
- _constructor = new RegistryInfrastructureConstructor(handler, LOG, _registryAssembly);
}
- /**
- * Adds a {@link ModuleDescriptorProvider} as a source for
- * {@link ModuleDescriptor module descriptors} to this RegistryBuilder. Adding the same provider
- * instance multiple times has no effect.
- *
- * @since 1.1
- */
- public void addModuleDescriptorProvider(ModuleDescriptorProvider provider)
+ public RegistryDefinition getRegistryDefinition()
{
- _moduleDescriptorProviders.add(provider);
+ if (_registryDefinition == null) {
+ _registryDefinition = new RegistryDefinition(_errorHandler);
+ }
+ return _registryDefinition;
}
-
+
/**
* This first loads all modules provided by the ModuleDescriptorProvider, then resolves all the
* contributions, then constructs and returns the Registry.
*/
public Registry constructRegistry(Locale locale)
{
- for (Iterator i = _moduleDescriptorProviders.iterator(); i.hasNext();)
+ RegistryDefinition definition = getRegistryDefinition();
+
+ definition.resolveExtensions();
+
+ // Post process phase
+ for (Iterator i = definition.getPostProcessors().iterator(); i.hasNext();)
{
- ModuleDescriptorProvider provider = (ModuleDescriptorProvider) i.next();
+ RegistryPostProcessor processor = (RegistryPostProcessor) i.next();
- processModuleDescriptorProvider(provider);
+ processor.postprocess(definition, _errorHandler);
}
- // Process any deferred operations. Post processing is added by
- // both the parser and the registry constructor.
-
- _registryAssembly.performPostProcessing();
-
- RegistryInfrastructure infrastructure = _constructor
- .constructRegistryInfrastructure(locale);
+ RegistryInfrastructureConstructor constructor = new RegistryInfrastructureConstructor(_errorHandler, LOG, locale);
+ RegistryInfrastructure infrastructure = constructor
+ .constructRegistryInfrastructure(definition);
infrastructure.startup();
return new RegistryImpl(infrastructure);
}
- private void processModuleDescriptorProvider(ModuleDescriptorProvider provider)
+ public void autoDetectModules()
{
- List descriptors = provider.getModuleDescriptors(_errorHandler);
-
- Iterator i = descriptors.iterator();
- while (i.hasNext())
+ RegistryProviderAutoDetector detector = new RegistryProviderAutoDetector(new DefaultClassResolver());
+ List providers = detector.getProviders();
+ for (Iterator iterProviders = providers.iterator(); iterProviders.hasNext();)
{
- ModuleDescriptor md = (ModuleDescriptor) i.next();
-
- _constructor.addModuleDescriptor(md);
+ RegistryProvider provider = (RegistryProvider) iterProviders.next();
+ provider.process(getRegistryDefinition(), _errorHandler);
}
}
/**
- * Adds a default module descriptor provider to this <code>RegistryBuilder</code>. A default
- * module descriptor provider is merely a {@link XmlModuleDescriptorProvider} constructed with a
- * {@link DefaultClassResolver}.
- *
- * @since 1.1
- */
- public void addDefaultModuleDescriptorProvider()
- {
- addModuleDescriptorProvider(new XmlModuleDescriptorProvider(new DefaultClassResolver()));
- }
-
- /**
* Constructs a default registry based on just the modules visible to the thread context class
* loader (this is sufficient is the majority of cases), and using the default locale. If you
* have different error handling needs, or wish to pick up HiveMind module deployment
@@ -192,8 +145,13 @@
public static Registry constructDefaultRegistry()
{
RegistryBuilder builder = new RegistryBuilder();
- builder.addDefaultModuleDescriptorProvider();
+ builder.autoDetectModules();
return builder.constructRegistry(Locale.getDefault());
+ }
+
+ public ErrorHandler getErrorHandler()
+ {
+ return _errorHandler;
}
}
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java Mon Jun 12 14:44:52 2006
@@ -16,7 +16,6 @@
import java.util.List;
import java.util.Locale;
-import java.util.Map;
import org.apache.hivemind.Location;
import org.apache.hivemind.Messages;
@@ -54,19 +53,9 @@
return _infrastructure.containsService(serviceId, serviceInterface, null);
}
- public List getConfiguration(String configurationId)
+ public Object getConfiguration(String configurationId)
{
return _infrastructure.getConfiguration(configurationId, null);
- }
-
- public boolean isConfigurationMappable(String configurationId)
- {
- return _infrastructure.isConfigurationMappable(configurationId, null);
- }
-
- public Map getConfigurationAsMap(String configurationId)
- {
- return _infrastructure.getConfigurationAsMap(configurationId, null);
}
public String expandSymbols(String input, Location location)
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java Mon Jun 12 14:44:52 2006
@@ -15,38 +15,27 @@
package org.apache.hivemind.impl;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Map.Entry;
import org.apache.commons.logging.Log;
import org.apache.hivemind.ErrorHandler;
-import org.apache.hivemind.Location;
-import org.apache.hivemind.Occurances;
import org.apache.hivemind.ShutdownCoordinator;
-import org.apache.hivemind.conditional.EvaluationContextImpl;
-import org.apache.hivemind.conditional.Node;
-import org.apache.hivemind.conditional.Parser;
-import org.apache.hivemind.internal.ConfigurationPoint;
+import org.apache.hivemind.definition.ConfigurationPointDefinition;
+import org.apache.hivemind.definition.ContributionDefinition;
+import org.apache.hivemind.definition.ModuleDefinition;
+import org.apache.hivemind.definition.RegistryDefinition;
+import org.apache.hivemind.definition.RegistryNature;
+import org.apache.hivemind.definition.ServiceImplementationDefinition;
+import org.apache.hivemind.definition.ServiceInterceptorDefinition;
+import org.apache.hivemind.definition.ServicePointDefinition;
import org.apache.hivemind.internal.Module;
import org.apache.hivemind.internal.RegistryInfrastructure;
-import org.apache.hivemind.internal.ServicePoint;
-import org.apache.hivemind.parse.ConfigurationPointDescriptor;
-import org.apache.hivemind.parse.ContributionDescriptor;
-import org.apache.hivemind.parse.DependencyDescriptor;
-import org.apache.hivemind.parse.ImplementationDescriptor;
-import org.apache.hivemind.parse.InstanceBuilder;
-import org.apache.hivemind.parse.InterceptorDescriptor;
-import org.apache.hivemind.parse.ModuleDescriptor;
-import org.apache.hivemind.parse.ServicePointDescriptor;
-import org.apache.hivemind.schema.Schema;
-import org.apache.hivemind.schema.impl.SchemaImpl;
-import org.apache.hivemind.util.IdUtils;
/**
- * Fed a series of {@link org.apache.hivemind.parse.ModuleDescriptor}s, this class will assemble
+ * Fed a series of {@link org.apache.hivemind.parse.ModuleDefinition}s, this class will assemble
* them into a final {@link org.apache.hivemind.internal.RegistryInfrastructure} as well as perform
* some validations.
* <p>
@@ -61,145 +50,75 @@
private Log _log;
- private RegistryAssembly _assembly;
+ private RegistryInfrastructureImpl _infrastructure;
- /** @since 1.1 */
-
- private Parser _conditionalExpressionParser;
-
- public RegistryInfrastructureConstructor(ErrorHandler errorHandler, Log log,
- RegistryAssembly assembly)
+ public RegistryInfrastructureConstructor(ErrorHandler errorHandler, Log log, Locale locale)
{
_errorHandler = errorHandler;
_log = log;
- _assembly = assembly;
+
+ _infrastructure = new RegistryInfrastructureImpl(_errorHandler, locale);
}
/**
- * Map of {@link ModuleDescriptor} keyed on module id.
- */
-
- private Map _moduleDescriptors = new HashMap();
-
- /**
- * Map of {@link ModuleImpl} keyed on module id.
- */
- private Map _modules = new HashMap();
-
- /**
- * Map of {@link Schema} keyed on fully qualified module id.
- */
- private Map _schemas = new HashMap();
-
- /**
- * Map of {@link ServicePointImpl} keyed on fully qualified id.
- */
-
- private Map _servicePoints = new HashMap();
-
- /**
- * Map of {@link ConfigurationPointImpl} keyed on fully qualified id.
- */
-
- private Map _configurationPoints = new HashMap();
-
- /**
* Shutdown coordinator shared by all objects.
*/
private ShutdownCoordinator _shutdownCoordinator = new ShutdownCoordinatorImpl();
/**
- * This class is used to check the dependencies of a ModuleDescriptor. As the checker is run it
- * will log errors to the ErrorHandler if dependencies don't resolve or the versions dont match.
+ * Constructs the registry infrastructure, based on data collected during the prior calls to
+ * {@link #addModuleDefinition(ModuleDefinition)}. Expects that all post-processing of the
+ * {@link RegistryAssembly} has already occured.
*/
- private class ModuleDependencyChecker implements Runnable
+ public RegistryInfrastructure constructRegistryInfrastructure(RegistryDefinition definition)
{
- private ModuleDescriptor _source;
-
- public ModuleDependencyChecker(ModuleDescriptor source)
- {
- _source = source;
+ addModules(definition);
+
+ // Copy natures from registry definition to registry
+ for (Iterator natures = definition.getNatures().entrySet().iterator(); natures.hasNext();)
+ {
+ Map.Entry natureEntry = (Entry) natures.next();
+ RegistryNature nature = (RegistryNature) natureEntry.getValue();
+ nature.setRegistry(_infrastructure);
+ _infrastructure.addNature((Class) natureEntry.getKey(), nature);
}
+
+ _infrastructure.setShutdownCoordinator(_shutdownCoordinator);
- public void run()
- {
- List dependencies = _source.getDependencies();
- int count = size(dependencies);
-
- for (int i = 0; i < count; i++)
- {
- DependencyDescriptor dependency = (DependencyDescriptor) dependencies.get(i);
- checkDependency(dependency);
- }
- }
-
- private void checkDependency(DependencyDescriptor dependency)
- {
- ModuleDescriptor requiredModule = (ModuleDescriptor) _moduleDescriptors.get(dependency
- .getModuleId());
-
- if (requiredModule == null)
- {
- _errorHandler.error(
- _log,
- ImplMessages.dependencyOnUnknownModule(dependency),
- dependency.getLocation(),
- null);
- return;
- }
+ // The caller is responsible for invoking startup().
- if (dependency.getVersion() != null
- && !dependency.getVersion().equals(requiredModule.getVersion()))
- {
- _errorHandler.error(
- _log,
- ImplMessages.dependencyVersionMismatch(dependency),
- dependency.getLocation(),
- null);
- return;
- }
- }
+ return _infrastructure;
}
- /**
- * Constructs the registry infrastructure, based on data collected during the prior calls to
- * {@link #addModuleDescriptor(ModuleDescriptor)}. Expects that all post-processing of the
- * {@link RegistryAssembly} has already occured.
- */
- public RegistryInfrastructure constructRegistryInfrastructure(Locale locale)
+ private void addModules(RegistryDefinition definition)
{
- RegistryInfrastructureImpl result = new RegistryInfrastructureImpl(_errorHandler, locale);
-
- addServiceAndConfigurationPoints(result);
-
- addImplementationsAndContributions();
-
- checkForMissingServices();
-
- checkContributionCounts();
-
- result.setShutdownCoordinator(_shutdownCoordinator);
+ // Add each module to the registry.
- addModulesToRegistry(result);
+ Iterator i = definition.getModules().iterator();
+ while (i.hasNext())
+ {
+ ModuleDefinition module = (ModuleDefinition) i.next();
- // The caller is responsible for invoking startup().
+ if (_log.isDebugEnabled())
+ _log.debug("Adding module " + module.getId() + " to registry");
- return result;
+ addModule(module);
+ }
}
- public void addModuleDescriptor(ModuleDescriptor md)
+ public void addModule(ModuleDefinition moduleDefinition)
{
- String id = md.getModuleId();
+ String id = moduleDefinition.getId();
if (_log.isDebugEnabled())
_log.debug("Processing module " + id);
- if (_modules.containsKey(id))
+ if (_infrastructure.getModule(id) != null)
{
- Module existing = (Module) _modules.get(id);
+ Module existing = _infrastructure.getModule(id);
- _errorHandler.error(_log, ImplMessages.duplicateModuleId(id, existing.getLocation(), md
+ _errorHandler.error(_log, ImplMessages.duplicateModuleId(id, existing.getLocation(), moduleDefinition
.getLocation()), null, null);
// Ignore the duplicate module descriptor.
@@ -208,67 +127,30 @@
ModuleImpl module = new ModuleImpl();
- module.setLocation(md.getLocation());
+ module.setLocation(moduleDefinition.getLocation());
module.setModuleId(id);
- module.setPackageName(md.getPackageName());
- module.setClassResolver(md.getClassResolver());
-
- if (size(md.getDependencies()) > 0)
- _assembly.addPostProcessor(new ModuleDependencyChecker(md));
-
- for (Iterator schemas = md.getSchemas().iterator(); schemas.hasNext();)
- {
- SchemaImpl schema = (SchemaImpl) schemas.next();
-
- schema.setModule(module);
-
- _schemas.put(IdUtils.qualify(id, schema.getId()), schema);
- }
+ module.setPackageName(moduleDefinition.getPackageName());
+ module.setClassResolver(moduleDefinition.getClassResolver());
- _modules.put(id, module);
+ addServicePoints(moduleDefinition, module);
+
+ addConfigurationPoints(moduleDefinition, module);
+
+ module.setRegistry(_infrastructure);
+ _infrastructure.addModule(module);
- _moduleDescriptors.put(id, md);
}
- private void addServiceAndConfigurationPoints(RegistryInfrastructureImpl infrastructure)
+ private void addServicePoints(ModuleDefinition md, Module module)
{
- for (Iterator i = _moduleDescriptors.values().iterator(); i.hasNext();)
- {
- ModuleDescriptor md = (ModuleDescriptor) i.next();
-
- String id = md.getModuleId();
-
- ModuleImpl module = (ModuleImpl) _modules.get(id);
-
- addServicePoints(infrastructure, module, md);
-
- addConfigurationPoints(infrastructure, module, md);
- }
- }
-
- private void addServicePoints(RegistryInfrastructureImpl infrastructure, Module module,
- ModuleDescriptor md)
- {
- String moduleId = md.getModuleId();
- List services = md.getServicePoints();
- int count = size(services);
+ String moduleId = md.getId();
- for (int i = 0; i < count; i++)
+ for (Iterator services = md.getServicePoints().iterator(); services.hasNext();)
{
- ServicePointDescriptor sd = (ServicePointDescriptor) services.get(i);
+ ServicePointDefinition sd = (ServicePointDefinition) services.next();
String pointId = moduleId + "." + sd.getId();
- ServicePoint existingPoint = (ServicePoint) _servicePoints.get(pointId);
-
- if (existingPoint != null)
- {
- _errorHandler.error(_log, ImplMessages.duplicateExtensionPointId(
- pointId,
- existingPoint), sd.getLocation(), null);
- continue;
- }
-
if (_log.isDebugEnabled())
_log.debug("Creating service point " + pointId);
@@ -281,52 +163,34 @@
point.setExtensionPointId(pointId);
point.setLocation(sd.getLocation());
point.setModule(module);
-
point.setServiceInterfaceName(sd.getInterfaceClassName());
-
- point.setParametersSchema(findSchema(sd.getParametersSchema(), module, sd
- .getParametersSchemaId(), point.getLocation()));
-
- point.setParametersCount(sd.getParametersCount());
point.setVisibility(sd.getVisibility());
- point.setShutdownCoordinator(_shutdownCoordinator);
-
- infrastructure.addServicePoint(point);
-
- // Save this for the second phase, where contributions
- // from other modules are applied.
+ // 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());
+ }
- _servicePoints.put(pointId, point);
+ point.setShutdownCoordinator(_shutdownCoordinator);
- addInternalImplementations(module, pointId, sd);
+ addImplementation(sd, point, module);
+ addInterceptors(sd, point, module);
+
+ _infrastructure.addServicePoint(point);
}
}
- private void addConfigurationPoints(RegistryInfrastructureImpl registry, Module module,
- ModuleDescriptor md)
+ private void addConfigurationPoints(ModuleDefinition md, Module module)
{
- String moduleId = md.getModuleId();
- List points = md.getConfigurationPoints();
- int count = size(points);
-
- for (int i = 0; i < count; i++)
+ String moduleId = md.getId();
+ for (Iterator points = md.getConfigurationPoints().iterator(); points.hasNext();)
{
- ConfigurationPointDescriptor cpd = (ConfigurationPointDescriptor) points.get(i);
+ ConfigurationPointDefinition cpd = (ConfigurationPointDefinition) points.next();
String pointId = moduleId + "." + cpd.getId();
- ConfigurationPoint existingPoint = (ConfigurationPoint) _configurationPoints
- .get(pointId);
-
- if (existingPoint != null)
- {
- _errorHandler.error(_log, ImplMessages.duplicateExtensionPointId(
- pointId,
- existingPoint), cpd.getLocation(), null);
- continue;
- }
-
if (_log.isDebugEnabled())
_log.debug("Creating configuration point " + pointId);
@@ -335,385 +199,96 @@
point.setExtensionPointId(pointId);
point.setLocation(cpd.getLocation());
point.setModule(module);
- point.setExpectedCount(cpd.getCount());
-
- point.setContributionsSchema(findSchema(cpd.getContributionsSchema(), module, cpd
- .getContributionsSchemaId(), cpd.getLocation()));
-
+ 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());
+ }
point.setShutdownCoordinator(_shutdownCoordinator);
- registry.addConfigurationPoint(point);
-
- // Needed later when we reconcile the rest
- // of the configuration contributions.
+ addContributions(cpd, point, module);
+
+ _infrastructure.addConfigurationPoint(point);
- _configurationPoints.put(pointId, point);
}
}
- private void addContributionElements(Module sourceModule, ConfigurationPointImpl point,
- List elements)
+ private void addImplementation(ServicePointDefinition sd, ServicePointImpl point, Module sourceModule)
{
- if (size(elements) == 0)
- return;
-
- if (_log.isDebugEnabled())
- _log
- .debug("Adding contributions to configuration point "
- + point.getExtensionPointId());
-
- ContributionImpl c = new ContributionImpl();
- c.setContributingModule(sourceModule);
- c.addElements(elements);
-
- point.addContribution(c);
- }
-
- private void addModulesToRegistry(RegistryInfrastructureImpl registry)
- {
- // Add each module to the registry.
-
- Iterator i = _modules.values().iterator();
- while (i.hasNext())
- {
- ModuleImpl module = (ModuleImpl) i.next();
-
- if (_log.isDebugEnabled())
- _log.debug("Adding module " + module.getModuleId() + " to registry");
-
- module.setRegistry(registry);
- }
- }
-
- private void addImplementationsAndContributions()
- {
- for (Iterator i = _moduleDescriptors.values().iterator(); i.hasNext();)
- {
- ModuleDescriptor md = (ModuleDescriptor) i.next();
+ ServiceImplementationDefinition impl = sd.getDefaultImplementation();
+ if (impl != null) {
if (_log.isDebugEnabled())
- _log.debug("Adding contributions from module " + md.getModuleId());
-
- addImplementations(md);
- addContributions(md);
- }
- }
-
- private void addImplementations(ModuleDescriptor md)
- {
- String moduleId = md.getModuleId();
- Module sourceModule = (Module) _modules.get(moduleId);
-
- List implementations = md.getImplementations();
- int count = size(implementations);
-
- for (int i = 0; i < count; i++)
- {
- ImplementationDescriptor impl = (ImplementationDescriptor) implementations.get(i);
-
- if (!includeContribution(impl.getConditionalExpression(), sourceModule, impl
- .getLocation()))
- continue;
-
- String pointId = impl.getServiceId();
- String qualifiedId = IdUtils.qualify(moduleId, pointId);
-
- addImplementations(sourceModule, qualifiedId, impl);
- }
-
- }
-
- private void addContributions(ModuleDescriptor md)
- {
- String moduleId = md.getModuleId();
- Module sourceModule = (Module) _modules.get(moduleId);
-
- List contributions = md.getContributions();
- int count = size(contributions);
-
- for (int i = 0; i < count; i++)
- {
- ContributionDescriptor cd = (ContributionDescriptor) contributions.get(i);
-
- if (!includeContribution(cd.getConditionalExpression(), sourceModule, cd.getLocation()))
- continue;
-
- String pointId = cd.getConfigurationId();
- String qualifiedId = IdUtils.qualify(moduleId, pointId);
-
- ConfigurationPointImpl point = (ConfigurationPointImpl) _configurationPoints
- .get(qualifiedId);
-
- if (point == null)
- {
- _errorHandler.error(_log, ImplMessages.unknownConfigurationPoint(moduleId, cd), cd
- .getLocation(), null);
-
- continue;
- }
-
+ _log.debug("Adding implementation to service extension point " + point.getExtensionPointId());
+
+ // TODO annotations: Visibility
if (!point.visibleToModule(sourceModule))
{
- _errorHandler.error(_log, ImplMessages.configurationPointNotVisible(
- point,
- sourceModule), cd.getLocation(), null);
- continue;
+ _errorHandler.error(
+ _log,
+ ImplMessages.servicePointNotVisible(point, sourceModule),
+ sd.getLocation(),
+ null);
+ return;
}
-
- addContributionElements(sourceModule, point, cd.getElements());
- }
- }
-
- private Schema findSchema(SchemaImpl schema, Module module, String schemaId, Location location)
- {
- if (schema != null)
- {
- schema.setModule(module);
- return schema;
- }
-
- if (schemaId == null)
- return null;
-
- String moduleId = module.getModuleId();
- String qualifiedId = IdUtils.qualify(moduleId, schemaId);
-
- return getSchema(qualifiedId, moduleId, location);
- }
-
- private Schema getSchema(String schemaId, String referencingModule, Location reference)
- {
- Schema schema = (Schema) _schemas.get(schemaId);
-
- if (schema == null)
- _errorHandler
- .error(_log, ImplMessages.unableToResolveSchema(schemaId), reference, null);
- else if (!schema.visibleToModule(referencingModule))
- {
- _errorHandler.error(
- _log,
- ImplMessages.schemaNotVisible(schemaId, referencingModule),
- reference,
- null);
- schema = null;
- }
-
- return schema;
- }
-
- /**
- * Adds internal service contributions; the contributions provided inplace with the service
- * definition.
- */
- private void addInternalImplementations(Module sourceModule, String pointId,
- ServicePointDescriptor spd)
- {
- InstanceBuilder builder = spd.getInstanceBuilder();
- List interceptors = spd.getInterceptors();
-
- if (builder == null && interceptors == null)
- return;
-
- if (builder != null)
- addServiceInstanceBuilder(sourceModule, pointId, builder, true);
-
- if (interceptors == null)
- return;
-
- int count = size(interceptors);
-
- for (int i = 0; i < count; i++)
- {
- InterceptorDescriptor id = (InterceptorDescriptor) interceptors.get(i);
- addInterceptor(sourceModule, pointId, id);
- }
- }
-
- /**
- * Adds ordinary service contributions.
- */
-
- private void addImplementations(Module sourceModule, String pointId, ImplementationDescriptor id)
- {
- InstanceBuilder builder = id.getInstanceBuilder();
- List interceptors = id.getInterceptors();
-
- if (builder != null)
- addServiceInstanceBuilder(sourceModule, pointId, builder, false);
-
- int count = size(interceptors);
- for (int i = 0; i < count; i++)
- {
- InterceptorDescriptor ind = (InterceptorDescriptor) interceptors.get(i);
-
- addInterceptor(sourceModule, pointId, ind);
- }
- }
-
- /**
- * Adds an {@link InstanceBuilder} to a service extension point.
- */
- private void addServiceInstanceBuilder(Module sourceModule, String pointId,
- InstanceBuilder builder, boolean isDefault)
- {
- if (_log.isDebugEnabled())
- _log.debug("Adding " + builder + " to service extension point " + pointId);
-
- ServicePointImpl point = (ServicePointImpl) _servicePoints.get(pointId);
-
- if (point == null)
- {
- _errorHandler.error(
- _log,
- ImplMessages.unknownServicePoint(sourceModule, pointId),
- builder.getLocation(),
- null);
- return;
- }
-
- if (!point.visibleToModule(sourceModule))
- {
- _errorHandler.error(
- _log,
- ImplMessages.servicePointNotVisible(point, sourceModule),
- builder.getLocation(),
- null);
- return;
- }
-
- if (point.getServiceConstructor(isDefault) != null)
- {
- _errorHandler.error(
- _log,
- ImplMessages.duplicateFactory(sourceModule, pointId, point),
- builder.getLocation(),
- null);
-
- return;
- }
-
- point.setServiceModel(builder.getServiceModel());
- point.setServiceConstructor(builder.createConstructor(point, sourceModule), isDefault);
- }
-
- private void addInterceptor(Module sourceModule, String pointId, InterceptorDescriptor id)
- {
- if (_log.isDebugEnabled())
- _log.debug("Adding " + id + " to service extension point " + pointId);
-
- ServicePointImpl point = (ServicePointImpl) _servicePoints.get(pointId);
-
- String sourceModuleId = sourceModule.getModuleId();
-
- if (point == null)
- {
- _errorHandler.error(_log, ImplMessages.unknownServicePoint(sourceModule, pointId), id
- .getLocation(), null);
-
- return;
- }
-
- if (!point.visibleToModule(sourceModule))
- {
- _errorHandler.error(_log, ImplMessages.servicePointNotVisible(point, sourceModule), id
- .getLocation(), null);
- return;
+
+ point.setServiceModel(impl.getServiceModel());
+ point.setServiceConstructor(impl.getServiceConstructor(), true);
}
- ServiceInterceptorContributionImpl sic = new ServiceInterceptorContributionImpl();
-
- // Allow the factory id to be unqualified, to refer to an interceptor factory
- // service from within the same module.
-
- sic.setFactoryServiceId(IdUtils.qualify(sourceModuleId, id.getFactoryServiceId()));
- sic.setLocation(id.getLocation());
-
- sic.setFollowingInterceptorIds(IdUtils.qualifyList(sourceModuleId, id.getBefore()));
- sic.setPrecedingInterceptorIds(IdUtils.qualifyList(sourceModuleId, id.getAfter()));
- sic.setName(id.getName() != null ? IdUtils.qualify(sourceModuleId, id.getName()) : null);
- sic.setContributingModule(sourceModule);
- sic.setParameters(id.getParameters());
-
- point.addInterceptorContribution(sic);
}
-
- /**
- * Checks that each service has at service constructor.
- */
- private void checkForMissingServices()
+
+ private void addContributions(ConfigurationPointDefinition cpd, ConfigurationPointImpl point, Module sourceModule)
{
- Iterator i = _servicePoints.values().iterator();
- while (i.hasNext())
+ for (Iterator contributions = cpd.getContributions().iterator(); contributions.hasNext();)
{
- ServicePointImpl point = (ServicePointImpl) i.next();
+ ContributionDefinition cd = (ContributionDefinition) contributions.next();
+
+// if (_log.isDebugEnabled())
+// _log.debug("Adding interceptor " + id. + " to service extension point " + pointId);
- if (point.getServiceConstructor() != null)
- continue;
-
- _errorHandler.error(_log, ImplMessages.missingService(point), null, null);
- }
- }
-
- /**
- * Checks that each configuration extension point has the right number of contributions.
- */
-
- private void checkContributionCounts()
- {
- Iterator i = _configurationPoints.values().iterator();
-
- while (i.hasNext())
- {
- ConfigurationPointImpl point = (ConfigurationPointImpl) i.next();
-
- Occurances expected = point.getExpectedCount();
-
- int actual = point.getContributionCount();
-
- if (expected.inRange(actual))
- continue;
-
- _errorHandler.error(_log, ImplMessages.wrongNumberOfContributions(
- point,
- actual,
- expected), point.getLocation(), null);
+ String sourceModuleId = sourceModule.getModuleId();
+
+ if (!point.visibleToModule(sourceModule))
+ {
+ _errorHandler.error(_log, ImplMessages.configurationNotVisible(point.getExtensionPointId(), sourceModule), cpd
+ .getLocation(), null);
+ return;
+ }
+
+ point.addContribution(cd.getContributionConstructor());
}
-
+
}
- /**
- * Filters a contribution based on an expression. Returns true if the expression is null, or
- * evaluates to true. Returns false if the expression if non-null and evaluates to false, or an
- * exception occurs evaluating the expression.
- *
- * @param expression
- * to parse and evaluate
- * @param location
- * of the expression (used if an error is reported)
- * @since 1.1
- */
-
- private boolean includeContribution(String expression, Module module, Location location)
+ private void addInterceptors(ServicePointDefinition sd, ServicePointImpl point, Module sourceModule)
{
- if (expression == null)
- return true;
-
- if (_conditionalExpressionParser == null)
- _conditionalExpressionParser = new Parser();
+ String pointId = point.getExtensionPointId();
- try
+ for (Iterator interceptors = sd.getInterceptors().iterator(); interceptors.hasNext();)
{
- Node node = _conditionalExpressionParser.parse(expression);
+ ServiceInterceptorDefinition id = (ServiceInterceptorDefinition) interceptors.next();
+
+// if (_log.isDebugEnabled())
+// _log.debug("Adding interceptor " + id. + " to service extension point " + pointId);
- return node.evaluate(new EvaluationContextImpl(module.getClassResolver()));
- }
- catch (RuntimeException ex)
- {
- _errorHandler.error(_log, ex.getMessage(), location, ex);
-
- return false;
+// String sourceModuleId = sourceModule.getModuleId();
+
+ if (!point.visibleToModule(sourceModule))
+ {
+ _errorHandler.error(_log, ImplMessages.servicePointNotVisible(point, sourceModule), id
+ .getLocation(), null);
+ return;
+ }
+
+ point.addInterceptor(id.getServiceConstructor());
}
}
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java Mon Jun 12 14:44:52 2006
@@ -41,7 +41,6 @@
import org.apache.hivemind.internal.ser.ServiceSerializationSupport;
import org.apache.hivemind.internal.ser.ServiceToken;
import org.apache.hivemind.order.Orderer;
-import org.apache.hivemind.schema.Translator;
import org.apache.hivemind.service.ThreadEventNotifier;
import org.apache.hivemind.util.Defense;
import org.apache.hivemind.util.PropertyUtils;
@@ -58,6 +57,11 @@
private static final String SYMBOL_SOURCES = "hivemind.SymbolSources";
/**
+ * Map of {@link Module} keyed on module id.
+ */
+ private Map _modules = new HashMap();
+
+ /**
* Map of {@link ServicePoint} keyed on fully qualified service id.
*/
private Map _servicePoints = new HashMap();
@@ -80,6 +84,8 @@
private ShutdownCoordinator _shutdownCoordinator;
+ private Map _natures = new HashMap();
+
/**
* Map of {@link org.apache.hivemind.internal.ser.ServiceToken}, keyed on service id.
*
@@ -100,8 +106,6 @@
private ThreadEventNotifier _threadEventNotifier;
- private TranslatorManager _translatorManager;
-
private SymbolExpander _expander;
public RegistryInfrastructureImpl(ErrorHandler errorHandler, Locale locale)
@@ -109,8 +113,6 @@
_errorHandler = errorHandler;
_locale = locale;
- _translatorManager = new TranslatorManager(this, errorHandler);
-
_expander = new SymbolExpander(_errorHandler, this);
}
@@ -118,6 +120,14 @@
{
return _locale;
}
+
+ public void addModule(Module module)
+ {
+ checkStarted();
+
+ _modules.put(module.getModuleId(), module);
+
+ }
public void addServicePoint(ServicePoint point)
{
@@ -263,25 +273,11 @@
return result;
}
- public List getConfiguration(String configurationId, Module module)
+ public Object getConfiguration(String configurationId, Module module)
{
ConfigurationPoint point = getConfigurationPoint(configurationId, module);
- return point.getElements();
- }
-
- public boolean isConfigurationMappable(String configurationId, Module module)
- {
- ConfigurationPoint point = getConfigurationPoint(configurationId, module);
-
- return point.areElementsMappable();
- }
-
- public Map getConfigurationAsMap(String configurationId, Module module)
- {
- ConfigurationPoint point = getConfigurationPoint(configurationId, module);
-
- return point.getElementsAsMap();
+ return point.getContainer();
}
public String toString()
@@ -320,7 +316,7 @@
if (_variableSources != null)
return _variableSources;
- List contributions = getConfiguration(SYMBOL_SOURCES, null);
+ List contributions = (List) getConfiguration(SYMBOL_SOURCES, null);
Orderer o = new Orderer(LogFactory.getLog(SYMBOL_SOURCES), _errorHandler, ImplMessages
.symbolSourceContribution());
@@ -458,7 +454,7 @@
private void readServiceModelFactories()
{
- List l = getConfiguration("hivemind.ServiceModels", null);
+ List l = (List) getConfiguration("hivemind.ServiceModels", null);
_serviceModelFactories = new HashMap();
@@ -537,11 +533,6 @@
return _errorHandler;
}
- public Translator getTranslator(String constructor)
- {
- return _translatorManager.getTranslator(constructor);
- }
-
public Object getServiceFromToken(ServiceToken token)
{
Defense.notNull(token, "token");
@@ -589,21 +580,10 @@
public Module getModule(String moduleId)
{
- for (Iterator i = _servicePoints.values().iterator(); i.hasNext();)
- {
- final ServicePoint servicePoint = (ServicePoint) i.next();
-
- if (servicePoint.getModule().getModuleId().equals(moduleId))
- {
- return servicePoint.getModule();
- }
- }
- return null;
+ return (Module) _modules.get(moduleId);
}
- /*
- * (non-Javadoc)
- *
+ /**
* @see org.apache.hivemind.internal.RegistryInfrastructure#getServiceIds(java.lang.Class)
*/
public List getServiceIds(Class serviceInterface)
@@ -626,4 +606,21 @@
}
return serviceIds;
}
+
+ /**
+ * @see org.apache.hivemind.internal.RegistryInfrastructure#getNature(java.lang.Class)
+ */
+ public Object getNature(Class natureType)
+ {
+ return _natures.get(natureType);
+ }
+
+ /**
+ * @see org.apache.hivemind.internal.RegistryInfrastructure#addNature(java.lang.Class, java.lang.Object)
+ */
+ public void addNature(Class natureType, Object nature)
+ {
+ _natures.put(natureType, nature);
+ }
+
}
Added: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryPostProcessor.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryPostProcessor.java?rev=413747&view=auto
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryPostProcessor.java (added)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryPostProcessor.java Mon Jun 12 14:44:52 2006
@@ -0,0 +1,18 @@
+package org.apache.hivemind.impl;
+
+import org.apache.hivemind.ErrorHandler;
+import org.apache.hivemind.definition.RegistryDefinition;
+
+public interface RegistryPostProcessor
+{
+ /**
+ * Is called after all registry providers have run through their process method.
+ * That means, all extension points of all modules are now known to the registry
+ * definition.
+ *
+ * @param registryDefinition
+ * @param errorHandler
+ */
+ public void postprocess(RegistryDefinition registryDefinition, ErrorHandler errorHandler);
+
+}
Added: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryProvider.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryProvider.java?rev=413747&view=auto
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryProvider.java (added)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryProvider.java Mon Jun 12 14:44:52 2006
@@ -0,0 +1,10 @@
+package org.apache.hivemind.impl;
+
+import org.apache.hivemind.ErrorHandler;
+import org.apache.hivemind.definition.RegistryDefinition;
+
+public interface RegistryProvider
+{
+ public void process(RegistryDefinition registryDefinition, ErrorHandler errorHandler);
+
+}
Added: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryProviderAutoDetector.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryProviderAutoDetector.java?rev=413747&view=auto
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryProviderAutoDetector.java (added)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryProviderAutoDetector.java Mon Jun 12 14:44:52 2006
@@ -0,0 +1,124 @@
+package org.apache.hivemind.impl;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.ClassResolver;
+import org.apache.hivemind.util.URLResource;
+
+/**
+ * Searches for {@link org.apache.hivemind.impl.RegistryProvider} implementations
+ * that are defined in manifest files. Creates an instance of each
+ * implementation and returns them.
+ *
+ * @author Achim Huegen
+ */
+public class RegistryProviderAutoDetector
+{
+ private static final Log LOG = LogFactory.getLog(RegistryProviderAutoDetector.class);
+ public static final String MANIFEST = "META-INF/MANIFEST.MF";
+ public static final String HIVEMIND_SECTION_NAME = "hivemind";
+ public static final String PROVIDER_ATTRIBUTE_NAME = "hivemind-provider";
+
+ private List _providers = new ArrayList();
+
+ public RegistryProviderAutoDetector(ClassResolver resolver)
+ {
+ processManifestFiles(resolver);
+ }
+
+ public List getProviders()
+ {
+ return _providers;
+ }
+
+ private void processManifestFiles(ClassResolver resolver)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Processing manifest files visible to " + resolver);
+
+ ClassLoader loader = resolver.getClassLoader();
+ Enumeration e = null;
+
+ try
+ {
+ e = loader.getResources(MANIFEST);
+ }
+ catch (IOException ex)
+ {
+ throw new ApplicationRuntimeException(ImplMessages.unableToFindProviders(resolver, ex),
+ ex);
+ }
+
+ while (e.hasMoreElements())
+ {
+ URL descriptorURL = (URL) e.nextElement();
+
+ processManifestFile(resolver, new URLResource(descriptorURL));
+ }
+
+ }
+
+
+ private void processManifestFile(ClassResolver resolver, URLResource resource)
+ {
+ URL url = resource.getResourceURL();
+ Manifest manifest;
+ try
+ {
+ manifest = new Manifest(url.openStream());
+ }
+ catch (IOException e)
+ {
+ throw new ApplicationRuntimeException(ImplMessages.unableToReadManifest(url, e),
+ e);
+ }
+ // Search for an entry that defines a provider class
+// Attributes attributes = manifest.getAttributes(HIVEMIND_SECTION_NAME);
+ Attributes attributes = manifest.getMainAttributes();
+ if (attributes != null) {
+ String providerClassName = attributes.getValue(PROVIDER_ATTRIBUTE_NAME);
+ if (providerClassName != null) {
+ loadProvider(resolver, providerClassName);
+ }
+ }
+ }
+
+ private void loadProvider(ClassResolver resolver, String providerClassName)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Loading provider " + providerClassName);
+ Object provider = null;
+ try
+ {
+ Class providerClass = resolver.findClass(providerClassName);
+ provider = providerClass.newInstance();
+ }
+ catch (Exception e)
+ {
+ Exception cause = e;
+ if (e instanceof InvocationTargetException)
+ {
+ cause = (InvocationTargetException) e;
+ }
+ throw new ApplicationRuntimeException(ImplMessages.unableToCreateProvider(providerClassName, e),
+ cause);
+ }
+ // Check type of provider
+ if (!(provider instanceof RegistryProvider)) {
+ throw new ApplicationRuntimeException(ImplMessages.providerWrongType(providerClassName, RegistryProvider.class));
+ }
+
+ _providers.add(provider);
+ }
+
+}
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java Mon Jun 12 14:44:52 2006
@@ -22,15 +22,14 @@
import org.apache.commons.logging.LogFactory;
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.HiveMind;
-import org.apache.hivemind.Occurances;
import org.apache.hivemind.ShutdownCoordinator;
import org.apache.hivemind.events.RegistryShutdownListener;
import org.apache.hivemind.internal.ServiceImplementationConstructor;
+import org.apache.hivemind.internal.ServiceInterceptorConstructor;
import org.apache.hivemind.internal.ServiceInterceptorContribution;
import org.apache.hivemind.internal.ServiceModel;
import org.apache.hivemind.internal.ServiceModelFactory;
import org.apache.hivemind.order.Orderer;
-import org.apache.hivemind.schema.Schema;
import org.apache.hivemind.service.InterfaceSynthesizer;
import org.apache.hivemind.util.ToStringBuilder;
@@ -58,14 +57,10 @@
private ServiceImplementationConstructor _serviceConstructor;
- private List _interceptorContributions;
+ private List _interceptorConstructors;
private boolean _interceptorsOrdered;
- private Schema _parametersSchema;
-
- private Occurances _parametersCount;
-
private String _serviceModel;
private ShutdownCoordinator _shutdownCoordinator;
@@ -80,21 +75,19 @@
builder.append("serviceInterfaceName", _serviceInterfaceName);
builder.append("defaultServiceConstructor", _defaultServiceConstructor);
builder.append("serviceConstructor", _serviceConstructor);
- builder.append("interceptorContributions", _interceptorContributions);
- builder.append("parametersSchema", _parametersSchema);
- builder.append("parametersCount", _parametersCount);
+ builder.append("interceptorConstructors", _interceptorConstructors);
builder.append("serviceModel", _serviceModel);
if (_building)
builder.append("building", _building);
}
- public void addInterceptorContribution(ServiceInterceptorContribution contribution)
+ public void addInterceptor(ServiceInterceptorConstructor constructor)
{
- if (_interceptorContributions == null)
- _interceptorContributions = new ArrayList();
+ if (_interceptorConstructors == null)
+ _interceptorConstructors = new ArrayList();
- _interceptorContributions.add(contribution);
+ _interceptorConstructors.add(constructor);
}
public synchronized Class getServiceInterface()
@@ -168,16 +161,6 @@
_serviceInterfaceName = string;
}
- public void setParametersSchema(Schema schema)
- {
- _parametersSchema = schema;
- }
-
- public Schema getParametersSchema()
- {
- return _parametersSchema;
- }
-
public ServiceImplementationConstructor getServiceConstructor(boolean defaultConstructor)
{
return defaultConstructor ? _defaultServiceConstructor : _serviceConstructor;
@@ -245,7 +228,7 @@
public void clearConstructorInformation()
{
_serviceConstructor = null;
- _interceptorContributions = null;
+ _interceptorConstructors = null;
}
// Hm. Does this need to be synchronized?
@@ -254,16 +237,17 @@
{
if (!_interceptorsOrdered)
{
- _interceptorContributions = orderInterceptors();
+ // TODO annotations: Order interceptors
+// _interceptorConstructors = orderInterceptors();
_interceptorsOrdered = true;
}
- return _interceptorContributions;
+ return _interceptorConstructors;
}
private List orderInterceptors()
{
- if (HiveMind.isEmpty(_interceptorContributions))
+ if (HiveMind.isEmpty(_interceptorConstructors))
return null;
// Any error logging should go to the extension point
@@ -274,7 +258,7 @@
Orderer orderer = new Orderer(log, getModule().getErrorHandler(), ImplMessages
.interceptorContribution());
- Iterator i = _interceptorContributions.iterator();
+ Iterator i = _interceptorConstructors.iterator();
while (i.hasNext())
{
ServiceInterceptorContribution sic = (ServiceInterceptorContribution) i.next();
@@ -308,16 +292,6 @@
getService();
_serviceModelObject.instantiateService();
- }
-
- public Occurances getParametersCount()
- {
- return _parametersCount;
- }
-
- public void setParametersCount(Occurances occurances)
- {
- _parametersCount = occurances;
}
/**
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/servicemodel/AbstractServiceModelImpl.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/servicemodel/AbstractServiceModelImpl.java?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/servicemodel/AbstractServiceModelImpl.java (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/servicemodel/AbstractServiceModelImpl.java Mon Jun 12 14:44:52 2006
@@ -25,8 +25,9 @@
import org.apache.hivemind.impl.ConstructableServicePoint;
import org.apache.hivemind.impl.InterceptorStackImpl;
import org.apache.hivemind.impl.ProxyBuilder;
+import org.apache.hivemind.internal.Module;
import org.apache.hivemind.internal.ServiceImplementationConstructor;
-import org.apache.hivemind.internal.ServiceInterceptorContribution;
+import org.apache.hivemind.internal.ServiceInterceptorConstructor;
import org.apache.hivemind.internal.ServiceModel;
import org.apache.hivemind.service.ClassFab;
import org.apache.hivemind.util.ConstructorUtils;
@@ -79,7 +80,7 @@
for (int i = count - 1; i >= 0; i--)
{
- ServiceInterceptorContribution ic = (ServiceInterceptorContribution) interceptors
+ ServiceInterceptorConstructor ic = (ServiceInterceptorConstructor) interceptors
.get(i);
stack.process(ic);
@@ -105,7 +106,10 @@
Class declaredInterface = _servicePoint.getDeclaredInterface();
ServiceImplementationConstructor constructor = _servicePoint.getServiceConstructor();
- Object result = constructor.constructCoreServiceImplementation();
+ String contributingModuleId = constructor.getContributingModuleId();
+ // Is there a more elegant way to retrieve a module?
+ Module contributingModule = _servicePoint.getModule().getModule(contributingModuleId);
+ Object result = constructor.constructCoreServiceImplementation(_servicePoint, contributingModule);
if (result == null)
throw new ApplicationRuntimeException(ServiceModelMessages
Added: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationConstructor.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationConstructor.java?rev=413747&view=auto
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationConstructor.java (added)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationConstructor.java Mon Jun 12 14:44:52 2006
@@ -0,0 +1,31 @@
+// 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.internal;
+
+import org.apache.hivemind.Locatable;
+
+/**
+ * A contribution to a configuration point that is used to
+ * create the configuration container object.
+ *
+ * @author Achim Huegen
+ */
+public interface ConfigurationConstructor extends Locatable
+{
+ /**
+ * Creates a new configuration container.
+ */
+ public Object constructConfigurationContainer(Module module);
+}
Modified: jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationPoint.java
URL: http://svn.apache.org/viewvc/jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationPoint.java?rev=413747&r1=413746&r2=413747&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationPoint.java (original)
+++ jakarta/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/ConfigurationPoint.java Mon Jun 12 14:44:52 2006
@@ -14,11 +14,6 @@
package org.apache.hivemind.internal;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.hivemind.schema.Schema;
/**
* An extension point that provides configuration data in the form of a list of elements.
@@ -28,40 +23,15 @@
public interface ConfigurationPoint extends ExtensionPoint
{
/**
- * Returns the constructed extensions as a list of elements assembled from the various
- * contributions. The List is unmodifiable. May return an empty list, but won't return null. May
+ * Returns the container that holds the configuration data. May
* return a proxy to the actual data (which is constructed only as needed), but user code
* shouldn't care about that.
*/
- public List getElements();
-
+ public Object getContainer();
+
/**
- * Returns true if the elements contributed to this configuration point can be
- * {@link #getElementsAsMap() retrieved as a Map}. The contributions in the map are keyed on
- * an attribute as specified by the contributions schema. Thus, as a requirement, this
- * configuration point must have a defined schema, which in turn must support
- * {@link Schema#canInstancesBeKeyed() keying} of all valid instances.
- *
- * @since 1.1
+ * @return the type of the container that holds the configuration data
*/
- public boolean areElementsMappable();
+ public Class getContainerType();
- /**
- * Returns the constructed extensions as a Map of elements assembled from the various
- * contributions. The returned Map is unmodifiable and is keyed on the contribution elements'
- * {@link org.apache.hivemind.schema.ElementModel#getKeyAttribute() key attribute}. Just as
- * {@link #getElements()} this method may also return a proxy.
- * <p>
- * If there is no key attribute defined for this configuration's contribution elements an
- * {@link org.apache.hivemind.ApplicationRuntimeException} is thrown.
- *
- * @since 1.1
- */
- public Map getElementsAsMap() throws ApplicationRuntimeException;
-
- /**
- * Returns the Schema for contributions to the configuration point (which may be null if the
- * point does not define a schema for contributions).
- */
- public Schema getContributionsSchema();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org