henning 2003/03/12 15:10:41
Modified: xdocs changes.xml
xdocs/services pull-service.xml
src/java/org/apache/turbine/services/pull
TurbinePullService.java
Added: src/java/org/apache/turbine/services/pull
RunDataApplicationTool.java
Log:
Add a new Tool Type: RunDataApplicationTool. This is for e.g. global or
session tools, which still need access to a current RunData object. Tools
implementing this interface get a RunData object passed at every refresh().
Revision Changes Path
1.41 +4 -0 jakarta-turbine-2/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/xdocs/changes.xml,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- changes.xml 12 Mar 2003 23:01:58 -0000 1.40
+++ changes.xml 12 Mar 2003 23:10:41 -0000 1.41
@@ -266,6 +266,10 @@
The Pull Service got a new scope: authorized tools. These are like Session
Tools but only
available after the user logged in.
</li>
+ <li>
+ The Pull Service got a new type of tools: RunDataApplicationTools. These
tools get the
+ current RunData object passed at every refresh().
+ </li>
</ul>
</p>
</subsection>
1.3 +3 -1 jakarta-turbine-2/xdocs/services/pull-service.xml
Index: pull-service.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/xdocs/services/pull-service.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pull-service.xml 12 Mar 2003 22:57:56 -0000 1.2
+++ pull-service.xml 12 Mar 2003 23:10:41 -0000 1.3
@@ -177,6 +177,7 @@
<p>
Tools can implement the org.apache.turbine.services.pull.ApplicationTool
+or the org.apache.turbine.services.pull.RunDataApplicationTool
interface. This will provide a hook for the service to initialise them
through the 'init' method and, except for request scope tools, to be
refreshed through the 'refresh' method. The type of the init argument
@@ -191,7 +192,8 @@
refreshed on each request. On Request Tools this makes no difference,
because here, the refresh() is never called (they're instantiated on
every request). All other scopes get a call to refresh() on every
-request.
+request. If you chose to implement the RunDataApplicationTool interface,
+you get the current RunData object passed to your tool.
</p>
<p>
1.16 +15 -1
jakarta-turbine-2/src/java/org/apache/turbine/services/pull/TurbinePullService.java
Index: TurbinePullService.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/pull/TurbinePullService.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- TurbinePullService.java 12 Mar 2003 22:57:56 -0000 1.15
+++ TurbinePullService.java 12 Mar 2003 23:10:41 -0000 1.16
@@ -531,6 +531,12 @@
// into the context if "refreshToolsPerRequest"
// was wanted.
//
+ // RunDataApplicationTools now have a parameter
+ // for refresh. If it is not refreshed immediately
+ // after init(), the parameter value will be undefined
+ // until the 2nd run. So we refresh all the session
+ // tools on every run, even if we just init'ed it.
+ //
if (refreshToolsPerRequest)
{
@@ -649,6 +655,10 @@
{
((ApplicationTool) tool).init(param);
}
+ else if (tool instanceof RunDataApplicationTool)
+ {
+ ((RunDataApplicationTool) tool).init(param);
+ }
}
/**
@@ -662,6 +672,10 @@
if (tool instanceof ApplicationTool)
{
((ApplicationTool) tool).refresh();
+ }
+ else if (tool instanceof RunDataApplicationTool)
+ {
+ ((RunDataApplicationTool) tool).refresh(data);
}
}
}
1.1
jakarta-turbine-2/src/java/org/apache/turbine/services/pull/RunDataApplicationTool.java
Index: RunDataApplicationTool.java
===================================================================
package org.apache.turbine.services.pull;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import org.apache.turbine.util.RunData;
/**
* Tools in the Toolbox that need a Rundata Object on every refresh should
* implement this interface.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Henning P. Schmiedehausen</a>
* @version $Id: RunDataApplicationTool.java,v 1.1 2003/03/12 23:10:41 henning Exp $
*/
public interface RunDataApplicationTool
{
/**
* Initialize the application tool. The data parameter holds a different
* type depending on how the tool is being instantiated:
* <ul>
* <li>For global tools data will be null
* <li>For request tools data will be of type RunData
* <li>For session and persistent tools data will be of type User
*
* @param data initialization data
*/
public void init(Object data);
/**
* Refresh the application tool. This is
* necessary for development work where you
* probably want the tool to refresh itself
* if it is using configuration information
* that is typically cached after initialization
*
* @param data The current RunData Object
*/
public void refresh(RunData data);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]