commit | author | age
|
cacf8b
|
1 |
/* |
JM |
2 |
* Copyright 2013 gitblit.com. |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
16 |
package com.gitblit; |
|
17 |
|
|
18 |
import javax.inject.Singleton; |
|
19 |
|
|
20 |
import org.apache.wicket.protocol.http.WebApplication; |
|
21 |
|
|
22 |
import com.gitblit.git.GitServlet; |
|
23 |
import com.gitblit.manager.IFederationManager; |
|
24 |
import com.gitblit.manager.IGitblitManager; |
|
25 |
import com.gitblit.manager.INotificationManager; |
|
26 |
import com.gitblit.manager.IProjectManager; |
|
27 |
import com.gitblit.manager.IRepositoryManager; |
|
28 |
import com.gitblit.manager.IRuntimeManager; |
|
29 |
import com.gitblit.manager.ISessionManager; |
|
30 |
import com.gitblit.manager.IUserManager; |
bdfdc9
|
31 |
import com.gitblit.manager.NotificationManager; |
e24670
|
32 |
import com.gitblit.manager.RuntimeManager; |
8f1c9f
|
33 |
import com.gitblit.manager.UserManager; |
cacf8b
|
34 |
import com.gitblit.wicket.GitBlitWebApp; |
JM |
35 |
import com.gitblit.wicket.GitblitWicketFilter; |
|
36 |
|
|
37 |
import dagger.Module; |
|
38 |
import dagger.Provides; |
|
39 |
|
|
40 |
/** |
|
41 |
* DaggerModule references all injectable objects. |
|
42 |
* |
|
43 |
* @author James Moger |
|
44 |
* |
|
45 |
*/ |
|
46 |
@Module( |
|
47 |
injects = { |
e24670
|
48 |
IStoredSettings.class, |
JM |
49 |
|
cacf8b
|
50 |
// core managers |
JM |
51 |
IRuntimeManager.class, |
|
52 |
INotificationManager.class, |
|
53 |
IUserManager.class, |
|
54 |
ISessionManager.class, |
|
55 |
IRepositoryManager.class, |
|
56 |
IProjectManager.class, |
|
57 |
IGitblitManager.class, |
|
58 |
IFederationManager.class, |
|
59 |
|
325396
|
60 |
// the monolithic manager |
JM |
61 |
Gitblit.class, |
|
62 |
|
cacf8b
|
63 |
// filters & servlets |
JM |
64 |
GitServlet.class, |
|
65 |
GitFilter.class, |
|
66 |
PagesServlet.class, |
|
67 |
PagesFilter.class, |
|
68 |
RpcServlet.class, |
|
69 |
RpcFilter.class, |
|
70 |
DownloadZipServlet.class, |
|
71 |
DownloadZipFilter.class, |
|
72 |
SyndicationServlet.class, |
|
73 |
SyndicationFilter.class, |
|
74 |
FederationServlet.class, |
|
75 |
SparkleShareInviteServlet.class, |
|
76 |
BranchGraphServlet.class, |
|
77 |
RobotsTxtServlet.class, |
|
78 |
LogoServlet.class, |
|
79 |
EnforceAuthenticationFilter.class, |
|
80 |
GitblitWicketFilter.class |
|
81 |
} |
|
82 |
) |
|
83 |
public class DaggerModule { |
|
84 |
|
|
85 |
final GitBlit gitblit; |
|
86 |
|
|
87 |
// HACK but necessary for now |
|
88 |
public DaggerModule(GitBlit gitblit) { |
|
89 |
this.gitblit = gitblit; |
|
90 |
} |
|
91 |
|
e24670
|
92 |
@Provides @Singleton IStoredSettings provideSettings() { |
JM |
93 |
return new FileSettings(); |
|
94 |
} |
|
95 |
|
|
96 |
@Provides @Singleton IRuntimeManager provideRuntimeManager(IStoredSettings settings) { |
|
97 |
return new RuntimeManager(settings); |
cacf8b
|
98 |
} |
JM |
99 |
|
bdfdc9
|
100 |
@Provides @Singleton INotificationManager provideNotificationManager(IStoredSettings settings) { |
JM |
101 |
return new NotificationManager(settings); |
cacf8b
|
102 |
} |
JM |
103 |
|
8f1c9f
|
104 |
@Provides @Singleton IUserManager provideUserManager(IRuntimeManager runtimeManager) { |
JM |
105 |
return new UserManager(runtimeManager); |
cacf8b
|
106 |
} |
JM |
107 |
|
|
108 |
@Provides @Singleton ISessionManager provideSessionManager() { |
|
109 |
return gitblit; |
|
110 |
} |
|
111 |
|
|
112 |
@Provides @Singleton IRepositoryManager provideRepositoryManager() { |
|
113 |
return gitblit; |
|
114 |
} |
|
115 |
|
|
116 |
@Provides @Singleton IProjectManager provideProjectManager() { |
|
117 |
return gitblit; |
|
118 |
} |
|
119 |
|
|
120 |
@Provides @Singleton IGitblitManager provideGitblitManager() { |
|
121 |
return gitblit; |
|
122 |
} |
|
123 |
|
|
124 |
@Provides @Singleton IFederationManager provideFederationManager() { |
|
125 |
return gitblit; |
|
126 |
} |
|
127 |
|
325396
|
128 |
@Provides @Singleton Gitblit provideGitblit( |
JM |
129 |
IRuntimeManager runtimeManager, |
|
130 |
INotificationManager notificationManager, |
|
131 |
IUserManager userManager, |
|
132 |
ISessionManager sessionManager, |
|
133 |
IRepositoryManager repositoryManager, |
|
134 |
IProjectManager projectManager, |
|
135 |
IGitblitManager gitblitManager, |
|
136 |
IFederationManager federationManager) { |
|
137 |
|
|
138 |
return new Gitblit( |
|
139 |
runtimeManager, |
|
140 |
notificationManager, |
|
141 |
userManager, |
|
142 |
sessionManager, |
|
143 |
repositoryManager, |
|
144 |
projectManager, |
|
145 |
federationManager, |
|
146 |
gitblitManager); |
|
147 |
} |
|
148 |
|
cacf8b
|
149 |
@Provides @Singleton WebApplication provideWebApplication( |
JM |
150 |
IRuntimeManager runtimeManager, |
|
151 |
INotificationManager notificationManager, |
|
152 |
IUserManager userManager, |
|
153 |
ISessionManager sessionManager, |
|
154 |
IRepositoryManager repositoryManager, |
|
155 |
IProjectManager projectManager, |
|
156 |
IGitblitManager gitblitManager, |
|
157 |
IFederationManager federationManager) { |
|
158 |
|
|
159 |
return new GitBlitWebApp( |
|
160 |
runtimeManager, |
|
161 |
notificationManager, |
|
162 |
userManager, |
|
163 |
sessionManager, |
|
164 |
repositoryManager, |
|
165 |
projectManager, |
|
166 |
gitblitManager, |
|
167 |
federationManager); |
|
168 |
} |
|
169 |
} |