mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
indent and fix wrong imports
This commit is contained in:
@@ -33,14 +33,15 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import de.triology.scm.plugins.restart.ServletContainer;
|
||||
import de.triology.scm.plugins.restart.ServletContainerDetector;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Detects the ServletContainer.
|
||||
@@ -51,28 +52,31 @@ import de.triology.scm.plugins.restart.ServletContainerDetector;
|
||||
*/
|
||||
public class ServletContainerDetector
|
||||
{
|
||||
|
||||
/** Make usage of the logging framework. */
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ServletContainerDetector.class);
|
||||
/** Servlet request for alternate detection method. */
|
||||
private HttpServletRequest request = null;
|
||||
private static final Logger LOGGER =
|
||||
LoggerFactory.getLogger(ServletContainerDetector.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs a new ServletContainerDetector.
|
||||
* @deprecated Use {@link ServletContainerDetector#detect(HttpServletRequest)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public ServletContainerDetector() {
|
||||
|
||||
}
|
||||
public ServletContainerDetector() {}
|
||||
|
||||
/**
|
||||
* Constructs a new ServletContainerDetector depending on the ServletRequest.
|
||||
* @param req The ServletRequest.
|
||||
*/
|
||||
private ServletContainerDetector(final HttpServletRequest req) {
|
||||
private ServletContainerDetector(final HttpServletRequest req)
|
||||
{
|
||||
request = req;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Detects the ServletContainer.
|
||||
*
|
||||
@@ -87,8 +91,10 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Alternate detection of ServletContainer using DefaultServletDetection.
|
||||
*
|
||||
* @param req The used Servlet instance.
|
||||
* @return the detected ServletContainer.
|
||||
* @since 1.32
|
||||
*/
|
||||
public static ServletContainer detect(final HttpServletRequest req)
|
||||
{
|
||||
@@ -104,6 +110,7 @@ public class ServletContainerDetector
|
||||
public ServletContainer detectContainer()
|
||||
{
|
||||
LOGGER.trace("Detecting servlet container...");
|
||||
|
||||
ServletContainer container = ServletContainer.UNKNOWN;
|
||||
|
||||
if (isScmServer())
|
||||
@@ -155,7 +162,8 @@ public class ServletContainerDetector
|
||||
container = ServletContainer.TOMCAT;
|
||||
}
|
||||
|
||||
if (ServletContainer.UNKNOWN.equals(container)) {
|
||||
if (ServletContainer.UNKNOWN.equals(container))
|
||||
{
|
||||
LOGGER.trace("Servlet container is unknown.");
|
||||
}
|
||||
|
||||
@@ -164,6 +172,24 @@ public class ServletContainerDetector
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a Eclipse Jetty.
|
||||
*
|
||||
* @since 1.32
|
||||
* @return true if the ServletContainer is a Eclipse Jetty
|
||||
*/
|
||||
public boolean isEclipseJetty()
|
||||
{
|
||||
boolean jetty = detect("/org/eclipse/jetty/server/Server.class");
|
||||
|
||||
if (!jetty && (null != request))
|
||||
{
|
||||
jetty = detectDefaultServlet("org.eclipse.jetty");
|
||||
}
|
||||
|
||||
return jetty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a Geronimo.
|
||||
*
|
||||
@@ -235,21 +261,6 @@ public class ServletContainerDetector
|
||||
return detect("/org/mortbay/jetty/Server.class");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a Eclipse Jetty.
|
||||
*
|
||||
* @since 1.32
|
||||
* @return true if the ServletContainer is a Eclipse Jetty
|
||||
*/
|
||||
public boolean isEclipseJetty()
|
||||
{
|
||||
boolean jetty = detect("/org/eclipse/jetty/server/Server.class");
|
||||
if (!jetty && null != request) {
|
||||
jetty = detectDefaultServlet("org.eclipse.jetty");
|
||||
}
|
||||
return jetty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a OC4J.
|
||||
*
|
||||
@@ -281,6 +292,7 @@ public class ServletContainerDetector
|
||||
public boolean isScmServer()
|
||||
{
|
||||
LOGGER.debug("App name is: " + System.getProperty("app.name"));
|
||||
|
||||
return "scm-server".equals(System.getProperty("app.name"));
|
||||
}
|
||||
|
||||
@@ -365,11 +377,16 @@ public class ServletContainerDetector
|
||||
*
|
||||
* @since 1.32
|
||||
* @param keyword Part of the class path that is needed at the implementation class.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean detectDefaultServlet(final String keyword)
|
||||
{
|
||||
|
||||
// Request the default servlet (its pretty safe to say it will always be there)
|
||||
final RequestDispatcher dispatcher = request.getSession().getServletContext().getNamedDispatcher("default");
|
||||
final RequestDispatcher dispatcher =
|
||||
request.getSession().getServletContext().getNamedDispatcher("default");
|
||||
|
||||
if (dispatcher == null)
|
||||
{
|
||||
return false;
|
||||
@@ -378,4 +395,9 @@ public class ServletContainerDetector
|
||||
// If the request dispatcher implementation contains the keyword, we can claim a match
|
||||
return dispatcher.getClass().getName().contains(keyword);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Servlet request for alternate detection method. */
|
||||
private HttpServletRequest request = null;
|
||||
}
|
||||
Reference in New Issue
Block a user