mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
improve utils
This commit is contained in:
@@ -24,6 +24,10 @@ import sonia.scm.web.ScmWebPluginContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
@@ -62,6 +66,7 @@ public class ContextListener extends GuiceServletContextListener
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent servletContextEvent)
|
||||
{
|
||||
enableDebugLogging();
|
||||
webPluginContext =
|
||||
new ScmWebPluginContext(servletContextEvent.getServletContext());
|
||||
|
||||
@@ -100,6 +105,24 @@ public class ContextListener extends GuiceServletContextListener
|
||||
return Guice.createInjector(modules);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
private void enableDebugLogging()
|
||||
{
|
||||
Logger logger = LogManager.getLogManager().getLogger("");
|
||||
|
||||
logger.setLevel(Level.FINEST);
|
||||
|
||||
ConsoleHandler handler = new ConsoleHandler();
|
||||
|
||||
handler.setLevel(Level.FINEST);
|
||||
logger.addHandler(handler);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
@@ -9,7 +9,7 @@ package sonia.scm.plugin;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.util.Util;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -82,7 +82,7 @@ public abstract class AbstractResourceServlet extends HttpServlet
|
||||
}
|
||||
finally
|
||||
{
|
||||
Util.close(output);
|
||||
IOUtil.close(output);
|
||||
}
|
||||
|
||||
this.content = output.toByteArray();
|
||||
@@ -164,7 +164,7 @@ public abstract class AbstractResourceServlet extends HttpServlet
|
||||
}
|
||||
finally
|
||||
{
|
||||
Util.close(output);
|
||||
IOUtil.close(output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,20 +12,18 @@ package sonia.scm.plugin;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import sonia.scm.util.IOUtil;
|
||||
import sonia.scm.util.Util;
|
||||
import sonia.scm.web.ScmWebPlugin;
|
||||
import sonia.scm.web.ScmWebPluginContext;
|
||||
import sonia.scm.web.WebResource;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
@@ -109,11 +107,11 @@ public class ScriptResourceServlet extends AbstractResourceServlet
|
||||
{
|
||||
try
|
||||
{
|
||||
Util.copy(input, stream);
|
||||
IOUtil.copy(input, stream);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Util.close(input);
|
||||
IOUtil.close(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user