summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/DaggerModule.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-11-18 22:31:37 -0500
committerJames Moger <james.moger@gitblit.com>2013-11-29 11:05:46 -0500
commitcacf8bff097fbb66a7be1bfe267b5da2605145f8 (patch)
tree7096df41b5944c569b1db24203eae8dcfa26ba04 /src/main/java/com/gitblit/DaggerModule.java
parent79cad53bba094cffa1d25581edbf4972a5158cd4 (diff)
downloadgitblit-cacf8bff097fbb66a7be1bfe267b5da2605145f8.tar.gz
gitblit-cacf8bff097fbb66a7be1bfe267b5da2605145f8.zip
Use Dagger to inject managers into all filters and servlets
Change-Id: I9bb2cc0cbfac9841b13bed15a474fefb24355cd4
Diffstat (limited to 'src/main/java/com/gitblit/DaggerModule.java')
-rw-r--r--src/main/java/com/gitblit/DaggerModule.java136
1 files changed, 136 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/DaggerModule.java b/src/main/java/com/gitblit/DaggerModule.java
new file mode 100644
index 00000000..7ee8ecd6
--- /dev/null
+++ b/src/main/java/com/gitblit/DaggerModule.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2013 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit;
+
+import javax.inject.Singleton;
+
+import org.apache.wicket.protocol.http.WebApplication;
+
+import com.gitblit.git.GitServlet;
+import com.gitblit.manager.IFederationManager;
+import com.gitblit.manager.IGitblitManager;
+import com.gitblit.manager.INotificationManager;
+import com.gitblit.manager.IProjectManager;
+import com.gitblit.manager.IRepositoryManager;
+import com.gitblit.manager.IRuntimeManager;
+import com.gitblit.manager.ISessionManager;
+import com.gitblit.manager.IUserManager;
+import com.gitblit.wicket.GitBlitWebApp;
+import com.gitblit.wicket.GitblitWicketFilter;
+
+import dagger.Module;
+import dagger.Provides;
+
+/**
+ * DaggerModule references all injectable objects.
+ *
+ * @author James Moger
+ *
+ */
+@Module(
+ injects = {
+ // core managers
+ IRuntimeManager.class,
+ INotificationManager.class,
+ IUserManager.class,
+ ISessionManager.class,
+ IRepositoryManager.class,
+ IProjectManager.class,
+ IGitblitManager.class,
+ IFederationManager.class,
+
+ // filters & servlets
+ GitServlet.class,
+ GitFilter.class,
+ PagesServlet.class,
+ PagesFilter.class,
+ RpcServlet.class,
+ RpcFilter.class,
+ DownloadZipServlet.class,
+ DownloadZipFilter.class,
+ SyndicationServlet.class,
+ SyndicationFilter.class,
+ FederationServlet.class,
+ SparkleShareInviteServlet.class,
+ BranchGraphServlet.class,
+ RobotsTxtServlet.class,
+ LogoServlet.class,
+ EnforceAuthenticationFilter.class,
+ GitblitWicketFilter.class
+ }
+)
+public class DaggerModule {
+
+ final GitBlit gitblit;
+
+ // HACK but necessary for now
+ public DaggerModule(GitBlit gitblit) {
+ this.gitblit = gitblit;
+ }
+
+ @Provides @Singleton IRuntimeManager provideRuntimeManager() {
+ return gitblit;
+ }
+
+ @Provides @Singleton INotificationManager provideNotificationManager() {
+ return gitblit;
+ }
+
+ @Provides @Singleton IUserManager provideUserManager() {
+ return gitblit;
+ }
+
+ @Provides @Singleton ISessionManager provideSessionManager() {
+ return gitblit;
+ }
+
+ @Provides @Singleton IRepositoryManager provideRepositoryManager() {
+ return gitblit;
+ }
+
+ @Provides @Singleton IProjectManager provideProjectManager() {
+ return gitblit;
+ }
+
+ @Provides @Singleton IGitblitManager provideGitblitManager() {
+ return gitblit;
+ }
+
+ @Provides @Singleton IFederationManager provideFederationManager() {
+ return gitblit;
+ }
+
+ @Provides @Singleton WebApplication provideWebApplication(
+ IRuntimeManager runtimeManager,
+ INotificationManager notificationManager,
+ IUserManager userManager,
+ ISessionManager sessionManager,
+ IRepositoryManager repositoryManager,
+ IProjectManager projectManager,
+ IGitblitManager gitblitManager,
+ IFederationManager federationManager) {
+
+ return new GitBlitWebApp(
+ runtimeManager,
+ notificationManager,
+ userManager,
+ sessionManager,
+ repositoryManager,
+ projectManager,
+ gitblitManager,
+ federationManager);
+ }
+} \ No newline at end of file