hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahue...@apache.org
Subject svn commit: r478899 - in /hivemind/branches/branch-2-0-annot: annotations/src/java/org/apache/hivemind/annotations/ annotations/src/java/org/apache/hivemind/annotations/internal/ annotations/src/test/org/apache/hivemind/annotations/ framework/src/java/...
Date Fri, 24 Nov 2006 15:38:09 GMT
Author: ahuegen
Date: Fri Nov 24 07:38:04 2006
New Revision: 478899

URL: http://svn.apache.org/viewvc?view=rev&rev=478899
Log:
Extracted management of SymbolSources from registry and made it a separate service in the xml module.

Added:
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/SymbolSource.java   (contents, props changed)
      - copied, changed from r478883, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/SymbolSource.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/DefaultsSymbolSource.java   (contents, props changed)
      - copied, changed from r478883, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/DefaultsSymbolSource.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/FactoryDefault.java   (contents, props changed)
      - copied, changed from r478883, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/FactoryDefault.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolSourceContribution.java   (contents, props changed)
      - copied, changed from r478883, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/SymbolSourceContribution.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SystemPropertiesSymbolSource.java   (contents, props changed)
      - copied, changed from r478883, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/SystemPropertiesSymbolSource.java
Removed:
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/SymbolSource.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/SymbolSourceContribution.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/SystemPropertiesSymbolSource.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/DefaultsSymbolSource.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/FactoryDefault.java
Modified:
    hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Registry.java
    hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java
    hivemind/branches/branch-2-0-annot/annotations/src/test/org/apache/hivemind/annotations/SimpleAnnotatedModule.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/Registry.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ModuleImpl.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/Module.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/RegistryInfrastructure.java
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestMisc.java
    hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/SymbolExpander.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolExpanderImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/TranslatorManagerImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlContributionImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlCoreServicesProvider.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplMessages.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplStrings.properties
    hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSymbolExpander.java

Modified: hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Registry.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Registry.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Registry.java (original)
+++ hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/Registry.java Fri Nov 24 07:38:04 2006
@@ -1,6 +1,5 @@
 package org.apache.hivemind.annotations;
 
-import org.apache.hivemind.SymbolSource;
 import org.apache.hivemind.service.Autowiring;
 
 /**
@@ -9,7 +8,7 @@
  * 
  * @author Achim Huegen
  */
-public interface Registry extends SymbolSource
+public interface Registry 
 {
     public <T> T getService(String serviceId, Class<T> serviceInterface);
     public <T> T getService(Class<T> serviceInterface);

Modified: hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/annotations/src/java/org/apache/hivemind/annotations/internal/RegistryImpl.java Fri Nov 24 07:38:04 2006
@@ -64,12 +64,4 @@
         return getService(Autowiring.class);
     }
 
-    /**
-     * @see org.apache.hivemind.SymbolSource#valueForSymbol(java.lang.String)
-     */
-    public String valueForSymbol(String name)
-    {
-        return _delegate.valueForSymbol(name);
-    }
-
 }

Modified: hivemind/branches/branch-2-0-annot/annotations/src/test/org/apache/hivemind/annotations/SimpleAnnotatedModule.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/annotations/src/test/org/apache/hivemind/annotations/SimpleAnnotatedModule.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/annotations/src/test/org/apache/hivemind/annotations/SimpleAnnotatedModule.java (original)
+++ hivemind/branches/branch-2-0-annot/annotations/src/test/org/apache/hivemind/annotations/SimpleAnnotatedModule.java Fri Nov 24 07:38:04 2006
@@ -1,11 +1,8 @@
 package org.apache.hivemind.annotations;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 
-import org.apache.hivemind.service.impl.FactoryDefault;
-
 public class SimpleAnnotatedModule extends AbstractAnnotatedModule
 {
     @Service(id = "Test")
@@ -36,14 +33,13 @@
     @Contribution(configurationId = "Demo")
     public void contributeData(List<String> container)
     {
-        String translatedData = getRegistry().valueForSymbol("testsymbol");
-        container.add(translatedData);
+        container.add("contributed-data");
     }
     
-    @Contribution(configurationId = "hivemind.ApplicationDefaults")
-    public void contributeDefaults(HashMap<String,FactoryDefault> container)
-    {
-        container.put("testsymbol", new FactoryDefault("testsymbol", "value"));
-    }
+//    @Contribution(configurationId = "hivemind.ApplicationDefaults")
+//    public void contributeDefaults(HashMap<String,FactoryDefault> container)
+//    {
+//        container.put("testsymbol", new FactoryDefault("testsymbol", "value"));
+//    }
     
 }

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/Registry.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/Registry.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/Registry.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/Registry.java Fri Nov 24 07:38:04 2006
@@ -20,13 +20,11 @@
 /**
  * The HiveMind registry; primarily this is used to gain access to services.
  * <p>
- * In addition, Registry implements {@link org.apache.hivemind.SymbolSource} which allows
- * programatic access to substitution symbols.
  * 
  * @author Howard Lewis Ship
  */
 
-public interface Registry extends SymbolSource
+public interface Registry
 {
     /**
      * Returns true if a configuration for the specified id exists.

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java Fri Nov 24 07:38:04 2006
@@ -2,17 +2,13 @@
 
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
-import java.util.Map;
 
 import org.apache.hivemind.ErrorHandler;
 import org.apache.hivemind.HiveMind;
 import org.apache.hivemind.ShutdownCoordinator;
-import org.apache.hivemind.SymbolSource;
-import org.apache.hivemind.SymbolSourceContribution;
 import org.apache.hivemind.definition.ConfigurationPointDefinition;
 import org.apache.hivemind.definition.ModuleDefinition;
 import org.apache.hivemind.definition.ModuleDefinitionHelper;
@@ -40,7 +36,6 @@
 import org.apache.hivemind.service.impl.AutowiringImpl;
 import org.apache.hivemind.service.impl.AutowiringStrategyContribution;
 import org.apache.hivemind.service.impl.ClassFactoryImpl;
-import org.apache.hivemind.service.impl.DefaultsSymbolSource;
 import org.apache.hivemind.service.impl.EagerLoader;
 import org.apache.hivemind.service.impl.InterfaceSynthesizerImpl;
 import org.apache.hivemind.service.impl.ThreadEventNotifierImpl;
@@ -76,14 +71,6 @@
 
         helper = new ModuleDefinitionHelper(md);
         
-        addSymbolSourcesConfiguration(md);
-        
-        // SymbolSource implementation driven by the FactoryDefaults configuration point.
-        addSymbolSource(md, "FactoryDefaultsSymbolSource", "FactoryDefaults");
-        
-        // SymbolSource implementation driven by the ApplicationDefaults configuration point.
-        addSymbolSource(md, "ApplicationDefaultsSymbolSource", "ApplicationDefaults");
-
         addClassFactory(md);
 
         addThreadEventNotifier(md);
@@ -105,65 +92,6 @@
         addAutowiring(md);
         
         addAutowiringStrategiesConfiguration();
-    }
-
-    /**
-     * Provides a list of sources (SymbolSource) for values of substitution symbols.
-     */
-    private void addSymbolSourcesConfiguration(ModuleDefinition md)
-    {
-        ConfigurationPointDefinition cpd = helper.addConfigurationPoint("SymbolSources",
-                new CreateClassConfigurationConstructor(md.getLocation(), ArrayList.class.getName()), List.class
-                        .getName());
-
-        helper.addContributionDefinition(cpd, new ContributionConstructor()
-        {
-
-            public void contribute(ContributionConstructionContext context, Object container)
-            {
-                // Add the default symbol sources FactoryDefaults and
-                // ApplicationDefaults
-                SymbolSource factoryDefaults = (SymbolSource) context.getService(
-                        "FactoryDefaultsSymbolSource", SymbolSource.class);
-                SymbolSourceContribution factoryDefaultsContrib = new SymbolSourceContribution(factoryDefaults,
-                        "hivemind.FactoryDefaults", null, null);
-                ((List) container).add(factoryDefaultsContrib);
-
-                SymbolSource applicationDefaults = (SymbolSource) context.getService(
-                        "ApplicationDefaultsSymbolSource", SymbolSource.class);
-                SymbolSourceContribution applicationDefaultsContrib = new SymbolSourceContribution(applicationDefaults,
-                        "hivemind.ApplicationDefaults", null, "hivemind.FactoryDefaults");
-                ((List) container).add(applicationDefaultsContrib);
-            }
-        });
-    }
-    
-    /**
-     * Adds a service that implements the symbol source interface and a
-     * corresponding configuration point that holds the symbol values.
-     */
-    private void addSymbolSource(ModuleDefinition md, final String servicePointId, final String configurationId)
-    {
-        ServicePointDefinition spd = helper.addServicePoint(servicePointId, SymbolSource.class.getName());
-
-        // Define inline implementation constructor, that wires the corresponding configuration
-        ImplementationConstructor constructor = new AbstractServiceImplementationConstructor(md.getLocation())
-        {
-            public Object constructCoreServiceImplementation(ImplementationConstructionContext context)
-            {
-                DefaultsSymbolSource result = new DefaultsSymbolSource();
-                result.setDefaults(((Map) context.getConfiguration(configurationId)).values());
-                result.initializeService();
-                return result;
-            }
-        };
-        helper.addServiceImplementation(spd, constructor, ServiceModel.SINGLETON);
-        
-        // Configuration point for setting defaults for symbol values.
-
-        helper.addConfigurationPoint(configurationId, 
-                new CreateClassConfigurationConstructor(md.getLocation(), HashMap.class.getName()), 
-                Map.class.getName());
     }
 
     /**

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java Fri Nov 24 07:38:04 2006
@@ -136,11 +136,6 @@
         return _formatter.format("no-such-configuration", pointId);
     }
 
-    static String symbolSourceContribution()
-    {
-        return _formatter.getMessage("symbol-source-contribution");
-    }
-
     static String badInterface(String interfaceName, String pointId)
     {
         return _formatter.format("bad-interface", interfaceName, pointId);

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties Fri Nov 24 07:38:04 2006
@@ -31,7 +31,6 @@
 duplicate-factory=Module {0} has contributed a instance builder to service point {1}, which conflicts with an existing contribution by module {2}. The duplicate contribution has been ignored.  
 
 no-such-configuration=Configuration point {0} does not exist.
-symbol-source-contribution=symbol source
 bad-interface=Unable to find interface {0} (for service {1}).
 service-wrong-interface=Service {0} does not implement the requested interface ({1}).  The declared service interface type is {2}.
 shutdown-coordinator-failure=Unable to shutdown {0}: {1}

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ModuleImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ModuleImpl.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ModuleImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ModuleImpl.java Fri Nov 24 07:38:04 2006
@@ -162,11 +162,6 @@
         return _registry.getErrorHander();
     }
 
-    public String valueForSymbol(String symbol)
-    {
-        return _registry.valueForSymbol(symbol);
-    }
-
     public synchronized Class resolveType(String type)
     {
         Class result = (Class) _typeCache.get(type);

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java Fri Nov 24 07:38:04 2006
@@ -82,11 +82,6 @@
         _infrastructure.cleanupThread();
     }
 
-    public String valueForSymbol(String name)
-    {
-        return _infrastructure.valueForSymbol(name);
-    }
-
     /** @since 1.1 */
     public void setupThread()
     {

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java Fri Nov 24 07:38:04 2006
@@ -23,14 +23,11 @@
 import java.util.Locale;
 import java.util.Map;
 
-import org.apache.commons.logging.LogFactory;
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.ErrorHandler;
 import org.apache.hivemind.HiveMind;
 import org.apache.hivemind.HiveMindMessages;
 import org.apache.hivemind.ShutdownCoordinator;
-import org.apache.hivemind.SymbolSource;
-import org.apache.hivemind.SymbolSourceContribution;
 import org.apache.hivemind.internal.ConfigurationPoint;
 import org.apache.hivemind.internal.Module;
 import org.apache.hivemind.internal.RegistryInfrastructure;
@@ -39,7 +36,6 @@
 import org.apache.hivemind.internal.ser.ServiceSerializationHelper;
 import org.apache.hivemind.internal.ser.ServiceSerializationSupport;
 import org.apache.hivemind.internal.ser.ServiceToken;
-import org.apache.hivemind.order.Orderer;
 import org.apache.hivemind.service.ThreadEventNotifier;
 import org.apache.hivemind.util.Defense;
 import org.apache.hivemind.util.PropertyUtils;
@@ -53,7 +49,6 @@
 public final class RegistryInfrastructureImpl implements RegistryInfrastructure,
         ServiceSerializationSupport
 {
-    private static final String SYMBOL_SOURCES = "hivemind.SymbolSources";
 
     /**
      * Map of {@link Module} keyed on module id.
@@ -75,8 +70,6 @@
      */
     private Map _configurationPoints = new HashMap();
 
-    private SymbolSource[] _variableSources;
-
     private ErrorHandler _errorHandler;
 
     private Locale _locale;
@@ -287,56 +280,6 @@
         return builder.toString();
     }
 
-    public String valueForSymbol(String name)
-    {
-        checkShutdown();
-
-        SymbolSource[] sources = getSymbolSources();
-
-        for (int i = 0; i < sources.length; i++)
-        {
-            String value = sources[i].valueForSymbol(name);
-
-            if (value != null)
-                return value;
-        }
-
-        return null;
-    }
-
-    private synchronized SymbolSource[] getSymbolSources()
-    {
-        if (_variableSources != null)
-            return _variableSources;
-
-        List contributions = (List) getConfiguration(SYMBOL_SOURCES, null);
-
-        Orderer o = new Orderer(LogFactory.getLog(SYMBOL_SOURCES), _errorHandler, ImplMessages
-                .symbolSourceContribution());
-
-        Iterator i = contributions.iterator();
-        while (i.hasNext())
-        {
-            SymbolSourceContribution c = (SymbolSourceContribution) i.next();
-
-            o.add(c, c.getName(), c.getPrecedingNames(), c.getFollowingNames());
-        }
-
-        List sources = o.getOrderedObjects();
-
-        int count = sources.size();
-
-        _variableSources = new SymbolSource[count];
-
-        for (int j = 0; j < count; j++)
-        {
-            SymbolSourceContribution c = (SymbolSourceContribution) sources.get(j);
-            _variableSources[j] = c.getSource();
-        }
-
-        return _variableSources;
-    }
-
     public void setShutdownCoordinator(ShutdownCoordinator coordinator)
     {
         _shutdownCoordinator = coordinator;
@@ -373,7 +316,6 @@
         _servicePointsByInterfaceClassName = null;
         _configurationPoints = null;
         _shutdownCoordinator = null;
-        _variableSources = null;
         _serviceModelFactories = null;
         _threadEventNotifier = null;
         _serviceTokens = null;

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/Module.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/Module.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/Module.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/Module.java Fri Nov 24 07:38:04 2006
@@ -21,7 +21,6 @@
 import org.apache.hivemind.ErrorHandler;
 import org.apache.hivemind.Locatable;
 import org.apache.hivemind.Messages;
-import org.apache.hivemind.SymbolSource;
 
 /**
  * The definition of a HiveMind Module. A Module is a container of service extension points and
@@ -36,7 +35,7 @@
  * 
  * @author Howard Lewis Ship
  */
-public interface Module extends Locatable, SymbolSource
+public interface Module extends Locatable
 {
     /**
      * Returns the unique identifier for this module.

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/RegistryInfrastructure.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/RegistryInfrastructure.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/RegistryInfrastructure.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/internal/RegistryInfrastructure.java Fri Nov 24 07:38:04 2006
@@ -18,7 +18,6 @@
 import java.util.Locale;
 
 import org.apache.hivemind.ErrorHandler;
-import org.apache.hivemind.SymbolSource;
 
 /**
  * Extension of {@link org.apache.hivemind.Registry} provided by some internals of HiveMind to
@@ -26,7 +25,7 @@
  * 
  * @author Howard Lewis Ship
  */
-public interface RegistryInfrastructure extends SymbolSource
+public interface RegistryInfrastructure
 {
     /**
      * Obtains a service from the registry. Typically, what's returned is a proxy, but that's

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=478899&r1=478898&r2=478899
==============================================================================
--- 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 Fri Nov 24 07:38:04 2006
@@ -17,12 +17,10 @@
 import java.util.HashMap;
 
 import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.hivemind.SymbolSource;
 import org.apache.hivemind.definition.construction.ImplementationConstructionContext;
 import org.apache.hivemind.impl.CreateClassServiceConstructor;
 import org.apache.hivemind.impl.ModuleImpl;
 import org.apache.hivemind.impl.ServicePointImpl;
-import org.apache.hivemind.impl.SystemPropertiesSymbolSource;
 import org.apache.hivemind.internal.ImplementationConstructionContextImpl;
 import org.apache.hivemind.internal.Module;
 import org.apache.hivemind.internal.ServicePoint;
@@ -133,12 +131,5 @@
                     "Unable to instantiate instance of class hivemind.test.PrivateBean");
         }
 
-    }
-
-    public void testSystemPropertiesSymbolSource()
-    {
-        SymbolSource s = new SystemPropertiesSymbolSource();
-
-        assertEquals(System.getProperty("user.home"), s.valueForSymbol("user.home"));
     }
 }

Modified: hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml Fri Nov 24 07:38:04 2006
@@ -49,7 +49,7 @@
           follow.
         </attribute> 
   
-        <conversion class="SymbolSourceContribution"> 
+        <conversion class="impl.SymbolSourceContribution"> 
           <map attribute="class" property="source"/> 
           <map attribute="service-id" property="source"/> 
           <map attribute="before" property="followingNames"/> 
@@ -69,7 +69,7 @@
       <attribute name="value" required="true">
         The value for the symbol.
       </attribute>
-      <conversion class="service.impl.FactoryDefault"/>
+      <conversion class="impl.FactoryDefault"/>
     </element>
   </schema>
   

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/SymbolExpander.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/SymbolExpander.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/SymbolExpander.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/SymbolExpander.java Fri Nov 24 07:38:04 2006
@@ -3,14 +3,21 @@
 import org.apache.hivemind.Location;
 
 /**
- * A simple parser used to identify symbols in a string and expand them via a
- * {@link org.apache.hivemind.SymbolSource}.
+ * Manages a list of {@link org.apache.hivemind.SymbolSource} and offers methods to 
+ * lookup symbol values and identify symbols in a string and expand them
  * 
  * @author Howard Lewis Ship
  */
 public interface SymbolExpander
 {
     /**
+     * Returns the value for the symbol, if this source can provide one.
+     * Iterates all known {@link SymbolSource}s.
+     * Returns null if no source can provide a value.
+     */
+    public String valueForSymbol(String name);
+
+    /**
      * <p>
      * Identifies symbols in the text and expands them, using the {@link SymbolSource}. Returns the
      * modified text. May return text if text does not contain any symbols.
@@ -21,4 +28,6 @@
      *            the location to report errors (undefined symbols)
      */
     public String expandSymbols(String text, Location location);
+    
+    
 }

Copied: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/SymbolSource.java (from r478883, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/SymbolSource.java)
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/SymbolSource.java?view=diff&rev=478899&p1=hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/SymbolSource.java&r1=478883&p2=hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/SymbolSource.java&r2=478899
==============================================================================
    (empty)

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/SymbolSource.java
------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.3

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/SymbolSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/SymbolSource.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/DefaultsSymbolSource.java (from r478883, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/DefaultsSymbolSource.java)
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/DefaultsSymbolSource.java?view=diff&rev=478899&p1=hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/DefaultsSymbolSource.java&r1=478883&p2=hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/DefaultsSymbolSource.java&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/DefaultsSymbolSource.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/DefaultsSymbolSource.java Fri Nov 24 07:38:04 2006
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.hivemind.service.impl;
+package org.apache.hivemind.impl;
 
 import java.util.ArrayList;
 import java.util.Collection;

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/DefaultsSymbolSource.java
------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.9

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/DefaultsSymbolSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/DefaultsSymbolSource.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/FactoryDefault.java (from r478883, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/FactoryDefault.java)
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/FactoryDefault.java?view=diff&rev=478899&p1=hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/FactoryDefault.java&r1=478883&p2=hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/FactoryDefault.java&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/FactoryDefault.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/FactoryDefault.java Fri Nov 24 07:38:04 2006
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.hivemind.service.impl;
+package org.apache.hivemind.impl;
 
 
 /**

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/FactoryDefault.java
------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.4

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/FactoryDefault.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/FactoryDefault.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolExpanderImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolExpanderImpl.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolExpanderImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolExpanderImpl.java Fri Nov 24 07:38:04 2006
@@ -14,12 +14,16 @@
 
 package org.apache.hivemind.impl;
 
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hivemind.ErrorHandler;
 import org.apache.hivemind.Location;
 import org.apache.hivemind.SymbolExpander;
 import org.apache.hivemind.SymbolSource;
+import org.apache.hivemind.order.Orderer;
 
 /**
  * A simple parser used to identify symbols in a string and expand them via a
@@ -29,23 +33,81 @@
  */
 public class SymbolExpanderImpl implements SymbolExpander
 {
+    private static final Log LOG = LogFactory.getLog(SymbolExpanderImpl.class);
+
+    private static final int STATE_START = 0;
+
+    private static final int STATE_DOLLAR = 1;
+
+    private static final int STATE_COLLECT_SYMBOL_NAME = 2;
+    
     private ErrorHandler _errorHandler;
 
-    private SymbolSource _source;
+    private SymbolSource[] _symbolSources;
+
+    private List _contributedSymbolSources;
 
-    public SymbolExpanderImpl(ErrorHandler handler, SymbolSource source)
+    public SymbolExpanderImpl(ErrorHandler handler, List symbolSourceContributions)
     {
         _errorHandler = handler;
-        _source = source;
+        _contributedSymbolSources = symbolSourceContributions;
     }
 
-    private static final Log LOG = LogFactory.getLog(SymbolExpanderImpl.class);
+    public SymbolExpanderImpl(ErrorHandler handler, SymbolSource[] symbolSources)
+    {
+        _errorHandler = handler;
+        _symbolSources = symbolSources;
+    }
+    
+    private synchronized SymbolSource[] initContributedSymbolSources(List contributions)
+    {
+        SymbolSource[] symbolSources;
+        
+        Orderer o = new Orderer(LogFactory.getLog(SymbolExpander.class), _errorHandler, XmlImplMessages
+                .symbolSourceContribution());
 
-    private static final int STATE_START = 0;
+        Iterator i = contributions.iterator();
+        while (i.hasNext())
+        {
+            SymbolSourceContribution c = (SymbolSourceContribution) i.next();
 
-    private static final int STATE_DOLLAR = 1;
+            o.add(c, c.getName(), c.getPrecedingNames(), c.getFollowingNames());
+        }
 
-    private static final int STATE_COLLECT_SYMBOL_NAME = 2;
+        List sources = o.getOrderedObjects();
+
+        int count = sources.size();
+
+        symbolSources = new SymbolSource[count];
+
+        for (int j = 0; j < count; j++)
+        {
+            SymbolSourceContribution c = (SymbolSourceContribution) sources.get(j);
+            symbolSources[j] = c.getSource();
+        }
+
+        return symbolSources;
+    }
+
+    public String valueForSymbol(String name)
+    {
+        if (_symbolSources == null && _contributedSymbolSources != null) {
+            // Load the contributions as late as possible since the
+            // parsing of the xml contributions will trigger a recursive call.
+            _symbolSources = initContributedSymbolSources(_contributedSymbolSources);
+            _contributedSymbolSources = null;
+        }
+        
+        for (int i = 0; i < _symbolSources.length; i++)
+        {
+            String value = _symbolSources[i].valueForSymbol(name);
+
+            if (value != null)
+                return value;
+        }
+
+        return null;
+    }
 
     /**
      * @see org.apache.hivemind.SymbolExpander#expandSymbols(java.lang.String, org.apache.hivemind.Location)
@@ -208,7 +270,7 @@
 
     private String expandSymbol(String name, Location location)
     {
-        String value = _source.valueForSymbol(name);
+        String value = valueForSymbol(name);
 
         if (value != null)
             return value;

Copied: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolSourceContribution.java (from r478883, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/SymbolSourceContribution.java)
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolSourceContribution.java?view=diff&rev=478899&p1=hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/SymbolSourceContribution.java&r1=478883&p2=hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolSourceContribution.java&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/SymbolSourceContribution.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolSourceContribution.java Fri Nov 24 07:38:04 2006
@@ -12,7 +12,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.hivemind;
+package org.apache.hivemind.impl;
+
+import org.apache.hivemind.Orderable;
+import org.apache.hivemind.SymbolSource;
 
 /**
  * Contribution to the <code>org.apache.hivemind.SymbolSource</code>

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolSourceContribution.java
------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.4

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolSourceContribution.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SymbolSourceContribution.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SystemPropertiesSymbolSource.java (from r478883, hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/SystemPropertiesSymbolSource.java)
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SystemPropertiesSymbolSource.java?view=diff&rev=478899&p1=hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/SystemPropertiesSymbolSource.java&r1=478883&p2=hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SystemPropertiesSymbolSource.java&r2=478899
==============================================================================
    (empty)

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SystemPropertiesSymbolSource.java
------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.3

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SystemPropertiesSymbolSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SystemPropertiesSymbolSource.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/TranslatorManagerImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/TranslatorManagerImpl.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/TranslatorManagerImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/TranslatorManagerImpl.java Fri Nov 24 07:38:04 2006
@@ -81,7 +81,7 @@
 
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.hivemind.impl.TranslatorManager#getTranslator(java.lang.String)
      */
     public synchronized Translator getTranslator(String constructor)

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlContributionImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlContributionImpl.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlContributionImpl.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlContributionImpl.java Fri Nov 24 07:38:04 2006
@@ -19,7 +19,6 @@
 import java.util.List;
 
 import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.hivemind.TranslatorManager;
 import org.apache.hivemind.definition.construction.ContributionConstructionContext;
 import org.apache.hivemind.definition.construction.ContributionConstructor;
 import org.apache.hivemind.impl.natures.XmlConfigurationPointNature;

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlCoreServicesProvider.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlCoreServicesProvider.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlCoreServicesProvider.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlCoreServicesProvider.java Fri Nov 24 07:38:04 2006
@@ -1,17 +1,24 @@
 package org.apache.hivemind.impl;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.ErrorHandler;
 import org.apache.hivemind.SymbolExpander;
+import org.apache.hivemind.SymbolSource;
 import org.apache.hivemind.TranslatorManager;
+import org.apache.hivemind.definition.ConfigurationPointDefinition;
 import org.apache.hivemind.definition.ModuleDefinition;
 import org.apache.hivemind.definition.ModuleDefinitionHelper;
 import org.apache.hivemind.definition.RegistryDefinition;
 import org.apache.hivemind.definition.ServicePointDefinition;
+import org.apache.hivemind.definition.construction.ContributionConstructionContext;
+import org.apache.hivemind.definition.construction.ContributionConstructor;
 import org.apache.hivemind.definition.construction.ImplementationConstructionContext;
 import org.apache.hivemind.definition.construction.ImplementationConstructor;
 import org.apache.hivemind.internal.AbstractServiceImplementationConstructor;
@@ -25,6 +32,7 @@
 public class XmlCoreServicesProvider implements RegistryProvider
 {
     private static final Log LOG = LogFactory.getLog(XmlCoreServicesProvider.class);
+    private ModuleDefinitionHelper helper;
 
     public void process(RegistryDefinition registryDefinition, ErrorHandler errorHandler)
     {
@@ -38,7 +46,19 @@
         if (moduleDefinition == null) {
             throw new ApplicationRuntimeException("Module 'hivemind' not found.");
         }
+        
+        helper = new ModuleDefinitionHelper(moduleDefinition);
+        
         addTranslatorManager(moduleDefinition, errorHandler);
+        
+        addSymbolSourcesConfiguration(moduleDefinition);
+        
+        // SymbolSource implementation driven by the FactoryDefaults configuration point.
+        addSymbolSource(moduleDefinition, "FactoryDefaultsSymbolSource", "FactoryDefaults");
+        
+        // SymbolSource implementation driven by the ApplicationDefaults configuration point.
+        addSymbolSource(moduleDefinition, "ApplicationDefaultsSymbolSource", "ApplicationDefaults");
+        
         addSymbolExpander(moduleDefinition, errorHandler);
     }
     
@@ -47,7 +67,6 @@
      */
     private void addTranslatorManager(ModuleDefinition md, final ErrorHandler errorHandler)
     {
-        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(md);
         ServicePointDefinition spd = helper.addServicePoint("TranslationManager", TranslatorManager.class.getName());
 
         // Define inline implementation constructor, that wires the Translators configuration
@@ -64,19 +83,78 @@
     }
     
     /**
+     * Provides a list of sources (SymbolSource) for values of substitution symbols.
+     */
+    private void addSymbolSourcesConfiguration(ModuleDefinition md)
+    {
+        ConfigurationPointDefinition cpd = helper.addConfigurationPoint("SymbolSources",
+                new CreateClassConfigurationConstructor(md.getLocation(), ArrayList.class.getName()), List.class
+                        .getName());
+
+        helper.addContributionDefinition(cpd, new ContributionConstructor()
+        {
+
+            public void contribute(ContributionConstructionContext context, Object container)
+            {
+                // Add the default symbol sources FactoryDefaults and
+                // ApplicationDefaults
+                SymbolSource factoryDefaults = (SymbolSource) context.getService(
+                        "FactoryDefaultsSymbolSource", SymbolSource.class);
+                SymbolSourceContribution factoryDefaultsContrib = new SymbolSourceContribution(factoryDefaults,
+                        "hivemind.FactoryDefaults", null, null);
+                ((List) container).add(factoryDefaultsContrib);
+
+                SymbolSource applicationDefaults = (SymbolSource) context.getService(
+                        "ApplicationDefaultsSymbolSource", SymbolSource.class);
+                SymbolSourceContribution applicationDefaultsContrib = new SymbolSourceContribution(applicationDefaults,
+                        "hivemind.ApplicationDefaults", null, "hivemind.FactoryDefaults");
+                ((List) container).add(applicationDefaultsContrib);
+            }
+        });
+    }
+    
+    /**
+     * Adds a service that implements the symbol source interface and a
+     * corresponding configuration point that holds the symbol values.
+     */
+    private void addSymbolSource(ModuleDefinition md, final String servicePointId, final String configurationId)
+    {
+        ServicePointDefinition spd = helper.addServicePoint(servicePointId, SymbolSource.class.getName());
+
+        // Define inline implementation constructor, that wires the corresponding configuration
+        ImplementationConstructor constructor = new AbstractServiceImplementationConstructor(md.getLocation())
+        {
+            public Object constructCoreServiceImplementation(ImplementationConstructionContext context)
+            {
+                DefaultsSymbolSource result = new DefaultsSymbolSource();
+                result.setDefaults(((Map) context.getConfiguration(configurationId)).values());
+                result.initializeService();
+                return result;
+            }
+        };
+        helper.addServiceImplementation(spd, constructor, ServiceModel.SINGLETON);
+        
+        // Configuration point for setting defaults for symbol values.
+
+        helper.addConfigurationPoint(configurationId, 
+                new CreateClassConfigurationConstructor(md.getLocation(), HashMap.class.getName()), 
+                Map.class.getName());
+    }    
+    /**
      * @see SymbolExpander
      */
     private void addSymbolExpander(ModuleDefinition md, final ErrorHandler errorHandler)
     {
-        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(md);
         ServicePointDefinition spd = helper.addServicePoint("SymbolExpander", SymbolExpander.class.getName());
 
-        // Define inline implementation constructor, that wires ErrorHandler and SymbolSource
+        // Define inline implementation constructor, that wires ErrorHandler and SymbolSources
         ImplementationConstructor constructor = new AbstractServiceImplementationConstructor(md.getLocation())
         {
             public Object constructCoreServiceImplementation(ImplementationConstructionContext context)
             {
-                SymbolExpander result = new SymbolExpanderImpl(errorHandler, context.getRegistry());
+                List symbolSources = (List) context.getConfiguration("SymbolSources");
+
+                SymbolExpander result = new SymbolExpanderImpl(errorHandler, symbolSources);
                 return result;
             }
         };

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplMessages.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplMessages.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplMessages.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplMessages.java Fri Nov 24 07:38:04 2006
@@ -141,4 +141,9 @@
         return _formatter.format("no-such-symbol", name);
     }
 
+    static String symbolSourceContribution()
+    {
+        return _formatter.getMessage("symbol-source-contribution");
+    }
+
 }

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplStrings.properties
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplStrings.properties?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplStrings.properties (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplStrings.properties Fri Nov 24 07:38:04 2006
@@ -41,5 +41,5 @@
 unable-to-find-module-resource=Unable to locate HiveMind module deployment descriptors in {0}
 
 no-such-symbol=No value available for symbol ''{0}''.
-
+symbol-source-contribution=symbol source
 

Modified: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSymbolExpander.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSymbolExpander.java?view=diff&rev=478899&r1=478898&r2=478899
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSymbolExpander.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSymbolExpander.java Fri Nov 24 07:38:04 2006
@@ -39,7 +39,7 @@
 
     private void attempt(String expected, String text)
     {
-        SymbolExpanderImpl e = new SymbolExpanderImpl(null, new SymbolSourceFixture());
+        SymbolExpanderImpl e = new SymbolExpanderImpl(null, new SymbolSource[] {new SymbolSourceFixture()});
 
         String actual = e.expandSymbols(text, null);
 
@@ -102,7 +102,7 @@
 
         replayControls();
 
-        SymbolExpanderImpl e = new SymbolExpanderImpl(eh, source);
+        SymbolExpanderImpl e = new SymbolExpanderImpl(eh, new SymbolSource[] {source});
 
         String actual = e.expandSymbols("Unknown ${symbol}", l);
 
@@ -120,4 +120,12 @@
     {
     	attempt("${not-a-symbol}", "$${not-a-symbol}");
     }
+
+    public void testSystemPropertiesSymbolSource()
+    {
+        SymbolSource s = new SystemPropertiesSymbolSource();
+
+        assertEquals(System.getProperty("user.home"), s.valueForSymbol("user.home"));
+    }
+    
 }



Mime
View raw message