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 2004/08/27 15:42:49 UTC

cvs commit: jakarta-tapestry/junit/src/org/apache/tapestry/services/impl TestPropertySource.java TestBasicInfrastructure.java

hlship      2004/08/27 06:42:49

  Modified:    framework/src/org/apache/tapestry/services/impl
                        ApplicationGlobalsImpl.java ImplStrings.properties
                        ImplMessages.java
               framework/src/org/apache/tapestry/engine AbstractEngine.java
                        DefaultPropertySource.java
               framework/src/org/apache/tapestry/services
                        ApplicationGlobals.java
               contrib  build.xml
               framework/src/org/apache/tapestry/request
                        RequestContext.java
               junit/mock-scripts TestMissingAppSpec.xml
               framework build.xml
               .        .classpath
               junit/src/org/apache/tapestry/junit
                        TestEngineServiceLink.java
               framework/src/org/apache/tapestry ApplicationServlet.java
               framework/conf/META-INF hivemodule.xml
               junit/src/org/apache/tapestry/services/impl
                        TestBasicInfrastructure.java
  Added:       framework/src/org/apache/tapestry/services/impl
                        GlobalPropertyObjectProvider.java
                        InvokeEngineTerminator.java
                        RequestGlobalsInitializer.java
                        SymbolSourcesPropertySourceFactory.java
                        ServletContextPropertySource.java
                        ServletPropertySource.java PropertySourceImpl.java
                        RequestGlobalsImpl.java
                        PropertySourceContribution.java
                        SymbolSourcesPropertySource.java
               framework/src/org/apache/tapestry/services
                        RequestGlobals.java
               junit/src/org/apache/tapestry/services/impl
                        TestPropertySource.java
  Removed:     framework/src/org/apache/tapestry/services/impl
                        ServletInfoImpl.java StoreServletInfoFilter.java
                        ServletInfoInitializer.java
               framework/src/org/apache/tapestry/services ServletInfo.java
               junit/mock-scripts TestMissingEngine.xml
  Log:
  Replace the bulk of the Tapestry ApplicationServlet with a collection of HiveMind services and pipelines.
  
  Revision  Changes    Path
  1.4       +7 -0      jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/ApplicationGlobalsImpl.java
  
  Index: ApplicationGlobalsImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/ApplicationGlobalsImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ApplicationGlobalsImpl.java	25 Aug 2004 19:53:45 -0000	1.3
  +++ ApplicationGlobalsImpl.java	27 Aug 2004 13:42:47 -0000	1.4
  @@ -14,6 +14,7 @@
   
   package org.apache.tapestry.services.impl;
   
  +import javax.servlet.ServletConfig;
   import javax.servlet.ServletContext;
   import javax.servlet.http.HttpServlet;
   
  @@ -58,4 +59,10 @@
   	{
   		return _servlet.getServletName();
   	}
  +	
  +    public ServletConfig getServletConfig()
  +    {
  +        return _servlet.getServletConfig();
  +    }
  +
   }
  
  
  
  1.3       +1 -0      jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/ImplStrings.properties
  
  Index: ImplStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/ImplStrings.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ImplStrings.properties	23 Aug 2004 14:53:16 -0000	1.2
  +++ ImplStrings.properties	27 Aug 2004 13:42:47 -0000	1.3
  @@ -15,5 +15,6 @@
   initializer-contribution=application initializer
   no-application-specification=Could not find an application specification for application servlet {0}.
   error-instantiating-engine=Unable to instantiate engine as instance of class {0}: {1}
  +no-such-global-property=Global property ''{0}'' does not exist.
   
   
  
  
  
  1.4       +5 -0      jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/ImplMessages.java
  
  Index: ImplMessages.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/ImplMessages.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ImplMessages.java	23 Aug 2004 14:53:16 -0000	1.3
  +++ ImplMessages.java	27 Aug 2004 13:42:47 -0000	1.4
  @@ -43,4 +43,9 @@
       {
           return _formatter.format("error-instantiating-engine", engineClass.getName(), cause);
       }
  +
  +    public static String noSuchGlobalProperty(String propertyName)
  +    {
  +        return _formatter.format("no-such-global-property", propertyName);
  +    }
   }
  
  
  
  1.1                  jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/GlobalPropertyObjectProvider.java
  
  Index: GlobalPropertyObjectProvider.java
  ===================================================================
  //  Copyright 2004 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.services.impl;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.hivemind.Location;
  import org.apache.hivemind.internal.Module;
  import org.apache.hivemind.service.ObjectProvider;
  import org.apache.tapestry.engine.IPropertySource;
  
  /**
   * An implementation of {@link org.apache.hivemind.service.ObjectProvider}
   * that gets the actual value from the
   * <code>tapestry.GlobalPropertySource</code> service.
   *
   * @author Howard Lewis Ship
   * @since 3.1
   */
  public class GlobalPropertyObjectProvider implements ObjectProvider
  {
      private IPropertySource _source;
  
      /**
       * Gets the value; the locator is the key passed to
       * {@link IPropertySource#getPropertyValue(String)}.
       */
      public Object provideObject(
          Module contributingModule,
          Class propertyType,
          String locator,
          Location location)
      {
          try
          {
              return _source.getPropertyValue(locator);
          }
          catch (Exception ex)
          {
              throw new ApplicationRuntimeException(ex.getMessage(), location, ex);
          }
      }
  
      public void setSource(IPropertySource source)
      {
          _source = source;
      }
  
  }
  
  
  
  1.1                  jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/InvokeEngineTerminator.java
  
  Index: InvokeEngineTerminator.java
  ===================================================================
  //  Copyright 2004 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.services.impl;
  import java.io.IOException;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.tapestry.IEngine;
  import org.apache.tapestry.request.RequestContext;
  import org.apache.tapestry.services.EngineManager;
  import org.apache.tapestry.services.RequestServicer;
  import org.apache.tapestry.spec.IApplicationSpecification;
  
  /**
   * The terminatior for the <code>tapestry.RequestProcessor</code> pipeline,
   * this service is responsible for locating the correct engine instance and
   * letting it to the rest of the request.
   *
   * @author Howard Lewis Ship
   * @since 3.1
   */
  public class InvokeEngineTerminator implements RequestServicer
  {
  	private HttpServlet _servlet;
      private EngineManager _engineManager;
      private IApplicationSpecification _specification;
  
      public void service(HttpServletRequest request, HttpServletResponse response)
          throws IOException, ServletException
      {
          IEngine engine = _engineManager.getEngineInstance();
  
          RequestContext context = new RequestContext(_servlet, request, response, _specification);
  
          try
          {
              engine.service(context);
          }
          finally
          {
              _engineManager.storeEngineInstance(engine);
  
              context.cleanup();
          }
  
      }
  
      public void setEngineManager(EngineManager manager)
      {
          _engineManager = manager;
      }
  
      public void setServlet(HttpServlet servlet)
      {
          _servlet = servlet;
      }
  
      public void setSpecification(IApplicationSpecification specification)
      {
          _specification = specification;
      }
  
  }
  
  
  
  1.1                  jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/RequestGlobalsInitializer.java
  
  Index: RequestGlobalsInitializer.java
  ===================================================================
  //  Copyright 2004 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.services.impl;
  
  import java.io.IOException;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.tapestry.services.RequestServicer;
  import org.apache.tapestry.services.RequestServicerFilter;
  import org.apache.tapestry.services.RequestGlobals;
  
  /**
   * A {@link org.apache.tapestry.services.RequestServicerFilter} threaded early onto the pipeline,
   * which invokes {@link org.apache.tapestry.services.ServletInfo#store(HttpServletRequest, HttpServletResponse)}
   * so that other services can obtain the current thread's request and response.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class RequestGlobalsInitializer implements RequestServicerFilter
  {
      private RequestGlobals _requestGlobals;
  
      public void setRequestGlobals(RequestGlobals info)
      {
          _requestGlobals = info;
      }
  
      public void service(
          HttpServletRequest request,
          HttpServletResponse response,
          RequestServicer servicer)
          throws IOException, ServletException
      {
          _requestGlobals.store(request, response);
  
          servicer.service(request, response);
      }
  
  }
  
  
  
  1.1                  jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/SymbolSourcesPropertySourceFactory.java
  
  Index: SymbolSourcesPropertySourceFactory.java
  ===================================================================
  //  Copyright 2004 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.services.impl;
  
  import java.util.List;
  
  import org.apache.commons.logging.Log;
  import org.apache.hivemind.ServiceImplementationFactory;
  import org.apache.hivemind.internal.Module;
  
  /**
   * Used to create an service instance of {@link  org.apache.tapestry.services.impl.SymbolSourcesPropertySource}.
   * This is because SSPS needs an instance of {@link org.apache.hivemind.internal.Module}, and there's
   * no way to do that with hivemind.BuilderFactory.
   *
   * @author Howard Lewis Ship
   * @since 3.1
   */
  public class SymbolSourcesPropertySourceFactory implements ServiceImplementationFactory
  {
  
      public Object createCoreServiceImplementation(
          String serviceId,
          Class serviceInterface,
          Log serviceLog,
          Module invokingModule,
          List parameters)
      {
          return new SymbolSourcesPropertySource(invokingModule);
      }
  
  }
  
  
  
  1.1                  jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/ServletContextPropertySource.java
  
  Index: ServletContextPropertySource.java
  ===================================================================
  //  Copyright 2004 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.services.impl;
  
  import javax.servlet.ServletContext;
  
  import org.apache.tapestry.engine.IPropertySource;
  
  /**
   * Searches for property values in the servlet context's init parameters.
   *
   * @author Howard Lewis Ship
   * @since 3.1
   */
  public class ServletContextPropertySource implements IPropertySource
  {
      private ServletContext _context;
  
      public String getPropertyValue(String propertyName)
      {
          return _context.getInitParameter(propertyName);
      }
  
      public void setContext(ServletContext context)
      {
          _context = context;
      }
  
  }
  
  
  
  1.1                  jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/ServletPropertySource.java
  
  Index: ServletPropertySource.java
  ===================================================================
  //  Copyright 2004 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.services.impl;
  
  import javax.servlet.ServletConfig;
  
  import org.apache.tapestry.engine.IPropertySource;
  
  /**
   * Obtains property values from {@link javax.servlet.ServletConfig} for
   * the application servlet.
   *
   * @author Howard Lewis Ship
   * @since 3.1
   */
  public class ServletPropertySource implements IPropertySource
  {
      private ServletConfig _servletConfig;
  
      public String getPropertyValue(String propertyName)
      {
          return _servletConfig.getInitParameter(propertyName);
      }
  
      public void setServletConfig(ServletConfig config)
      {
          _servletConfig = config;
      }
  }
  
  
  
  1.1                  jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/PropertySourceImpl.java
  
  Index: PropertySourceImpl.java
  ===================================================================
  //  Copyright 2004 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.services.impl;
  
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.commons.logging.Log;
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.hivemind.ErrorHandler;
  import org.apache.hivemind.order.Orderer;
  import org.apache.tapestry.engine.IPropertySource;
  
  /**
   * Orders a list of {@link org.apache.tapestry.services.impl.PropertySourceContribution}s
   * and get property values from them (the first non-null result being returned).
   *
   * @author Howard Lewis Ship
   * @since 3.1
   */
  public class PropertySourceImpl implements IPropertySource
  {
      private List _contributions;
      private List _orderedSources;
      private ErrorHandler _errorHandler;
      private Log _log;
  
      public void initializeService()
      {
          Orderer orderer = new Orderer(_log, _errorHandler, "property source");
  
          Iterator i = _contributions.iterator();
  
          while (i.hasNext())
          {
              PropertySourceContribution c = (PropertySourceContribution) i.next();
  
              orderer.add(c, c.getName(), c.getAfter(), c.getBefore());
          }
  
          _orderedSources = orderer.getOrderedObjects();
      }
  
      public String getPropertyValue(String propertyName)
      {
          Iterator i = _orderedSources.iterator();
  
          while (i.hasNext())
          {
              IPropertySource source = (IPropertySource) i.next();
  
              String result = source.getPropertyValue(propertyName);
  
              if (result != null)
                  return result;
          }
  
          throw new ApplicationRuntimeException(ImplMessages.noSuchGlobalProperty(propertyName));
      }
  
      public void setContributions(List list)
      {
          _contributions = list;
      }
  
      public void setErrorHandler(ErrorHandler handler)
      {
          _errorHandler = handler;
      }
  
      public void setLog(Log log)
      {
          _log = log;
      }
  
  }
  
  
  
  1.1                  jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/RequestGlobalsImpl.java
  
  Index: RequestGlobalsImpl.java
  ===================================================================
  //  Copyright 2004 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.services.impl;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.hivemind.impl.BaseLocatable;
  import org.apache.tapestry.services.RequestGlobals;
  
  /**
   * Wrapper around {@link org.apache.hivemind.service.ThreadLocalStorage} used
   * to store and retrieve Servlet API info.
   *
   * @author Howard Lewis Ship
   * @since 3.1
   */
  public class RequestGlobalsImpl extends BaseLocatable implements RequestGlobals
  {
      private HttpServletRequest _request;
      private HttpServletResponse _response;
  
      public void store(HttpServletRequest request, HttpServletResponse response)
      {
          _request = request;
          _response = response;
      }
  
      public HttpServletRequest getRequest()
      {
          return _request;
      }
  
      public HttpServletResponse getResponse()
      {
          return _response;
      }
  }
  
  
  
  1.1                  jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/PropertySourceContribution.java
  
  Index: PropertySourceContribution.java
  ===================================================================
  //  Copyright 2004 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.services.impl;
  
  import org.apache.hivemind.impl.BaseLocatable;
  import org.apache.tapestry.engine.IPropertySource;
  
  /**
   * A contribution into the <code>tapestry.PropertySources</code>
   * configuration point.
   *
   * @author Howard Lewis Ship
   * @since 3.1
   */
  public class PropertySourceContribution extends BaseLocatable implements IPropertySource
  {
      private String _name;
      private String _before;
      private String _after;
      private IPropertySource _source;
  
      public String getAfter()
      {
          return _after;
      }
  
      public String getBefore()
      {
          return _before;
      }
  
      public String getName()
      {
          return _name;
      }
  
      public void setAfter(String string)
      {
          _after = string;
      }
  
      public void setBefore(String string)
      {
          _before = string;
      }
  
      public void setName(String string)
      {
          _name = string;
      }
  
      public void setSource(IPropertySource source)
      {
          _source = source;
      }
  
      public String getPropertyValue(String propertyName)
      {
          return _source.getPropertyValue(propertyName);
      }
  
  }
  
  
  
  1.1                  jakarta-tapestry/framework/src/org/apache/tapestry/services/impl/SymbolSourcesPropertySource.java
  
  Index: SymbolSourcesPropertySource.java
  ===================================================================
  //  Copyright 2004 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.services.impl;
  
  import org.apache.hivemind.internal.Module;
  import org.apache.tapestry.engine.IPropertySource;
  
  /**
   * Property source that bridges to HiveMind Symbol Sources.
   *
   * @author Howard Lewis Ship
   * @since 3.1
   */
  public class SymbolSourcesPropertySource implements IPropertySource
  {
      private Module _module;
  
      public SymbolSourcesPropertySource(Module module)
      {
          _module = module;
      }
  
      /**
       * Invokes {@link Module#getSymbolValue(java.lang.String)}.
       */
      public String getPropertyValue(String propertyName)
      {
          return _module.getSymbolValue(propertyName);
      }
  
  }
  
  
  
  1.34      +7 -4      jakarta-tapestry/framework/src/org/apache/tapestry/engine/AbstractEngine.java
  
  Index: AbstractEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/engine/AbstractEngine.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- AbstractEngine.java	4 Jul 2004 21:00:00 -0000	1.33
  +++ AbstractEngine.java	27 Aug 2004 13:42:48 -0000	1.34
  @@ -704,9 +704,8 @@
               _localeChanged = false;
   
               RequestContext context = cycle.getRequestContext();
  -            ApplicationServlet servlet = context.getServlet();
   
  -            servlet.writeLocaleCookie(_locale, this, context);
  +            ApplicationServlet.writeLocaleCookie(_locale, this, context);
           }
   
           // Commit all changes and ignore further changes.
  @@ -791,7 +790,11 @@
   
       public boolean service(RequestContext context) throws ServletException, IOException
       {
  -        ApplicationServlet servlet = context.getServlet();
  +    	// TODO: Switch this around sound that we don't downcast ... in fact,
  +    	// all of the stuff we get from the servlet will be coming out of the
  +    	// registry soon enough.
  +    	
  +        ApplicationServlet servlet = (ApplicationServlet) context.getServlet();
           IRequestCycle cycle = null;
           ResponseOutputStream output = null;
           IMonitor monitor = null;
  @@ -800,7 +803,7 @@
               LOG.debug("Begin service " + context.getRequestURI());
   
           if (_specification == null)
  -            _specification = servlet.getApplicationSpecification();
  +            _specification = context.getApplicationSpecification();
   
           // The servlet invokes setLocale() before invoking service().  We want
           // to ignore that setLocale() ... that is, not force a cookie to be
  
  
  
  1.4       +23 -21    jakarta-tapestry/framework/src/org/apache/tapestry/engine/DefaultPropertySource.java
  
  Index: DefaultPropertySource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/engine/DefaultPropertySource.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultPropertySource.java	4 Aug 2004 15:05:59 -0000	1.3
  +++ DefaultPropertySource.java	27 Aug 2004 13:42:48 -0000	1.4
  @@ -16,7 +16,8 @@
   
   import java.util.ResourceBundle;
   
  -import org.apache.tapestry.ApplicationServlet;
  +import javax.servlet.http.HttpServlet;
  +
   import org.apache.tapestry.request.RequestContext;
   import org.apache.tapestry.spec.IApplicationSpecification;
   import org.apache.tapestry.util.DelegatingPropertySource;
  @@ -61,19 +62,20 @@
           "org.apache.tapestry.property-source";
   
       private IPropertySource _degatingPropertySource;
  -    
  -	/**
  -	 * Creates a new default property source for looking up application-specific
  -	 * properties. The search order of the property source is shown in the
  -	 * documentation of this class.
  -	 * 
  -	 * @param context the request context for which this property source will be created
  -	 */
  -	public DefaultPropertySource(RequestContext context) {
  +
  +    /**
  +     * Creates a new default property source for looking up application-specific
  +     * properties. The search order of the property source is shown in the
  +     * documentation of this class.
  +     * 
  +     * @param context the request context for which this property source will be created
  +     */
  +    public DefaultPropertySource(RequestContext context)
  +    {
           DelegatingPropertySource result = new DelegatingPropertySource();
   
  -        ApplicationServlet servlet = context.getServlet();
  -        IApplicationSpecification spec = servlet.getApplicationSpecification();
  +        HttpServlet servlet = context.getServlet();
  +        IApplicationSpecification spec = context.getApplicationSpecification();
   
           result.addSource(new PropertyHolderPropertySource(spec));
           result.addSource(new ServletPropertySource(servlet.getServletConfig()));
  @@ -99,13 +101,13 @@
           result.addSource(new ResourceBundlePropertySource(bundle));
   
           _degatingPropertySource = result;
  -	}
  -	
  -	/**
  -	 * @see org.apache.tapestry.engine.IPropertySource#getPropertyValue(java.lang.String)
  -	 */
  -	public String getPropertyValue(String propertyName)
  -	{
  -		return _degatingPropertySource.getPropertyValue(propertyName);
  -	}
  +    }
  +
  +    /**
  +     * @see org.apache.tapestry.engine.IPropertySource#getPropertyValue(java.lang.String)
  +     */
  +    public String getPropertyValue(String propertyName)
  +    {
  +        return _degatingPropertySource.getPropertyValue(propertyName);
  +    }
   }
  
  
  
  1.5       +3 -0      jakarta-tapestry/framework/src/org/apache/tapestry/services/ApplicationGlobals.java
  
  Index: ApplicationGlobals.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/services/ApplicationGlobals.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ApplicationGlobals.java	25 Aug 2004 19:53:54 -0000	1.4
  +++ ApplicationGlobals.java	27 Aug 2004 13:42:48 -0000	1.5
  @@ -14,6 +14,7 @@
   
   package org.apache.tapestry.services;
   
  +import javax.servlet.ServletConfig;
   import javax.servlet.ServletContext;
   import javax.servlet.http.HttpServlet;
   
  @@ -39,4 +40,6 @@
       ServletContext getContext();
       
       String getServletName();
  +    
  +    ServletConfig getServletConfig();
   }
  
  
  
  1.1                  jakarta-tapestry/framework/src/org/apache/tapestry/services/RequestGlobals.java
  
  Index: RequestGlobals.java
  ===================================================================
  //  Copyright 2004 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.services;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  /**
   * Access point for thread-local information about the current
   * request.
   *
   * @author Howard Lewis Ship
   */
  public interface RequestGlobals
  {
      public void store(HttpServletRequest request, HttpServletResponse response);
  
      public HttpServletRequest getRequest();
  
      public HttpServletResponse getResponse();
  }
  
  
  
  1.23      +3 -2      jakarta-tapestry/contrib/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/build.xml,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- build.xml	25 Aug 2004 19:53:48 -0000	1.22
  +++ build.xml	27 Aug 2004 13:42:48 -0000	1.23
  @@ -30,11 +30,12 @@
       <project-dependency artifact="tapestry"/>
   
       <ibiblio-dependency artifact="commons-logging"    version="1.0.4"               group="commons-logging"/>
  -    <ibiblio-dependency artifact="hivemind"           version="1.0-rc-1"            group="hivemind"/>
  -    <ibiblio-dependency artifact="commons-lang"       version="2.0"                 group="commons-lang"/>
  +    <ibiblio-dependency artifact="hivemind"           version="1.0-rc-2-snapshot"   group="hivemind"/>
  +    <ibiblio-dependency artifact="hivemind-lib"       version="1.0-rc-2-snapshot"   group="hivemind"/>
       <ibiblio-dependency artifact="commons-codec"      version="1.2"                 group="commons-codec"/>
       <ibiblio-dependency artifact="ognl"               version="2.6.3"               group="ognl"/>
       <ibiblio-dependency artifact="jboss-j2ee"         version="3.2.1"               group="jboss"/>
  +    <ibiblio-dependency artifact="commons-lang"       version="2.0"                 group="commons-lang"/>
       
       <!--
       <ibiblio-dependency artifact="bsf"                version="2.3.0"               group="bsf"/>
  
  
  
  1.13      +23 -14    jakarta-tapestry/framework/src/org/apache/tapestry/request/RequestContext.java
  
  Index: RequestContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/request/RequestContext.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- RequestContext.java	4 Jul 2004 21:00:15 -0000	1.12
  +++ RequestContext.java	27 Aug 2004 13:42:48 -0000	1.13
  @@ -28,13 +28,13 @@
   import javax.servlet.ServletConfig;
   import javax.servlet.ServletContext;
   import javax.servlet.http.Cookie;
  +import javax.servlet.http.HttpServlet;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import javax.servlet.http.HttpSession;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.tapestry.ApplicationServlet;
   import org.apache.tapestry.IMarkupWriter;
   import org.apache.tapestry.IRender;
   import org.apache.tapestry.IRequestCycle;
  @@ -112,10 +112,11 @@
       private HttpSession _session;
       private HttpServletRequest _request;
       private HttpServletResponse _response;
  -    private ApplicationServlet _servlet;
  +    private HttpServlet _servlet;
       private DecodedRequest _decodedRequest;
       private IMultipartDecoder _decoder;
       private boolean _decoded;
  +    private IApplicationSpecification _specification;
   
       /**
        * A mapping of the cookies available in the request.
  @@ -137,14 +138,16 @@
        **/
   
       public RequestContext(
  -        ApplicationServlet servlet,
  +        HttpServlet servlet,
           HttpServletRequest request,
  -        HttpServletResponse response)
  +        HttpServletResponse response,
  +        IApplicationSpecification specification)
           throws IOException
       {
           _servlet = servlet;
           _request = request;
           _response = response;
  +        _specification = specification;
   
           // All three parameters may be null if created from
           // AbstractEngine.cleanupEngine().
  @@ -176,14 +179,12 @@
        **/
   
       protected IMultipartDecoder obtainMultipartDecoder(
  -        ApplicationServlet servlet,
  +        HttpServlet servlet,
           HttpServletRequest request)
           throws IOException
       {
  -        IApplicationSpecification spec = servlet.getApplicationSpecification();
  -
  -        if (spec.checkExtension(Tapestry.MULTIPART_DECODER_EXTENSION_NAME))
  -            return (IMultipartDecoder) spec.getExtension(
  +        if (_specification.checkExtension(Tapestry.MULTIPART_DECODER_EXTENSION_NAME))
  +            return (IMultipartDecoder) _specification.getExtension(
                   Tapestry.MULTIPART_DECODER_EXTENSION_NAME,
                   IMultipartDecoder.class);
   
  @@ -235,14 +236,13 @@
           if (_decodedRequest != null)
               return _decodedRequest;
   
  -        IApplicationSpecification spec = _servlet.getApplicationSpecification();
           IRequestDecoder decoder = null;
   
  -        if (!spec.checkExtension(Tapestry.REQUEST_DECODER_EXTENSION_NAME))
  +        if (!_specification.checkExtension(Tapestry.REQUEST_DECODER_EXTENSION_NAME))
               decoder = new DefaultRequestDecoder();
           else
               decoder =
  -                (IRequestDecoder) spec.getExtension(
  +                (IRequestDecoder) _specification.getExtension(
                       Tapestry.REQUEST_DECODER_EXTENSION_NAME,
                       IRequestDecoder.class);
   
  @@ -535,7 +535,7 @@
           return result;
       }
   
  -    public ApplicationServlet getServlet()
  +    public HttpServlet getServlet()
       {
           return _servlet;
       }
  @@ -1072,7 +1072,8 @@
        **/
       private IMultipartDecoder getDecoder()
       {
  -        if (_decoder != null && !_decoded) {
  +        if (_decoder != null && !_decoded)
  +        {
               _decoder.decode(_request);
               _decoded = true;
           }
  @@ -1090,6 +1091,14 @@
       {
           _decoder = decoder;
           _decoded = false;
  +    }
  +
  +    /**
  +     * @since 3.1 --- but probably pretty temporary!
  +     */
  +    public IApplicationSpecification getApplicationSpecification()
  +    {
  +        return _specification;
       }
   
   }
  
  
  
  1.3       +0 -1      jakarta-tapestry/junit/mock-scripts/TestMissingAppSpec.xml
  
  Index: TestMissingAppSpec.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/junit/mock-scripts/TestMissingAppSpec.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestMissingAppSpec.xml	9 Mar 2004 22:09:52 -0000	1.2
  +++ TestMissingAppSpec.xml	27 Aug 2004 13:42:48 -0000	1.3
  @@ -1,6 +1,5 @@
   <?xml version="1.0" encoding="UTF-8"?>
   
  -<!-- $Id$ -->
   <!--
      Copyright 2004 The Apache Software Foundation
     
  
  
  
  1.34      +2 -2      jakarta-tapestry/framework/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/build.xml,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- build.xml	25 Aug 2004 19:53:50 -0000	1.33
  +++ build.xml	27 Aug 2004 13:42:48 -0000	1.34
  @@ -39,8 +39,8 @@
   		<ibiblio-dependency artifact="commons-fileupload" version="1.0"                 group="commons-fileupload"/>    
       <ibiblio-dependency artifact="commons-lang"       version="2.0"                 group="commons-lang"/>
       <ibiblio-dependency artifact="commons-logging"    version="1.0.4"               group="commons-logging"/>
  -    <ibiblio-dependency artifact="hivemind"           version="1.0-rc-1"            group="hivemind"/>
  -    <ibiblio-dependency artifact="hivemind-lib"       version="1.0-rc-1"            group="hivemind"/>
  +    <ibiblio-dependency artifact="hivemind"           version="1.0-rc-2-snapshot"   group="hivemind"/>
  +    <ibiblio-dependency artifact="hivemind-lib"       version="1.0-rc-2-snapshot"   group="hivemind"/>
       <ibiblio-dependency artifact="oro"                version="2.0.6"               group="oro"/>
   		<ibiblio-dependency artifact="javassist"          version="2.6"                 group="jboss"/>
   		<ibiblio-dependency artifact="servletapi"         version="2.3"                 group="servletapi"/>
  
  
  
  1.50      +3 -2      jakarta-tapestry/.classpath
  
  Index: .classpath
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/.classpath,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- .classpath	25 Aug 2004 19:53:45 -0000	1.49
  +++ .classpath	27 Aug 2004 13:42:48 -0000	1.50
  @@ -20,8 +20,9 @@
       <classpathentry kind="lib" path="ext-package/lib/ognl-2.6.3.jar"/>
       <classpathentry kind="lib" path="ext-package/lib/oro-2.0.6.jar"/>
       <classpathentry kind="lib" path="ext-package/lib/servletapi-2.3.jar"/>
  -    <classpathentry kind="lib" path="ext-package/lib/hivemind-1.0-rc-1.jar"/>
  -    <classpathentry kind="lib" path="ext-package/lib/hivemind-lib-1.0-rc-1.jar"/>
       <classpathentry kind="lib" path="ext-package/lib/jboss-j2ee-3.2.1.jar"/>
  +    <classpathentry kind="lib"
  +        path="ext-package/lib/hivemind-1.0-rc-2-snapshot.jar" sourcepath="C:/workspace/jakarta-hivemind/framework/src/java"/>
  +    <classpathentry kind="lib" path="ext-package/lib/hivemind-lib-1.0-rc-2-snapshot.jar"/>
       <classpathentry kind="output" path="bin"/>
   </classpath>
  
  
  
  1.8       +3 -2      jakarta-tapestry/junit/src/org/apache/tapestry/junit/TestEngineServiceLink.java
  
  Index: TestEngineServiceLink.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/junit/src/org/apache/tapestry/junit/TestEngineServiceLink.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestEngineServiceLink.java	5 May 2004 02:41:20 -0000	1.7
  +++ TestEngineServiceLink.java	27 Aug 2004 13:42:48 -0000	1.8
  @@ -32,10 +32,10 @@
   import org.apache.tapestry.Tapestry;
   import org.apache.tapestry.engine.EngineServiceLink;
   import org.apache.tapestry.request.RequestContext;
  +import org.apache.tapestry.spec.ApplicationSpecification;
   import org.apache.tapestry.test.mock.MockContext;
   import org.apache.tapestry.test.mock.MockServletConfig;
   
  -
   public class TestEngineServiceLink extends TapestryTestCase
   {
       private class TestRequest implements HttpServletRequest
  @@ -321,7 +321,8 @@
           engine.setServletPath(servletPath);
   
           HttpServletRequest request = new TestRequest();
  -        RequestContext context = new RequestContext(servlet, request, null);
  +        RequestContext context =
  +            new RequestContext(servlet, request, null, new ApplicationSpecification());
   
           return new MockRequestCycle(engine, context);
       }
  
  
  
  1.13      +13 -269   jakarta-tapestry/framework/src/org/apache/tapestry/ApplicationServlet.java
  
  Index: ApplicationServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/ApplicationServlet.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ApplicationServlet.java	25 Aug 2004 19:53:55 -0000	1.12
  +++ ApplicationServlet.java	27 Aug 2004 13:42:49 -0000	1.13
  @@ -24,7 +24,6 @@
   import javax.servlet.http.HttpServlet;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  -import javax.servlet.http.HttpSession;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -32,18 +31,17 @@
   import org.apache.hivemind.Registry;
   import org.apache.hivemind.impl.DefaultClassResolver;
   import org.apache.hivemind.impl.RegistryBuilder;
  -import org.apache.tapestry.engine.BaseEngine;
   import org.apache.tapestry.engine.IPropertySource;
   import org.apache.tapestry.request.RequestContext;
   import org.apache.tapestry.services.ApplicationGlobals;
   import org.apache.tapestry.services.ApplicationInitializer;
  +import org.apache.tapestry.services.RequestServicer;
   import org.apache.tapestry.spec.IApplicationSpecification;
   import org.apache.tapestry.util.DelegatingPropertySource;
   import org.apache.tapestry.util.ServletContextPropertySource;
   import org.apache.tapestry.util.ServletPropertySource;
   import org.apache.tapestry.util.SystemPropertiesPropertySource;
   import org.apache.tapestry.util.exception.ExceptionAnalyzer;
  -import org.apache.tapestry.util.pool.Pool;
   
   /**
    *  Links a servlet container with a Tapestry application.  The servlet has some
  @@ -99,14 +97,6 @@
       public static final String LOCALE_COOKIE_NAME = "org.apache.tapestry.locale";
   
       /**
  -     *  A {@link Pool} used to store {@link IEngine engine}s that are not currently
  -     *  in use.  The key is on {@link Locale}.
  -     *
  -     */
  -
  -    private Pool _enginePool = new Pool();
  -
  -    /**
        *  The application specification, which is read once and kept in memory
        *  thereafter.
        *
  @@ -115,23 +105,6 @@
       private IApplicationSpecification _specification;
   
       /**
  -     * The name under which the {@link IEngine engine} is stored within the
  -     * {@link HttpSession}.
  -     *
  -     */
  -
  -    private String _attributeName;
  -
  -    /**
  -     *  The resolved class name used to instantiate the engine.
  -     * 
  -     *  @since 3.0
  -     * 
  -     */
  -
  -    private String _engineClassName;
  -
  -    /**
        *  Used to search for configuration properties.
        * 
        *  
  @@ -167,6 +140,8 @@
   
       private Registry _registry;
   
  +    private RequestServicer _requestServicer;
  +
       /**
        * Handles the GET and POST requests. Performs the following:
        * <ul>
  @@ -179,85 +154,9 @@
       protected void doService(HttpServletRequest request, HttpServletResponse response)
           throws IOException, ServletException
       {
  -        RequestContext context = null;
  -
           try
           {
  -
  -            // Create a context from the various bits and pieces.
  -
  -            context = createRequestContext(request, response);
  -
  -            // The subclass provides the engine.
  -
  -            IEngine engine = getEngine(context);
  -
  -            if (engine == null)
  -                throw new ServletException(
  -                    Tapestry.getMessage("ApplicationServlet.could-not-locate-engine"));
  -
  -            boolean dirty = engine.service(context);
  -
  -            HttpSession session = context.getSession();
  -
  -            // When there's an active session, we *may* store it into
  -            // the HttpSession and we *will not* store the engine
  -            // back into the engine pool.
  -
  -            if (session != null)
  -            {
  -                // If the service may have changed the engine and the
  -                // special storeEngine flag is on, then re-save the engine
  -                // into the session.  Otherwise, we only save the engine
  -                // into the session when the session is first created (is new).
  -
  -                try
  -                {
  -
  -                    boolean forceStore =
  -                        engine.isStateful() && (session.getAttribute(_attributeName) == null);
  -
  -                    if (forceStore || dirty)
  -                    {
  -                        if (LOG.isDebugEnabled())
  -                            LOG.debug("Storing " + engine + " into session as " + _attributeName);
  -
  -                        session.setAttribute(_attributeName, engine);
  -                    }
  -                }
  -                catch (IllegalStateException ex)
  -                {
  -                    // Ignore because the session been's invalidated.
  -                    // Allow the engine (which has state particular to the client)
  -                    // to be reclaimed by the garbage collector.
  -
  -                    if (LOG.isDebugEnabled())
  -                        LOG.debug("Session invalidated.");
  -                }
  -
  -                // The engine is stateful and stored in a session.  Even if it started
  -                // the request cycle in the pool, it doesn't go back.
  -
  -                return;
  -            }
  -
  -            if (engine.isStateful())
  -            {
  -                LOG.error(
  -                    Tapestry.format("ApplicationServlet.engine-stateful-without-session", engine));
  -                return;
  -            }
  -
  -            // No session; the engine contains no state particular to
  -            // the client (except for locale).  Don't throw it away,
  -            // instead save it in a pool for later reuse (by this, or another
  -            // client in the same locale).
  -
  -            if (LOG.isDebugEnabled())
  -                LOG.debug("Returning " + engine + " to pool.");
  -
  -            _enginePool.store(engine.getLocale(), engine);
  -
  +            _requestServicer.service(request, response);
           }
           catch (ServletException ex)
           {
  @@ -279,29 +178,6 @@
   
               throw ex;
           }
  -        finally
  -        {
  -            if (context != null)
  -                context.cleanup();
  -        }
  -
  -    }
  -
  -    /**
  -     *  Invoked by {@link #doService(HttpServletRequest, HttpServletResponse)} to create
  -     *  the {@link RequestContext} for this request cycle.  Some applications may need to
  -     *  replace the default RequestContext with a subclass for particular behavior.
  -     * 
  -     *  @since 2.3
  -     * 
  -     */
  -
  -    protected RequestContext createRequestContext(
  -        HttpServletRequest request,
  -        HttpServletResponse response)
  -        throws IOException
  -    {
  -        return new RequestContext(this, request, response);
       }
   
       protected void show(Exception ex)
  @@ -330,6 +206,7 @@
        *  Returns the application specification, which is read
        *  by the {@link #init(ServletConfig)} method.
        *
  +     *  @deprecated Use {@link RequestContext#getApplicationSpecification()} instead.
        */
   
       public IApplicationSpecification getApplicationSpecification()
  @@ -338,75 +215,6 @@
       }
   
       /**
  -     *  Retrieves the {@link IEngine engine} that will process this
  -     *  request.  This comes from one of the following places:
  -     *  <ul>
  -     *  <li>The {@link HttpSession}, if the there is one.
  -     *  <li>From the pool of available engines
  -     *  <li>Freshly created
  -     *  </ul>
  -     *
  -     */
  -
  -    protected IEngine getEngine(RequestContext context) throws ServletException
  -    {
  -        IEngine engine = null;
  -        HttpSession session = context.getSession();
  -
  -        // If there's a session, then find the engine within it.
  -
  -        if (session != null)
  -        {
  -            engine = (IEngine) session.getAttribute(_attributeName);
  -            if (engine != null)
  -            {
  -                if (LOG.isDebugEnabled())
  -                    LOG.debug("Retrieved " + engine + " from session " + session.getId() + ".");
  -
  -                return engine;
  -            }
  -
  -            if (LOG.isDebugEnabled())
  -                LOG.debug("Session exists, but doesn't contain an engine.");
  -        }
  -
  -        Locale locale = getLocaleFromRequest(context);
  -
  -        engine = (IEngine) _enginePool.retrieve(locale);
  -
  -        if (engine == null)
  -        {
  -            engine = createEngine(context);
  -            engine.setLocale(locale);
  -        }
  -        else
  -        {
  -            if (LOG.isDebugEnabled())
  -                LOG.debug("Using pooled engine " + engine + " (from locale " + locale + ").");
  -        }
  -
  -        return engine;
  -    }
  -
  -    /**
  -     *  Determines the {@link Locale} for the incoming request.
  -     *  This is determined from the locale cookie or, if not set,
  -     *  from the request itself.  This may return null
  -     *  if no locale is determined.
  -     *
  -     */
  -
  -    protected Locale getLocaleFromRequest(RequestContext context) throws ServletException
  -    {
  -        Cookie cookie = context.getCookie(LOCALE_COOKIE_NAME);
  -
  -        if (cookie != null)
  -            return Tapestry.getLocale(cookie.getValue());
  -
  -        return context.getRequest().getLocale();
  -    }
  -
  -    /**
        *  Reads the application specification when the servlet is
        *  first initialized.  All {@link IEngine engine instances}
        *  will have access to the specification via the servlet.
  @@ -436,8 +244,6 @@
   
               throw new ServletException(TapestryMessages.servletInitFailure(ex), ex);
           }
  -
  -        _attributeName = "org.apache.tapestry.engine:" + config.getServletName();
       }
   
       /**
  @@ -477,74 +283,6 @@
       }
   
       /**
  -     *  Invoked by {@link #getEngine(RequestContext)} to create
  -     *  the {@link IEngine} instance specific to the
  -     *  application, if not already in the
  -     *  {@link HttpSession}.
  -     *
  -     *  <p>The {@link IEngine} instance returned is stored into the
  -     *  {@link HttpSession}.
  -     *
  -     *  @see #getEngineClassName()    
  -     *
  -     */
  -
  -    protected IEngine createEngine(RequestContext context) throws ServletException
  -    {
  -        try
  -        {
  -            String className = getEngineClassName();
  -
  -            if (LOG.isDebugEnabled())
  -                LOG.debug("Creating engine from class " + className);
  -
  -            Class engineClass = getClassResolver().findClass(className);
  -
  -            IEngine result = (IEngine) engineClass.newInstance();
  -
  -            if (LOG.isDebugEnabled())
  -                LOG.debug("Created engine " + result);
  -
  -            return result;
  -        }
  -        catch (Exception ex)
  -        {
  -            throw new ServletException(ex);
  -        }
  -    }
  -
  -    /**
  -     * 
  -     *  Returns the name of the class to use when instantiating
  -     *  an engine instance for this application.  
  -     *  If the application specification
  -     *  provides a value, this is returned.  Otherwise, a search for
  -     *  the configuration property 
  -     *  <code>org.apache.tapestry.engine-class</code>
  -     *  occurs (see {@link #searchConfiguration(String)}).
  -     * 
  -     *  <p>If the search is still unsuccessful, then
  -     *  {@link org.apache.tapestry.engine.BaseEngine} is used.
  -     * 
  -     */
  -
  -    protected String getEngineClassName()
  -    {
  -        if (_engineClassName != null)
  -            return _engineClassName;
  -
  -        _engineClassName = _specification.getEngineClassName();
  -
  -        if (_engineClassName == null)
  -            _engineClassName = searchConfiguration("org.apache.tapestry.engine-class");
  -
  -        if (_engineClassName == null)
  -            _engineClassName = BaseEngine.class.getName();
  -
  -        return _engineClassName;
  -    }
  -
  -    /**
        *  Searches for a configuration property in:
        *  <ul>
        *  <li>The servlet's initial parameters
  @@ -598,7 +336,7 @@
        *  @since 1.0.1
        */
   
  -    public void writeLocaleCookie(Locale locale, IEngine engine, RequestContext cycle)
  +    public static void writeLocaleCookie(Locale locale, IEngine engine, RequestContext cycle)
       {
           if (LOG.isDebugEnabled())
               LOG.debug("Writing locale cookie " + locale);
  @@ -654,7 +392,8 @@
           _registry.cleanupThread();
   
           // This is temporary, since most of the code still gets the
  -        // specification from the servlet.
  +        // specification from the servlet --- in fact, has to downcase
  +        // RequestContext.getServlet() to do so.
   
           ApplicationGlobals ag =
               (ApplicationGlobals) _registry.getService(
  @@ -662,6 +401,11 @@
                   ApplicationGlobals.class);
   
           _specification = ag.getSpecification();
  +
  +        _requestServicer =
  +            (RequestServicer) _registry.getService(
  +                "tapestry.RequestServicerPipeline",
  +                RequestServicer.class);
       }
   
       /**
  
  
  
  1.5       +140 -15   jakarta-tapestry/framework/conf/META-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/conf/META-INF/hivemodule.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- hivemodule.xml	25 Aug 2004 20:44:27 -0000	1.4
  +++ hivemodule.xml	27 Aug 2004 13:42:49 -0000	1.5
  @@ -109,19 +109,19 @@
     </contribution>
     
     <service-point id="EnginePool" interface="org.apache.tapestry.services.ObjectPool">
  -    <create-instance class="org.apache.tapestry.services.impl.ObjectPool"/>
  +    <create-instance class="org.apache.tapestry.services.impl.ObjectPoolImpl"/>
     </service-point>
     
  -  <service-point id="ServletInfo" interface="org.apache.tapestry.services.ServletInfo">
  +  <service-point id="RequestGlobals" interface="org.apache.tapestry.services.RequestGlobals">
       Stores the request and response for the current thread.
       
  -    <create-instance class="org.apache.tapestry.services.impl.ServletInfoImpl" model="threaded"/>
  +    <create-instance class="org.apache.tapestry.services.impl.RequestGlobalsImpl" model="threaded"/>
     </service-point>
     
  -  <service-point id="ServletInfoInitializer" interface="org.apache.tapestry.services.RequestServicerFilter">
  +  <service-point id="RequestGlobalsInitializer" interface="org.apache.tapestry.services.RequestServicerFilter">
       <invoke-factory>
  -      <construct class="org.apache.tapestry.services.impl.ServletInfoInitializer">
  -        <set-service property="servletInfo" service-id="ServletInfo"/>
  +      <construct class="org.apache.tapestry.services.impl.RequestGlobalsInitializer">
  +        <set-service property="requestGlobals" service-id="RequestGlobals"/>
         </construct>
       </invoke-factory>
     </service-point>
  @@ -129,10 +129,10 @@
     <service-point id="HttpServletRequest" interface="javax.servlet.http.HttpServletRequest">
       
       Exposes the current thread's HttpServletRequest as a service. The request is actually
  -    stored in the ServletInfo service.
  +    stored in the RequestGlobals service.
       
       <invoke-factory service-id="hivemind.lib.ServicePropertyFactory">
  -      <constuct service-id="ServletInfo" property="request"/>
  +      <construct service-id="RequestGlobals" property="request"/>
       </invoke-factory>
     </service-point>
     
  @@ -157,9 +157,9 @@
         <construct class="org.apache.tapestry.services.impl.CookieSourceImpl">
           <set-service property="request" service-id="HttpServletRequest"/>
         </construct>
  -    </invoke-factory>
  -    
  +    </invoke-factory>    
     </service-point>
  +  
     <service-point id="EngineManager" interface="org.apache.tapestry.services.EngineManager">
       Obtains an IEngine implementation for the current request, either from a pool of
       such engine instance, from a factory, or from the HttpSession.
  @@ -168,7 +168,7 @@
         <construct class="org.apache.tapestry.services.impl.EngineManagerImpl">
           <set-service property="enginePool" service-id="EnginePool"/>
           <set-service property="request" service-id="HttpServletRequest"/>
  -        <set-object property="servletName" object="service-property:ApplicationGlobals:servletName"/>
  +        <set-object property="servletName" value="service-property:ApplicationGlobals:servletName"/>
           <set-service property="engineFactory" service-id="EngineFactory"/>
           <set-service property="localeExtractor" service-id="LocaleExtractor"/>
         </construct>
  @@ -182,15 +182,14 @@
       <invoke-factory>
         <construct class="org.apache.tapestry.services.impl.EngineFactoryImpl">
           <set-service property="applicationSpecification" service-id="ApplicationSpecification"/>
  -        <set property="defaultEngineClassName"
  -            value="${org.apache.tapestry.engine-class}"/>
  +        <set-object property="defaultEngineClassName" value="global-property:org.apache.tapestry.engine-class"/>
         </construct>
       </invoke-factory>
       
     </service-point>
     
     <contribution configuration-id="hivemind.FactoryDefaults">
  -    <default key="org.apache.tapestry.engine-class" value="org.apache.tapestry.engine.BaseEngine"/>
  +    <default symbol="org.apache.tapestry.engine-class" value="org.apache.tapestry.engine.BaseEngine"/>
     </contribution>
     
     <service-point id="RequestServicerPipeline" interface="org.apache.tapestry.services.RequestServicer">
  @@ -203,6 +202,21 @@
       </invoke-factory>    
     </service-point>
     
  +  <service-point id="InvokeEngineTerminator" interface="org.apache.tapestry.services.RequestServicer">
  +    
  +    Terminator service for the RequestServicerPipeline. This locates an IEngine instance that
  +    can take control of the request.
  +    
  +    <invoke-factory>
  +      <construct class="org.apache.tapestry.services.impl.InvokeEngineTerminator">
  +        <set-service property="engineManager" service-id="EngineManager"/>
  +        <set-object property="specification" value="service-property:ApplicationGlobals:specification"/>
  +        <set-object property="servlet" value="service-property:ApplicationGlobals:servlet"/>
  +      </construct>
  +    </invoke-factory>
  +    
  +  </service-point>
  +  
     <configuration-point id="RequestServicerPipeline" schema-id="hivemind.lib.Pipeline">
       
       A pipeline for processing an incoming request.
  @@ -210,6 +224,117 @@
     </configuration-point>
     
     <contribution configuration-id="RequestServicerPipeline">
  -    <filter name="ServletInfoInitializer" before="*" object="service:ServletInfoInitializer"/>
  +    <filter name="RequestGlobalsInitializer" before="*" object="service:RequestGlobalsInitializer"/>
  +    <terminator object="service:InvokeEngineTerminator"/>
  +  </contribution>
  +  
  +  
  +  
  +  <configuration-point id="GlobalPropertySources">
  +    
  +    Specifies a sequence of property sources used to resolve global application configuration data, which may
  +    be in web.xml (servlet init parameters or servlet
  +    context init parameters), or provided as HiveMind substitution symbol.
  +    
  +    <schema>
  +      <element name="source">
  +        
  +        <attribute name="name" required="true">
  +          The name of the contribution, used to control ordering.
  +        </attribute>
  +        
  +        <attribute name="before">
  +          List of sources that should process before this source.
  +        </attribute>
  +        
  +        <attribute name="after">
  +          List of sources that should process after this source.
  +        </attribute>
  +        
  +        <attribute name="object" translator="object">
  +          The object or service that implements the IPropertySource interface.
  +        </attribute>
  +        
  +        <conversion class="org.apache.tapestry.services.impl.PropertySourceContribution">
  +          <map property="source" attribute="object"/>
  +        </conversion>
  +        
  +      </element>
  +    </schema>
  +  </configuration-point>
  +  
  +  <service-point id="GlobalPropertySource" interface="org.apache.tapestry.engine.IPropertySource">
  +    
  +    Service point of obtaining configuration data resolved using GlobalPropertySourcePipeline
  +    configuration point.
  +    
  +    <invoke-factory>
  +      <construct class="org.apache.tapestry.services.impl.PropertySourceImpl">
  +        <set-configuration property="contributions" configuration-id="GlobalPropertySources"/>
  +      </construct>
  +    </invoke-factory>
  +    
  +  </service-point>
  +  
  +  <service-point id="ServletPropertySource" interface="org.apache.tapestry.engine.IPropertySource">
  +    
  +    Searches for properties in the application servlets' configuration.
  +    
  +    <invoke-factory>
  +      <construct class="org.apache.tapestry.services.impl.ServletPropertySource">
  +        <set-object property="servletConfig" value="service-property:ApplicationGlobals:servletConfig"/>
  +      </construct>
  +    </invoke-factory>    
  +  </service-point>
  +  
  +  <service-point id="ServletContextPropertySource" interface="org.apache.tapestry.engine.IPropertySource">
  +    
  +    Searches the servlet context for properties.
  +    
  +    <invoke-factory>
  +      <construct class="org.apache.tapestry.services.impl.ServletContextPropertySource">
  +        <set-object property="context" value="service-property:ApplicationGlobals:context"/>
  +      </construct>
  +    </invoke-factory>
  +  </service-point>
  +  
  +  <service-point id="SymbolSourcesPropertySource" interface="org.apache.tapestry.engine.IPropertySource">
  +    
  +    Bridges into HiveMind's symbol sources to resolve configuration properties.
  +    
  +    <!-- This is tricky, we need to use a custom builder factory. -->
  +    
  +    <invoke-factory service-id="SymbolSourcesPropertySourceFactory"/>
  +    
  +  </service-point>
  +  
  +  <service-point id="SymbolSourcesPropertySourceFactory" interface="org.apache.hivemind.ServiceImplementationFactory" parameters-occurs="none">
  +    
  +    A special-purpose ServiceImplementationFactory used just to create the SymbolSourcesPropertySource service.
  +    
  +    <create-instance class="org.apache.tapestry.services.impl.SymbolSourcesPropertySourceFactory"/>
  +  </service-point>
  +  
  +  <contribution configuration-id="GlobalPropertySources">
  +    <source name="servlet" object="service:ServletPropertySource"/>
  +    <source name="context" object="service:ServletContextPropertySource" after="servlet"/>
  +    <source name="symbols" object="service:SymbolSourcesPropertySource" after="context"/>
  +  </contribution>
  +  
  +  <service-point id="GlobalPropertyObjectProvider" interface="org.apache.hivemind.service.ObjectProvider">
  +    
  +    An object provider based on obtaining global properties from the GlobalPropertySource
  +    service.
  +    
  +    <invoke-factory>
  +      <construct class="org.apache.tapestry.services.impl.GlobalPropertyObjectProvider">
  +        <set-service property="source" service-id="GlobalPropertySource"/>
  +      </construct>
  +    </invoke-factory>
  +    
  +  </service-point>
  +  
  +  <contribution configuration-id="hivemind.ObjectProviders">
  +    <provider prefix="global-property" service-id="GlobalPropertyObjectProvider"/>
     </contribution>
   </module>
  
  
  
  1.5       +65 -11    jakarta-tapestry/junit/src/org/apache/tapestry/services/impl/TestBasicInfrastructure.java
  
  Index: TestBasicInfrastructure.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/junit/src/org/apache/tapestry/services/impl/TestBasicInfrastructure.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestBasicInfrastructure.java	23 Aug 2004 14:53:15 -0000	1.4
  +++ TestBasicInfrastructure.java	27 Aug 2004 13:42:49 -0000	1.5
  @@ -22,7 +22,9 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.hivemind.ClassResolver;
  +import org.apache.hivemind.Location;
   import org.apache.hivemind.Registry;
   import org.apache.hivemind.impl.DefaultClassResolver;
   import org.apache.hivemind.impl.DefaultErrorHandler;
  @@ -30,10 +32,12 @@
   import org.apache.hivemind.test.HiveMindTestCase;
   import org.apache.hivemind.util.ClasspathResource;
   import org.apache.tapestry.ApplicationServlet;
  +import org.apache.tapestry.engine.IPropertySource;
   import org.apache.tapestry.services.ApplicationInitializer;
   import org.apache.tapestry.services.ClasspathResourceFactory;
  +import org.apache.tapestry.services.RequestGlobals;
   import org.apache.tapestry.services.RequestServicer;
  -import org.apache.tapestry.services.ServletInfo;
  +import org.easymock.MockControl;
   
   /**
    * Tests for:
  @@ -50,9 +54,9 @@
   {
       private static final Log LOG = LogFactory.getLog(TestBasicInfrastructure.class);
   
  -    public void testServletInfoImpl()
  +    public void testRequestGlobals()
       {
  -        ServletInfoImpl si = new ServletInfoImpl();
  +        RequestGlobalsImpl si = new RequestGlobalsImpl();
   
           HttpServletRequest r = (HttpServletRequest) newMock(HttpServletRequest.class);
           HttpServletResponse p = (HttpServletResponse) newMock(HttpServletResponse.class);
  @@ -67,9 +71,9 @@
           verifyControls();
       }
   
  -    public void testStoreServletInfoFilter() throws Exception
  +    public void testRequestGlobalsInitializer() throws Exception
       {
  -        ServletInfo si = (ServletInfo) newMock(ServletInfo.class);
  +        RequestGlobals si = (RequestGlobals) newMock(RequestGlobals.class);
           HttpServletRequest r = (HttpServletRequest) newMock(HttpServletRequest.class);
           HttpServletResponse p = (HttpServletResponse) newMock(HttpServletResponse.class);
           RequestServicer n = (RequestServicer) newMock(RequestServicer.class);
  @@ -80,11 +84,11 @@
   
           replayControls();
   
  -        StoreServletInfoFilter f = new StoreServletInfoFilter();
  +        RequestGlobalsInitializer rgi = new RequestGlobalsInitializer();
   
  -        f.setServletInfo(si);
  +        rgi.setRequestGlobals(si);
   
  -        f.service(r, p, n);
  +        rgi.service(r, p, n);
   
           verifyControls();
       }
  @@ -156,13 +160,13 @@
       {
           HttpServletRequest request = (HttpServletRequest) newMock(HttpServletRequest.class);
           HttpServletResponse response = (HttpServletResponse) newMock(HttpServletResponse.class);
  -        ServletInfo servletInfo = (ServletInfo) newMock(ServletInfo.class);
  +        RequestGlobals servletInfo = (RequestGlobals) newMock(RequestGlobals.class);
   
  -        ServletInfoInitializer sii = new ServletInfoInitializer();
  +        RequestGlobalsInitializer sii = new RequestGlobalsInitializer();
   
           RequestServicer rs = (RequestServicer) newMock(RequestServicer.class);
   
  -        sii.setServletInfo(servletInfo);
  +        sii.setRequestGlobals(servletInfo);
   
           // Training
   
  @@ -174,6 +178,56 @@
   
           sii.service(request, response, rs);
   
  +        verifyControls();
  +    }
  +
  +    public void testGlobalPropertyObjectProviderSuccess()
  +    {
  +        MockControl sourceControl = newControl(IPropertySource.class);
  +        IPropertySource source = (IPropertySource) sourceControl.getMock();
  +
  +        // Training
  +
  +        source.getPropertyValue("foo");
  +        sourceControl.setReturnValue("bar");
  +
  +        replayControls();
  +
  +        GlobalPropertyObjectProvider p = new GlobalPropertyObjectProvider();
  +        p.setSource(source);
  +
  +        assertEquals("bar", p.provideObject(null, null, "foo", null));
  +        
  +        verifyControls();
  +    }
  +
  +    public void testGlobalPropertyObjectProviderFailure()
  +    {
  +        Location l = fabricateLocation(223);
  +
  +        MockControl sourceControl = newControl(IPropertySource.class);
  +        IPropertySource source = (IPropertySource) sourceControl.getMock();
  +
  +        // Training    	
  +
  +        source.getPropertyValue("foo");
  +        sourceControl.setThrowable(new ApplicationRuntimeException("failure"));
  +
  +        replayControls();
  +
  +        GlobalPropertyObjectProvider p = new GlobalPropertyObjectProvider();
  +        p.setSource(source);
  +
  +        try
  +        {
  +            p.provideObject(null, null, "foo", l);
  +        }
  +        catch (ApplicationRuntimeException ex)
  +        {
  +            assertEquals("failure", ex.getMessage());
  +            assertEquals(l, ex.getLocation());
  +        }
  +        
           verifyControls();
       }
   }
  
  
  
  1.1                  jakarta-tapestry/junit/src/org/apache/tapestry/services/impl/TestPropertySource.java
  
  Index: TestPropertySource.java
  ===================================================================
  //  Copyright 2004 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.services.impl;
  
  import java.util.Collections;
  
  import org.apache.commons.logging.Log;
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.hivemind.ErrorHandler;
  import org.apache.hivemind.test.HiveMindTestCase;
  import org.apache.tapestry.engine.IPropertySource;
  import org.easymock.MockControl;
  
  /**
   * Tests for {@link org.apache.tapestry.services.impl.PropertySourceImpl}.
   *
   * @author Howard Lewis Ship
   * @since 3.1
   */
  public class TestPropertySource extends HiveMindTestCase
  {
      public void testSuccess()
      {
          MockControl sourceControl = newControl(IPropertySource.class);
          IPropertySource source = (IPropertySource) sourceControl.getMock();
  
          Log log = (Log) newMock(Log.class);
          ErrorHandler eh = (ErrorHandler) newMock(ErrorHandler.class);
  
          // Training
  
          source.getPropertyValue("foo");
          sourceControl.setReturnValue("bar");
  
          replayControls();
  
          PropertySourceContribution c = new PropertySourceContribution();
          c.setName("psc");
          c.setSource(source);
  
          PropertySourceImpl ps = new PropertySourceImpl();
  
          ps.setContributions(Collections.singletonList(c));
          ps.setLog(log);
          ps.setErrorHandler(eh);
  
          ps.initializeService();
  
          assertEquals("bar", ps.getPropertyValue("foo"));
  
          verifyControls();
      }
  
      public void testFailure()
      {
          Log log = (Log) newMock(Log.class);
          ErrorHandler eh = (ErrorHandler) newMock(ErrorHandler.class);
  
          replayControls();
  
          PropertySourceImpl ps = new PropertySourceImpl();
  
          ps.setContributions(Collections.EMPTY_LIST);
          ps.setLog(log);
          ps.setErrorHandler(eh);
  
          ps.initializeService();
  
          try
          {
              ps.getPropertyValue("foo");
          }
          catch (ApplicationRuntimeException ex)
          {
              assertEquals(ImplMessages.noSuchGlobalProperty("foo"), ex.getMessage());
          }
  
          verifyControls();
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org