Return-Path: Delivered-To: apmail-jakarta-tapestry-dev-archive@www.apache.org Received: (qmail 30162 invoked from network); 2 Feb 2005 05:41:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 2 Feb 2005 05:41:20 -0000 Received: (qmail 75285 invoked by uid 500); 2 Feb 2005 05:41:19 -0000 Delivered-To: apmail-jakarta-tapestry-dev-archive@jakarta.apache.org Received: (qmail 75267 invoked by uid 500); 2 Feb 2005 05:41:19 -0000 Mailing-List: contact tapestry-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tapestry development" Reply-To: "Tapestry development" Delivered-To: mailing list tapestry-dev@jakarta.apache.org Received: (qmail 75254 invoked by uid 500); 2 Feb 2005 05:41:18 -0000 Received: (qmail 75170 invoked by uid 99); 2 Feb 2005 05:41:18 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Tue, 01 Feb 2005 21:41:17 -0800 Received: (qmail 30078 invoked by uid 1616); 2 Feb 2005 05:41:15 -0000 Date: 2 Feb 2005 05:41:15 -0000 Message-ID: <20050202054115.30077.qmail@minotaur.apache.org> From: hlship@apache.org To: jakarta-tapestry-cvs@apache.org Subject: cvs commit: jakarta-tapestry/framework/src/java/org/apache/tapestry/engine RequestCycle.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N hlship 2005/02/01 21:41:15 Modified: framework/src/java/org/apache/tapestry/services/impl RequestCycleFactoryImpl.java framework/src/java/org/apache/tapestry IEngine.java TapestryStrings.properties IRequestCycle.java framework/src/java/org/apache/tapestry/listener ListenerMap.java framework/src/descriptor/META-INF tapestry.request.xml framework/src/java/org/apache/tapestry/engine RequestCycle.java Added: framework/src/java/org/apache/tapestry/listener ListenerStrings.properties ListenerMessages.java SyntheticListener.java Log: Inject Infrastructure into RequestCycleFactory, RequestCycle Add getInfrastructure() to IRequestCycle. Refactor ListenerMap (to be improved shortly). Revision Changes Path 1.5 +8 -14 jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/RequestCycleFactoryImpl.java Index: RequestCycleFactoryImpl.java =================================================================== RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/RequestCycleFactoryImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- RequestCycleFactoryImpl.java 28 Jan 2005 21:07:16 -0000 1.4 +++ RequestCycleFactoryImpl.java 2 Feb 2005 05:41:15 -0000 1.5 @@ -27,6 +27,7 @@ import org.apache.tapestry.engine.ServiceEncodingImpl; import org.apache.tapestry.record.PropertyPersistenceStrategySource; import org.apache.tapestry.request.RequestContext; +import org.apache.tapestry.services.Infrastructure; import org.apache.tapestry.services.RequestCycleFactory; import org.apache.tapestry.services.ServiceConstants; import org.apache.tapestry.services.ServiceMap; @@ -42,14 +43,12 @@ private IMonitorFactory _monitorFactory; - private ServiceMap _serviceMap; - private PropertyPersistenceStrategySource _strategySource; - private IPageSource _pageSource; - private ErrorHandler _errorHandler; + private Infrastructure _infrastructure; + public IRequestCycle newRequestCycle(IEngine engine, RequestContext context) { IMonitor monitor = _monitorFactory.createMonitor(context); @@ -60,8 +59,8 @@ IEngineService service = findService(parameters); - return new RequestCycle(engine, context, parameters, service, _pageSource, _strategySource, - _errorHandler, monitor); + return new RequestCycle(engine, context, parameters, service, _infrastructure, + _strategySource, _errorHandler, monitor); } private IEngineService findService(QueryParameterMap parameters) @@ -71,7 +70,7 @@ if (serviceName == null) serviceName = Tapestry.HOME_SERVICE; - return _serviceMap.getService(serviceName); + return _infrastructure.getServiceMap().getService(serviceName); } /** @@ -124,11 +123,6 @@ _monitorFactory = monitorFactory; } - public void setServiceMap(ServiceMap serviceMap) - { - _serviceMap = serviceMap; - } - public void setStrategySource(PropertyPersistenceStrategySource strategySource) { _strategySource = strategySource; @@ -139,8 +133,8 @@ _errorHandler = errorHandler; } - public void setPageSource(IPageSource pageSource) + public void setInfrastructure(Infrastructure infrastructure) { - _pageSource = pageSource; + _infrastructure = infrastructure; } } \ No newline at end of file 1.12 +5 -2 jakarta-tapestry/framework/src/java/org/apache/tapestry/IEngine.java Index: IEngine.java =================================================================== RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/IEngine.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- IEngine.java 28 Jan 2005 21:07:15 -0000 1.11 +++ IEngine.java 2 Feb 2005 05:41:15 -0000 1.12 @@ -36,8 +36,11 @@ * application. The engine is a delegate to the {@link ApplicationServlet}via the * {@link #service(RequestContext)}method. *

- * Engine instances are persisted in the {@link javax.servlet.http.HttpSession}and are - * serializable. + * Starting in release 3.1, the engine is kept around only for compatibility (with release + * 3.0). It's functions have been moved over into a collection of HiveMind + * services (or are in the process of doing so). + * + * @deprecated To be removed in 3.2. * * @author Howard Lewis Ship */ 1.15 +0 -5 jakarta-tapestry/framework/src/java/org/apache/tapestry/TapestryStrings.properties Index: TapestryStrings.properties =================================================================== RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/TapestryStrings.properties,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- TapestryStrings.properties 28 Jan 2005 21:07:15 -0000 1.14 +++ TapestryStrings.properties 2 Feb 2005 05:41:15 -0000 1.15 @@ -204,11 +204,6 @@ AbstractLinkComponent.no-nesting=ILinkComponents may not be nested. AbstractLinkComponent.events-need-body=A link component with multiple functions for a single event type must be contained within a Body. -# org.apache.tapestry.listener - -ListenerMap.object-missing-method=Object {0} does not implement a listener method named ''{1}''. -ListenerMap.unable-to-invoke-method=Unable to invoke method {0} on {1}: {2} - # org.apache.tapestry.multipart UploadPart.unable-to-open-content-file=Unable to open uploaded file ''{0}''. 1.8 +11 -0 jakarta-tapestry/framework/src/java/org/apache/tapestry/IRequestCycle.java Index: IRequestCycle.java =================================================================== RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/IRequestCycle.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- IRequestCycle.java 28 Jan 2005 21:07:15 -0000 1.7 +++ IRequestCycle.java 2 Feb 2005 05:41:15 -0000 1.8 @@ -18,6 +18,7 @@ import org.apache.tapestry.engine.IEngineService; import org.apache.tapestry.engine.IMonitor; import org.apache.tapestry.request.RequestContext; +import org.apache.tapestry.services.Infrastructure; /** * Controller object that manages a single request cycle. A request cycle is one 'hit' on the web @@ -72,6 +73,7 @@ /** * Returns the engine which is processing this request cycle. + * @deprecated To be removed in 3.2 */ public IEngine getEngine(); @@ -306,4 +308,13 @@ */ public void forgetPage(String name); + + /** + * Returns the central {@link org.apache.tapestry.services.Infrastructure} object + * used to manage the processing of the request. + * + * @since 3.1 + */ + + public Infrastructure getInfrastructure(); } \ No newline at end of file 1.5 +6 -50 jakarta-tapestry/framework/src/java/org/apache/tapestry/listener/ListenerMap.java Index: ListenerMap.java =================================================================== RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/listener/ListenerMap.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ListenerMap.java 5 Jan 2005 23:17:30 -0000 1.4 +++ ListenerMap.java 2 Feb 2005 05:41:15 -0000 1.5 @@ -26,9 +26,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.hivemind.ApplicationRuntimeException; import org.apache.tapestry.IActionListener; -import org.apache.tapestry.IComponent; import org.apache.tapestry.IRequestCycle; -import org.apache.tapestry.Tapestry; /** * Maps a class to a set of listeners based on the public methods of the class. @@ -66,46 +64,6 @@ private static Map _classMap = new HashMap(); - /** - * Implements both listener interfaces. - */ - - private class SyntheticListener implements IActionListener - { - private Method _method; - - SyntheticListener(Method method) - { - _method = method; - } - - private void invoke(IRequestCycle cycle) - { - Object[] args = new Object[] - { cycle }; - - invokeTargetMethod(_target, _method, args); - } - - public void actionTriggered(IComponent component, IRequestCycle cycle) - { - invoke(cycle); - } - - public String toString() - { - StringBuffer buffer = new StringBuffer("SyntheticListener["); - - buffer.append(_target); - buffer.append(' '); - buffer.append(_method); - buffer.append(']'); - - return buffer.toString(); - } - - } - public ListenerMap(Object target) { _target = target; @@ -148,12 +106,11 @@ Method method = (Method) _methodMap.get(name); if (method == null) - throw new ApplicationRuntimeException(Tapestry.format( - "ListenerMap.object-missing-method", + throw new ApplicationRuntimeException(ListenerMessages.objectMissingMethod( _target, name)); - return new SyntheticListener(method); + return new SyntheticListener(_target, method); } /** @@ -233,7 +190,7 @@ * Invoked by the inner listener/adaptor classes to invoke the method. */ - private static void invokeTargetMethod(Object target, Method method, Object[] args) + static void invokeTargetMethod(Object target, Method method, Object[] args) { if (LOG.isDebugEnabled()) LOG.debug("Invoking listener method " + method + " on " + target); @@ -268,11 +225,10 @@ // Catch InvocationTargetException or, preferrably, // the inner exception here (if its a runtime exception). - throw new ApplicationRuntimeException(Tapestry.format( - "ListenerMap.unable-to-invoke-method", - method.getName(), + throw new ApplicationRuntimeException(ListenerMessages.unableToInvokeMethod( + method, target, - ex.getMessage()), ex); + ex), ex); } } 1.1 jakarta-tapestry/framework/src/java/org/apache/tapestry/listener/ListenerStrings.properties Index: ListenerStrings.properties =================================================================== # Copyright 2005 The Apache Software Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. object-missing-method=Object {0} does not implement a listener method named ''{1}''. unable-to-invoke-method=Unable to invoke method {0} on {1}: {2} 1.1 jakarta-tapestry/framework/src/java/org/apache/tapestry/listener/ListenerMessages.java Index: ListenerMessages.java =================================================================== // Copyright 2005 The Apache Software Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package org.apache.tapestry.listener; import java.lang.reflect.Method; import org.apache.hivemind.impl.MessageFormatter; /** * @author Howard M. Lewis Ship * @since 3.1 */ class ListenerMessages { private static final MessageFormatter _formatter = new MessageFormatter(ListenerMessages.class, "ListenerStrings"); public static String objectMissingMethod(Object target, String name) { return _formatter.format("object-missing-method", target, name); } public static String unableToInvokeMethod(Method method, Object target, Throwable ex) { return _formatter.format("unable-to-invoke-method", method.getName(), target, ex); } } 1.1 jakarta-tapestry/framework/src/java/org/apache/tapestry/listener/SyntheticListener.java Index: SyntheticListener.java =================================================================== // Copyright 2005 The Apache Software Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package org.apache.tapestry.listener; import java.lang.reflect.Method; import org.apache.tapestry.IActionListener; import org.apache.tapestry.IComponent; import org.apache.tapestry.IRequestCycle; /** * @author Howard Lewis Ship * @since 3.1 */ public class SyntheticListener implements IActionListener { private Object _target; private Method _method; public SyntheticListener(Object target, Method method) { _target = target; _method = method; } private void invoke(IRequestCycle cycle) { Object[] args = new Object[] { cycle }; ListenerMap.invokeTargetMethod(_target, _method, args); } public void actionTriggered(IComponent component, IRequestCycle cycle) { invoke(cycle); } public String toString() { StringBuffer buffer = new StringBuffer("SyntheticListener["); buffer.append(_target); buffer.append(' '); buffer.append(_method); buffer.append(']'); return buffer.toString(); } } 1.11 +1 -2 jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.request.xml Index: tapestry.request.xml =================================================================== RCS file: /home/cvs/jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.request.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- tapestry.request.xml 29 Jan 2005 16:45:14 -0000 1.10 +++ tapestry.request.xml 2 Feb 2005 05:41:15 -0000 1.11 @@ -149,9 +149,8 @@ - - + 1.9 +14 -3 jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/RequestCycle.java Index: RequestCycle.java =================================================================== RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/RequestCycle.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- RequestCycle.java 28 Jan 2005 21:07:15 -0000 1.8 +++ RequestCycle.java 2 Feb 2005 05:41:15 -0000 1.9 @@ -40,6 +40,7 @@ import org.apache.tapestry.record.PageRecorderImpl; import org.apache.tapestry.record.PropertyPersistenceStrategySource; import org.apache.tapestry.request.RequestContext; +import org.apache.tapestry.services.Infrastructure; import org.apache.tapestry.util.QueryParameterMap; /** @@ -73,6 +74,10 @@ private IPageSource _pageSource; + /** @since 3.1 */ + + private Infrastructure _infrastructure; + /** * Contains parameters extracted from the request context, plus any decoded by any * {@link ServiceEncoder}s. @@ -119,8 +124,7 @@ */ public RequestCycle(IEngine engine, RequestContext requestContext, - QueryParameterMap parameters, IEngineService service, - IPageSource pageSource, + QueryParameterMap parameters, IEngineService service, Infrastructure infrastructure, PropertyPersistenceStrategySource strategySource, ErrorHandler errorHandler, IMonitor monitor) { @@ -128,7 +132,8 @@ _requestContext = requestContext; _parameters = parameters; _service = service; - _pageSource = pageSource; + _infrastructure = infrastructure; + _pageSource = _infrastructure.getPageSource(); _strategySource = strategySource; _log = new ErrorLogImpl(errorHandler, LOG); _monitor = monitor; @@ -662,4 +667,10 @@ _strategySource.discardAllStoredChanged(pageName, this); } + /** @since 3.1 */ + + public Infrastructure getInfrastructure() + { + return _infrastructure; + } } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org