mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Use logger, fix JavaDoc.
This commit is contained in:
@@ -25,15 +25,24 @@ import javax.servlet.ServletContext;
|
|||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
import javax.servlet.ServletContextListener;
|
import javax.servlet.ServletContextListener;
|
||||||
import net.sourceforge.guacamole.GuacamoleException;
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple HttpServlet which outputs XML containing a list of all authorized
|
* Simple ServletContextListener which loads a WebSocket tunnel implementation
|
||||||
* configurations for the current user.
|
* if available, using the Servlet 3.0 API to dynamically load and install
|
||||||
|
* the tunnel servlet.
|
||||||
|
*
|
||||||
|
* Note that because Guacamole depends on the Servlet 2.5 API, and 3.0 may
|
||||||
|
* not be available or needed if WebSocket is not desired, the 3.0 API is
|
||||||
|
* detected and invoked dynamically via reflection.
|
||||||
*
|
*
|
||||||
* @author Michael Jumper
|
* @author Michael Jumper
|
||||||
*/
|
*/
|
||||||
public class WebSocketSupportLoader implements ServletContextListener {
|
public class WebSocketSupportLoader implements ServletContextListener {
|
||||||
|
|
||||||
|
private Logger logger = LoggerFactory.getLogger(WebSocketSupportLoader.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contextDestroyed(ServletContextEvent sce) {
|
public void contextDestroyed(ServletContextEvent sce) {
|
||||||
}
|
}
|
||||||
@@ -45,8 +54,7 @@ public class WebSocketSupportLoader implements ServletContextListener {
|
|||||||
|
|
||||||
// Attempt to find WebSocket servlet
|
// Attempt to find WebSocket servlet
|
||||||
Class<Servlet> servlet = (Class<Servlet>) GuacamoleClassLoader.getInstance().findClass(
|
Class<Servlet> servlet = (Class<Servlet>) GuacamoleClassLoader.getInstance().findClass(
|
||||||
"net.sourceforge.guacamole.net.basic.BasicGuacamoleTunnelServlet"
|
"net.sourceforge.guacamole.net.basic.BasicGuacamoleWebSocketTunnelServlet"
|
||||||
//"net.sourceforge.guacamole.net.basic.BasicGuacamoleWebSocketTunnelServlet"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Dynamically add servlet IF SERVLET 3.0 API AVAILABLE!
|
// Dynamically add servlet IF SERVLET 3.0 API AVAILABLE!
|
||||||
@@ -65,31 +73,36 @@ public class WebSocketSupportLoader implements ServletContextListener {
|
|||||||
|
|
||||||
// If we succesfully load and register the WebSocket tunnel servlet,
|
// If we succesfully load and register the WebSocket tunnel servlet,
|
||||||
// WebSocket is supported.
|
// WebSocket is supported.
|
||||||
System.err.println("WebSocket support found!");
|
logger.info("WebSocket support found and loaded.");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException e) {
|
|
||||||
// Servlet API 3.0 unsupported
|
// Servlet API 3.0 unsupported
|
||||||
System.err.println("Servlet API 3.0 not found.");
|
catch (ClassNotFoundException e) {
|
||||||
|
logger.error("Servlet API 3.0 not found.", e);
|
||||||
}
|
}
|
||||||
catch (NoSuchMethodException e) {
|
catch (NoSuchMethodException e) {
|
||||||
// Servlet API 3.0 unsupported
|
logger.error("Servlet API 3.0 found, but incomplete.", e);
|
||||||
System.err.println("Servlet API 3.0 not found.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Servlet API 3.0 found, but errors during use
|
||||||
catch (IllegalAccessException e) {
|
catch (IllegalAccessException e) {
|
||||||
|
logger.error("Unable to load WebSocket tunnel servlet.", e);
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException e) {
|
catch (InvocationTargetException e) {
|
||||||
|
logger.error("Internal error loading WebSocket tunnel servlet.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException e) {
|
|
||||||
|
|
||||||
// If no such servlet class, WebSocket support not present
|
// If no such servlet class, WebSocket support not present
|
||||||
System.err.println("WebSocket support not found.");
|
catch (ClassNotFoundException e) {
|
||||||
|
logger.info("WebSocket support not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log all GuacamoleExceptions
|
||||||
catch (GuacamoleException e) {
|
catch (GuacamoleException e) {
|
||||||
e.printStackTrace();
|
logger.error("Unable to load/detect WebSocket support.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user