Skip to content

Commit

Permalink
WW-4504 - Mark current logging layer as @deprecated and use Log4j2 as…
Browse files Browse the repository at this point in the history
… default one

- Use log4j2 Logger and LogManager instead of xwork implementation everywhere
  • Loading branch information
jogep committed May 25, 2015
1 parent 340312e commit 95805e5
Show file tree
Hide file tree
Showing 268 changed files with 798 additions and 867 deletions.
3 changes: 1 addition & 2 deletions apps/jboss-blank/src/test/java/example/HelloWorldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

package example;

import org.apache.struts2.StrutsTestCase;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.StrutsTestCase;

public class HelloWorldTest extends StrutsTestCase {

Expand Down
16 changes: 5 additions & 11 deletions apps/mailreader/src/main/java/mailreader2/ApplicationListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,14 @@

package mailreader2;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts.apps.mailreader.dao.impl.memory.MemoryUserDatabase;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.struts.apps.mailreader.dao.impl.memory.MemoryUserDatabase;

import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
import java.io.*;

/**
* <p><code>ServletContextListener</code> that initializes and finalizes the
Expand Down Expand Up @@ -100,7 +94,7 @@ public final class ApplicationListener implements ServletContextListener {
/**
* <p>Logging output for this plug in instance.</p>
*/
private Logger log = LoggerFactory.getLogger(this.getClass());
private Logger log = LogManager.getLogger(this.getClass());

// ------------------------------------------------------------- Properties

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
*/
package mailreader2;

import com.opensymphony.xwork2.interceptor.Interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.Action;
import java.util.Map;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import org.apache.struts.apps.mailreader.dao.User;

import java.util.Map;

public class AuthenticationInterceptor implements Interceptor {

public void destroy () {}
Expand Down
2 changes: 1 addition & 1 deletion apps/mailreader/src/main/java/mailreader2/Login.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

package mailreader2;

import org.apache.struts.apps.mailreader.dao.User;
import org.apache.struts.apps.mailreader.dao.ExpiredPasswordException;
import org.apache.struts.apps.mailreader.dao.User;

/**
* <p> Validate a user login. </p>
Expand Down
11 changes: 5 additions & 6 deletions apps/mailreader/src/main/java/mailreader2/MailreaderSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

package mailreader2;

import java.util.Map;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts.apps.mailreader.dao.ExpiredPasswordException;
import org.apache.struts.apps.mailreader.dao.Subscription;
import org.apache.struts.apps.mailreader.dao.User;
Expand All @@ -32,9 +33,7 @@
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;
import java.util.Map;

/**
* <p> Base Action for MailreaderSupport application. </p>
Expand Down Expand Up @@ -388,7 +387,7 @@ public User findUser(String username, String password)
/**
* <p><code>Log</code> instance for this application. </p>
*/
protected Logger log = LoggerFactory.getLogger(Constants.PACKAGE);
protected Logger log = LogManager.getLogger(Constants.PACKAGE);

/**
* <p> Persist the User object, including subscriptions, to the database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
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;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.struts2.dispatcher.SessionMap;

public class ChatAuthenticationInterceptor implements Interceptor {

private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(ChatAuthenticationInterceptor.class);
private static final Logger LOG = LogManager.getLogger(ChatAuthenticationInterceptor.class);
public static final String USER_SESSION_KEY = "chatUserSessionKey";

public void destroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
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;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

import javax.servlet.http.HttpSession;

Expand All @@ -34,7 +34,7 @@
*/
public class ChatInterceptor implements Interceptor {

private static final Logger LOG = LoggerFactory.getLogger(ChatInterceptor.class);
private static final Logger LOG = LogManager.getLogger(ChatInterceptor.class);

private static final long serialVersionUID = 1L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
package org.apache.struts2.showcase.chat;

import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

Expand All @@ -31,7 +31,7 @@

public class ChatSessionListener implements HttpSessionListener {

private static final Logger LOG = LoggerFactory.getLogger(ChatSessionListener.class);
private static final Logger LOG = LogManager.getLogger(ChatSessionListener.class);

public void sessionCreated(HttpSessionEvent event) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
package org.apache.struts2.showcase.chat;

import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.struts2.util.StrutsTypeConverter;

import java.text.ParseException;
Expand All @@ -31,7 +31,7 @@

public class DateConverter extends StrutsTypeConverter {

private static final Logger LOG = LoggerFactory.getLogger(DateConverter.class);
private static final Logger LOG = LogManager.getLogger(DateConverter.class);

public Object convertFromString(Map context, String[] values, Class toClass) {

Expand Down
12 changes: 4 additions & 8 deletions bundles/demo/src/main/java/actions/osgi/BundlesAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@
*/
package actions.osgi;

import org.osgi.framework.BundleContext;
import org.osgi.framework.Bundle;
import org.apache.struts2.osgi.interceptor.BundleContextAware;
import org.apache.struts2.osgi.interceptor.ServiceAware;
import org.apache.struts2.convention.annotation.ResultPath;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.ResultPath;
import org.apache.struts2.osgi.interceptor.BundleContextAware;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

/**
* This action shows how to interact with the OSGi container, using the OSGi interceptor
Expand Down
5 changes: 0 additions & 5 deletions bundles/demo/src/main/java/actions/osgi/HelloWorldAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ResultPath;
import org.apache.struts2.osgi.interceptor.BundleContextAware;
import org.apache.struts2.osgi.interceptor.ServiceAware;
import org.osgi.framework.BundleContext;

import java.util.List;

@ResultPath("/content")
public class HelloWorldAction extends ActionSupport {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean class="actions.osgi.Message" id="message">
<constructor-arg type="java.lang.String" value="Welcome to the OSGi plugin. You can checkout any time you like, but can never leave"/>
Expand Down
13 changes: 7 additions & 6 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@
<optional>true</optional>
</dependency>

<!-- Logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>

<!-- File upload -->
<dependency>
<groupId>commons-fileupload</groupId>
Expand Down Expand Up @@ -258,12 +265,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/apache/struts2/RequestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

package org.apache.struts2;

import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.commons.lang3.time.FastDateFormat;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
Expand All @@ -37,7 +37,7 @@
*/
public class RequestUtils {

private static final Logger LOG = LoggerFactory.getLogger(RequestUtils.class);
private static final Logger LOG = LogManager.getLogger(RequestUtils.class);

private static final TimeZone GMT = TimeZone.getTimeZone("GMT");

Expand Down
10 changes: 4 additions & 6 deletions core/src/main/java/org/apache/struts2/ServletActionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@

package org.apache.struts2;

import java.util.Map;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.dispatcher.mapper.ActionMapping;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;

import org.apache.struts2.dispatcher.mapper.ActionMapping;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.util.ValueStack;
import java.util.Map;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
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;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsException;
import org.apache.struts2.StrutsStatics;
Expand Down Expand Up @@ -118,7 +118,7 @@
*/
@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 Logger LOG = LoggerFactory.getLogger(ActionComponent.class);
private static final Logger LOG = LogManager.getLogger(ActionComponent.class);

protected HttpServletResponse res;
protected HttpServletRequest req;
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/apache/struts2/components/Anchor.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

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;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
Expand Down Expand Up @@ -61,7 +61,7 @@
description = "Render a HTML href element that when clicked can optionally call a URL via remote XMLHttpRequest and updates its targets",
allowDynamicAttributes = true)
public class Anchor extends ClosingUIBean {
private static final Logger LOG = LoggerFactory.getLogger(Anchor.class);
private static final Logger LOG = LogManager.getLogger(Anchor.class);

public static final String OPEN_TEMPLATE = "a";
public static final String TEMPLATE = "a-close";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
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;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

/**
* <!-- START SNIPPET: javadoc -->
Expand Down Expand Up @@ -119,7 +119,7 @@
@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 Logger LOG = LoggerFactory.getLogger(AppendIterator.class);
private static final Logger LOG = LogManager.getLogger(AppendIterator.class);

private AppendIteratorFilter appendIteratorFilter= null;
private List _parameters;
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/apache/struts2/components/Bean.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.opensymphony.xwork2.ObjectFactory;
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;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
Expand Down Expand Up @@ -95,7 +95,7 @@
@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 final Logger LOG = LoggerFactory.getLogger(Bean.class);
protected static final Logger LOG = LogManager.getLogger(Bean.class);

protected Object bean;
protected String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
package org.apache.struts2.components;

import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.struts2.views.annotations.StrutsTagAttribute;

import javax.servlet.http.HttpServletRequest;
Expand All @@ -34,7 +34,7 @@
* ClosingUIBean is the standard superclass for UI components such as div etc.
*/
public abstract class ClosingUIBean extends UIBean {
private static final Logger LOG = LoggerFactory.getLogger(ClosingUIBean.class);
private static final Logger LOG = LogManager.getLogger(ClosingUIBean.class);

protected ClosingUIBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
super(stack, request, response);
Expand Down
Loading

0 comments on commit 95805e5

Please sign in to comment.