diff options
author | James Moger <james.moger@gitblit.com> | 2013-12-11 23:12:12 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-12-11 23:12:12 -0500 |
commit | 65d5bb3f1cbfb42be5a3c4aa077b7ab2504082af (patch) | |
tree | 4d4c709c499c0ed46c237a7e2cb04dec28acdea2 /src/main/java/com/gitblit/servlet/DownloadZipServlet.java | |
parent | e55930b4a3c657eb71fad3aa3f2d276439fc4a8c (diff) | |
download | gitblit-65d5bb3f1cbfb42be5a3c4aa077b7ab2504082af.tar.gz gitblit-65d5bb3f1cbfb42be5a3c4aa077b7ab2504082af.zip |
Rollback to Servlet 2.5
Combining Dagger and Servlet 3 works really well on stock Tomcat and
Jetty but it is a troublesome combination on JEE containers with their
own ideas on how to instantiate classes. JBoss AS 7 has been
particularly nasty and it is just simpler to scaleback and stay with
Servlet 2.5 than it is to fight all permuations of containers.
Instead of using constructor DI, the servlets and filters each have an
inject(ObjectGaph) method which is automatically called during
initialization. Each servlet or filter is responsible for retrieving
the required dependency from the graph. The Dagger object graph is
created in the context listener and stuffed into the context as an
attribute.
Change-Id: Ib5714584fe73e2a6b9c6fda12af080a43356cbda
Diffstat (limited to 'src/main/java/com/gitblit/servlet/DownloadZipServlet.java')
-rw-r--r-- | src/main/java/com/gitblit/servlet/DownloadZipServlet.java | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/main/java/com/gitblit/servlet/DownloadZipServlet.java b/src/main/java/com/gitblit/servlet/DownloadZipServlet.java index 437a9c26..6a64778c 100644 --- a/src/main/java/com/gitblit/servlet/DownloadZipServlet.java +++ b/src/main/java/com/gitblit/servlet/DownloadZipServlet.java @@ -21,7 +21,6 @@ import java.text.ParseException; import java.util.Date;
import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jgit.lib.Repository;
@@ -32,13 +31,15 @@ import org.slf4j.LoggerFactory; import com.gitblit.Constants;
import com.gitblit.IStoredSettings;
import com.gitblit.Keys;
+import com.gitblit.dagger.DaggerServlet;
import com.gitblit.manager.IRepositoryManager;
-import com.gitblit.manager.IRuntimeManager;
import com.gitblit.utils.CompressionUtils;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.MarkdownUtils;
import com.gitblit.utils.StringUtils;
+import dagger.ObjectGraph;
+
/**
* Streams out a zip file from the specified repository for any tree path at any
* revision.
@@ -46,15 +47,15 @@ import com.gitblit.utils.StringUtils; * @author James Moger
*
*/
-public class DownloadZipServlet extends HttpServlet {
+public class DownloadZipServlet extends DaggerServlet {
private static final long serialVersionUID = 1L;
private transient Logger logger = LoggerFactory.getLogger(DownloadZipServlet.class);
- private final IStoredSettings settings;
+ private IStoredSettings settings;
- private final IRepositoryManager repositoryManager;
+ private IRepositoryManager repositoryManager;
public static enum Format {
zip(".zip"), tar(".tar"), gz(".tar.gz"), xz(".tar.xz"), bzip2(".tar.bzip2");
@@ -75,13 +76,10 @@ public class DownloadZipServlet extends HttpServlet { }
}
- public DownloadZipServlet(
- IRuntimeManager runtimeManager,
- IRepositoryManager repositoryManager) {
-
- super();
- this.settings = runtimeManager.getSettings();
- this.repositoryManager = repositoryManager;
+ @Override
+ protected void inject(ObjectGraph dagger) {
+ this.settings = dagger.get(IStoredSettings.class);
+ this.repositoryManager = dagger.get(IRepositoryManager.class);
}
/**
|