Skip to content

Commit

Permalink
migrate to Jakarta EE
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Aug 26, 2022
1 parent 0088e60 commit e2c0cc6
Show file tree
Hide file tree
Showing 37 changed files with 192 additions and 212 deletions.
17 changes: 12 additions & 5 deletions logback-access/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -65,8 +65,15 @@
</dependency>

<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
Expand Down Expand Up @@ -135,7 +142,7 @@
<Import-Package>
ch.qos.logback.core.rolling,
ch.qos.logback.core.rolling.helper,
javax.servlet.*;version="4.0.0",
jakarta.servlet.*;version="4.0.0",
org.apache.catalina.*;version="${tomcat.version}";resolution:=optional,
org.eclipse.jetty.*;version="${jetty.version}";resolution:=optional,
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
*/
package ch.qos.logback.access;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import ch.qos.logback.core.status.StatusManager;
import ch.qos.logback.core.status.ViewStatusMessagesServletBase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.io.File;
import java.net.URL;
import java.util.EventListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -243,20 +244,10 @@ enum State {
String fileName;
String resource;

// Jetty 9.4.x and newer is considered modern.
boolean modernJettyRequestLog;
boolean quiet = false;

public RequestLogImpl() {
putObject(CoreConstants.EVALUATOR_MAP, new HashMap<String, EventEvaluator<?>>());

// plumb the depths of Jetty and the environment ...
if (EnvUtil.isClassAvailable(this.getClass(), "jakarta.servlet.http.HttpServlet")) {
throw new RuntimeException("The new jakarta.servlet classes are not supported by this " + "version of logback-access (check for a newer version of logback-access that " + "does support it)");
}

// look for modern approach to RequestLog
modernJettyRequestLog = EnvUtil.isClassAvailable(this.getClass(), "org.eclipse.jetty.server.CustomRequestLog");
}

@Override
Expand All @@ -270,11 +261,7 @@ public void log(Request jettyRequest, Response jettyResponse) {
}

private JettyServerAdapter makeJettyServerAdapter(Request jettyRequest, Response jettyResponse) {
if (modernJettyRequestLog) {
return new JettyModernServerAdapter(jettyRequest, jettyResponse);
} else {
return new JettyServerAdapter(jettyRequest, jettyResponse);
}
return new JettyModernServerAdapter(jettyRequest, jettyResponse);
}

protected void addInfo(String msg) {
Expand Down Expand Up @@ -402,6 +389,16 @@ public boolean isFailed() {
return state == State.FAILED;
}

@Override
public boolean addEventListener(EventListener listener) {
return false;
}

@Override
public boolean removeEventListener(EventListener listener) {
return false;
}


public boolean isQuiet() {
return quiet;
Expand Down Expand Up @@ -466,13 +463,10 @@ public FilterReply getFilterChainDecision(IAccessEvent event) {
return fai.getFilterChainDecision(event);
}


@Override
public void addLifeCycleListener(LifeCycle.Listener listener) {
// we'll implement this when asked
}

@Override
public void removeLifeCycleListener(LifeCycle.Listener listener) {
// we'll implement this when asked
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import java.util.ArrayList;
import java.util.List;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.FilterConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import static ch.qos.logback.access.AccessConstants.LB_OUTPUT_BUFFER;
import static ch.qos.logback.access.AccessConstants.TEE_FILTER_INCLUDES_PARAM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import java.io.IOException;
import java.io.InputStreamReader;

import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import jakarta.servlet.ServletInputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequestWrapper;

import static ch.qos.logback.access.AccessConstants.LB_INPUT_BUFFER;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponseWrapper;

public class TeeHttpServletResponse extends HttpServletResponseWrapper {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import java.io.IOException;
import java.io.InputStream;

import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.ReadListener;
import jakarta.servlet.ServletInputStream;
import jakarta.servlet.http.HttpServletRequest;

class TeeServletInputStream extends ServletInputStream {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;

import javax.servlet.ServletOutputStream;
import javax.servlet.ServletResponse;
import javax.servlet.WriteListener;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.WriteListener;

public class TeeServletOutputStream extends ServletOutputStream {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

import ch.qos.logback.access.AccessConstants;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

public class Util {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
package ch.qos.logback.access.sift;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;

import ch.qos.logback.access.spi.IAccessEvent;
import ch.qos.logback.core.sift.AbstractDiscriminator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import ch.qos.logback.core.Context;
import ch.qos.logback.core.spi.SequenceNumberGenerator;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.Serializable;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

import ch.qos.logback.core.spi.DeferredProcessingAware;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;

import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

import ch.qos.logback.access.AccessConstants;

import javax.servlet.*;
import javax.servlet.http.*;
import jakarta.servlet.*;
import jakarta.servlet.http.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import java.io.PrintWriter;
import java.util.*;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletResponse;

public class DummyResponse implements HttpServletResponse {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
package ch.qos.logback.access.dummy;

import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.WriteListener;

import java.io.IOException;
import java.io.OutputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.handler.AbstractHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;


public class JettyFixtureBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.Cookie;
import jakarta.servlet.http.Cookie;

import ch.qos.logback.access.spi.IAccessEvent;
import org.junit.After;
Expand Down
19 changes: 9 additions & 10 deletions logback-classic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@
</dependency>

<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<artifactId>jakarta.mail</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
Expand All @@ -103,18 +103,18 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail</artifactId>
<!--<version>2.0.0-alpha-1</version> -->
<version>1.5.14</version>

<version>2.0.0-alpha-1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
Expand Down Expand Up @@ -147,7 +147,6 @@
<manifestEntries>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
<Multi-Release>true</Multi-Release>
</manifestEntries>
<manifestFile>
${project.build.outputDirectory}/META-INF/MANIFEST.MF
Expand Down Expand Up @@ -293,7 +292,7 @@
of java code. -->
<Import-Package>
sun.reflect;resolution:=optional,
javax.*;resolution:=optional,
jakarta.*;resolution:=optional,
org.xml.*;resolution:=optional,
org.slf4j,
org.slf4j.spi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
package ch.qos.logback.classic;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.slf4j.LoggerFactory;

Expand Down
Loading

0 comments on commit e2c0cc6

Please sign in to comment.