From db4f6b5740c6ea45d9e2209dc569bc18904a8b4d Mon Sep 17 00:00:00 2001 From: James Moger Date: Sun, 17 Nov 2013 16:15:24 -0500 Subject: Define manager interfaces and update all of Gitblit to use managers These manager interfaces define how the GitBlit singleton will eventually be split into smaller component managers. The Wicket app and all servlets have been updated to request the needed managers. There are _very_ few method signature changes - although there are a handful. This is a surgical sharding of responsibility based on a proof of concept refactor. Instead of random references to GittBlit.self() there are now precise references to the manager interface required to accomplish some task. Some tasks may require references to multiple managers. The code is now littered with calls to GitBlit.getManager(class) and those familiar with the code-base will no doubt notice the duplication of methods from IUserService in IUserManager and the addition of implementation methods in the GitBlit context class. When the GitBlit class is broken apart and the existing external authentication user service classes are refactored to AuthenticationService classes, this will again simplify and flatten. But in order to safely and cleanly modularize the stable code-base we will have to live with a little duplication for a short while. Change-Id: I7314ec8acaab2dcc6092785ed4434cc09fdbbe16 --- src/main/java/com/gitblit/LogoServlet.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/gitblit/LogoServlet.java') diff --git a/src/main/java/com/gitblit/LogoServlet.java b/src/main/java/com/gitblit/LogoServlet.java index eb167e72..4222f8ff 100644 --- a/src/main/java/com/gitblit/LogoServlet.java +++ b/src/main/java/com/gitblit/LogoServlet.java @@ -27,6 +27,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.gitblit.manager.IRuntimeManager; + /** * Handles requests for logo.png * @@ -45,7 +47,8 @@ public class LogoServlet extends HttpServlet { @Override protected long getLastModified(HttpServletRequest req) { - File file = GitBlit.getFileOrFolder(Keys.web.headerLogo, "${baseFolder}/logo.png"); + IRuntimeManager runtimeManager = GitBlit.getManager(IRuntimeManager.class); + File file = runtimeManager.getFileOrFolder(Keys.web.headerLogo, "${baseFolder}/logo.png"); if (file.exists()) { return Math.max(lastModified, file.lastModified()); } else { @@ -59,7 +62,8 @@ public class LogoServlet extends HttpServlet { InputStream is = null; try { String contentType = null; - File file = GitBlit.getFileOrFolder(Keys.web.headerLogo, "${baseFolder}/logo.png"); + IRuntimeManager runtimeManager = GitBlit.getManager(IRuntimeManager.class); + File file = runtimeManager.getFileOrFolder(Keys.web.headerLogo, "${baseFolder}/logo.png"); if (file.exists()) { // custom logo ServletContext context = request.getSession().getServletContext(); @@ -88,7 +92,7 @@ public class LogoServlet extends HttpServlet { } catch (Exception e) { e.printStackTrace(); } finally { - if(is != null) { + if (is != null) { is.close(); } } -- cgit v1.2.3