You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2007/05/07 21:00:53 UTC

svn commit: r535954 - in /tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src: main/java/org/apache/tapestry/ main/java/org/apache/tapestry/internal/ main/java/org/apache/tapestry/internal/services/ main/java/org/apache/tapestry/internal/test...

Author: hlship
Date: Mon May  7 12:00:52 2007
New Revision: 535954

URL: http://svn.apache.org/viewvc?view=rev&rev=535954
Log:
Change how a couple of key services are initialized, to be based on symbols (via @Inject @Value) rather than explicit API calls.

Added:
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/ServletContextSymbolProvider.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SingleKeySymbolProvider.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SyntheticModuleDef.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SyntheticSymbolSourceContributionDef.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/ServletContextSymbolProviderTest.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/SingleKeySymbolProviderTest.java
Modified:
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/TapestryFilter.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/InternalConstants.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryAppInitializer.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AliasImpl.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentClassResolverImpl.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalModule.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ServicesMessages.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/Alias.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentClassResolver.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AliasImplTest.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentClassResolverImplTest.java
    tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/TapestryFilter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/TapestryFilter.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/TapestryFilter.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/TapestryFilter.java Mon May  7 12:00:52 2007
@@ -21,6 +21,7 @@
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
@@ -29,11 +30,12 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.tapestry.internal.InternalConstants;
+import org.apache.tapestry.internal.ServletContextSymbolProvider;
 import org.apache.tapestry.internal.TapestryAppInitializer;
 import org.apache.tapestry.ioc.IOCUtilities;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.RegistryBuilder;
+import org.apache.tapestry.ioc.services.SymbolProvider;
 import org.apache.tapestry.services.HttpServletRequestHandler;
 import org.apache.tapestry.services.ServletApplicationInitializer;
 import org.apache.tapestry.services.TapestryModule;
@@ -63,12 +65,13 @@
     {
         _config = filterConfig;
 
-        // Note: configured as a <context-param>, not a filter <init-param>
-        String appPackage = _config.getServletContext().getInitParameter(
-                InternalConstants.TAPESTRY_APP_PACKAGE_PARAM);
+        ServletContext context = _config.getServletContext();
+
         String filterName = _config.getFilterName();
 
-        TapestryAppInitializer appInitializer = new TapestryAppInitializer(appPackage, filterName,
+        SymbolProvider provider = new ServletContextSymbolProvider(context);
+
+        TapestryAppInitializer appInitializer = new TapestryAppInitializer(provider, filterName,
                 "servlet");
 
         _registry = appInitializer.getRegistry();

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/InternalConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/InternalConstants.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/InternalConstants.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/InternalConstants.java Mon May  7 12:00:52 2007
@@ -22,6 +22,8 @@
      */
     public static final String TAPESTRY_APP_PACKAGE_PARAM = "tapestry.app-package";
 
+    public static final String TAPESTRY_ALIAS_MODE_SYMBOL = "tapestry.alias-mode";
+    
     /**
      * The extension used for Tapestry component template files. Template files are well-formed XML
      * files. This is also used as the extension for page render requests (perhaps these will be

Added: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/ServletContextSymbolProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/ServletContextSymbolProvider.java?view=auto&rev=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/ServletContextSymbolProvider.java (added)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/ServletContextSymbolProvider.java Mon May  7 12:00:52 2007
@@ -0,0 +1,45 @@
+// Copyright 2007 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.tapestry.internal;
+
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry.ioc.internal.util.InternalUtils;
+import org.apache.tapestry.ioc.services.SymbolProvider;
+
+/**
+ * A wrapper around {@link ServletContext} that makes init-parameters accessible as symbols.
+ */
+public class ServletContextSymbolProvider implements SymbolProvider
+{
+    private final Map<String, String> _properties = CollectionFactory.newCaseInsensitiveMap();
+
+    public ServletContextSymbolProvider(ServletContext context)
+    {
+        for (String name : InternalUtils.toList(context.getInitParameterNames()))
+        {
+            _properties.put(name, context.getInitParameter(name));
+        }
+    }
+
+    public String valueForSymbol(String symbolName)
+    {
+        return _properties.get(symbolName);
+    }
+
+}

Added: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SingleKeySymbolProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SingleKeySymbolProvider.java?view=auto&rev=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SingleKeySymbolProvider.java (added)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SingleKeySymbolProvider.java Mon May  7 12:00:52 2007
@@ -0,0 +1,41 @@
+// Copyright 2007 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.tapestry.internal;
+
+import org.apache.tapestry.ioc.services.SymbolProvider;
+
+/**
+ * Implementation of {@link SymbolProvider} that only supports a single key/value pair.
+ */
+public class SingleKeySymbolProvider implements SymbolProvider
+{
+    private final String _symbolName;
+
+    private final String _value;
+
+    public SingleKeySymbolProvider(final String symbolName, final String value)
+    {
+        _symbolName = symbolName;
+        _value = value;
+    }
+
+    public String valueForSymbol(String symbolName)
+    {
+        if (_symbolName.equalsIgnoreCase(symbolName)) return _value;
+
+        return null;
+    }
+
+}

Added: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SyntheticModuleDef.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SyntheticModuleDef.java?view=auto&rev=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SyntheticModuleDef.java (added)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SyntheticModuleDef.java Mon May  7 12:00:52 2007
@@ -0,0 +1,80 @@
+// Copyright 2007 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.tapestry.internal;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.apache.tapestry.ioc.def.ContributionDef;
+import org.apache.tapestry.ioc.def.DecoratorDef;
+import org.apache.tapestry.ioc.def.ModuleDef;
+import org.apache.tapestry.ioc.def.ServiceDef;
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
+
+/**
+ * A synthetic module definition, used to mix in some additional "pre-built" service configuration
+ * contributions.
+ */
+public class SyntheticModuleDef implements ModuleDef
+{
+    private final Class _builderClass;
+
+    private final Set<ContributionDef> _contributionDefs;
+
+    public SyntheticModuleDef(Class builderClass, ContributionDef... contributionDefs)
+    {
+        _builderClass = builderClass;
+        _contributionDefs = CollectionFactory.newSet(contributionDefs);
+    }
+
+    /**
+     * Returns an arbitrary class (this is necessary because of how the RegistryBuilder assigns a
+     * Log for each module, even a synthetic module.
+     */
+    public Class getBuilderClass()
+    {
+        return _builderClass;
+    }
+
+    /** Returns the configured set. */
+    public Set<ContributionDef> getContributionDefs()
+    {
+        return _contributionDefs;
+    }
+
+    /** Returns an empty set. */
+    public Set<DecoratorDef> getDecoratorDefs()
+    {
+        return Collections.emptySet();
+    }
+
+    /** Returns "SyntheticModule". */
+    public String getLogName()
+    {
+        return "SyntheticModule";
+    }
+
+    /** Returns null. */
+    public ServiceDef getServiceDef(String serviceId)
+    {
+        return null;
+    }
+
+    /** Returns an empty set. */
+    public Set<String> getServiceIds()
+    {
+        return Collections.emptySet();
+    }
+}

Added: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SyntheticSymbolSourceContributionDef.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SyntheticSymbolSourceContributionDef.java?view=auto&rev=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SyntheticSymbolSourceContributionDef.java (added)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/SyntheticSymbolSourceContributionDef.java Mon May  7 12:00:52 2007
@@ -0,0 +1,65 @@
+// Copyright 2007 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.tapestry.internal;
+
+import org.apache.tapestry.ioc.Configuration;
+import org.apache.tapestry.ioc.MappedConfiguration;
+import org.apache.tapestry.ioc.ModuleBuilderSource;
+import org.apache.tapestry.ioc.ObjectLocator;
+import org.apache.tapestry.ioc.OrderedConfiguration;
+import org.apache.tapestry.ioc.def.ContributionDef;
+import org.apache.tapestry.ioc.services.SymbolProvider;
+
+/** Makes a contribution to the SymbolSource service configuration. */
+public class SyntheticSymbolSourceContributionDef implements ContributionDef
+{
+    private final String _contributionName;
+
+    private final SymbolProvider _provider;
+
+    private final String[] _constraints;
+
+    public SyntheticSymbolSourceContributionDef(String contributionName, SymbolProvider provider,
+            String... constraints)
+    {
+        _contributionName = contributionName;
+        _provider = provider;
+        _constraints = constraints;
+    }
+
+    public void contribute(ModuleBuilderSource moduleBuilderSource, ObjectLocator locator,
+            Configuration configuration)
+    {
+    }
+
+    @SuppressWarnings("unchecked")
+    public void contribute(ModuleBuilderSource moduleBuilderSource, ObjectLocator locator,
+            OrderedConfiguration configuration)
+    {
+        configuration.add(_contributionName, _provider, _constraints);
+    }
+
+    public void contribute(ModuleBuilderSource moduleBuilderSource, ObjectLocator locator,
+            MappedConfiguration configuration)
+    {
+    }
+
+    /** Returns "SymbolSource". */
+    public String getServiceId()
+    {
+        return "SymbolSource";
+    }
+
+}

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryAppInitializer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryAppInitializer.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryAppInitializer.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryAppInitializer.java Mon May  7 12:00:52 2007
@@ -20,8 +20,9 @@
 import org.apache.tapestry.ioc.IOCUtilities;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.RegistryBuilder;
+import org.apache.tapestry.ioc.def.ContributionDef;
 import org.apache.tapestry.ioc.internal.util.InternalUtils;
-import org.apache.tapestry.services.Alias;
+import org.apache.tapestry.ioc.services.SymbolProvider;
 import org.apache.tapestry.services.TapestryModule;
 
 /**
@@ -36,43 +37,52 @@
  */
 public class TapestryAppInitializer
 {
-    private String _appPackage;
+    private final SymbolProvider _appProvider;
 
-    private String _appName;
+    private final String _appPackage;
 
-    private String _aliasMode;
+    private final String _appName;
 
-    private Registry _registry;
+    private final String _aliasMode;
 
-    private long _startTime;
+    private final Registry _registry;
 
-    private long _registryCreatedTime;
+    private final long _startTime;
+
+    private final long _registryCreatedTime;
 
     private final Map<String, Object> _serviceOverrides;
 
     public TapestryAppInitializer(String appPackage, String appName, String aliasMode)
     {
-        this(appPackage, appName, aliasMode, null);
+        this(new SingleKeySymbolProvider(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM, appPackage),
+                appName, aliasMode);
     }
 
-    public TapestryAppInitializer(String appPackage, String appName, String aliasMode,
+    public TapestryAppInitializer(SymbolProvider appProvider, String appName, String aliasMode)
+    {
+        this(appProvider, appName, aliasMode, null);
+    }
+
+    public TapestryAppInitializer(SymbolProvider appProvider, String appName, String aliasMode,
             Map<String, Object> serviceOverrides)
     {
-        _appPackage = appPackage;
+        _appProvider = appProvider;
+
+        _appPackage = _appProvider.valueForSymbol(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM);
+
         _appName = appName;
         _aliasMode = aliasMode;
         _serviceOverrides = serviceOverrides;
 
         _startTime = System.currentTimeMillis();
 
-        createRegistry();
+        _registry = createRegistry();
 
         _registryCreatedTime = System.currentTimeMillis();
-
-        setupServices();
     }
 
-    private void createRegistry()
+    private Registry createRegistry()
     {
         RegistryBuilder builder = new RegistryBuilder();
 
@@ -98,9 +108,25 @@
 
         addModules(builder);
 
+        addSyntheticModules(builder);
+
         overrideServices(builder);
 
-        _registry = builder.build();
+        return builder.build();
+    }
+
+    private void addSyntheticModules(RegistryBuilder builder)
+    {
+        ContributionDef symbolSourceContribution = new SyntheticSymbolSourceContributionDef(
+                "ServletContext", _appProvider, "before:ApplicationDefaults");
+
+        ContributionDef aliasModeContribution = new SyntheticSymbolSourceContributionDef(
+                "AliasMode", new SingleKeySymbolProvider(
+                        InternalConstants.TAPESTRY_ALIAS_MODE_SYMBOL, _aliasMode),
+                "before:ServletContext");
+
+        builder.add(new SyntheticModuleDef(TapestryAppInitializer.class, symbolSourceContribution,
+                aliasModeContribution));
     }
 
     private void overrideServices(RegistryBuilder builder)
@@ -112,13 +138,6 @@
                 builder.addServiceOverride(e.getKey(), e.getValue());
             }
         }
-    }
-
-    private void setupServices()
-    {
-        Alias alias = _registry.getService("Alias", Alias.class);
-
-        alias.setMode(_aliasMode);
     }
 
     /**

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AliasImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AliasImpl.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AliasImpl.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AliasImpl.java Mon May  7 12:00:52 2007
@@ -15,14 +15,12 @@
 package org.apache.tapestry.internal.services;
 
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
-import static org.apache.tapestry.ioc.internal.util.Defense.notNull;
 
 import java.util.Map;
 
 import org.apache.tapestry.ioc.AnnotationProvider;
-import org.apache.tapestry.ioc.ObjectProvider;
 import org.apache.tapestry.ioc.ObjectLocator;
-import org.apache.tapestry.ioc.internal.util.OneShotLock;
+import org.apache.tapestry.ioc.ObjectProvider;
 import org.apache.tapestry.services.Alias;
 import org.apache.tapestry.services.AliasManager;
 
@@ -32,19 +30,18 @@
 
     private final Map<Class, Object> _properties = newMap();
 
+    private final String _mode;
+
     private boolean _initialized = false;
 
     private AliasManager _masterManager;
 
     private AliasManager _overridesManager;
 
-    private String _mode;
-
-    private final OneShotLock _lock = new OneShotLock();
-
-    public AliasImpl(AliasManager masterManager, AliasManager overridesManager)
+    public AliasImpl(AliasManager masterManager, String mode, AliasManager overridesManager)
     {
         _masterManager = masterManager;
+        _mode = mode;
         _overridesManager = overridesManager;
     }
 
@@ -53,16 +50,9 @@
         return this;
     }
 
-    // Probably don't need to make this concurrent, since it executes at startup,
-    // before multithreading takes hold.
-
-    public synchronized void setMode(String mode)
+    private synchronized void initialize()
     {
-        _mode = notNull(mode, "mode");
-
-        // This method may only be invoked once.
-
-        _lock.lock();
+        if (_initialized) return;
 
         _properties.putAll(_masterManager.getAliasesForMode(_mode));
         _properties.putAll(_overridesManager.getAliasesForMode(_mode));
@@ -76,7 +66,7 @@
     public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider,
             ObjectLocator locator)
     {
-        if (!_initialized) throw new RuntimeException(ServicesMessages.aliasModeNotSet());
+        initialize();
 
         Object object = _properties.get(objectType);
 

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentClassResolverImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentClassResolverImpl.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentClassResolverImpl.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentClassResolverImpl.java Mon May  7 12:00:52 2007
@@ -23,6 +23,8 @@
 import java.util.Map;
 
 import org.apache.tapestry.events.InvalidationListener;
+import org.apache.tapestry.ioc.annotations.Inject;
+import org.apache.tapestry.ioc.annotations.Value;
 import org.apache.tapestry.services.ComponentClassResolver;
 import org.apache.tapestry.services.LibraryMapping;
 
@@ -38,7 +40,7 @@
 
     private final ClassNameLocator _classNameLocator;
 
-    private String _appRootPackage;
+    private final String _appRootPackage;
 
     // Map from folder name to a list of root package names.
     // The key does not begin or end with a slash.
@@ -64,11 +66,21 @@
     private final Map<String, String> _pageClassNameToLogicalName = newMap();
 
     public ComponentClassResolverImpl(ComponentInstantiatorSource componentInstantiatorSource,
-            ClassNameLocator classNameLocator, Collection<LibraryMapping> mappings)
+            ClassNameLocator classNameLocator,
+
+            @Inject
+            @Value("${tapestry.app-package}")
+            String appRootPackage,
+
+            Collection<LibraryMapping> mappings)
     {
         _componentInstantiatorSource = componentInstantiatorSource;
         _classNameLocator = classNameLocator;
 
+        _appRootPackage = appRootPackage;
+
+        addPackagesToInstantiatorSource(_appRootPackage);
+
         for (LibraryMapping mapping : mappings)
         {
             String prefix = mapping.getPathPrefix();
@@ -311,12 +323,5 @@
             throw new IllegalArgumentException(ServicesMessages.pageNameUnresolved(pageClassName));
 
         return result;
-    }
-
-    public void setApplicationPackage(String packageName)
-    {
-        _appRootPackage = packageName;
-
-        addPackagesToInstantiatorSource(packageName);
     }
 }

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalModule.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalModule.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalModule.java Mon May  7 12:00:52 2007
@@ -29,17 +29,16 @@
 import org.apache.tapestry.Binding;
 import org.apache.tapestry.ComponentResources;
 import org.apache.tapestry.events.InvalidationListener;
-import org.apache.tapestry.internal.InternalConstants;
 import org.apache.tapestry.internal.bindings.LiteralBinding;
 import org.apache.tapestry.internal.bindings.PropBindingFactory;
 import org.apache.tapestry.internal.util.IntegerRange;
 import org.apache.tapestry.ioc.Configuration;
 import org.apache.tapestry.ioc.Location;
 import org.apache.tapestry.ioc.MappedConfiguration;
+import org.apache.tapestry.ioc.ObjectLocator;
 import org.apache.tapestry.ioc.ObjectProvider;
 import org.apache.tapestry.ioc.OrderedConfiguration;
 import org.apache.tapestry.ioc.ServiceBinder;
-import org.apache.tapestry.ioc.ObjectLocator;
 import org.apache.tapestry.ioc.ServiceResources;
 import org.apache.tapestry.ioc.annotations.InjectService;
 import org.apache.tapestry.ioc.annotations.Scope;
@@ -419,22 +418,6 @@
             final ApplicationGlobals applicationGlobals, final PropertyAccess propertyAccess,
             final TypeCoercer typeCoercer)
     {
-        ApplicationInitializerFilter setApplicationPackage = new ApplicationInitializerFilter()
-        {
-            public void initializeApplication(Context context, ApplicationInitializer initializer)
-            {
-                String packageName = context
-                        .getInitParameter(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM);
-
-                applicationGlobals.store(packageName);
-                _componentClassResolver.setApplicationPackage(packageName);
-
-                initializer.initializeApplication(context);
-            }
-        };
-
-        configuration.add("SetApplicationPackage", setApplicationPackage, "before:*.*");
-
         final InvalidationListener listener = new InvalidationListener()
         {
             public void objectWasInvalidated()

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ServicesMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ServicesMessages.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ServicesMessages.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ServicesMessages.java Mon May  7 12:00:52 2007
@@ -49,11 +49,6 @@
                 existing);
     }
 
-    static final String aliasModeNotSet()
-    {
-        return MESSAGES.get("alias-mode-not-set");
-    }
-
     static final String markupWriterNoCurrentElement()
     {
         return MESSAGES.get("markup-writer-no-current-element");

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java Mon May  7 12:00:52 2007
@@ -34,6 +34,10 @@
 import org.apache.tapestry.Link;
 import org.apache.tapestry.events.InvalidationListener;
 import org.apache.tapestry.internal.InternalComponentResources;
+import org.apache.tapestry.internal.InternalConstants;
+import org.apache.tapestry.internal.SingleKeySymbolProvider;
+import org.apache.tapestry.internal.SyntheticModuleDef;
+import org.apache.tapestry.internal.SyntheticSymbolSourceContributionDef;
 import org.apache.tapestry.internal.parser.ComponentTemplate;
 import org.apache.tapestry.internal.parser.TemplateToken;
 import org.apache.tapestry.internal.services.ComponentInstantiatorSource;
@@ -62,13 +66,15 @@
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.RegistryBuilder;
 import org.apache.tapestry.ioc.Resource;
+import org.apache.tapestry.ioc.def.ContributionDef;
+import org.apache.tapestry.ioc.def.ModuleDef;
 import org.apache.tapestry.ioc.internal.InternalRegistry;
 import org.apache.tapestry.ioc.internal.util.MessagesImpl;
+import org.apache.tapestry.ioc.services.SymbolProvider;
 import org.apache.tapestry.model.ComponentModel;
 import org.apache.tapestry.model.EmbeddedComponentModel;
 import org.apache.tapestry.runtime.Component;
 import org.apache.tapestry.runtime.RenderQueue;
-import org.apache.tapestry.services.Alias;
 import org.apache.tapestry.services.ComponentClassResolver;
 import org.apache.tapestry.services.Request;
 import org.apache.tapestry.services.TapestryModule;
@@ -94,9 +100,20 @@
 
         builder.add(TapestryModule.class);
 
+        // A synthetic module to ensure that the tapestry.alias-mode is set correctly.
+
+        SymbolProvider provider = new SingleKeySymbolProvider(
+                InternalConstants.TAPESTRY_ALIAS_MODE_SYMBOL, "servlet");
+        ContributionDef contribution = new SyntheticSymbolSourceContributionDef("AliasMode",
+                provider, "before:ApplicationDefaults");
+
+        ModuleDef module = new SyntheticModuleDef(InternalBaseTestCase.class, contribution);
+
+        builder.add(module);
+
         _registry = builder.build();
 
-        _registry.getService(Alias.class).setMode("servlet");
+        // _registry.getService(Alias.class).setMode("servlet");
     }
 
     @AfterSuite

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/Alias.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/Alias.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/Alias.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/Alias.java Mon May  7 12:00:52 2007
@@ -17,17 +17,13 @@
 import org.apache.tapestry.ioc.ObjectProvider;
 
 /**
- * Primarily, the Alias service is an ObjectProvider that fits into the command chain and disambiguates
- * injections on type. Contributions to the Alias service identify the normal service to inject for a
- * particular service interface; this is only necessary when there is more than one service implementing
- * the same interface.
- * 
+ * Primarily, the Alias service is an ObjectProvider that fits into the command chain and
+ * disambiguates injections on type. Contributions to the Alias service identify the normal service
+ * to inject for a particular service interface; this is only necessary when there is more than one
+ * service implementing the same interface.
  */
 public interface Alias
 {
-    /** Inform the Alias service about what mode it is operating in. */
-    void setMode(String mode);
-
     /**
      * Returns an object that can provide objects based on contributions into the Alias (and
      * AliasOverrides) service.

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentClassResolver.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentClassResolver.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentClassResolver.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentClassResolver.java Mon May  7 12:00:52 2007
@@ -27,9 +27,9 @@
  * package is expected to have sub-packages: "pages", "components", "mixins" and "base" ("base" is
  * for base classes).
  * <p>
- * The resolver performs a search of the classpath (via {@link ClassNameLocator}, to build up
- * a set of case-insensitive maps from logical page name, component type, or mixin type to fully
- * qualified class name.
+ * The resolver performs a search of the classpath (via {@link ClassNameLocator}, to build up a set
+ * of case-insensitive maps from logical page name, component type, or mixin type to fully qualified
+ * class name.
  * <p>
  * Certain ambiguities occur if mapped packages overlap, either in terms of the the prefixes or the
  * package names. Keep things clearly seperate to avoid lookup problems.
@@ -94,12 +94,4 @@
      *             if the mixin type can not be resolved
      */
     String resolveMixinTypeToClassName(String mixinType);
-
-    /**
-     * Sets the root package for the application. Pages are expected to be in a sub-package named
-     * "pages" (i.e., root.pages). Components will be in a sub-package named "components".
-     * 
-     * @param packageName
-     */
-    void setApplicationPackage(String packageName);
 }

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java Mon May  7 12:00:52 2007
@@ -157,10 +157,10 @@
 import org.apache.tapestry.ioc.Location;
 import org.apache.tapestry.ioc.MappedConfiguration;
 import org.apache.tapestry.ioc.Messages;
+import org.apache.tapestry.ioc.ObjectLocator;
 import org.apache.tapestry.ioc.ObjectProvider;
 import org.apache.tapestry.ioc.OrderedConfiguration;
 import org.apache.tapestry.ioc.ServiceBinder;
-import org.apache.tapestry.ioc.ObjectLocator;
 import org.apache.tapestry.ioc.ServiceResources;
 import org.apache.tapestry.ioc.annotations.InjectService;
 import org.apache.tapestry.ioc.annotations.SubModule;
@@ -236,6 +236,10 @@
 
     public static Alias build(Log log,
 
+    @org.apache.tapestry.ioc.annotations.Inject
+    @Value("${tapestry.alias-mode}")
+    String mode,
+
     @InjectService("AliasOverrides")
     AliasManager overridesManager,
 
@@ -243,7 +247,7 @@
     {
         AliasManager manager = new AliasManagerImpl(log, configuration);
 
-        return new AliasImpl(manager, overridesManager);
+        return new AliasImpl(manager, mode, overridesManager);
     }
 
     /**
@@ -591,14 +595,7 @@
             }
         };
 
-        // Or you can defuse the dependency by using @InjectService("foo") instead of
-        // @Inject("service:foo"). The latter requires the MasterObjectProvider, which requires
-        // the Alias service, which then fails if any contribution
-        // to the Alias service configuration makes use of @Inject. However, since its likely that
-        // end users will try
-        // to do this, the wrapper has been left in place (it does very little harm).
-
-        configuration.add("Alias", wrapper);
+        configuration.add("Alias", wrapper, "after:Value");
 
         configuration.add("Asset", assetObjectProvider, "before:Alias");
     }

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java Mon May  7 12:00:52 2007
@@ -23,6 +23,8 @@
 import org.apache.tapestry.dom.Document;
 import org.apache.tapestry.dom.Element;
 import org.apache.tapestry.dom.Node;
+import org.apache.tapestry.internal.InternalConstants;
+import org.apache.tapestry.internal.SingleKeySymbolProvider;
 import org.apache.tapestry.internal.TapestryAppInitializer;
 import org.apache.tapestry.internal.services.ActionLinkTarget;
 import org.apache.tapestry.internal.services.ComponentInvocation;
@@ -31,9 +33,9 @@
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.internal.NullAnnotationProvider;
 import org.apache.tapestry.ioc.internal.util.Defense;
+import org.apache.tapestry.ioc.services.SymbolProvider;
 import org.apache.tapestry.ioc.util.StrategyRegistry;
 import org.apache.tapestry.services.ApplicationGlobals;
-import org.apache.tapestry.services.ComponentClassResolver;
 
 /**
  * This class is used to run a Tapestry app in an in-process testing environment. You can ask it to
@@ -107,12 +109,12 @@
         _preferedLanguage = Locale.ENGLISH;
         _contextPath = contextPath;
         _cookies = new CookiesForPageTester();
-        _registry = new TapestryAppInitializer(appPackage, appName, "test",
-                addDefaultOverrides(serviceOverrides)).getRegistry();
 
-        // This is normally done by the ApplicationInitializer pipeline service.
+        SymbolProvider provider = new SingleKeySymbolProvider(
+                InternalConstants.TAPESTRY_APP_PACKAGE_PARAM, appPackage);
 
-        _registry.getService(ComponentClassResolver.class).setApplicationPackage(appPackage);
+        _registry = new TapestryAppInitializer(provider, appName, "test",
+                addDefaultOverrides(serviceOverrides)).getRegistry();
 
         _localizationSetter = _registry.getService("LocalizationSetter", LocalizationSetter.class);
 

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties Mon May  7 12:00:52 2007
@@ -13,7 +13,6 @@
 # limitations under the License.
 
 duplicate-contribution=Contribution %s (for type %s) conflicts with existing contribution %s and has been ignored.
-alias-mode-not-set=The Alias service's mode has not been set. Unable to determine the correct set of alias properties.
 markup-writer-no-current-element=This markup writer does not have a current element. \
   The current element is established with the first call to element() and is \
   maintained across subsequent calls. 

Added: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/ServletContextSymbolProviderTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/ServletContextSymbolProviderTest.java?view=auto&rev=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/ServletContextSymbolProviderTest.java (added)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/ServletContextSymbolProviderTest.java Mon May  7 12:00:52 2007
@@ -0,0 +1,65 @@
+// Copyright 2007 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.tapestry.internal;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tapestry.ioc.services.SymbolProvider;
+import org.apache.tapestry.ioc.test.TestBase;
+import org.testng.annotations.Test;
+
+public class ServletContextSymbolProviderTest extends TestBase
+{
+    @Test
+    public void access_of_keys_is_case_insensitive()
+    {
+        ServletContext context = newMock(ServletContext.class);
+
+        String key1 = "fred";
+        String value1 = "Fred Flintstone";
+        String key2 = "barney";
+        String value2 = "Barney Rubble";
+
+        expect(context.getInitParameterNames()).andReturn(toEnumeration(key1, key2));
+
+        expect(context.getInitParameter(key1)).andReturn(value1);
+        expect(context.getInitParameter(key2)).andReturn(value2);
+
+        replay();
+
+        SymbolProvider p = new ServletContextSymbolProvider(context);
+
+        assertEquals(p.valueForSymbol(key1), value1);
+        assertEquals(p.valueForSymbol(key2), value2);
+
+        // Not in config is null
+        assertNull(p.valueForSymbol("wilma"));
+
+        // Check for case insensitivity
+        assertEquals(p.valueForSymbol("FRED"), value1);
+
+        verify();
+    }
+
+    protected final <T> Enumeration<T> toEnumeration(T... values)
+    {
+        return Collections.enumeration(Arrays.asList(values));
+    }
+
+}

Added: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/SingleKeySymbolProviderTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/SingleKeySymbolProviderTest.java?view=auto&rev=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/SingleKeySymbolProviderTest.java (added)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/SingleKeySymbolProviderTest.java Mon May  7 12:00:52 2007
@@ -0,0 +1,42 @@
+// Copyright 2007 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.tapestry.internal;
+
+import org.apache.tapestry.ioc.services.SymbolProvider;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class SingleKeySymbolProviderTest extends Assert
+{
+    private final SymbolProvider _provider = new SingleKeySymbolProvider("fred", "flintstone");
+
+    @Test
+    public void exact_match()
+    {
+        assertEquals(_provider.valueForSymbol("fred"), "flintstone");
+    }
+
+    @Test
+    public void case_insensitive()
+    {
+        assertEquals(_provider.valueForSymbol("FRED"), "flintstone");
+    }
+
+    @Test
+    public void non_match()
+    {
+        assertNull(_provider.valueForSymbol("barney"));
+    }
+}

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AliasImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AliasImplTest.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AliasImplTest.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AliasImplTest.java Mon May  7 12:00:52 2007
@@ -31,36 +31,6 @@
 {
     private Map<Class, Object> _emptyMap = Collections.emptyMap();
 
-    @Test
-    public void mode_not_set_when_resolution_requested()
-    {
-        AliasManager manager = newAliasManager();
-        AliasManager overridesManager = newAliasManager();
-        ObjectLocator locator = mockObjectLocator();
-        AnnotationProvider annotationProvider = mockAnnotationProvider();
-
-        replay();
-
-        Alias alias = new AliasImpl(manager, overridesManager);
-
-        // Do not assume that alias and provider are the same;
-        // that's an implementation choice.
-
-        ObjectProvider provider = alias.getObjectProvider();
-
-        try
-        {
-            provider.provide(Runnable.class, annotationProvider, locator);
-            unreachable();
-        }
-        catch (RuntimeException ex)
-        {
-            assertEquals(ex.getMessage(), ServicesMessages.aliasModeNotSet());
-        }
-
-        verify();
-    }
-
     protected final AliasManager newAliasManager()
     {
         return newMock(AliasManager.class);
@@ -86,9 +56,7 @@
 
         replay();
 
-        Alias alias = new AliasImpl(manager, overridesManager);
-
-        alias.setMode(mode);
+        Alias alias = new AliasImpl(manager, mode, overridesManager);
 
         // Do not assume that infra and provider are the same;
         // that's an implementation choice.
@@ -131,9 +99,7 @@
 
         replay();
 
-        Alias alias = new AliasImpl(manager, overridesManager);
-
-        alias.setMode(mode);
+        Alias alias = new AliasImpl(manager, mode, overridesManager);
 
         ObjectProvider provider = alias.getObjectProvider();
 
@@ -160,9 +126,7 @@
 
         replay();
 
-        Alias alias = new AliasImpl(manager, overridesManager);
-
-        alias.setMode(mode);
+        Alias alias = new AliasImpl(manager, mode, overridesManager);
 
         // Do not assume that infra and provider are the same;
         // that's an implementation choice.

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentClassResolverImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentClassResolverImplTest.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentClassResolverImplTest.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentClassResolverImplTest.java Mon May  7 12:00:52 2007
@@ -43,11 +43,7 @@
     {
         List<LibraryMapping> list = Arrays.asList(mappings);
 
-        ComponentClassResolverImpl resolver = new ComponentClassResolverImpl(source, locator, list);
-
-        resolver.setApplicationPackage(APP_ROOT_PACKAGE);
-
-        return resolver;
+        return new ComponentClassResolverImpl(source, locator, APP_ROOT_PACKAGE, list);
     }
 
     @Test

Modified: tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java?view=diff&rev=535954&r1=535953&r2=535954
==============================================================================
--- tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java (original)
+++ tapestry/tapestry5/branches/hlship-20070503/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java Mon May  7 12:00:52 2007
@@ -31,14 +31,20 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.tapestry.internal.InternalComponentResources;
+import org.apache.tapestry.internal.InternalConstants;
+import org.apache.tapestry.internal.SingleKeySymbolProvider;
+import org.apache.tapestry.internal.SyntheticModuleDef;
+import org.apache.tapestry.internal.SyntheticSymbolSourceContributionDef;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.internal.transform.pages.BasicComponent;
 import org.apache.tapestry.internal.transform.pages.BasicSubComponent;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.RegistryBuilder;
+import org.apache.tapestry.ioc.def.ContributionDef;
+import org.apache.tapestry.ioc.def.ModuleDef;
 import org.apache.tapestry.ioc.services.PropertyAccess;
+import org.apache.tapestry.ioc.services.SymbolProvider;
 import org.apache.tapestry.runtime.Component;
-import org.apache.tapestry.services.Alias;
 import org.apache.tapestry.services.TapestryModule;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
@@ -276,9 +282,18 @@
 
         builder.add(TapestryModule.class);
 
+        SymbolProvider provider = new SingleKeySymbolProvider(
+                InternalConstants.TAPESTRY_ALIAS_MODE_SYMBOL, "servlet");
+        ContributionDef contribution = new SyntheticSymbolSourceContributionDef("AliasMode",
+                provider, "before:ApplicationDefaults");
+
+        ModuleDef module = new SyntheticModuleDef(InternalBaseTestCase.class, contribution);
+
+        builder.add(module);
+
         _registry = builder.build();
 
-        _registry.getService("Alias", Alias.class).setMode("servlet");
+        // _registry.getService("Alias", Alias.class).setMode("servlet");
 
         _source = _registry.getService(ComponentInstantiatorSource.class);
         _access = _registry.getService(PropertyAccess.class);