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