mirror of
https://github.com/apache/struts.git
synced 2026-08-10 09:06:55 +00:00
Compare commits
70 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ea055ccb9d | |||
| 82e768b673 | |||
| 002f4ab8c0 | |||
| 2cce257320 | |||
| 146d2677c6 | |||
| f628fa5baa | |||
| 36e823c7e9 | |||
| 90efa7b36a | |||
| 342a201eb7 | |||
| dbcc05d102 | |||
| c231c7290a | |||
| 8c483d68bc | |||
| 6a5c4c2c53 | |||
| 2ba492bceb | |||
| 9375fe9c6a | |||
| de6869e67f | |||
| 97fa4e4a37 | |||
| c8db212ccf | |||
| bbc9c697cd | |||
| 09d906ef98 | |||
| 04505b92a2 | |||
| 6ee3d124e4 | |||
| 5494663fd4 | |||
| b07f659693 | |||
| 2ea2d869cc | |||
| bbd4170da6 | |||
| 4e9821f05b | |||
| 74b2fb7bf4 | |||
| 250442591c | |||
| f087df85f9 | |||
| 4283e8972d | |||
| 712fd1a1ab | |||
| 35521822c3 | |||
| d452e63c79 | |||
| 81b7e03f1f | |||
| c8eef15176 | |||
| 8645eee9bd | |||
| 86777e8614 | |||
| 5ccff073f5 | |||
| c9eaf8f3e0 | |||
| b3893699ae | |||
| 0023041b60 | |||
| a3e6c3c124 | |||
| 0be14bb564 | |||
| f88c1e7dcb | |||
| f58eafdab5 | |||
| 74c03ad8a0 | |||
| 135d31371b | |||
| 29a23e7dfa | |||
| 37bc43a90b | |||
| 71130ad3d4 | |||
| d8f865dcc4 | |||
| 82b39dc8fb | |||
| fb42b3e194 | |||
| 0e9d6210ef | |||
| 2763cf9a00 | |||
| fe264d59a4 | |||
| 68c4436d44 | |||
| 101aa85aa1 | |||
| 962f5886af | |||
| 1352a01555 | |||
| 2092931e7b | |||
| f7cee24e11 | |||
| 6c29f36d23 | |||
| 92aa692879 | |||
| b66d3bd2a9 | |||
| 7b781ce56d | |||
| cbdf6f296c | |||
| 895682acd0 | |||
| 415377c10f |
+1
-1
@@ -27,7 +27,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>2.1.0</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-api</artifactId>
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>2.1.0</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-blank</artifactId>
|
||||
|
||||
@@ -21,10 +21,12 @@
|
||||
|
||||
package example;
|
||||
|
||||
import org.apache.struts2.StrutsTestCase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class HelloWorldTest extends TestCase {
|
||||
public class HelloWorldTest extends StrutsTestCase {
|
||||
|
||||
public void testHelloWorld() throws Exception {
|
||||
HelloWorld hello_world = new HelloWorld();
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>2.1.0</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-mailreader</artifactId>
|
||||
|
||||
@@ -21,14 +21,20 @@
|
||||
|
||||
package mailreader2;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts.apps.mailreader.dao.impl.memory.MemoryUserDatabase;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import java.io.*;
|
||||
|
||||
import org.apache.struts.apps.mailreader.dao.impl.memory.MemoryUserDatabase;
|
||||
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <p><code>ServletContextListener</code> that initializes and finalizes the
|
||||
@@ -94,7 +100,7 @@ public final class ApplicationListener implements ServletContextListener {
|
||||
/**
|
||||
* <p>Logging output for this plug in instance.</p>
|
||||
*/
|
||||
private Log log = LogFactory.getLog(this.getClass());
|
||||
private Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
// ------------------------------------------------------------- Properties
|
||||
|
||||
|
||||
@@ -21,18 +21,20 @@
|
||||
|
||||
package mailreader2;
|
||||
|
||||
import org.apache.struts2.interceptor.ApplicationAware;
|
||||
import org.apache.struts2.interceptor.SessionAware;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts.apps.mailreader.dao.ExpiredPasswordException;
|
||||
import org.apache.struts.apps.mailreader.dao.Subscription;
|
||||
import org.apache.struts.apps.mailreader.dao.User;
|
||||
import org.apache.struts.apps.mailreader.dao.UserDatabase;
|
||||
import org.apache.struts.apps.mailreader.dao.impl.memory.MemorySubscription;
|
||||
import org.apache.struts.apps.mailreader.dao.impl.memory.MemoryUser;
|
||||
import java.util.Map;
|
||||
import org.apache.struts2.interceptor.ApplicationAware;
|
||||
import org.apache.struts2.interceptor.SessionAware;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <p> Base Action for MailreaderSupport application. </p>
|
||||
@@ -386,7 +388,7 @@ public class MailreaderSupport extends ActionSupport
|
||||
/**
|
||||
* <p><code>Log</code> instance for this application. </p>
|
||||
*/
|
||||
protected Log log = LogFactory.getLog(Constants.PACKAGE);
|
||||
protected Logger log = LoggerFactory.getLogger(Constants.PACKAGE);
|
||||
|
||||
/**
|
||||
* <p> Persist the User object, including subscriptions, to the database.
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>2.1.0</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
|
||||
+48
-48
@@ -27,7 +27,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>2.1.0</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-portlet</artifactId>
|
||||
@@ -39,38 +39,38 @@
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/apps/portlet/</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/apps/portlet/</url>
|
||||
</scm>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>pluto</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- configure maven-war-plugin to use updated web.xml -->
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<configuration>
|
||||
<webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- bind 'pluto:assemble' goal to 'process-resources' lifecycle -->
|
||||
<plugin>
|
||||
<groupId>org.apache.pluto</groupId>
|
||||
<artifactId>maven-pluto-plugin</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>assemble</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>pluto</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- configure maven-war-plugin to use updated web.xml -->
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<configuration>
|
||||
<webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- bind 'pluto:assemble' goal to 'process-resources' lifecycle -->
|
||||
<plugin>
|
||||
<groupId>org.apache.pluto</groupId>
|
||||
<artifactId>maven-pluto-plugin</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>assemble</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>portlet-api</groupId>
|
||||
@@ -109,21 +109,21 @@
|
||||
<artifactId>commons-digester</artifactId>
|
||||
<version>1.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.9</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>2.1.0</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-showcase</artifactId>
|
||||
|
||||
+4
-4
@@ -21,20 +21,20 @@
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.dispatcher.SessionMap;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
public class ChatAuthenticationInterceptor implements Interceptor {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log _log = LogFactory.getLog(ChatAuthenticationInterceptor.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChatAuthenticationInterceptor.class);
|
||||
|
||||
public static final String USER_SESSION_KEY = "chatUserSessionKey";
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ChatAuthenticationInterceptor implements Interceptor {
|
||||
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
|
||||
_log.debug("Authenticating chat user");
|
||||
LOG.debug("Authenticating chat user");
|
||||
|
||||
SessionMap session = (SessionMap) ActionContext.getContext().get(ActionContext.SESSION);
|
||||
User user = (User) session.get(USER_SESSION_KEY);
|
||||
|
||||
@@ -22,20 +22,19 @@ package org.apache.struts2.showcase.chat;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Authenticate showcase chat example, make sure everyone have a username.
|
||||
*/
|
||||
public class ChatInterceptor implements Interceptor {
|
||||
|
||||
private static final Log _log = LogFactory.getLog(ChatInterceptor.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChatInterceptor.class);
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -51,7 +50,7 @@ public class ChatInterceptor implements Interceptor {
|
||||
HttpSession session = (HttpSession) ActionContext.getContext().get(ActionContext.SESSION);
|
||||
User chatUser = (User) session.getAttribute(CHAT_USER_SESSION_KEY);
|
||||
if (chatUser == null) {
|
||||
_log.debug("Chat user not logged in");
|
||||
LOG.debug("Chat user not logged in");
|
||||
return Action.LOGIN;
|
||||
}
|
||||
return invocation.invoke();
|
||||
|
||||
+5
-4
@@ -24,14 +24,15 @@ import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
public class ChatSessionListener implements HttpSessionListener {
|
||||
|
||||
private static final Log _log = LogFactory.getLog(ChatSessionListener.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChatSessionListener.class);
|
||||
|
||||
public void sessionCreated(HttpSessionEvent event) {
|
||||
}
|
||||
@@ -45,7 +46,7 @@ public class ChatSessionListener implements HttpSessionListener {
|
||||
ChatService service = (ChatService) context.getBean("chatService");
|
||||
service.logout(user.getName());
|
||||
|
||||
_log.info("session expired, logged user ["+user.getName()+"] out");
|
||||
LOG.info("session expired, logged user ["+user.getName()+"] out");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,14 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.util.StrutsTypeConverter;
|
||||
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
public class DateConverter extends StrutsTypeConverter {
|
||||
|
||||
private static final Log _log = LogFactory.getLog(DateConverter.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DateConverter.class);
|
||||
|
||||
public Object convertFromString(Map context, String[] values, Class toClass) {
|
||||
|
||||
@@ -41,7 +42,7 @@ public class DateConverter extends StrutsTypeConverter {
|
||||
return sdf.parse(values[0]);
|
||||
}
|
||||
catch(ParseException e) {
|
||||
_log.error("error converting value ["+values[0]+"] to Date ", e);
|
||||
LOG.error("error converting value ["+values[0]+"] to Date ", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.struts2.views.freemarker.FreemarkerManager;
|
||||
import org.apache.struts2.views.freemarker.ScopesHashModel;
|
||||
|
||||
import com.opensymphony.xwork2.util.OgnlValueStack;
|
||||
import com.opensymphony.xwork2.ognl.OgnlValueStack;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<constant name="struts.devMode" value="true" />
|
||||
<constant name="struts.configuration.xml.reload" value="false" />
|
||||
<constant name="struts.custom.i18n.resources" value="globalMessages" />
|
||||
<constant name="struts.action.extension" value="action,," />
|
||||
|
||||
<constant name="struts.codebehind.defaultPackage" value="person" />
|
||||
<constant name="struts.freemarker.manager.classname" value="customFreemarkerManager" />
|
||||
@@ -66,6 +67,8 @@
|
||||
</interceptor-stack>
|
||||
</interceptors>
|
||||
|
||||
<default-action-ref name="showcase" />
|
||||
|
||||
<action name="showcase">
|
||||
<result>showcase.jsp</result>
|
||||
</action>
|
||||
|
||||
@@ -48,9 +48,9 @@ A submit button, with "notifyTopics"
|
||||
<br/><br/>
|
||||
|
||||
Use an image as submit
|
||||
|
||||
<s:url value="/images/struts-power.gif" var="imgUrl" />
|
||||
<sx:submit type="image" label="Alt Text" targets="t1"
|
||||
src="${pageContext.request.contextPath}/images/struts-power.gif" href="%{ajaxTest}" />
|
||||
src="%{imgUrl}" href="%{ajaxTest}" />
|
||||
<br/><br/>
|
||||
|
||||
<label for="textInput">Text to be echoed</label>
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>2.1.0</version>
|
||||
</parent>
|
||||
|
||||
<scm>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6
-12
@@ -27,7 +27,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>2.1.0</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-core</artifactId>
|
||||
@@ -55,9 +55,9 @@
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>com.opensymphony.xwork</groupId>
|
||||
<groupId>com.opensymphony</groupId>
|
||||
<artifactId>xwork</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<version>2.1.0</version>
|
||||
<classifier>sources</classifier>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
@@ -289,9 +289,9 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.opensymphony.xwork</groupId>
|
||||
<groupId>com.opensymphony</groupId>
|
||||
<artifactId>xwork</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>-->
|
||||
@@ -326,12 +326,6 @@
|
||||
<version>2.6.11</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Ajax -->
|
||||
<dependency>
|
||||
<groupId>uk.ltd.getahead</groupId>
|
||||
@@ -465,7 +459,7 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>jmock</groupId>
|
||||
<artifactId>jmock</artifactId>
|
||||
<version>1.0.1</version>
|
||||
|
||||
@@ -37,12 +37,20 @@ public class RequestUtils {
|
||||
*/
|
||||
public static String getServletPath(HttpServletRequest request) {
|
||||
String servletPath = request.getServletPath();
|
||||
|
||||
|
||||
String requestUri = request.getRequestURI();
|
||||
// Detecting other characters that the servlet container cut off (like anything after ';')
|
||||
if (requestUri != null && servletPath != null && !requestUri.endsWith(servletPath)) {
|
||||
int pos = requestUri.indexOf(servletPath);
|
||||
if (pos > -1) {
|
||||
servletPath = requestUri.substring(requestUri.indexOf(servletPath));
|
||||
}
|
||||
}
|
||||
|
||||
if (null != servletPath && !"".equals(servletPath)) {
|
||||
return servletPath;
|
||||
}
|
||||
|
||||
String requestUri = request.getRequestURI();
|
||||
|
||||
int startIndex = request.getContextPath().equals("") ? 0 : request.getContextPath().length();
|
||||
int endIndex = request.getPathInfo() == null ? requestUri.length() : requestUri.lastIndexOf(request.getPathInfo());
|
||||
|
||||
|
||||
@@ -165,4 +165,19 @@ public final class StrutsConstants {
|
||||
/** The name of the parameter to determine whether static method access will be allowed in OGNL expressions or not */
|
||||
public static final String STRUTS_ALLOW_STATIC_METHOD_ACCESS = "struts.ognl.allowStaticMethodAccess";
|
||||
|
||||
/** The com.opensymphony.xwork2.validator.ActionValidatorManager implementation class */
|
||||
public static final String STRUTS_ACTIONVALIDATORMANAGER = "struts.actionValidatorManager";
|
||||
|
||||
/** The {@link com.opensymphony.xwork2.util.ValueStackFactory} implementation class */
|
||||
public static final String STRUTS_VALUESTACKFACTORY = "struts.valueStackFactory";
|
||||
|
||||
/** The {@link com.opensymphony.xwork2.reflection.ReflectionProvider} implementation class */
|
||||
public static final String STRUTS_REFLECTIONPROVIDER = "struts.reflectionProvider";
|
||||
|
||||
/** The {@link com.opensymphony.xwork2.reflection.ReflectionContextFactory} implementation class */
|
||||
public static final String STRUTS_REFLECTIONCONTEXTFACTORY = "struts.reflectionContextFactory";
|
||||
|
||||
/** The {@link com.opensymphony.xwork2.util.PatternMatcher} implementation class */
|
||||
public static final String STRUTS_PATTERNMATCHER = "struts.patternMatcher";
|
||||
|
||||
}
|
||||
|
||||
@@ -20,18 +20,57 @@
|
||||
*/
|
||||
package org.apache.struts2;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.SimpleFormatter;
|
||||
|
||||
import org.apache.struts2.dispatcher.Dispatcher;
|
||||
import org.apache.struts2.util.StrutsTestCaseHelper;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkTestCase;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import com.opensymphony.xwork2.util.logging.jdk.JdkLoggerFactory;
|
||||
|
||||
/**
|
||||
* Base test case for JUnit testing Struts.
|
||||
*/
|
||||
public abstract class StrutsTestCase extends XWorkTestCase {
|
||||
|
||||
static {
|
||||
ConsoleHandler handler = new ConsoleHandler();
|
||||
final SimpleDateFormat df = new SimpleDateFormat("mm:ss.SSS");
|
||||
Formatter formatter = new Formatter() {
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(record.getLevel());
|
||||
sb.append(':');
|
||||
for (int x=9-record.getLevel().toString().length(); x>0; x--) {
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append('[');
|
||||
sb.append(df.format(new Date(record.getMillis())));
|
||||
sb.append("] ");
|
||||
sb.append(formatMessage(record));
|
||||
sb.append('\n');
|
||||
return sb.toString();
|
||||
}
|
||||
};
|
||||
handler.setFormatter(formatter);
|
||||
Logger logger = Logger.getLogger("");
|
||||
if (logger.getHandlers().length > 0)
|
||||
logger.removeHandler(logger.getHandlers ()[0]);
|
||||
logger.addHandler(handler);
|
||||
logger.setLevel(Level.WARNING);
|
||||
LoggerFactory.setLoggerFactory(new JdkLoggerFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the configuration settings, XWork configuration, and
|
||||
* message resources
|
||||
|
||||
@@ -23,6 +23,7 @@ package org.apache.struts2.components;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
@@ -30,14 +31,12 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.dispatcher.Dispatcher;
|
||||
import org.apache.struts2.dispatcher.RequestMap;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.views.jsp.TagUtils;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
@@ -46,6 +45,8 @@ import com.opensymphony.xwork2.ActionProxyFactory;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -59,8 +60,8 @@ import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
* <li>id (String) - the id (if specified) to put the action under stack's context.
|
||||
* <li>name* (String) - name of the action to be executed (without the extension suffix eg. .action)</li>
|
||||
* <li>namespace (String) - default to the namespace where this action tag is invoked</li>
|
||||
* <li>executeResult (Boolean) - default is false. Decides wheather the result of this action is to be executed or not</li>
|
||||
* <li>ignoreContextParams (Boolean) - default to false. Decides wheather the request parameters are to be included when the action is invoked</li>
|
||||
* <li>executeResult (Boolean) - default is false. Decides whether the result of this action is to be executed or not</li>
|
||||
* <li>ignoreContextParams (Boolean) - default to false. Decides whether the request parameters are to be included when the action is invoked</li>
|
||||
* </ul>
|
||||
* <!-- END SNIPPET: params -->
|
||||
*
|
||||
@@ -115,11 +116,12 @@ import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
*/
|
||||
@StrutsTag(name="action", tldTagClass="org.apache.struts2.views.jsp.ActionTag", description="Execute an action from within a view")
|
||||
public class ActionComponent extends ContextBean {
|
||||
private static final Log LOG = LogFactory.getLog(ActionComponent.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ActionComponent.class);
|
||||
|
||||
protected HttpServletResponse res;
|
||||
protected HttpServletRequest req;
|
||||
|
||||
protected ValueStackFactory valueStackFactory;
|
||||
protected ActionProxyFactory actionProxyFactory;
|
||||
protected ActionProxy proxy;
|
||||
protected String name;
|
||||
@@ -141,6 +143,11 @@ public class ActionComponent extends ContextBean {
|
||||
public void setActionProxyFactory(ActionProxyFactory actionProxyFactory) {
|
||||
this.actionProxyFactory = actionProxyFactory;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setValueStackFactory(ValueStackFactory valueStackFactory) {
|
||||
this.valueStackFactory = valueStackFactory;
|
||||
}
|
||||
|
||||
public boolean end(Writer writer, String body) {
|
||||
boolean end = super.end(writer, "", false);
|
||||
@@ -164,18 +171,8 @@ public class ActionComponent extends ContextBean {
|
||||
return end;
|
||||
}
|
||||
|
||||
private Map createExtraContext() {
|
||||
Map parentParams = null;
|
||||
|
||||
if (!ignoreContextParams) {
|
||||
parentParams = new ActionContext(getStack().getContext()).getParameters();
|
||||
}
|
||||
|
||||
Map newParams = (parentParams != null) ? new HashMap(parentParams) : new HashMap();
|
||||
|
||||
if (parameters != null) {
|
||||
newParams.putAll(parameters);
|
||||
}
|
||||
protected Map createExtraContext() {
|
||||
Map newParams = createParametersForContext();
|
||||
|
||||
ActionContext ctx = new ActionContext(stack.getContext());
|
||||
ServletContext servletContext = (ServletContext) ctx.get(ServletActionContext.SERVLET_CONTEXT);
|
||||
@@ -192,7 +189,7 @@ public class ActionComponent extends ContextBean {
|
||||
res,
|
||||
servletContext);
|
||||
|
||||
ValueStack newStack = ValueStackFactory.getFactory().createValueStack(stack);
|
||||
ValueStack newStack = valueStackFactory.createValueStack(stack);
|
||||
extraContext.put(ActionContext.VALUE_STACK, newStack);
|
||||
|
||||
// add page context, such that ServletDispatcherResult will do an include
|
||||
@@ -201,6 +198,40 @@ public class ActionComponent extends ContextBean {
|
||||
return extraContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates parameters map using parameters from the value stack and component parameters. Any non-String array
|
||||
* values will be converted into a single-value String array.
|
||||
*
|
||||
* @return A map of String[] parameters
|
||||
*/
|
||||
protected Map<String,String[]> createParametersForContext() {
|
||||
Map parentParams = null;
|
||||
|
||||
if (!ignoreContextParams) {
|
||||
parentParams = new ActionContext(getStack().getContext()).getParameters();
|
||||
}
|
||||
|
||||
Map<String,String[]> newParams = (parentParams != null)
|
||||
? new HashMap<String,String[]>(parentParams)
|
||||
: new HashMap<String,String[]>();
|
||||
|
||||
if (parameters != null) {
|
||||
Map<String,String[]> params = new HashMap<String,String[]>();
|
||||
for (Iterator i = parameters.entrySet().iterator(); i.hasNext(); ) {
|
||||
Map.Entry entry = (Map.Entry) i.next();
|
||||
String key = (String) entry.getKey();
|
||||
Object val = entry.getValue();
|
||||
if (val.getClass().isArray() && String.class == val.getClass().getComponentType()) {
|
||||
params.put(key, (String[])val);
|
||||
} else {
|
||||
params.put(key, new String[]{val.toString()});
|
||||
}
|
||||
}
|
||||
newParams.putAll(params);
|
||||
}
|
||||
return newParams;
|
||||
}
|
||||
|
||||
public ActionProxy getProxy() {
|
||||
return proxy;
|
||||
}
|
||||
@@ -247,9 +278,7 @@ public class ActionComponent extends ContextBean {
|
||||
try {
|
||||
|
||||
proxy = actionProxyFactory.createActionProxy(namespace, actionName, createExtraContext(), executeResult, true);
|
||||
if (null != methodName) {
|
||||
proxy.setMethod(methodName);
|
||||
}
|
||||
proxy.setMethod(methodName);
|
||||
// set the new stack into the request for the taglib to use
|
||||
req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack());
|
||||
proxy.execute();
|
||||
|
||||
@@ -25,15 +25,15 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.components.Param.UnnamedParametric;
|
||||
import org.apache.struts2.util.AppendIteratorFilter;
|
||||
import org.apache.struts2.util.MakeIterator;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -118,7 +118,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
@StrutsTag(name="append", tldTagClass="org.apache.struts2.views.jsp.iterator.AppendIteratorTag", description="Append the values of a list of iterators to one iterator")
|
||||
public class AppendIterator extends ContextBean implements UnnamedParametric {
|
||||
|
||||
private static final Log _log = LogFactory.getLog(AppendIterator.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AppendIterator.class);
|
||||
|
||||
private AppendIteratorFilter appendIteratorFilter= null;
|
||||
private List _parameters;
|
||||
@@ -140,7 +140,7 @@ public class AppendIterator extends ContextBean implements UnnamedParametric {
|
||||
|
||||
Object iteratorEntryObj = paramEntries.next();
|
||||
if (! MakeIterator.isIterable(iteratorEntryObj)) {
|
||||
_log.warn("param with value resolved as "+iteratorEntryObj+" cannot be make as iterator, it will be ignored and hence will not appear in the merged iterator");
|
||||
LOG.warn("param with value resolved as "+iteratorEntryObj+" cannot be make as iterator, it will be ignored and hence will not appear in the merged iterator");
|
||||
continue;
|
||||
}
|
||||
appendIteratorFilter.setSource(MakeIterator.convert(iteratorEntryObj));
|
||||
|
||||
@@ -22,16 +22,16 @@ package org.apache.struts2.components;
|
||||
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.util.OgnlUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -96,11 +96,12 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
@StrutsTag(name="bean", tldTagClass="org.apache.struts2.views.jsp.BeanTag",
|
||||
description="Instantiate a JavaBean and place it in the context")
|
||||
public class Bean extends ContextBean {
|
||||
protected static Log log = LogFactory.getLog(Bean.class);
|
||||
protected static Logger LOG = LoggerFactory.getLogger(Bean.class);
|
||||
|
||||
protected Object bean;
|
||||
protected String name;
|
||||
protected ObjectFactory objectFactory;
|
||||
protected ReflectionProvider reflectionProvider;
|
||||
|
||||
public Bean(ValueStack stack) {
|
||||
super(stack);
|
||||
@@ -110,6 +111,11 @@ public class Bean extends ContextBean {
|
||||
public void setObjectFactory(ObjectFactory objectFactory) {
|
||||
this.objectFactory = objectFactory;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setReflectionProvider(ReflectionProvider prov) {
|
||||
this.reflectionProvider = prov;
|
||||
}
|
||||
|
||||
public boolean start(Writer writer) {
|
||||
boolean result = super.start(writer);
|
||||
@@ -120,7 +126,7 @@ public class Bean extends ContextBean {
|
||||
String beanName = findString(name, "name", "Bean name is required. Example: com.acme.FooBean");
|
||||
bean = objectFactory.buildBean(ClassLoaderUtil.loadClass(beanName, getClass()), stack.getContext());
|
||||
} catch (Exception e) {
|
||||
log.error("Could not instantiate bean", e);
|
||||
LOG.error("Could not instantiate bean", e);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -142,7 +148,7 @@ public class Bean extends ContextBean {
|
||||
}
|
||||
|
||||
public void addParameter(String key, Object value) {
|
||||
OgnlUtil.setProperty(key, value, bean, getStack().getContext());
|
||||
reflectionProvider.setProperty(key, value, bean, getStack().getContext());
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="The class name of the bean to be instantiated (must respect JavaBean specification)",
|
||||
|
||||
@@ -25,17 +25,17 @@ import java.io.Writer;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* ClosingUIBean is the standard superclass for UI components such as div etc.
|
||||
*/
|
||||
public abstract class ClosingUIBean extends UIBean {
|
||||
private static final Log LOG = LogFactory.getLog(ClosingUIBean.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ClosingUIBean.class);
|
||||
|
||||
protected ClosingUIBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
|
||||
super(stack, request, response);
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.util.Stack;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapper;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
@@ -342,7 +341,7 @@ public class Component {
|
||||
boolean includeContext, boolean encodeResult, boolean forceAddSchemeHostAndPort,
|
||||
boolean escapeAmp) {
|
||||
String finalAction = findString(action);
|
||||
String finalMethod = method != null ? findString(method) : method;
|
||||
String finalMethod = method != null ? findString(method) : method;
|
||||
String finalNamespace = determineNamespace(namespace, getStack(), req);
|
||||
ActionMapping mapping = new ActionMapping(finalAction, finalNamespace, finalMethod, parameters);
|
||||
String uri = actionMapper.getUriFromActionMapping(mapping);
|
||||
|
||||
@@ -29,14 +29,14 @@ import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.TextProvider;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -142,7 +142,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
@StrutsTag(name="date", tldBodyContent="empty", tldTagClass="org.apache.struts2.views.jsp.DateTag", description="Render a formatted date.")
|
||||
public class Date extends ContextBean {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(Date.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Date.class);
|
||||
/**
|
||||
* Property name to fall back when no format is specified
|
||||
*/
|
||||
|
||||
@@ -20,8 +20,9 @@
|
||||
*/
|
||||
package org.apache.struts2.components;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.OgnlUtil;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -38,11 +39,20 @@ import org.apache.struts2.StrutsException;
|
||||
description="Prints debugging information")
|
||||
public class Debug extends UIBean {
|
||||
public static final String TEMPLATE = "debug";
|
||||
|
||||
protected ReflectionProvider reflectionProvider;
|
||||
|
||||
|
||||
|
||||
public Debug(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
|
||||
super(stack, request, response);
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setReflectionProvider(ReflectionProvider prov) {
|
||||
this.reflectionProvider = prov;
|
||||
}
|
||||
|
||||
protected String getDefaultTemplate() {
|
||||
return TEMPLATE;
|
||||
}
|
||||
@@ -57,7 +67,7 @@ public class Debug extends UIBean {
|
||||
Object o = iter.next();
|
||||
Map values;
|
||||
try {
|
||||
values = OgnlUtil.getBeanMap(o);
|
||||
values = reflectionProvider.getBeanMap(o);
|
||||
} catch (Exception e) {
|
||||
throw new StrutsException("Caught an exception while getting the property values of " + o, e);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.io.Writer;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ package org.apache.struts2.components;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -51,7 +51,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
description="Render a file input field",
|
||||
allowDynamicAttributes=true)
|
||||
public class File extends UIBean {
|
||||
private final static Log log = LogFactory.getLog(File.class);
|
||||
private final static Logger LOG = LoggerFactory.getLogger(File.class);
|
||||
|
||||
final public static String TEMPLATE = "file";
|
||||
|
||||
@@ -74,13 +74,13 @@ public class File extends UIBean {
|
||||
String encType = (String) form.getParameters().get("enctype");
|
||||
if (!"multipart/form-data".equals(encType)) {
|
||||
// uh oh, this isn't good! Let's warn the developer
|
||||
log.warn("Struts has detected a file upload UI tag (s:file) being used without a form set to enctype 'multipart/form-data'. This is probably an error!");
|
||||
LOG.warn("Struts has detected a file upload UI tag (s:file) being used without a form set to enctype 'multipart/form-data'. This is probably an error!");
|
||||
}
|
||||
|
||||
String method = (String) form.getParameters().get("method");
|
||||
if (!"post".equalsIgnoreCase(method)) {
|
||||
// uh oh, this isn't good! Let's warn the developer
|
||||
log.warn("Struts has detected a file upload UI tag (s:file) being used without a form set to method 'POST'. This is probably an error!");
|
||||
LOG.warn("Struts has detected a file upload UI tag (s:file) being used without a form set to method 'POST'. This is probably an error!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.opensymphony.xwork2.config.entities.InterceptorMapping;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptorUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.validator.ActionValidatorManagerFactory;
|
||||
import com.opensymphony.xwork2.validator.ActionValidatorManager;
|
||||
import com.opensymphony.xwork2.validator.FieldValidator;
|
||||
import com.opensymphony.xwork2.validator.ValidationInterceptor;
|
||||
import com.opensymphony.xwork2.validator.Validator;
|
||||
@@ -107,6 +107,7 @@ public class Form extends ClosingUIBean {
|
||||
protected Configuration configuration;
|
||||
protected ObjectFactory objectFactory;
|
||||
protected UrlRenderer urlRenderer;
|
||||
protected ActionValidatorManager actionValidatorManager;
|
||||
|
||||
public Form(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
|
||||
super(stack, request, response);
|
||||
@@ -143,6 +144,11 @@ public class Form extends ClosingUIBean {
|
||||
public void setUrlRenderer(UrlRenderer urlRenderer) {
|
||||
this.urlRenderer = urlRenderer;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setActionValidatorManager(ActionValidatorManager mgr) {
|
||||
this.actionValidatorManager = mgr;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@@ -264,7 +270,7 @@ public class Form extends ClosingUIBean {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
List<Validator> all = ActionValidatorManagerFactory.getInstance().getValidators(actionClass, (String) getParameters().get("actionName"));
|
||||
List<Validator> all = actionValidatorManager.getValidators(actionClass, (String) getParameters().get("actionName"));
|
||||
List<Validator> validators = new ArrayList<Validator>();
|
||||
for (Validator validator : all) {
|
||||
if (validator instanceof FieldValidator) {
|
||||
|
||||
@@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
|
||||
@@ -26,13 +26,13 @@ import java.util.ResourceBundle;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.dispatcher.Dispatcher;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.LocaleProvider;
|
||||
import com.opensymphony.xwork2.TextProviderFactory;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.LocalizedTextUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
@@ -86,10 +86,16 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
public class I18n extends Component {
|
||||
protected boolean pushed;
|
||||
protected String name;
|
||||
protected Container container;
|
||||
|
||||
public I18n(ValueStack stack) {
|
||||
super(stack);
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setContainer(Container container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public boolean start(Writer writer) {
|
||||
boolean result = super.start(writer);
|
||||
@@ -105,7 +111,7 @@ public class I18n extends Component {
|
||||
if (bundle != null) {
|
||||
final Locale locale = (Locale) getStack().getContext().get(ActionContext.LOCALE);
|
||||
TextProviderFactory tpf = new TextProviderFactory();
|
||||
Dispatcher.getInstance().getContainer().inject(tpf);
|
||||
container.inject(tpf);
|
||||
getStack().push(tpf.createInstance(bundle, new LocaleProvider() {
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
@@ -129,7 +135,7 @@ public class I18n extends Component {
|
||||
return super.end(writer, body);
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Name of ressource bundle to use (eg foo/bar/customBundle)", required=true, defaultValue="String")
|
||||
@StrutsTagAttribute(description="Name of resource bundle to use (eg foo/bar/customBundle)", required=true, defaultValue="String")
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.io.Writer;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
|
||||
@@ -40,17 +40,16 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;
|
||||
import org.apache.struts2.RequestUtils;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.util.FastByteArrayOutputStream;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -98,7 +97,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
"(result of servlet or a JSP page)")
|
||||
public class Include extends Component {
|
||||
|
||||
private static final Log _log = LogFactory.getLog(Include.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Include.class);
|
||||
|
||||
private static String encoding;
|
||||
private static boolean encodingDefined = true;
|
||||
@@ -115,7 +114,7 @@ public class Include extends Component {
|
||||
}
|
||||
|
||||
@Inject(StrutsConstants.STRUTS_I18N_ENCODING)
|
||||
public static void setDefaultEncoding(String encoding) {
|
||||
public void setDefaultEncoding(String encoding) {
|
||||
defaultEncoding = encoding;
|
||||
}
|
||||
|
||||
@@ -148,7 +147,7 @@ public class Include extends Component {
|
||||
try {
|
||||
urlBuf.append(URLEncoder.encode(values.get(i).toString(), "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
_log.warn("unable to url-encode "+values.get(i).toString()+", it will be ignored");
|
||||
LOG.warn("unable to url-encode "+values.get(i).toString()+", it will be ignored");
|
||||
}
|
||||
|
||||
concat = "&";
|
||||
@@ -162,7 +161,7 @@ public class Include extends Component {
|
||||
try {
|
||||
include(result, writer, req, res);
|
||||
} catch (Exception e) {
|
||||
LogFactory.getLog(getClass()).warn("Exception thrown during include of " + result, e);
|
||||
LOG.warn("Exception thrown during include of " + result, e);
|
||||
}
|
||||
|
||||
return super.end(writer, body);
|
||||
|
||||
@@ -20,16 +20,18 @@
|
||||
*/
|
||||
package org.apache.struts2.components;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -72,7 +74,7 @@ import java.util.LinkedHashMap;
|
||||
@StrutsTag(name="inputtransferselect", tldTagClass="org.apache.struts2.views.jsp.ui.InputTransferSelectTag", description="Renders an input form")
|
||||
public class InputTransferSelect extends ListUIBean {
|
||||
|
||||
private static final Log _log = LogFactory.getLog(InputTransferSelect.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(InputTransferSelect.class);
|
||||
|
||||
private static final String TEMPLATE = "inputtransferselect";
|
||||
|
||||
@@ -198,7 +200,7 @@ public class InputTransferSelect extends ListUIBean {
|
||||
|
||||
}
|
||||
else {
|
||||
_log.warn("form enclosing inputtransferselect "+this+" not found, auto select upon form submit of inputtransferselect will not work");
|
||||
LOG.warn("form enclosing inputtransferselect "+this+" not found, auto select upon form submit of inputtransferselect will not work");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
*
|
||||
* </p> The next example iterates over a an action collection and passes every iterator value to another action. The
|
||||
* trick here lies in the use of the '[0]' operator. It takes the current iterator value and passes it on to the edit
|
||||
* action. Using the '[0]' operator has the same effect as using >s:property />. (The latter, however, does not
|
||||
* action. Using the '[0]' operator has the same effect as using <s:property />. (The latter, however, does not
|
||||
* work from inside the param tag). </p>
|
||||
*
|
||||
* <!-- END SNIPPET: example4description -->
|
||||
|
||||
@@ -25,15 +25,15 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.components.Param.UnnamedParametric;
|
||||
import org.apache.struts2.util.MakeIterator;
|
||||
import org.apache.struts2.util.MergeIteratorFilter;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -132,7 +132,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
"of a list of iterators into one iterator")
|
||||
public class MergeIterator extends ContextBean implements UnnamedParametric {
|
||||
|
||||
private static final Log _log = LogFactory.getLog(MergeIterator.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MergeIterator.class);
|
||||
|
||||
private MergeIteratorFilter mergeIteratorFilter = null;
|
||||
private List _parameters;
|
||||
@@ -154,7 +154,7 @@ public class MergeIterator extends ContextBean implements UnnamedParametric {
|
||||
for (Iterator parametersIterator = _parameters.iterator(); parametersIterator.hasNext(); ) {
|
||||
Object iteratorEntryObj = parametersIterator.next();
|
||||
if (! MakeIterator.isIterable(iteratorEntryObj)) {
|
||||
_log.warn("param with value resolved as "+iteratorEntryObj+" cannot be make as iterator, it will be ignored and hence will not appear in the merged iterator");
|
||||
LOG.warn("param with value resolved as "+iteratorEntryObj+" cannot be make as iterator, it will be ignored and hence will not appear in the merged iterator");
|
||||
continue;
|
||||
}
|
||||
mergeIteratorFilter.setSource(MakeIterator.convert(iteratorEntryObj));
|
||||
|
||||
@@ -27,15 +27,14 @@ import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -80,7 +79,7 @@ public class OptGroup extends Component {
|
||||
|
||||
public static final String INTERNAL_LIST_UI_BEAN_LIST_PARAMETER_KEY = "optGroupInternalListUiBeanList";
|
||||
|
||||
private static Log _log = LogFactory.getLog(OptGroup.class);
|
||||
private static Logger LOG = LoggerFactory.getLogger(OptGroup.class);
|
||||
|
||||
protected HttpServletRequest req;
|
||||
protected HttpServletResponse res;
|
||||
@@ -106,7 +105,7 @@ public class OptGroup extends Component {
|
||||
public boolean end(Writer writer, String body) {
|
||||
Select select = (Select) findAncestor(Select.class);
|
||||
if (select == null) {
|
||||
_log.error("incorrect use of OptGroup component, this component must be used within a Select component",
|
||||
LOG.error("incorrect use of OptGroup component, this component must be used within a Select component",
|
||||
new IllegalStateException("incorrect use of OptGroup component, this component must be used within a Select component"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -95,7 +95,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
@StrutsTag(name="optiontransferselect", tldTagClass="org.apache.struts2.views.jsp.ui.OptionTransferSelectTag", description="Renders an input form")
|
||||
public class OptionTransferSelect extends DoubleListUIBean {
|
||||
|
||||
private static final Log _log = LogFactory.getLog(OptionTransferSelect.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(OptionTransferSelect.class);
|
||||
|
||||
private static final String TEMPLATE = "optiontransferselect";
|
||||
|
||||
@@ -331,7 +331,7 @@ public class OptionTransferSelect extends DoubleListUIBean {
|
||||
|
||||
}
|
||||
else {
|
||||
_log.warn("form enclosing optiontransferselect "+this+" not found, auto select upon form submit of optiontransferselect will not work");
|
||||
LOG.warn("form enclosing optiontransferselect "+this+" not found, auto select upon form submit of optiontransferselect will not work");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.io.Writer;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
@@ -23,14 +23,13 @@ package org.apache.struts2.components;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.TextUtils;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -90,7 +89,7 @@ import com.opensymphony.xwork2.util.TextUtils;
|
||||
@StrutsTag(name="property", tldBodyContent="empty", tldTagClass="org.apache.struts2.views.jsp.PropertyTag",
|
||||
description="Print out expression which evaluates against the stack")
|
||||
public class Property extends Component {
|
||||
private static final Log LOG = LogFactory.getLog(Property.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Property.class);
|
||||
|
||||
public Property(ValueStack stack) {
|
||||
super(stack);
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.io.Writer;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ package org.apache.struts2.components;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
import org.apache.struts2.views.util.UrlHelper;
|
||||
@@ -32,6 +30,8 @@ import org.apache.struts2.views.util.UrlHelper;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Implementation of the {@link UrlRenderer} interface that creates URLs suitable in a servlet environment.
|
||||
@@ -41,7 +41,7 @@ public class ServletUrlRenderer implements UrlRenderer {
|
||||
/**
|
||||
* Provide a logging instance.
|
||||
*/
|
||||
private static final Log LOG = LogFactory.getLog(ServletUrlRenderer.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServletUrlRenderer.class);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,12 +25,12 @@ import java.io.Writer;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -52,7 +52,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
allowDynamicAttributes=true)
|
||||
public class Submit extends FormButton {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(Submit.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Submit.class);
|
||||
final public static String TEMPLATE = "submit";
|
||||
protected String src;
|
||||
|
||||
|
||||
@@ -27,14 +27,14 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import com.opensymphony.xwork2.TextProvider;
|
||||
import com.opensymphony.xwork2.util.TextUtils;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.TextProvider;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -119,7 +119,7 @@ import com.opensymphony.xwork2.TextProvider;
|
||||
description="Render a I18n text message",
|
||||
allowDynamicAttributes=true)
|
||||
public class Text extends ContextBean implements Param.UnnamedParametric {
|
||||
private static final Log LOG = LogFactory.getLog(Text.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Text.class);
|
||||
|
||||
protected List values = Collections.EMPTY_LIST;
|
||||
protected String actualName;
|
||||
|
||||
@@ -30,19 +30,19 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.components.template.Template;
|
||||
import org.apache.struts2.components.template.TemplateEngine;
|
||||
import org.apache.struts2.components.template.TemplateEngineManager;
|
||||
import org.apache.struts2.components.template.TemplateRenderingContext;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.views.util.ContextUtil;
|
||||
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* UIBean is the standard superclass of all Struts UI componentns.
|
||||
@@ -401,7 +401,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
*
|
||||
*/
|
||||
public abstract class UIBean extends Component {
|
||||
private static final Log LOG = LogFactory.getLog(UIBean.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UIBean.class);
|
||||
|
||||
protected HttpServletRequest request;
|
||||
protected HttpServletResponse response;
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
*/
|
||||
package org.apache.struts2.components;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@@ -32,13 +29,16 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.views.util.UrlHelper;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
*
|
||||
@@ -116,7 +116,7 @@ import org.apache.struts2.views.util.UrlHelper;
|
||||
*/
|
||||
@StrutsTag(name="url", tldTagClass="org.apache.struts2.views.jsp.URLTag", description="This tag is used to create a URL")
|
||||
public class URL extends ContextBean {
|
||||
private static final Log LOG = LogFactory.getLog(URL.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(URL.class);
|
||||
|
||||
/**
|
||||
* The includeParams attribute may have the value 'none', 'get' or 'all'.
|
||||
|
||||
@@ -26,12 +26,12 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -81,7 +81,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
description="Create a Select component with buttons to move the elements in the select component up and down")
|
||||
public class UpDownSelect extends Select {
|
||||
|
||||
private static final Log _log = LogFactory.getLog(UpDownSelect.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UpDownSelect.class);
|
||||
|
||||
|
||||
final public static String TEMPLATE = "updownselect";
|
||||
@@ -155,7 +155,7 @@ public class UpDownSelect extends Select {
|
||||
ancestorForm.getParameters().put("updownselectIds", m);
|
||||
}
|
||||
else {
|
||||
_log.warn("no ancestor form found for updownselect "+this+", therefore autoselect of all elements upon form submission will not work ");
|
||||
LOG.warn("no ancestor form found for updownselect "+this+", therefore autoselect of all elements upon form submission will not work ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,17 +29,16 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Base class for template engines.
|
||||
*/
|
||||
public abstract class BaseTemplateEngine implements TemplateEngine {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(BaseTemplateEngine.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BaseTemplateEngine.class);
|
||||
|
||||
/** The default theme properties file name. Default is 'theme.properties' */
|
||||
public static final String DEFAULT_THEME_PROPERTIES_FILE_NAME = "theme.properties";
|
||||
|
||||
+20
-17
@@ -20,22 +20,6 @@
|
||||
*/
|
||||
package org.apache.struts2.components.template;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.SimpleHash;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.views.freemarker.FreemarkerManager;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
@@ -43,6 +27,25 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.views.freemarker.FreemarkerManager;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.SimpleHash;
|
||||
|
||||
/**
|
||||
* Freemarker based template engine.
|
||||
*/
|
||||
@@ -66,7 +69,7 @@ public class FreemarkerTemplateEngine extends BaseTemplateEngine {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(FreemarkerTemplateEngine.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FreemarkerTemplateEngine.class);
|
||||
|
||||
@Inject
|
||||
public void setFreemarkerManager(FreemarkerManager mgr) {
|
||||
|
||||
@@ -20,22 +20,24 @@
|
||||
*/
|
||||
package org.apache.struts2.components.template;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.components.Include;
|
||||
import org.apache.struts2.components.UIBean;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import java.util.List;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* JSP based template engine.
|
||||
*/
|
||||
public class JspTemplateEngine extends BaseTemplateEngine {
|
||||
private static final Log LOG = LogFactory.getLog(JspTemplateEngine.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JspTemplateEngine.class);
|
||||
|
||||
public void renderTemplate(TemplateRenderingContext templateContext) throws Exception {
|
||||
Template template = templateContext.getTemplate();
|
||||
|
||||
+14
-12
@@ -20,27 +20,29 @@
|
||||
*/
|
||||
package org.apache.struts2.components.template;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.views.velocity.VelocityManager;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.context.Context;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.views.velocity.VelocityManager;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.context.Context;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Velocity based template engine.
|
||||
*/
|
||||
public class VelocityTemplateEngine extends BaseTemplateEngine {
|
||||
private static final Log LOG = LogFactory.getLog(VelocityTemplateEngine.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(VelocityTemplateEngine.class);
|
||||
|
||||
private VelocityManager velocityManager;
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ package org.apache.struts2.config;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.components.UrlRenderer;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapper;
|
||||
@@ -47,7 +45,14 @@ import com.opensymphony.xwork2.inject.Factory;
|
||||
import com.opensymphony.xwork2.inject.Scope;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.util.LocalizedTextUtil;
|
||||
import com.opensymphony.xwork2.util.PatternMatcher;
|
||||
import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionContextFactory;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
|
||||
import com.opensymphony.xwork2.validator.ActionValidatorManager;
|
||||
|
||||
/**
|
||||
* Selects the implementations of key framework extension points, using the loaded
|
||||
@@ -108,8 +113,45 @@ import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
* <td>singleton</td>
|
||||
* <td>Loads and processes Velocity templates</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>com.opensymphony.xwork2.validator.ActionValidatorManager</td>
|
||||
* <td>struts.actionValidatorManager</td>
|
||||
* <td>singleton</td>
|
||||
* <td>Main interface for validation managers (regular and annotation based). Handles both the loading of
|
||||
* configuration and the actual validation (since 2.1)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>com.opensymphony.xwork2.util.ValueStackFactory</td>
|
||||
* <td>struts.valueStackFactory</td>
|
||||
* <td>singleton</td>
|
||||
* <td>Creates value stacks (since 2.1)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>com.opensymphony.xwork2.reflection.ReflectionProvider</td>
|
||||
* <td>struts.reflectionProvider</td>
|
||||
* <td>singleton</td>
|
||||
* <td>Provides reflection services, key place to plug in a custom expression language (since 2.1)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>com.opensymphony.xwork2.reflection.ReflectionContextFactory</td>
|
||||
* <td>struts.reflectionContextFactory</td>
|
||||
* <td>singleton</td>
|
||||
* <td>Creates reflection context maps used for reflection and expression language operations (since 2.1)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>com.opensymphony.xwork2.config.PackageProvider</td>
|
||||
* <td>N/A</td>
|
||||
* <td>singleton</td>
|
||||
* <td>All beans registered as PackageProvider implementations will be automatically included in configuration building (since 2.1)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>com.opensymphony.xwork2.util.PatternMatcher</td>
|
||||
* <td>struts.patternMatcher</td>
|
||||
* <td>singleton</td>
|
||||
* <td>Matches patterns, such as action names, generally used in configuration (since 2.1)</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
*
|
||||
* <!-- END SNIPPET: extensionPoints -->
|
||||
* </p>
|
||||
* <p>
|
||||
@@ -131,7 +173,7 @@ import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
*/
|
||||
public class BeanSelectionProvider implements ConfigurationProvider {
|
||||
public static final String DEFAULT_BEAN_NAME = "struts";
|
||||
private static final Log LOG = LogFactory.getLog(BeanSelectionProvider.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BeanSelectionProvider.class);
|
||||
|
||||
public void destroy() {
|
||||
// NO-OP
|
||||
@@ -161,6 +203,11 @@ public class BeanSelectionProvider implements ConfigurationProvider {
|
||||
alias(FreemarkerManager.class, StrutsConstants.STRUTS_FREEMARKER_MANAGER_CLASSNAME, builder, props);
|
||||
alias(VelocityManager.class, StrutsConstants.STRUTS_VELOCITY_MANAGER_CLASSNAME, builder, props);
|
||||
alias(UrlRenderer.class, StrutsConstants.STRUTS_URL_RENDERER, builder, props);
|
||||
alias(ActionValidatorManager.class, StrutsConstants.STRUTS_ACTIONVALIDATORMANAGER, builder, props);
|
||||
alias(ValueStackFactory.class, StrutsConstants.STRUTS_VALUESTACKFACTORY, builder, props);
|
||||
alias(ReflectionProvider.class, StrutsConstants.STRUTS_REFLECTIONPROVIDER, builder, props);
|
||||
alias(ReflectionContextFactory.class, StrutsConstants.STRUTS_REFLECTIONCONTEXTFACTORY, builder, props);
|
||||
alias(PatternMatcher.class, StrutsConstants.STRUTS_PATTERNMATCHER, builder, props);
|
||||
|
||||
if ("true".equalsIgnoreCase(props.getProperty(StrutsConstants.STRUTS_DEVMODE))) {
|
||||
props.setProperty(StrutsConstants.STRUTS_I18N_RELOAD, "true");
|
||||
|
||||
@@ -24,11 +24,11 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
|
||||
import com.opensymphony.xwork2.util.LocalizedTextUtil;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ public class DefaultSettings extends Settings {
|
||||
/**
|
||||
* The logging instance for this class.
|
||||
*/
|
||||
protected Log log = LogFactory.getLog(this.getClass());
|
||||
protected Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The Settings object that handles API calls.
|
||||
|
||||
-11
@@ -20,26 +20,15 @@
|
||||
*/
|
||||
package org.apache.struts2.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapper;
|
||||
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.config.ConfigurationProvider;
|
||||
import com.opensymphony.xwork2.inject.ContainerBuilder;
|
||||
import com.opensymphony.xwork2.inject.Context;
|
||||
import com.opensymphony.xwork2.inject.Factory;
|
||||
import com.opensymphony.xwork2.util.LocalizedTextUtil;
|
||||
import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
|
||||
public class LegacyPropertiesConfigurationProvider implements ConfigurationProvider {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.opensymphony.xwork2.config.RuntimeConfiguration;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork2.inject.ContainerBuilder;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
|
||||
@@ -141,24 +142,11 @@ public class MethodConfigurationProvider implements ConfigurationProvider {
|
||||
* Updates ObjectFactory property.
|
||||
* @param factory
|
||||
*/
|
||||
@Inject
|
||||
public void setObjectFactory(ObjectFactory factory) {
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides ObjectFactory property.
|
||||
* @return
|
||||
* @throws ConfigurationException if ObjectFactory has not been set.
|
||||
*/
|
||||
private ObjectFactory getObjectFactory() throws ConfigurationException {
|
||||
if (factory == null) {
|
||||
factory = ObjectFactory.getObjectFactory();
|
||||
if (factory == null) throw new
|
||||
ConfigurationException("MethodConfigurationProvider.getObjectFactory: ObjectFactory==null");
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that character at a String position is upper case.
|
||||
* @param pos Position to test
|
||||
@@ -205,7 +193,6 @@ public class MethodConfigurationProvider implements ConfigurationProvider {
|
||||
String className = actionConfig.getClassName();
|
||||
Set actionMethods = new HashSet();
|
||||
Class actionClass;
|
||||
ObjectFactory factory = getObjectFactory();
|
||||
try {
|
||||
actionClass = factory.getClassInstance(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
@@ -24,16 +24,15 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.util.ClassLoaderUtils;
|
||||
|
||||
import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
import com.opensymphony.xwork2.util.location.Location;
|
||||
import com.opensymphony.xwork2.util.location.LocationImpl;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -42,7 +41,7 @@ import com.opensymphony.xwork2.util.location.LocationImpl;
|
||||
class PropertiesSettings extends Settings {
|
||||
|
||||
LocatableProperties settings;
|
||||
static Log LOG = LogFactory.getLog(PropertiesSettings.class);
|
||||
static Logger LOG = LoggerFactory.getLogger(PropertiesSettings.class);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,12 +24,12 @@ import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.util.location.Location;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -82,7 +82,7 @@ class Settings {
|
||||
/**
|
||||
* The Logging instance for this class.
|
||||
*/
|
||||
private static final Log LOG = LogFactory.getLog(Settings.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Settings.class);
|
||||
|
||||
/**
|
||||
* Registers a custom Settings implementation (plugin),
|
||||
|
||||
@@ -29,13 +29,9 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
|
||||
@@ -43,13 +39,15 @@ import com.opensymphony.xwork2.inject.ContainerBuilder;
|
||||
import com.opensymphony.xwork2.inject.Context;
|
||||
import com.opensymphony.xwork2.inject.Factory;
|
||||
import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Override Xwork class so we can use an arbitrary config file
|
||||
*/
|
||||
public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(StrutsXmlConfigurationProvider.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(StrutsXmlConfigurationProvider.class);
|
||||
private File baseDir = null;
|
||||
private String filename;
|
||||
private String reloadKey;
|
||||
@@ -162,7 +160,11 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider {
|
||||
@Override
|
||||
public boolean needsReload() {
|
||||
ActionContext ctx = ActionContext.getContext();
|
||||
return ctx.get(reloadKey) == null && super.needsReload();
|
||||
if (ctx != null) {
|
||||
return ctx.get(reloadKey) == null && super.needsReload();
|
||||
} else {
|
||||
return super.needsReload();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,9 @@ import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
|
||||
|
||||
/**
|
||||
@@ -68,7 +66,7 @@ import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
|
||||
*/
|
||||
public class ActionContextCleanUp implements Filter {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(ActionContextCleanUp.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ActionContextCleanUp.class);
|
||||
|
||||
private static final String COUNTER = "__cleanup_recursion_counter";
|
||||
|
||||
|
||||
@@ -35,14 +35,13 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsStatics;
|
||||
import org.apache.struts2.config.*;
|
||||
import org.apache.struts2.config.ClasspathConfigurationProvider.ClasspathPageLocator;
|
||||
import org.apache.struts2.config.ClasspathConfigurationProvider.PageLocator;
|
||||
import org.apache.struts2.config.BeanSelectionProvider;
|
||||
import org.apache.struts2.config.DefaultPropertiesProvider;
|
||||
import org.apache.struts2.config.LegacyPropertiesConfigurationProvider;
|
||||
import org.apache.struts2.config.StrutsXmlConfigurationProvider;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
import org.apache.struts2.dispatcher.multipart.MultiPartRequest;
|
||||
import org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper;
|
||||
@@ -51,25 +50,28 @@ import org.apache.struts2.util.ClassLoaderUtils;
|
||||
import org.apache.struts2.util.ObjectFactoryDestroyable;
|
||||
import org.apache.struts2.views.freemarker.FreemarkerManager;
|
||||
|
||||
import com.opensymphony.xwork2.util.FileManager;
|
||||
import com.opensymphony.xwork2.*;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionProxy;
|
||||
import com.opensymphony.xwork2.ActionProxyFactory;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.Result;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork2.config.ConfigurationProvider;
|
||||
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
|
||||
import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
|
||||
import com.opensymphony.xwork2.conversion.ObjectTypeDeterminerFactory;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.ContainerBuilder;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.FileManager;
|
||||
import com.opensymphony.xwork2.util.LocalizedTextUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
import com.opensymphony.xwork2.util.location.Location;
|
||||
import com.opensymphony.xwork2.util.location.LocationUtils;
|
||||
import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
|
||||
|
||||
import freemarker.template.Template;
|
||||
@@ -87,7 +89,7 @@ public class Dispatcher {
|
||||
/**
|
||||
* Provide a logging instance.
|
||||
*/
|
||||
private static final Log LOG = LogFactory.getLog(Dispatcher.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Dispatcher.class);
|
||||
|
||||
/**
|
||||
* Provide a thread local instance.
|
||||
@@ -155,18 +157,6 @@ public class Dispatcher {
|
||||
*/
|
||||
public static void setInstance(Dispatcher instance) {
|
||||
Dispatcher.instance.set(instance);
|
||||
|
||||
// Tie the ObjectFactory threadlocal instance to this Dispatcher instance
|
||||
if (instance != null) {
|
||||
Container cont = instance.getContainer();
|
||||
if (cont != null) {
|
||||
ObjectFactory.setObjectFactory(cont.getInstance(ObjectFactory.class));
|
||||
} else {
|
||||
LOG.warn("This dispatcher instance doesn't have a container, so the object factory won't be set.");
|
||||
}
|
||||
} else {
|
||||
ObjectFactory.setObjectFactory(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,6 +180,8 @@ public class Dispatcher {
|
||||
private ServletContext servletContext;
|
||||
private Map<String, String> initParams;
|
||||
|
||||
private ValueStackFactory valueStackFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Create the Dispatcher instance for a given ServletContext and set of initialization parameters.
|
||||
@@ -207,7 +199,7 @@ public class Dispatcher {
|
||||
* @param mode New setting
|
||||
*/
|
||||
@Inject(StrutsConstants.STRUTS_DEVMODE)
|
||||
public static void setDevMode(String mode) {
|
||||
public void setDevMode(String mode) {
|
||||
devMode = "true".equals(mode);
|
||||
}
|
||||
|
||||
@@ -216,7 +208,7 @@ public class Dispatcher {
|
||||
* @param val New setting
|
||||
*/
|
||||
@Inject(value=StrutsConstants.STRUTS_LOCALE, required=false)
|
||||
public static void setDefaultLocale(String val) {
|
||||
public void setDefaultLocale(String val) {
|
||||
defaultLocale = val;
|
||||
}
|
||||
|
||||
@@ -225,7 +217,7 @@ public class Dispatcher {
|
||||
* @param val New setting
|
||||
*/
|
||||
@Inject(StrutsConstants.STRUTS_I18N_ENCODING)
|
||||
public static void setDefaultEncoding(String val) {
|
||||
public void setDefaultEncoding(String val) {
|
||||
defaultEncoding = val;
|
||||
}
|
||||
|
||||
@@ -234,9 +226,14 @@ public class Dispatcher {
|
||||
* @param val New setting
|
||||
*/
|
||||
@Inject(StrutsConstants.STRUTS_MULTIPART_SAVEDIR)
|
||||
public static void setMultipartSaveDir(String val) {
|
||||
public void setMultipartSaveDir(String val) {
|
||||
multipartSaveDir = val;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setValueStackFactory(ValueStackFactory valueStackFactory) {
|
||||
this.valueStackFactory = valueStackFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases all instances bound to this dispatcher instance.
|
||||
@@ -302,19 +299,6 @@ public class Dispatcher {
|
||||
}
|
||||
}
|
||||
|
||||
private void init_ZeroConfiguration() {
|
||||
String packages = initParams.get("actionPackages");
|
||||
if (packages != null) {
|
||||
String[] names = packages.split("\\s*[,]\\s*");
|
||||
// Initialize the classloader scanner with the configured packages
|
||||
if (names.length > 0) {
|
||||
ClasspathConfigurationProvider provider = new ClasspathConfigurationProvider(names);
|
||||
provider.setPageLocator(new ServletContextPageLocator(servletContext));
|
||||
configurationManager.addConfigurationProvider(provider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void init_CustomConfigurationProviders() {
|
||||
String configProvs = initParams.get("configProviders");
|
||||
if (configProvs != null) {
|
||||
@@ -392,9 +376,6 @@ Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyExcepti
|
||||
boolean reloadi18n = Boolean.valueOf(container.getInstance(String.class, StrutsConstants.STRUTS_I18N_RELOAD));
|
||||
LocalizedTextUtil.setReloadBundles(reloadi18n);
|
||||
|
||||
ObjectTypeDeterminer objectTypeDeterminer = container.getInstance(ObjectTypeDeterminer.class);
|
||||
ObjectTypeDeterminerFactory.setInstance(objectTypeDeterminer);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
@@ -437,13 +418,13 @@ Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyExcepti
|
||||
init_DefaultProperties(); // [1]
|
||||
init_TraditionalXmlConfigurations(); // [2]
|
||||
init_LegacyStrutsProperties(); // [3]
|
||||
init_ZeroConfiguration(); // [4]
|
||||
init_CustomConfigurationProviders(); // [5]
|
||||
init_MethodConfigurationProvider();
|
||||
init_FilterInitParameters() ; // [6]
|
||||
init_AliasStandardObjects() ; // [7]
|
||||
|
||||
Container container = init_PreloadConfiguration();
|
||||
container.inject(this);
|
||||
init_CheckConfigurationReloading(container);
|
||||
init_CheckWebLogicWorkaround(container);
|
||||
|
||||
@@ -474,7 +455,7 @@ Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyExcepti
|
||||
// If there was a previous value stack, then create a new copy and pass it in to be used by the new Action
|
||||
ValueStack stack = (ValueStack) request.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY);
|
||||
if (stack != null) {
|
||||
extraContext.put(ActionContext.VALUE_STACK, ValueStackFactory.getFactory().createValueStack(stack));
|
||||
extraContext.put(ActionContext.VALUE_STACK, valueStackFactory.createValueStack(stack));
|
||||
}
|
||||
|
||||
String timerKey = "Handling request from Dispatcher";
|
||||
@@ -759,32 +740,7 @@ Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyExcepti
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search classpath for a page.
|
||||
*/
|
||||
private final class ServletContextPageLocator implements PageLocator {
|
||||
private final ServletContext context;
|
||||
private ClasspathPageLocator classpathPageLocator = new ClasspathPageLocator();
|
||||
|
||||
private ServletContextPageLocator(ServletContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public URL locate(String path) {
|
||||
URL url = null;
|
||||
try {
|
||||
url = context.getResource(path);
|
||||
if (url == null) {
|
||||
url = classpathPageLocator.locate(path);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Unable to resolve path "+path+" against the servlet context");
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provide an accessor class for static XWork utility.
|
||||
|
||||
@@ -42,18 +42,24 @@ import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.RequestUtils;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsStatics;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapper;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
import org.apache.struts2.util.ClassLoaderUtils;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.config.ConfigurationProvider;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
|
||||
/**
|
||||
* Master filter for Struts that handles four distinct
|
||||
@@ -124,6 +130,8 @@ import com.opensymphony.xwork2.ActionContext;
|
||||
*
|
||||
* <li><b>configProviders</b> - a comma-delimited list of Java classes that implement the
|
||||
* {@link ConfigurationProvider} interface that should be used for building the {@link Configuration}.</li>
|
||||
*
|
||||
* <li><b>loggerFactory</b> - The class name of the {@link LoggerFactory} implementation.</li>
|
||||
*
|
||||
* <li><b>*</b> - any other parameters are treated as framework constants.</li>
|
||||
*
|
||||
@@ -146,7 +154,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
/**
|
||||
* Provide a logging instance.
|
||||
*/
|
||||
private static final Log LOG = LogFactory.getLog(FilterDispatcher.class);
|
||||
private Logger log;
|
||||
|
||||
/**
|
||||
* Store set of path prefixes to use with static resources.
|
||||
@@ -161,22 +169,22 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
/**
|
||||
* Store state of StrutsConstants.STRUTS_SERVE_STATIC_CONTENT setting.
|
||||
*/
|
||||
private static boolean serveStatic;
|
||||
private boolean serveStatic;
|
||||
|
||||
/**
|
||||
* Store state of StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE setting.
|
||||
*/
|
||||
private static boolean serveStaticBrowserCache;
|
||||
private boolean serveStaticBrowserCache;
|
||||
|
||||
/**
|
||||
* Store state of StrutsConstants.STRUTS_I18N_ENCODING setting.
|
||||
*/
|
||||
private static String encoding;
|
||||
private String encoding;
|
||||
|
||||
/**
|
||||
* Provide ActionMapper instance, set by injection.
|
||||
*/
|
||||
private static ActionMapper actionMapper;
|
||||
private ActionMapper actionMapper;
|
||||
|
||||
/**
|
||||
* Provide FilterConfig instance, set on init.
|
||||
@@ -195,10 +203,13 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
* @param filterConfig The filter configuration
|
||||
*/
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
this.filterConfig = filterConfig;
|
||||
|
||||
this.filterConfig = filterConfig;
|
||||
|
||||
initLogging();
|
||||
|
||||
dispatcher = createDispatcher(filterConfig);
|
||||
dispatcher.init();
|
||||
dispatcher.getContainer().inject(this);
|
||||
|
||||
String param = filterConfig.getInitParameter("packages");
|
||||
String packages = "org.apache.struts2.static template org.apache.struts2.interceptor.debugging";
|
||||
@@ -208,6 +219,29 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
this.pathPrefixes = parse(packages);
|
||||
}
|
||||
|
||||
private void initLogging() {
|
||||
String factoryName = filterConfig.getInitParameter("loggerFactory");
|
||||
if (factoryName != null) {
|
||||
try {
|
||||
Class cls = ClassLoaderUtils.loadClass(factoryName, this.getClass());
|
||||
LoggerFactory fac = (LoggerFactory)cls.newInstance();
|
||||
LoggerFactory.setLoggerFactory(fac);
|
||||
} catch (InstantiationException e) {
|
||||
System.err.println("Unable to instantiate logger factory: "+factoryName+", using default");
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
System.err.println("Unable to access logger factory: "+factoryName+", using default");
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.err.println("Unable to locate logger factory class: "+factoryName+", using default");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
log = LoggerFactory.getLogger(FilterDispatcher.class);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls dispatcher.cleanup,
|
||||
* which in turn releases local threads and destroys any DispatchListeners.
|
||||
@@ -216,7 +250,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
*/
|
||||
public void destroy() {
|
||||
if (dispatcher == null) {
|
||||
LOG.warn("something is seriously wrong, Dispatcher is not initialized (null) ");
|
||||
log.warn("something is seriously wrong, Dispatcher is not initialized (null) ");
|
||||
} else {
|
||||
dispatcher.cleanup();
|
||||
}
|
||||
@@ -244,7 +278,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
* @param val New setting
|
||||
*/
|
||||
@Inject(StrutsConstants.STRUTS_SERVE_STATIC_CONTENT)
|
||||
public static void setServeStaticContent(String val) {
|
||||
public void setServeStaticContent(String val) {
|
||||
serveStatic = "true".equals(val);
|
||||
}
|
||||
|
||||
@@ -253,7 +287,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
* @param val New setting
|
||||
*/
|
||||
@Inject(StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE)
|
||||
public static void setServeStaticBrowserCache(String val) {
|
||||
public void setServeStaticBrowserCache(String val) {
|
||||
serveStaticBrowserCache = "true".equals(val);
|
||||
}
|
||||
|
||||
@@ -262,7 +296,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
* @param val New setting
|
||||
*/
|
||||
@Inject(StrutsConstants.STRUTS_I18N_ENCODING)
|
||||
public static void setEncoding(String val) {
|
||||
public void setEncoding(String val) {
|
||||
encoding = val;
|
||||
}
|
||||
|
||||
@@ -271,7 +305,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
* @param mapper New instance
|
||||
*/
|
||||
@Inject
|
||||
public static void setActionMapper(ActionMapper mapper) {
|
||||
public void setActionMapper(ActionMapper mapper) {
|
||||
actionMapper = mapper;
|
||||
}
|
||||
|
||||
@@ -330,7 +364,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
request = dispatcher.wrapRequest(request, getServletContext());
|
||||
} catch (IOException e) {
|
||||
String message = "Could not wrap servlet request with MultipartRequestWrapper!";
|
||||
LOG.error(message, e);
|
||||
log.error(message, e);
|
||||
throw new ServletException(message, e);
|
||||
}
|
||||
|
||||
@@ -385,13 +419,19 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
|
||||
String timerKey = "FilterDispatcher_doFilter: ";
|
||||
try {
|
||||
|
||||
// FIXME: this should be refactored better to not duplicate work with the action invocation
|
||||
ValueStack stack = dispatcher.getContainer().getInstance(ValueStackFactory.class).createValueStack();
|
||||
ActionContext ctx = new ActionContext(stack.getContext());
|
||||
ActionContext.setContext(ctx);
|
||||
|
||||
UtilTimerStack.push(timerKey);
|
||||
request = prepareDispatcherAndWrapRequest(request, response);
|
||||
ActionMapping mapping;
|
||||
try {
|
||||
mapping = actionMapper.getMapping(request, dispatcher.getConfigurationManager());
|
||||
} catch (Exception ex) {
|
||||
LOG.error("error getting ActionMapping", ex);
|
||||
log.error("error getting ActionMapping", ex);
|
||||
dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex);
|
||||
return;
|
||||
}
|
||||
@@ -447,7 +487,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
try {
|
||||
ifModifiedSince = request.getDateHeader("If-Modified-Since");
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Invalid If-Modified-Since header value: '" + request.getHeader("If-Modified-Since") + "', ignoring");
|
||||
log.warn("Invalid If-Modified-Since header value: '" + request.getHeader("If-Modified-Since") + "', ignoring");
|
||||
}
|
||||
long lastModifiedMillis = lastModifiedCal.getTimeInMillis();
|
||||
long now = cal.getTimeInMillis();
|
||||
|
||||
+5
-5
@@ -26,10 +26,11 @@ import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.config.ServletContextSingleton;
|
||||
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* When running Weblogic Server 6.1, this class should be
|
||||
@@ -48,8 +49,7 @@ import org.apache.struts2.config.ServletContextSingleton;
|
||||
*/
|
||||
public class FilterDispatcherCompatWeblogic61 extends FilterDispatcher {
|
||||
|
||||
private static Log log =
|
||||
LogFactory.getLog(FilterDispatcherCompatWeblogic61.class);
|
||||
private static Logger LOG = LoggerFactory.getLogger(FilterDispatcherCompatWeblogic61.class);
|
||||
|
||||
/**
|
||||
* dummy setter for {@link #filterConfig}; this method
|
||||
@@ -67,7 +67,7 @@ public class FilterDispatcherCompatWeblogic61 extends FilterDispatcher {
|
||||
try {
|
||||
init(filterConfig);
|
||||
} catch (ServletException se) {
|
||||
log.error("Couldn't set the filter configuration in this filter", se);
|
||||
LOG.error("Couldn't set the filter configuration in this filter", se);
|
||||
}
|
||||
|
||||
ServletContextSingleton singleton = ServletContextSingleton.getInstance();
|
||||
|
||||
@@ -27,10 +27,9 @@ import java.nio.charset.Charset;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
@@ -76,7 +75,7 @@ public class PlainTextResult extends StrutsResultSupport {
|
||||
|
||||
public static final int BUFFER_SIZE = 1024;
|
||||
|
||||
private static final Log _log = LogFactory.getLog(PlainTextResult.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PlainTextResult.class);
|
||||
|
||||
private static final long serialVersionUID = 3633371605905583950L;
|
||||
|
||||
@@ -120,7 +119,7 @@ public class PlainTextResult extends StrutsResultSupport {
|
||||
charset = Charset.forName(charSet);
|
||||
}
|
||||
else {
|
||||
_log.warn("charset ["+charSet+"] is not recognized ");
|
||||
LOG.warn("charset ["+charSet+"] is not recognized ");
|
||||
charset = null;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +147,7 @@ public class PlainTextResult extends StrutsResultSupport {
|
||||
reader = new InputStreamReader(servletContext.getResourceAsStream(finalLocation));
|
||||
}
|
||||
if (reader == null) {
|
||||
_log.warn("resource at location ["+finalLocation+"] cannot be obtained (return null) from ServletContext !!! ");
|
||||
LOG.warn("resource at location ["+finalLocation+"] cannot be obtained (return null) from ServletContext !!! ");
|
||||
}
|
||||
else {
|
||||
char[] buffer = new char[BUFFER_SIZE];
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
package org.apache.struts2.dispatcher;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -33,7 +32,10 @@ import org.apache.struts2.views.util.UrlHelper;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionException;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
@@ -111,12 +113,14 @@ import com.opensymphony.xwork2.inject.Inject;
|
||||
*
|
||||
* @see ActionMapper
|
||||
*/
|
||||
public class ServletActionRedirectResult extends ServletRedirectResult {
|
||||
public class ServletActionRedirectResult extends ServletRedirectResult implements ReflectionExceptionHandler {
|
||||
|
||||
private static final long serialVersionUID = -9042425229314584066L;
|
||||
|
||||
/** The default parameter */
|
||||
public static final String DEFAULT_PARAM = "actionName";
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServletActionRedirectResult.class);
|
||||
|
||||
protected String actionName;
|
||||
protected String namespace;
|
||||
@@ -225,4 +229,9 @@ public class ServletActionRedirectResult extends ServletRedirectResult {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void handle(ReflectionException ex) {
|
||||
// Only log as debug as they are probably parameters to be appended to the url
|
||||
LOG.debug(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ public class ServletDispatcherResult extends StrutsResultSupport {
|
||||
|
||||
private static final long serialVersionUID = -1970659272360685627L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(ServletDispatcherResult.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServletDispatcherResult.class);
|
||||
|
||||
public ServletDispatcherResult() {
|
||||
super();
|
||||
@@ -109,8 +109,8 @@ public class ServletDispatcherResult extends StrutsResultSupport {
|
||||
* HTTP request.
|
||||
*/
|
||||
public void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Forwarding to location " + finalLocation);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Forwarding to location " + finalLocation);
|
||||
}
|
||||
|
||||
PageContext pageContext = ServletActionContext.getPageContext();
|
||||
|
||||
@@ -23,8 +23,6 @@ package org.apache.struts2.dispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapper;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
@@ -32,6 +30,8 @@ import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public class ServletRedirectResult extends StrutsResultSupport {
|
||||
|
||||
private static final long serialVersionUID = 6316947346435301270L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(ServletRedirectResult.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServletRedirectResult.class);
|
||||
|
||||
protected boolean prependServletContext = true;
|
||||
|
||||
@@ -146,8 +146,8 @@ public class ServletRedirectResult extends StrutsResultSupport {
|
||||
finalLocation = response.encodeRedirectURL(finalLocation);
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Redirecting to finalLocation " + finalLocation);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Redirecting to finalLocation " + finalLocation);
|
||||
}
|
||||
|
||||
response.sendRedirect(finalLocation);
|
||||
|
||||
@@ -25,10 +25,9 @@ import java.io.OutputStream;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
@@ -80,7 +79,7 @@ public class StreamResult extends StrutsResultSupport {
|
||||
|
||||
private static final long serialVersionUID = -1468409635999059850L;
|
||||
|
||||
protected static final Log log = LogFactory.getLog(StreamResult.class);
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(StreamResult.class);
|
||||
|
||||
public static final String DEFAULT_PARAM = "inputName";
|
||||
|
||||
@@ -185,7 +184,7 @@ public class StreamResult extends StrutsResultSupport {
|
||||
if (inputStream == null) {
|
||||
String msg = ("Can not find a java.io.InputStream with the name [" + inputName + "] in the invocation stack. " +
|
||||
"Check the <param name=\"inputName\"> tag specified for this action.");
|
||||
log.error(msg);
|
||||
LOG.error(msg);
|
||||
throw new IllegalArgumentException(msg);
|
||||
}
|
||||
|
||||
@@ -206,7 +205,7 @@ public class StreamResult extends StrutsResultSupport {
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
log.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e);
|
||||
LOG.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,19 +217,19 @@ public class StreamResult extends StrutsResultSupport {
|
||||
// Get the outputstream
|
||||
oOutput = oResponse.getOutputStream();
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Streaming result [" + inputName + "] type=[" + contentType + "] length=[" + contentLength +
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Streaming result [" + inputName + "] type=[" + contentType + "] length=[" + contentLength +
|
||||
"] content-disposition=[" + contentDisposition + "]");
|
||||
}
|
||||
|
||||
// Copy input to output
|
||||
log.debug("Streaming to output buffer +++ START +++");
|
||||
LOG.debug("Streaming to output buffer +++ START +++");
|
||||
byte[] oBuff = new byte[bufferSize];
|
||||
int iSize;
|
||||
while (-1 != (iSize = inputStream.read(oBuff))) {
|
||||
oOutput.write(oBuff, 0, iSize);
|
||||
}
|
||||
log.debug("Streaming to output buffer +++ END +++");
|
||||
LOG.debug("Streaming to output buffer +++ END +++");
|
||||
|
||||
// Flush
|
||||
oOutput.flush();
|
||||
|
||||
@@ -62,26 +62,27 @@ public class StrutsRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
ActionContext ctx = ActionContext.getContext();
|
||||
Object attribute = super.getAttribute(s);
|
||||
|
||||
if (attribute == null) {
|
||||
boolean alreadyIn = false;
|
||||
Boolean b = (Boolean) ctx.get("__requestWrapper.getAttribute");
|
||||
if (b != null) {
|
||||
alreadyIn = b.booleanValue();
|
||||
}
|
||||
|
||||
// note: we don't let # come through or else a request for
|
||||
// #attr.foo or #request.foo could cause an endless loop
|
||||
if (!alreadyIn && s.indexOf("#") == -1) {
|
||||
try {
|
||||
// If not found, then try the ValueStack
|
||||
ctx.put("__requestWrapper.getAttribute", Boolean.TRUE);
|
||||
ValueStack stack = ctx.getValueStack();
|
||||
if (stack != null) {
|
||||
attribute = stack.findValue(s);
|
||||
if (ctx != null) {
|
||||
if (attribute == null) {
|
||||
boolean alreadyIn = false;
|
||||
Boolean b = (Boolean) ctx.get("__requestWrapper.getAttribute");
|
||||
if (b != null) {
|
||||
alreadyIn = b.booleanValue();
|
||||
}
|
||||
|
||||
// note: we don't let # come through or else a request for
|
||||
// #attr.foo or #request.foo could cause an endless loop
|
||||
if (!alreadyIn && s.indexOf("#") == -1) {
|
||||
try {
|
||||
// If not found, then try the ValueStack
|
||||
ctx.put("__requestWrapper.getAttribute", Boolean.TRUE);
|
||||
ValueStack stack = ctx.getValueStack();
|
||||
if (stack != null) {
|
||||
attribute = stack.findValue(s);
|
||||
}
|
||||
} finally {
|
||||
ctx.put("__requestWrapper.getAttribute", Boolean.FALSE);
|
||||
}
|
||||
} finally {
|
||||
ctx.put("__requestWrapper.getAttribute", Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ package org.apache.struts2.dispatcher;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.StrutsStatics;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.Result;
|
||||
import com.opensymphony.xwork2.util.TextParseUtil;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -102,7 +102,7 @@ import com.opensymphony.xwork2.util.TextParseUtil;
|
||||
*/
|
||||
public abstract class StrutsResultSupport implements Result, StrutsStatics {
|
||||
|
||||
private static final Log _log = LogFactory.getLog(StrutsResultSupport.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(StrutsResultSupport.class);
|
||||
|
||||
/** The default parameter */
|
||||
public static final String DEFAULT_PARAM = "location";
|
||||
@@ -205,7 +205,7 @@ public abstract class StrutsResultSupport implements Result, StrutsStatics {
|
||||
return URLEncoder.encode(parsedValue.toString(), "UTF-8");
|
||||
}
|
||||
catch(UnsupportedEncodingException e) {
|
||||
_log.warn("error while trying to encode ["+parsedValue+"]", e);
|
||||
LOG.warn("error while trying to encode ["+parsedValue+"]", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.JspFactory;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.views.JspSupportServlet;
|
||||
@@ -44,6 +42,8 @@ import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -86,7 +86,7 @@ public class VelocityResult extends StrutsResultSupport {
|
||||
|
||||
private static final long serialVersionUID = 7268830767762559424L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(VelocityResult.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(VelocityResult.class);
|
||||
|
||||
private String defaultEncoding;
|
||||
private VelocityManager velocityManager;
|
||||
@@ -161,7 +161,7 @@ public class VelocityResult extends StrutsResultSupport {
|
||||
// to do it all the time (WW-829). Since Velocity support is being deprecated, we'll oblige :)
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
log.error("Unable to render Velocity Template, '" + finalLocation + "'", e);
|
||||
LOG.error("Unable to render Velocity Template, '" + finalLocation + "'", e);
|
||||
throw e;
|
||||
} finally {
|
||||
if (usedJspFactory) {
|
||||
|
||||
@@ -36,6 +36,7 @@ public class ActionMapping {
|
||||
private String name;
|
||||
private String namespace;
|
||||
private String method;
|
||||
private String extension;
|
||||
private Map params;
|
||||
private Result result;
|
||||
|
||||
@@ -106,6 +107,13 @@ public class ActionMapping {
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The extension used during this request
|
||||
*/
|
||||
public String getExtension() {
|
||||
return extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param result The result
|
||||
@@ -141,4 +149,11 @@ public class ActionMapping {
|
||||
public void setParams(Map params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param extension The extension used in the request
|
||||
*/
|
||||
public void setExtension(String extension) {
|
||||
this.extension = extension;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,22 +21,17 @@
|
||||
package org.apache.struts2.dispatcher.mapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.FileManager;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
@@ -89,7 +84,7 @@ import com.opensymphony.xwork2.util.FileManager;
|
||||
*/
|
||||
public class CompositeActionMapper implements ActionMapper {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(CompositeActionMapper.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CompositeActionMapper.class);
|
||||
|
||||
protected Container container;
|
||||
|
||||
|
||||
@@ -20,24 +20,17 @@
|
||||
*/
|
||||
package org.apache.struts2.dispatcher.mapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.struts2.RequestUtils;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.dispatcher.ServletRedirectResult;
|
||||
import org.apache.struts2.util.PrefixTrie;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
@@ -183,7 +176,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
|
||||
protected List<String> extensions = new ArrayList<String>() {{ add("action"); add("");}};
|
||||
|
||||
protected Container container;
|
||||
protected Container container;
|
||||
|
||||
public DefaultActionMapper() {
|
||||
prefixTrie = new PrefixTrie() {
|
||||
@@ -272,11 +265,14 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
|
||||
@Inject(StrutsConstants.STRUTS_ACTION_EXTENSION)
|
||||
public void setExtensions(String extensions) {
|
||||
if (!"".equals(extensions)) {
|
||||
if (extensions != null && !"".equals(extensions)) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
Scanner scanner = new Scanner(extensions).useDelimiter(",");
|
||||
while (scanner.hasNext()) {
|
||||
list.add(scanner.next());
|
||||
String[] tokens = extensions.split(",");
|
||||
for (String token : tokens) {
|
||||
list.add(token);
|
||||
}
|
||||
if (extensions.endsWith(",")) {
|
||||
list.add("");
|
||||
}
|
||||
this.extensions = Collections.unmodifiableList(list);
|
||||
} else {
|
||||
@@ -294,7 +290,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
ActionMapping mapping = new ActionMapping();
|
||||
String uri = getUri(request);
|
||||
|
||||
uri = dropExtension(uri);
|
||||
uri = dropExtension(uri, mapping);
|
||||
if (uri == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -417,8 +413,21 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
* @param name
|
||||
* The action name
|
||||
* @return The action name without its extension
|
||||
* @deprecated Since 2.1, use {@link #dropExtension(java.lang.String,org.apache.struts2.dispatcher.mapper.ActionMapping)} instead
|
||||
*/
|
||||
protected String dropExtension(String name) {
|
||||
return dropExtension(name, new ActionMapping());
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the extension from the action name, storing it in the mapping for later use
|
||||
*
|
||||
* @param name
|
||||
* The action name
|
||||
* @param mapping The action mapping to store the extension in
|
||||
* @return The action name without its extension
|
||||
*/
|
||||
protected String dropExtension(String name, ActionMapping mapping) {
|
||||
if (extensions == null) {
|
||||
return name;
|
||||
}
|
||||
@@ -431,6 +440,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
String extension = "." + ext;
|
||||
if (name.endsWith(extension)) {
|
||||
name = name.substring(0, name.length() - extension.length());
|
||||
mapping.setExtension(ext);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -498,6 +508,15 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
}
|
||||
|
||||
String extension = getDefaultExtension();
|
||||
|
||||
// Look for the current extension, if available
|
||||
ActionContext context = ActionContext.getContext();
|
||||
if (context != null) {
|
||||
ActionMapping orig = (ActionMapping) context.get(ServletActionContext.ACTION_MAPPING);
|
||||
if (orig != null) {
|
||||
extension = orig.getExtension();
|
||||
}
|
||||
}
|
||||
if (extension != null) {
|
||||
|
||||
if (extension.length() == 0 || (extension.length() > 0 && uri.indexOf('.' + extension) == -1)) {
|
||||
|
||||
@@ -20,18 +20,19 @@
|
||||
*/
|
||||
package org.apache.struts2.dispatcher.mapper;
|
||||
|
||||
import com.opensymphony.xwork2.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.StringTokenizer;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
|
||||
import com.opensymphony.xwork2.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
*
|
||||
@@ -93,7 +94,7 @@ import org.apache.struts2.StrutsConstants;
|
||||
*/
|
||||
public class Restful2ActionMapper extends DefaultActionMapper {
|
||||
|
||||
protected static final Log LOG = LogFactory.getLog(Restful2ActionMapper.class);
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(Restful2ActionMapper.class);
|
||||
public static final String HTTP_METHOD_PARAM = "__http_method";
|
||||
private String idParameterName = null;
|
||||
|
||||
@@ -203,7 +204,7 @@ public class Restful2ActionMapper extends DefaultActionMapper {
|
||||
mapping.getParams().putAll(parameters);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.warn(e);
|
||||
LOG.warn("Unable to determine parameters from the url", e);
|
||||
}
|
||||
mapping.setName(actionName.substring(actionSlashPos+1));
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ import java.util.StringTokenizer;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.RequestUtils;
|
||||
|
||||
import com.opensymphony.xwork2.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ import com.opensymphony.xwork2.config.ConfigurationManager;
|
||||
*
|
||||
*/
|
||||
public class RestfulActionMapper implements ActionMapper {
|
||||
protected static final Log LOG = LogFactory.getLog(RestfulActionMapper.class);
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(RestfulActionMapper.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.struts2.dispatcher.mapper.ActionMapper#getMapping(javax.servlet.http.HttpServletRequest)
|
||||
@@ -105,7 +105,7 @@ public class RestfulActionMapper implements ActionMapper {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.warn(e);
|
||||
LOG.warn("Cannot determine url parameters", e);
|
||||
}
|
||||
|
||||
return new ActionMapping(actionName, "", "", parameters);
|
||||
|
||||
+8
-8
@@ -38,11 +38,11 @@ import org.apache.commons.fileupload.RequestContext;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Multipart form data request adapter for Jakarta Commons Fileupload package.
|
||||
@@ -50,7 +50,7 @@ import com.opensymphony.xwork2.inject.Inject;
|
||||
*/
|
||||
public class JakartaMultiPartRequest implements MultiPartRequest {
|
||||
|
||||
static final Log log = LogFactory.getLog(MultiPartRequest.class);
|
||||
static final Logger LOG = LoggerFactory.getLogger(MultiPartRequest.class);
|
||||
|
||||
// maps parameter name -> List of FileItem objects
|
||||
private Map<String,List<FileItem>> files = new HashMap<String,List<FileItem>>();
|
||||
@@ -91,9 +91,9 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
|
||||
|
||||
for (Object item1 : items) {
|
||||
FileItem item = (FileItem) item1;
|
||||
if (log.isDebugEnabled()) log.debug("Found item " + item.getFieldName());
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Found item " + item.getFieldName());
|
||||
if (item.isFormField()) {
|
||||
log.debug("Item is a normal form field");
|
||||
LOG.debug("Item is a normal form field");
|
||||
List<String> values;
|
||||
if (params.get(item.getFieldName()) != null) {
|
||||
values = params.get(item.getFieldName());
|
||||
@@ -113,11 +113,11 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
|
||||
}
|
||||
params.put(item.getFieldName(), values);
|
||||
} else {
|
||||
log.debug("Item is a file upload");
|
||||
LOG.debug("Item is a file upload");
|
||||
|
||||
// Skip file uploads that don't have a file name - meaning that no file was selected.
|
||||
if (item.getName() == null || item.getName().trim().length() < 1) {
|
||||
log.debug("No file has been uploaded for the field: " + item.getFieldName());
|
||||
LOG.debug("No file has been uploaded for the field: " + item.getFieldName());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
|
||||
}
|
||||
}
|
||||
} catch (FileUploadException e) {
|
||||
log.error(e);
|
||||
LOG.error("Unable to parse request", e);
|
||||
errors.add(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,6 @@ import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract wrapper class HTTP requests to handle multi-part data. <p>
|
||||
|
||||
+4
-3
@@ -31,10 +31,11 @@ import java.util.Vector;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.dispatcher.StrutsRequestWrapper;
|
||||
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Parse a multipart request and provide a wrapper around the request. The parsing implementation used
|
||||
@@ -53,7 +54,7 @@ import org.apache.struts2.dispatcher.StrutsRequestWrapper;
|
||||
*
|
||||
*/
|
||||
public class MultiPartRequestWrapper extends StrutsRequestWrapper {
|
||||
protected static final Log log = LogFactory.getLog(MultiPartRequestWrapper.class);
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(MultiPartRequestWrapper.class);
|
||||
|
||||
Collection<String> errors;
|
||||
MultiPartRequest multi;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
package org.apache.struts2.impl;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.DefaultActionProxy;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -31,9 +32,9 @@ public class StrutsActionProxy extends DefaultActionProxy {
|
||||
|
||||
private static final long serialVersionUID = -2434901249671934080L;
|
||||
|
||||
public StrutsActionProxy(String namespace, String actionName, Map extraContext,
|
||||
public StrutsActionProxy(ActionInvocation inv, String namespace, String actionName, Map extraContext,
|
||||
boolean executeResult, boolean cleanupContext) throws Exception {
|
||||
super(namespace, actionName, extraContext, executeResult, cleanupContext);
|
||||
super(inv, namespace, actionName, extraContext, executeResult, cleanupContext);
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
|
||||
@@ -24,19 +24,15 @@ package org.apache.struts2.impl;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.ActionProxy;
|
||||
import com.opensymphony.xwork2.DefaultActionProxyFactory;
|
||||
|
||||
public class StrutsActionProxyFactory extends DefaultActionProxyFactory {
|
||||
|
||||
public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext)
|
||||
throws Exception {
|
||||
return createActionProxy(namespace, actionName, extraContext, true, true);
|
||||
}
|
||||
|
||||
public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext,
|
||||
boolean executeResult, boolean cleanupContext) throws Exception {
|
||||
ActionProxy proxy = new StrutsActionProxy(namespace, actionName, extraContext, executeResult, cleanupContext);
|
||||
public ActionProxy createActionProxy(ActionInvocation inv, String namespace, String actionName, Map extraContext, boolean executeResult, boolean cleanupContext) throws Exception {
|
||||
|
||||
ActionProxy proxy = new StrutsActionProxy(inv, namespace, actionName, extraContext, executeResult, cleanupContext);
|
||||
container.inject(proxy);
|
||||
proxy.prepare();
|
||||
return proxy;
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.config.entities.InterceptorConfig;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.util.OgnlUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -51,7 +50,7 @@ public class StrutsObjectFactory extends ObjectFactory {
|
||||
// interceptor instances are long-lived and used across user sessions, so don't try to pass in any extra
|
||||
// context
|
||||
Object o = buildBean(className, null);
|
||||
OgnlUtil.setProperties(params, o);
|
||||
reflectionProvider.setProperties(params, o);
|
||||
|
||||
if (o instanceof Interceptor) {
|
||||
Interceptor interceptor = (Interceptor) o;
|
||||
@@ -92,7 +91,7 @@ public class StrutsObjectFactory extends ObjectFactory {
|
||||
return null;
|
||||
|
||||
Object result = buildBean(resultClassName, extraContext);
|
||||
OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext);
|
||||
reflectionProvider.setProperties(resultConfig.getParams(), result, extraContext);
|
||||
|
||||
if (result instanceof Result)
|
||||
return (Result) result;
|
||||
|
||||
@@ -28,30 +28,30 @@ import java.util.Set;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.TextParseUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
*
|
||||
* The aim of this interceptor is to set values in the stack/action based on cookie name/value
|
||||
* The aim of this intercepter is to set values in the stack/action based on cookie name/value
|
||||
* of interest. <p/>
|
||||
*
|
||||
* If an asterik is present in cookiesName parameter, it will be assume that
|
||||
* If an asterisk is present in cookiesName parameter, it will be assume that
|
||||
* all cookies name are to be injected into struts' action, even though
|
||||
* cookiesName is comma-separated by other values, eg (cookie1,*,cookie2). <p/>
|
||||
* cookiesName is comma-separated by other values, e.g. (cookie1,*,cookie2). <p/>
|
||||
*
|
||||
* If cookiesName is left empty it will assume that no cookie will be injected
|
||||
* into Struts' action. <p/>
|
||||
*
|
||||
* If an asterik is present in cookiesValue parameter, it will assume that all
|
||||
* If an asterisk is present in cookiesValue parameter, it will assume that all
|
||||
* cookies name irrespective of its value will be injected into Struts' action so
|
||||
* long as the cookie name matches those specified in cookiesName parameter.<p/>
|
||||
*
|
||||
@@ -161,7 +161,7 @@ public class CookieInterceptor extends AbstractInterceptor {
|
||||
|
||||
private static final long serialVersionUID = 4153142432948747305L;
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(CookieInterceptor.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CookieInterceptor.class);
|
||||
|
||||
private Set cookiesNameSet = Collections.EMPTY_SET;
|
||||
private Set cookiesValueSet = Collections.EMPTY_SET;
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
*/
|
||||
package org.apache.struts2.interceptor;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
@@ -80,14 +80,14 @@ public class CreateSessionInterceptor extends AbstractInterceptor {
|
||||
|
||||
private static final long serialVersionUID = -4590322556118858869L;
|
||||
|
||||
private static final Log _log = LogFactory.getLog(CreateSessionInterceptor.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CreateSessionInterceptor.class);
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
|
||||
*/
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
_log.debug("Creating HttpSession");
|
||||
LOG.debug("Creating HttpSession");
|
||||
ServletActionContext.getRequest().getSession(true);
|
||||
return invocation.invoke();
|
||||
}
|
||||
|
||||
@@ -23,14 +23,13 @@ package org.apache.struts2.interceptor;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.ActionProxy;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -68,9 +67,9 @@ import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
|
||||
*
|
||||
* <p/><b>Important</b>: Because the action will be running in a seperate thread, you can't use ActionContext because it
|
||||
* is a ThreadLocal. This means if you need to access, for example, session data, you need to implement SessionAware
|
||||
* rather than calling ActionContext.getSesion().
|
||||
* rather than calling ActionContext.getSession().
|
||||
*
|
||||
* <p/>The thread kicked off by this interceptor will be named in the form <b><u>actionName</u>BrackgroundProcess</b>.
|
||||
* <p/>The thread kicked off by this interceptor will be named in the form <b><u>actionName</u>BackgroundProcess</b>.
|
||||
* For example, the <i>search</i> action would run as a thread named <i>searchBackgroundProcess</i>.
|
||||
*
|
||||
* <!-- END SNIPPET: description -->
|
||||
@@ -165,7 +164,7 @@ public class ExecuteAndWaitInterceptor extends MethodFilterInterceptor {
|
||||
|
||||
private static final long serialVersionUID = -2754639196749652512L;
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(ExecuteAndWaitInterceptor.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ExecuteAndWaitInterceptor.class);
|
||||
|
||||
public static final String KEY = "__execWait";
|
||||
public static final String WAIT = "wait";
|
||||
@@ -197,7 +196,6 @@ public class ExecuteAndWaitInterceptor extends MethodFilterInterceptor {
|
||||
* Returns the name to associate the background process. Override to change the way background processes
|
||||
* are mapped to requests.
|
||||
*
|
||||
* @param actionInvocation The action invocation
|
||||
* @return the name of the background thread
|
||||
*/
|
||||
protected String getBackgroundProcessName(ActionProxy proxy) {
|
||||
|
||||
@@ -33,8 +33,6 @@ import java.util.StringTokenizer;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper;
|
||||
|
||||
@@ -44,6 +42,8 @@ import com.opensymphony.xwork2.ActionProxy;
|
||||
import com.opensymphony.xwork2.ValidationAware;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import com.opensymphony.xwork2.util.LocalizedTextUtil;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
@@ -162,7 +162,7 @@ public class FileUploadInterceptor extends AbstractInterceptor {
|
||||
|
||||
private static final long serialVersionUID = -4764627478894962478L;
|
||||
|
||||
protected static final Log log = LogFactory.getLog(FileUploadInterceptor.class);
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(FileUploadInterceptor.class);
|
||||
private static final String DEFAULT_DELIMITER = ",";
|
||||
private static final String DEFAULT_MESSAGE = "no.message.found";
|
||||
|
||||
@@ -199,9 +199,9 @@ public class FileUploadInterceptor extends AbstractInterceptor {
|
||||
HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
|
||||
|
||||
if (!(request instanceof MultiPartRequestWrapper)) {
|
||||
if (log.isDebugEnabled()) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
ActionProxy proxy = invocation.getProxy();
|
||||
log.debug(getTextMessage("struts.messages.bypass.request", new Object[]{proxy.getNamespace(), proxy.getActionName()}, ActionContext.getContext().getLocale()));
|
||||
LOG.debug(getTextMessage("struts.messages.bypass.request", new Object[]{proxy.getNamespace(), proxy.getActionName()}, ActionContext.getContext().getLocale()));
|
||||
}
|
||||
|
||||
return invocation.invoke();
|
||||
@@ -224,7 +224,7 @@ public class FileUploadInterceptor extends AbstractInterceptor {
|
||||
validation.addActionError(error);
|
||||
}
|
||||
|
||||
log.error(error);
|
||||
LOG.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,10 +257,10 @@ public class FileUploadInterceptor extends AbstractInterceptor {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.error(getTextMessage("struts.messages.invalid.file", new Object[]{inputName}, ActionContext.getContext().getLocale()));
|
||||
LOG.error(getTextMessage("struts.messages.invalid.file", new Object[]{inputName}, ActionContext.getContext().getLocale()));
|
||||
}
|
||||
} else {
|
||||
log.error(getTextMessage("struts.messages.invalid.content.type", new Object[]{inputName}, ActionContext.getContext().getLocale()));
|
||||
LOG.error(getTextMessage("struts.messages.invalid.content.type", new Object[]{inputName}, ActionContext.getContext().getLocale()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ public class FileUploadInterceptor extends AbstractInterceptor {
|
||||
File[] file = multiWrapper.getFiles(inputValue);
|
||||
for (int index = 0; index < file.length; index++) {
|
||||
File currentFile = file[index];
|
||||
log.info(getTextMessage("struts.messages.removing.file", new Object[]{inputValue, currentFile}, ActionContext.getContext().getLocale()));
|
||||
LOG.info(getTextMessage("struts.messages.removing.file", new Object[]{inputValue, currentFile}, ActionContext.getContext().getLocale()));
|
||||
|
||||
if ((currentFile != null) && currentFile.isFile()) {
|
||||
currentFile.delete();
|
||||
@@ -306,21 +306,21 @@ public class FileUploadInterceptor extends AbstractInterceptor {
|
||||
validation.addFieldError(inputName, errMsg);
|
||||
}
|
||||
|
||||
log.error(errMsg);
|
||||
LOG.error(errMsg);
|
||||
} else if (maximumSize != null && maximumSize.longValue() < file.length()) {
|
||||
String errMsg = getTextMessage("struts.messages.error.file.too.large", new Object[]{inputName, file.getName(), "" + file.length()}, locale);
|
||||
if (validation != null) {
|
||||
validation.addFieldError(inputName, errMsg);
|
||||
}
|
||||
|
||||
log.error(errMsg);
|
||||
LOG.error(errMsg);
|
||||
} else if ((! allowedTypesSet.isEmpty()) && (!containsItem(allowedTypesSet, contentType))) {
|
||||
String errMsg = getTextMessage("struts.messages.error.content.type.not.allowed", new Object[]{inputName, file.getName(), contentType}, locale);
|
||||
if (validation != null) {
|
||||
validation.addFieldError(inputName, errMsg);
|
||||
}
|
||||
|
||||
log.error(errMsg);
|
||||
LOG.error(errMsg);
|
||||
} else {
|
||||
fileIsAcceptable = true;
|
||||
}
|
||||
|
||||
@@ -25,13 +25,14 @@ import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.dispatcher.ServletRedirectResult;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.ValidationAware;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
@@ -43,12 +44,19 @@ import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
* <p/>
|
||||
*
|
||||
* In the 'STORE' mode, the interceptor will store the {@link ValidationAware} action's message / errors
|
||||
* and field errors into Http session.
|
||||
* and field errors into HTTP session.
|
||||
*
|
||||
* <p/>
|
||||
*
|
||||
* In the 'RETRIEVE' mode, the interceptor will retrieve the stored action's message / errors and field
|
||||
* errors and put them back into the {@link ValidationAware} action.
|
||||
*
|
||||
* <p/>
|
||||
*
|
||||
* In the 'AUTOMATIC' mode, the interceptor will always retrieve the stored action's message / errors
|
||||
* and field errors and put them back into the {@link ValidationAware} action, and after Action execution,
|
||||
* if the {@link Result} is an instance of {@link ServletRedirectResult}, the action's message / errors
|
||||
* and field errors into automatically be stored in the HTTP session..
|
||||
*
|
||||
* <p/>
|
||||
*
|
||||
@@ -85,7 +93,7 @@ import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
* <li>requestParameterSwitch - The request parameter that will indicate what mode this
|
||||
* interceptor is in. </li>
|
||||
* <li>operationMode - The operation mode this interceptor should be in
|
||||
* (either 'STORE', 'RETRIEVE' or 'NONE'). 'NONE' being the default.</li>
|
||||
* (either 'STORE', 'RETRIEVE', 'AUTOMATIC', or 'NONE'). 'NONE' being the default.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <!-- END SNIPPET: parameters -->
|
||||
@@ -140,9 +148,9 @@ public class MessageStoreInterceptor implements Interceptor {
|
||||
|
||||
private static final long serialVersionUID = 4491997514314242420L;
|
||||
|
||||
private static final Log _log = LogFactory.getLog(MessageStoreInterceptor.class);
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MessageStoreInterceptor.class);
|
||||
|
||||
public static final String AUTOMATIC_MODE = "AUTOMATIC";
|
||||
public static final String STORE_MODE = "STORE";
|
||||
public static final String RETRIEVE_MODE = "RETRIEVE";
|
||||
public static final String NONE = "NONE";
|
||||
@@ -189,13 +197,13 @@ public class MessageStoreInterceptor implements Interceptor {
|
||||
}
|
||||
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
_log.debug("entering MessageStoreInterceptor ...");
|
||||
LOG.debug("entering MessageStoreInterceptor ...");
|
||||
|
||||
before(invocation);
|
||||
String result = invocation.invoke();
|
||||
after(invocation, result);
|
||||
|
||||
_log.debug("exit executing MessageStoreInterceptor");
|
||||
LOG.debug("exit executing MessageStoreInterceptor");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -210,7 +218,8 @@ public class MessageStoreInterceptor implements Interceptor {
|
||||
String reqOperationMode = getRequestOperationMode(invocation);
|
||||
|
||||
if (RETRIEVE_MODE.equalsIgnoreCase(reqOperationMode) ||
|
||||
RETRIEVE_MODE.equalsIgnoreCase(operationMode)) {
|
||||
RETRIEVE_MODE.equalsIgnoreCase(operationMode) ||
|
||||
AUTOMATIC_MODE.equalsIgnoreCase(operationMode)) {
|
||||
|
||||
Object action = invocation.getAction();
|
||||
if (action instanceof ValidationAware) {
|
||||
@@ -218,7 +227,7 @@ public class MessageStoreInterceptor implements Interceptor {
|
||||
Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION);
|
||||
ValidationAware validationAwareAction = (ValidationAware) action;
|
||||
|
||||
_log.debug("retrieve error / message from session to populate into action ["+action+"]");
|
||||
LOG.debug("retrieve error / message from session to populate into action ["+action+"]");
|
||||
|
||||
Collection actionErrors = (Collection) session.get(actionErrorsSessionKey);
|
||||
Collection actionMessages = (Collection) session.get(actionMessagesSessionKey);
|
||||
@@ -256,15 +265,17 @@ public class MessageStoreInterceptor implements Interceptor {
|
||||
protected void after(ActionInvocation invocation, String result) throws Exception {
|
||||
|
||||
String reqOperationMode = getRequestOperationMode(invocation);
|
||||
boolean isRedirect = invocation.getResult() instanceof ServletRedirectResult;
|
||||
if (STORE_MODE.equalsIgnoreCase(reqOperationMode) ||
|
||||
STORE_MODE.equalsIgnoreCase(operationMode)) {
|
||||
STORE_MODE.equalsIgnoreCase(operationMode) ||
|
||||
(AUTOMATIC_MODE.equalsIgnoreCase(operationMode) && isRedirect)) {
|
||||
|
||||
Object action = invocation.getAction();
|
||||
if (action instanceof ValidationAware) {
|
||||
// store error / messages into session
|
||||
Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION);
|
||||
|
||||
_log.debug("store action ["+action+"] error/messages into session ");
|
||||
LOG.debug("store action ["+action+"] error/messages into session ");
|
||||
|
||||
ValidationAware validationAwareAction = (ValidationAware) action;
|
||||
session.put(actionErrorsSessionKey, validationAwareAction.getActionErrors());
|
||||
@@ -272,7 +283,7 @@ public class MessageStoreInterceptor implements Interceptor {
|
||||
session.put(fieldErrorsSessionKey, validationAwareAction.getFieldErrors());
|
||||
}
|
||||
else {
|
||||
_log.debug("Action ["+action+"] is not ValidationAware, no message / error that are storeable");
|
||||
LOG.debug("Action ["+action+"] is not ValidationAware, no message / error that are storeable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,5 +41,5 @@ public interface ParameterAware {
|
||||
*
|
||||
* @param parameters a Map of parameters (name/value Strings).
|
||||
*/
|
||||
public void setParameters(Map parameters);
|
||||
public void setParameters(Map<String,String[]> parameters);
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.security.Principal;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Proxy interface used together with PrincipalAware interface. It allows to get indirect access to
|
||||
* HttpServletRequest or PortletRequest Principal related methods.
|
||||
* Proxy interface used together with PrincipalAware interface. It allows indirect
|
||||
* access to HttpServletRequest or PortletRequest Principal related methods.
|
||||
*/
|
||||
public interface PrincipalProxy {
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
*/
|
||||
package org.apache.struts2.interceptor;
|
||||
|
||||
import org.apache.struts2.dispatcher.Dispatcher;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
|
||||
@@ -27,9 +27,6 @@ import java.util.Map;
|
||||
* Actions that want access to the current serlvet request attributes should implement this interface.<p />
|
||||
*
|
||||
* This interface is only relevant if the Action is used in a servlet environment.<p/>
|
||||
*
|
||||
* Note that using this interface makes the Action tied to a servlet environment, so it should be
|
||||
* avoided if possible since things like unit testing will become more difficult.
|
||||
*/
|
||||
public interface RequestAware {
|
||||
|
||||
|
||||
@@ -20,13 +20,10 @@
|
||||
*/
|
||||
package org.apache.struts2.interceptor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.dispatcher.SessionMap;
|
||||
@@ -37,6 +34,8 @@ import com.opensymphony.xwork2.ActionProxy;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import com.opensymphony.xwork2.interceptor.PreResultListener;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
@@ -142,7 +141,7 @@ public class ScopeInterceptor extends AbstractInterceptor implements PreResultLi
|
||||
|
||||
private static final long serialVersionUID = 9120762699600054395L;
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(ScopeInterceptor.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ScopeInterceptor.class);
|
||||
|
||||
private String[] application = null;
|
||||
private String[] session = null;
|
||||
|
||||
@@ -24,12 +24,12 @@ import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Actions that want access to the user's HTTP session should implement this interface.<p>
|
||||
* Actions that want access to the user's HTTP session attributes should implement this interface.<p>
|
||||
* <p/>
|
||||
* This interface is only relevant if the Action is used in a servlet environment.<p>
|
||||
* This will give them access to a Map where they can put objects that can be made available
|
||||
* to subsequent requests.<p/>
|
||||
* <p/>
|
||||
* Note that using this interface makes the Action tied to a servlet environment, so it should be
|
||||
* avoided if possible since things like unit testing will become more difficult.
|
||||
* Typical uses may be cached user data such as name, or a shopping cart.
|
||||
*
|
||||
*/
|
||||
public interface SessionAware {
|
||||
|
||||
+16
-9
@@ -37,8 +37,6 @@ import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.views.freemarker.FreemarkerManager;
|
||||
@@ -50,6 +48,9 @@ import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.interceptor.PreResultListener;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
@@ -90,7 +91,7 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
|
||||
private static final long serialVersionUID = -3097324155953078783L;
|
||||
|
||||
private final static Log log = LogFactory.getLog(DebuggingInterceptor.class);
|
||||
private final static Logger LOG = LoggerFactory.getLogger(DebuggingInterceptor.class);
|
||||
|
||||
private String[] ignorePrefixes = new String[]{"org.apache.struts.",
|
||||
"com.opensymphony.xwork2.", "xwork."};
|
||||
@@ -116,6 +117,7 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
private FreemarkerManager freemarkerManager;
|
||||
|
||||
private boolean consoleEnabled = false;
|
||||
private ReflectionProvider reflectionProvider;
|
||||
|
||||
@Inject(StrutsConstants.STRUTS_DEVMODE)
|
||||
public void setDevMode(String mode) {
|
||||
@@ -126,6 +128,11 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
public void setFreemarkerManager(FreemarkerManager mgr) {
|
||||
this.freemarkerManager = mgr;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setReflectionProvider(ReflectionProvider reflectionProvider) {
|
||||
this.reflectionProvider = reflectionProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused.
|
||||
@@ -184,7 +191,7 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
try {
|
||||
result.execute(inv);
|
||||
} catch (Exception ex) {
|
||||
log.error("Unable to create debugging console", ex);
|
||||
LOG.error("Unable to create debugging console", ex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -226,7 +233,7 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
try {
|
||||
StringWriter writer = new StringWriter();
|
||||
ObjectToHTMLWriter htmlWriter = new ObjectToHTMLWriter(writer);
|
||||
htmlWriter.write(rootObject, rootObjectExpression);
|
||||
htmlWriter.write(reflectionProvider, rootObject, rootObjectExpression);
|
||||
String html = writer.toString();
|
||||
writer.close();
|
||||
|
||||
@@ -243,7 +250,7 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
result.setLocation("/org/apache/struts2/interceptor/debugging/browser.ftl");
|
||||
result.execute(inv);
|
||||
} catch (Exception ex) {
|
||||
log.error("Unable to create debugging console", ex);
|
||||
LOG.error("Unable to create debugging console", ex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -358,8 +365,8 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
writer.flush();
|
||||
// Check stack for this object
|
||||
if ((bean != null) && (stack.contains(bean))) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("Circular reference detected, not serializing object: "
|
||||
if (LOG.isInfoEnabled()) {
|
||||
LOG.info("Circular reference detected, not serializing object: "
|
||||
+ name);
|
||||
}
|
||||
return;
|
||||
@@ -419,7 +426,7 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
LOG.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user