Author: mrdon
Date: Sat Aug 6 12:41:10 2005
New Revision: 230569
URL: http://svn.apache.org/viewcvs?rev=230569&view=rev
Log:
* Adding webwork integration
* Updating for new xwork snapshot w/ pojo action support
* Adding select locale command
* Started to separate actions that depend on webwork and servlet apis
Added:
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/AbstractSelectLocale.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/PopulateContextForRequest.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/servlet/
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/servlet/SelectLocale.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/CreateWebWorkActionProxy.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/InitWebWork.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/PopulateContextForWebWork.java
Modified:
struts/sandbox/trunk/ti/project.xml
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerActionInvocation.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/CreateActionProxy.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ProcessActionChain.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml
Modified: struts/sandbox/trunk/ti/project.xml
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/project.xml?rev=230569&r1=230568&r2=230569&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/project.xml (original)
+++ struts/sandbox/trunk/ti/project.xml Sat Aug 6 12:41:10 2005
@@ -181,6 +181,15 @@
<war.bundle>true</war.bundle>
</properties>
</dependency>
+
+ <dependency>
+ <groupId>opensymphony</groupId>
+ <artifactId>webwork</artifactId>
+ <version>SNAPSHOT</version>
+ <properties>
+ <war.bundle>true</war.bundle>
+ </properties>
+ </dependency>
<dependency>
<groupId>opensymphony</groupId>
Modified:
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerActionInvocation.java
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerActionInvocation.java?rev=230569&r1=230568&r2=230569&view=diff
==============================================================================
---
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerActionInvocation.java
(original)
+++
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerActionInvocation.java
Sat Aug 6 12:41:10 2005
@@ -46,12 +46,12 @@
public Method getActionMethod() {
if (actionMethod == null) {
- if (getPOJOAction() != null) {
+ if (getAction() != null) {
try {
- actionMethod =
proxy.getConfig().getMethod(getPOJOAction().getClass());
+ actionMethod =
proxy.getConfig().getMethod(getAction().getClass());
} catch (NoSuchMethodException ex) {
throw new IllegalStateException("Cannot location method
'"+proxy.getConfig().getMethodName()
- + "' in action '"+getPOJOAction().getClass()+"'");
+ + "' in action '"+getAction().getClass()+"'");
}
}
}
Added:
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/AbstractSelectLocale.java
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/AbstractSelectLocale.java?rev=230569&view=auto
==============================================================================
---
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/AbstractSelectLocale.java
(added)
+++
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/AbstractSelectLocale.java
Sat Aug 6 12:41:10 2005
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2003,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.ti.processor.chain;
+
+
+import java.util.Locale;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.chain.web.WebContext;
+
+import com.opensymphony.xwork.ActionContext;
+
+/**
+ * <p>Select the <code>Locale</code> to be used for this request.</p>
+ *
+ * @version $Rev: 179995 $ $Date: 2005-06-04 07:58:46 -0700 (Sat, 04 Jun 2005)
$
+ */
+
+public abstract class AbstractSelectLocale implements Command {
+
+ private static final Log log =
LogFactory.getLog(AbstractSelectLocale.class);
+
+ // ---------------------------------------------------------- Public
Methods
+
+
+ /**
+ * <p>Select the <code>Locale</code> to be used for this request.</p>
+ *
+ * @param actionCtx The <code>Context</code> for the current request
+ *
+ * @return <code>false</code> so that processing continues
+ */
+ public boolean execute(Context context) throws Exception {
+
+ WebContext ctx = (WebContext)context;
+
+ // Retrieve and cache appropriate Locale for this request
+ Locale locale = getLocale(ctx);
+ log.debug("set context locale to " + locale);
+
+ ActionContext.getContext().put(ActionContext.LOCALE, locale);
+
+ return (false);
+
+ }
+
+
+ // ------------------------------------------------------- Protected
Methods
+
+
+ /**
+ * <p>Return the <code>Locale</code> to be used for this request.</p>
+ *
+ * @param context The <code>Context</code> for this request
+ */
+ protected abstract Locale getLocale(WebContext context);
+
+
+}
Modified:
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/CreateActionProxy.java
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/CreateActionProxy.java?rev=230569&r1=230568&r2=230569&view=diff
==============================================================================
---
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/CreateActionProxy.java
(original)
+++
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/CreateActionProxy.java
Sat Aug 6 12:41:10 2005
@@ -17,67 +17,43 @@
*/
package org.apache.ti.processor.chain;
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.ti.config.mapper.ActionMapping;
+import org.apache.ti.processor.ProcessorException;
-import org.apache.commons.chain.Command;
import org.apache.commons.chain.Context;
+import org.apache.commons.chain.Command;
import org.apache.commons.chain.web.WebContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ti.config.mapper.ActionMapping;
-import org.apache.ti.processor.ProcessorException;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionProxy;
import com.opensymphony.xwork.ActionProxyFactory;
import com.opensymphony.xwork.config.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
- * Creates an ActionProxy instance
+ * Initializes XWork by replacing default factories.
*/
public class CreateActionProxy implements Command {
- protected static final Log log =
LogFactory.getLog(CreateActionProxy.class);
+ private static final Log log = LogFactory.getLog(CreateActionProxy.class);
- public boolean execute(Context origctx) {
- log.debug("Creating action proxy");
+ public boolean execute(Context origctx) throws Exception {
+ WebContext ctx = (WebContext)origctx;
- WebContext ctx = (WebContext) origctx;
-
ActionMapping mapping = (ActionMapping) ctx.get("actionMapping");
ActionProxy proxy = getActionProxy(ctx, mapping);
-
ctx.put("actionProxy", proxy);
+
return false;
}
-
+
protected ActionProxy getActionProxy(WebContext ctx, ActionMapping
mapping) {
- // request map wrapping the http request objects
- Map requestMap = ctx.getRequestScope();
-
- // parameters map wrapping the http paraneters.
- Map params = mapping.getParams();
- Map requestParams = ctx.getParamValues();
- if (params != null) {
- params.putAll(requestParams);
- } else {
- params = requestParams;
- }
-
- HashMap extraContext = createContextMap(requestMap, params,
ctx.getSessionScope(), ctx.getApplicationScope(), ctx);
-
- // If there was a previous value stack, then create a new copy and
pass it in to be used by the new Action
- //OgnlValueStack stack = (OgnlValueStack)
requestMap.get(ServletActionContext.WEBWORK_VALUESTACK_KEY);
- //if (stack != null) {
- // extraContext.put(ActionContext.VALUE_STACK, new
OgnlValueStack(stack));
- //}
try {
log.debug("Trying to get proxy");
- ActionProxy proxy =
ActionProxyFactory.getFactory().createActionProxy(mapping.getNamespace(),
mapping.getName(), extraContext);
-
//request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY,
proxy.getInvocation().getStack());
+ ActionProxy proxy =
ActionProxyFactory.getFactory().createActionProxy(mapping.getNamespace(),
mapping.getName(), ctx);
return proxy;
} catch (ConfigurationException e) {
log.error("Could not find action", e);
@@ -87,39 +63,4 @@
throw new ProcessorException(e);
}
}
-
- /**
- * Merges all application and servlet attributes into a single
<tt>HashMap</tt> to represent the entire
- * <tt>Action</tt> context.
- *
- * @param requestMap a Map of all request attributes.
- * @param parameterMap a Map of all request parameters.
- * @param sessionMap a Map of all session attributes.
- * @param applicationMap a Map of all servlet context attributes.
- * @return a HashMap representing the <tt>Action</tt> context.
- */
- public HashMap createContextMap(Map requestMap,
- Map parameterMap,
- Map sessionMap,
- Map applicationMap,
- WebContext ctx) {
- HashMap extraContext = new HashMap();
- extraContext.put(ActionContext.PARAMETERS, new HashMap(parameterMap));
- extraContext.put(ActionContext.SESSION, sessionMap);
- extraContext.put(ActionContext.APPLICATION, applicationMap);
- //extraContext.put(ActionContext.LOCALE, (locale == null) ?
request.getLocale() : locale);
-
- extraContext.put("webContext", ctx);
-
- // helpers to get access to request/session/application scope
- extraContext.put("request", requestMap);
- extraContext.put("session", sessionMap);
- extraContext.put("application", applicationMap);
- extraContext.put("parameters", parameterMap);
-
- return extraContext;
- }
-
-
-
}
Added:
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/PopulateContextForRequest.java
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/PopulateContextForRequest.java?rev=230569&view=auto
==============================================================================
---
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/PopulateContextForRequest.java
(added)
+++
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/PopulateContextForRequest.java
Sat Aug 6 12:41:10 2005
@@ -0,0 +1,108 @@
+/*
+ * $Id: .java 230535 2005-08-06 07:56:40Z mrdon $
+ *
+ * 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.ti.processor.chain;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.chain.web.WebContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.ti.config.mapper.ActionMapping;
+import org.apache.ti.processor.ProcessorException;
+
+import com.opensymphony.xwork.ActionContext;
+import com.opensymphony.xwork.ActionProxy;
+import com.opensymphony.xwork.ActionProxyFactory;
+import com.opensymphony.xwork.config.ConfigurationException;
+import com.opensymphony.xwork.interceptor.component.ComponentInterceptor;
+import com.opensymphony.xwork.interceptor.component.ComponentManager;
+
+/**
+ * Creates an ActionProxy instance
+ */
+public class PopulateContextForRequest implements Command {
+
+ protected static final Log log =
LogFactory.getLog(PopulateContextForRequest.class);
+
+ public boolean execute(Context origctx) {
+ log.debug("Initializing context map");
+
+ WebContext ctx = (WebContext) origctx;
+
+ ActionMapping mapping = (ActionMapping) ctx.get("actionMapping");
+
+ // request map wrapping the http request objects
+ Map requestMap = ctx.getRequestScope();
+
+ // parameters map wrapping the http paraneters.
+ Map params = mapping.getParams();
+ Map requestParams = ctx.getParamValues();
+ if (params != null) {
+ params.putAll(requestParams);
+ } else {
+ params = requestParams;
+ }
+
+ HashMap extraContext = createContextMap(requestMap, params,
ctx.getSessionScope(), ctx.getApplicationScope(), ctx);
+
+ ctx.putAll(extraContext);
+
+ return false;
+ }
+
+ /**
+ * Merges all application and servlet attributes into a single
<tt>HashMap</tt> to represent the entire
+ * <tt>Action</tt> context.
+ *
+ * @param requestMap a Map of all request attributes.
+ * @param parameterMap a Map of all request parameters.
+ * @param sessionMap a Map of all session attributes.
+ * @param applicationMap a Map of all servlet context attributes.
+ * @return a HashMap representing the <tt>Action</tt> context.
+ */
+ protected HashMap createContextMap(Map requestMap,
+ Map parameterMap,
+ Map sessionMap,
+ Map applicationMap,
+ WebContext ctx) {
+ HashMap extraContext = new HashMap();
+ extraContext.put(ActionContext.PARAMETERS, new HashMap(parameterMap));
+ extraContext.put(ActionContext.SESSION, sessionMap);
+ extraContext.put(ActionContext.APPLICATION, applicationMap);
+ //extraContext.put(ActionContext.LOCALE, (locale == null) ?
request.getLocale() : locale);
+
+ extraContext.put(ComponentInterceptor.COMPONENT_MANAGER,
requestMap.get(ComponentManager.COMPONENT_MANAGER_KEY));
+
+ extraContext.put("webContext", ctx);
+
+ // helpers to get access to request/session/application scope
+ extraContext.put("request", requestMap);
+ extraContext.put("session", sessionMap);
+ extraContext.put("application", applicationMap);
+ extraContext.put("parameters", parameterMap);
+
+ return extraContext;
+ }
+
+
+
+}
Modified:
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ProcessActionChain.java
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ProcessActionChain.java?rev=230569&r1=230568&r2=230569&view=diff
==============================================================================
---
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ProcessActionChain.java
(original)
+++
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ProcessActionChain.java
Sat Aug 6 12:41:10 2005
@@ -18,6 +18,7 @@
package org.apache.ti.processor.chain;
import org.apache.commons.chain.Context;
+import org.apache.commons.chain.web.WebContext;
import org.apache.commons.chain.impl.ChainBase;
import com.opensymphony.xwork.ActionContext;
@@ -33,24 +34,26 @@
private static final Log log = LogFactory.getLog(ProcessActionChain.class);
- public boolean execute(Context context) throws Exception {
+ public boolean execute(Context origctx) throws Exception {
+ WebContext ctx = (WebContext)origctx;
+
log.debug("Processing action chain");
+ ActionProxy proxy = (ActionProxy) ctx.get("actionProxy");
+
ActionContext nestedContext = ActionContext.getContext();
-
- ActionProxy proxy = (ActionProxy) context.get("actionProxy");
ActionContext.setContext(proxy.getInvocation().getInvocationContext());
boolean retCode = false;
try {
- retCode = super.execute(context);
+ retCode = super.execute(origctx);
} finally {
ActionContext.setContext(nestedContext);
}
-
+
return retCode;
}
-
+
}
Modified:
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml?rev=230569&r1=230568&r2=230569&view=diff
==============================================================================
---
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml
(original)
+++
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml
Sat Aug 6 12:41:10 2005
@@ -38,8 +38,9 @@
<chain name="start" >
<command name="createActionMapping" />
- <command name="initXWork" />
- <command name="createActionProxy"
className="org.apache.ti.processor.chain.CreateActionProxy" />
+ <command name="populateContextForRequest"
className="org.apache.ti.processor.chain.PopulateContextForRequest"/>
+ <command name="populateContextForWebWork"
className="org.apache.ti.processor.chain.webwork.PopulateContextForWebWork" />
+ <command name="createWebWorkActionProxy"
className="org.apache.ti.processor.chain.webwork.CreateWebWorkActionProxy"/>
<lookup
catalogName="struts-ti"
name="process-action"
@@ -49,10 +50,14 @@
<!-- ========== Initialization chain ========================= -->
<chain name="init" >
+ <command name="initXWork" />
+ <command name="initWebWork"
className="org.apache.ti.processor.chain.webwork.InitWebWork"/>
</chain>
<chain name="process-action"
className="org.apache.ti.processor.chain.ProcessActionChain">
+
<command name="initControllerContext" />
+ <command name="selectLocale"
className="org.apache.ti.processor.chain.servlet.SelectLocale" />
<command name="executeAction"
className="org.apache.ti.processor.chain.ExecuteAction" />
</chain>
Added:
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/servlet/SelectLocale.java
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/servlet/SelectLocale.java?rev=230569&view=auto
==============================================================================
---
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/servlet/SelectLocale.java
(added)
+++
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/servlet/SelectLocale.java
Sat Aug 6 12:41:10 2005
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2003,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.ti.processor.chain.servlet;
+
+
+import java.util.Locale;
+
+import org.apache.ti.processor.chain.AbstractSelectLocale;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.chain.web.WebContext;
+import org.apache.commons.chain.web.servlet.ServletWebContext;
+
+import com.opensymphony.xwork.ActionContext;
+
+import javax.servlet.http.HttpSession;
+
+
+/**
+ * <p>Select the <code>Locale</code> to be used for this request.</p>
+ *
+ * @version $Rev: 169091 $ $Date: 2005-05-07 09:11:38 -0700 (Sat, 07 May 2005)
$
+ */
+
+public class SelectLocale extends AbstractSelectLocale {
+
+
+ private static final Log log = LogFactory.getLog(SelectLocale.class);
+
+ // ------------------------------------------------------- Protected
Methods
+
+
+ /**
+ * <p>Return the <code>Locale</code> to be used for this request.</p>
+ *
+ * @param context The <code>Context</code> for this request
+ */
+ protected Locale getLocale(WebContext context) {
+
+ ServletWebContext saContext = (ServletWebContext) context;
+
+ // Has a Locale already been selected?
+ HttpSession session = saContext.getRequest().getSession();
+ Locale locale = (Locale) session.getAttribute(ActionContext.LOCALE);
+ if (locale != null) {
+ return (locale);
+ }
+
+ // Select and cache the Locale to be used
+ locale = saContext.getRequest().getLocale();
+ if (locale == null) {
+ locale = Locale.getDefault();
+ }
+ session.setAttribute(ActionContext.LOCALE, locale);
+ return (locale);
+
+ }
+}
+
Added:
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/CreateWebWorkActionProxy.java
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/CreateWebWorkActionProxy.java?rev=230569&view=auto
==============================================================================
---
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/CreateWebWorkActionProxy.java
(added)
+++
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/CreateWebWorkActionProxy.java
Sat Aug 6 12:41:10 2005
@@ -0,0 +1,73 @@
+/*
+ * $Id: InjectWebWorkValueStack.java 230535 2005-08-06 07:56:40Z mrdon $
+ *
+ * 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.ti.processor.chain.webwork;
+
+import org.apache.commons.chain.Context;
+import org.apache.commons.chain.Filter;
+import org.apache.commons.chain.web.WebContext;
+import org.apache.commons.chain.impl.ChainBase;
+import org.apache.ti.processor.chain.CreateActionProxy;
+import org.apache.ti.config.mapper.ActionMapping;
+
+import com.opensymphony.xwork.ActionContext;
+import com.opensymphony.xwork.ActionProxy;
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.xwork.util.OgnlValueStack;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Initializes XWork by replacing default factories.
+ */
+public class CreateWebWorkActionProxy extends CreateActionProxy implements
Filter {
+
+ private static final Log log =
LogFactory.getLog(CreateWebWorkActionProxy.class);
+
+ public boolean execute(Context origctx) throws Exception {
+ WebContext ctx = (WebContext)origctx;
+ log.debug("Injecting webwork value stack");
+
+ // If there was a previous value stack, then create a new copy and
pass it in to be used by the new Action
+ OgnlValueStack stack = (OgnlValueStack)
ctx.getRequestScope().get(ServletActionContext.WEBWORK_VALUESTACK_KEY);
+ if (stack != null) {
+ ctx.put(ActionContext.VALUE_STACK, new OgnlValueStack(stack));
+ }
+ ctx.put("origStack", stack);
+
+ ActionMapping mapping = (ActionMapping) ctx.get("actionMapping");
+ ActionProxy proxy = getActionProxy(ctx, mapping);
+ ctx.getRequestScope().put(ServletActionContext.WEBWORK_VALUESTACK_KEY,
proxy.getInvocation().getStack());
+ ctx.put("actionProxy", proxy);
+
+ return false;
+ }
+
+ public boolean postprocess(Context context, Exception exception) {
+ OgnlValueStack stack = (OgnlValueStack)context.get("origStack");
+
+ WebContext ctx = (WebContext)context;
+ // If there was a previous value stack then set it back onto the
request
+ if (stack != null) {
+
ctx.getRequestScope().put(ServletActionContext.WEBWORK_VALUESTACK_KEY, stack);
+ }
+ context.remove("origStack");
+
+ return false;
+ }
+}
Added:
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/InitWebWork.java
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/InitWebWork.java?rev=230569&view=auto
==============================================================================
---
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/InitWebWork.java
(added)
+++
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/InitWebWork.java
Sat Aug 6 12:41:10 2005
@@ -0,0 +1,55 @@
+/*
+ * $Id: Init.java 230535 2005-08-06 07:56:40Z mrdon $
+ *
+ * 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.ti.processor.chain.webwork;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.chain.web.WebContext;
+
+import com.opensymphony.xwork.ActionProxyFactory;
+import com.opensymphony.xwork.ObjectFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.opensymphony.util.FileManager;
+import com.opensymphony.xwork.util.LocalizedTextUtil;
+import com.opensymphony.webwork.config.Configuration;
+
+/**
+ * Initializes by replacing default factories
+ */
+public class InitWebWork implements Command {
+
+ private static final Log log = LogFactory.getLog(InitWebWork.class);
+
+ public boolean execute(Context origctx) {
+ log.debug("Initializing webwork");
+
+
LocalizedTextUtil.addDefaultResourceBundle("com/opensymphony/webwork/webwork-messages");
+
+ //check for configuration reloading
+ if
("true".equalsIgnoreCase(Configuration.getString("webwork.configuration.xml.reload")))
{
+ FileManager.setReloadingConfigs(true);
+ }
+
+ return false;
+ }
+
+
+}
Added:
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/PopulateContextForWebWork.java
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/PopulateContextForWebWork.java?rev=230569&view=auto
==============================================================================
---
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/PopulateContextForWebWork.java
(added)
+++
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/PopulateContextForWebWork.java
Sat Aug 6 12:41:10 2005
@@ -0,0 +1,65 @@
+/*
+ * $Id: CreateActionProxy.java 230535 2005-08-06 07:56:40Z mrdon $
+ *
+ * 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.ti.processor.chain.webwork;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.chain.web.WebContext;
+import org.apache.commons.chain.web.servlet.ServletWebContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ti.config.mapper.ActionMapping;
+import org.apache.ti.processor.ProcessorException;
+
+import com.opensymphony.xwork.ActionContext;
+import com.opensymphony.xwork.ActionProxy;
+import com.opensymphony.xwork.ActionProxyFactory;
+import com.opensymphony.xwork.config.ConfigurationException;
+
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.webwork.WebWorkStatics;
+import com.opensymphony.webwork.util.AttributeMap;
+
+
+/**
+ * Creates an ActionProxy instance
+ */
+public class PopulateContextForWebWork implements Command {
+
+ protected static final Log log =
LogFactory.getLog(PopulateContextForWebWork.class);
+
+ public boolean execute(Context ctx) {
+ log.debug("Initializing context map adding webwork values");
+
+ ServletWebContext servletCtx = (ServletWebContext) ctx;
+ ctx.put(WebWorkStatics.HTTP_REQUEST, servletCtx.getRequest());
+ ctx.put(WebWorkStatics.HTTP_RESPONSE, servletCtx.getResponse());
+ ctx.put(WebWorkStatics.SERVLET_CONTEXT, servletCtx.getContext());
+
+ AttributeMap attrMap = new AttributeMap(ctx);
+ ctx.put("attr", attrMap);
+
+ return false;
+ }
+
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]