| | |
| | | |
| | | import javax.inject.Singleton; |
| | | |
| | | import org.apache.wicket.protocol.http.WebApplication; |
| | | |
| | | import com.gitblit.git.GitServlet; |
| | | import com.gitblit.manager.AuthenticationManager; |
| | | import com.gitblit.manager.FederationManager; |
| | | import com.gitblit.manager.IAuthenticationManager; |
| | | import com.gitblit.manager.IFederationManager; |
| | | import com.gitblit.manager.IGitblitManager; |
| | | import com.gitblit.manager.IGitblit; |
| | | import com.gitblit.manager.INotificationManager; |
| | | import com.gitblit.manager.IPluginManager; |
| | | 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.manager.NotificationManager; |
| | | import com.gitblit.manager.PluginManager; |
| | | import com.gitblit.manager.ProjectManager; |
| | | import com.gitblit.manager.RepositoryManager; |
| | | import com.gitblit.manager.RuntimeManager; |
| | | import com.gitblit.manager.SessionManager; |
| | | import com.gitblit.manager.UserManager; |
| | | import com.gitblit.transport.ssh.FileKeyManager; |
| | | import com.gitblit.transport.ssh.IPublicKeyManager; |
| | | import com.gitblit.transport.ssh.MemoryKeyManager; |
| | | import com.gitblit.transport.ssh.NullKeyManager; |
| | | import com.gitblit.utils.StringUtils; |
| | | import com.gitblit.wicket.GitBlitWebApp; |
| | | import com.gitblit.wicket.GitblitWicketFilter; |
| | | |
| | | import dagger.Module; |
| | | import dagger.Provides; |
| | |
| | | * |
| | | */ |
| | | @Module( |
| | | library = true, |
| | | injects = { |
| | | IStoredSettings.class, |
| | | |
| | | // core managers |
| | | IRuntimeManager.class, |
| | | IPluginManager.class, |
| | | INotificationManager.class, |
| | | IUserManager.class, |
| | | ISessionManager.class, |
| | | IAuthenticationManager.class, |
| | | IPublicKeyManager.class, |
| | | IRepositoryManager.class, |
| | | IProjectManager.class, |
| | | IGitblitManager.class, |
| | | IFederationManager.class, |
| | | |
| | | // the monolithic manager |
| | | Gitblit.class, |
| | | IGitblit.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 |
| | | } |
| | | // the Gitblit Wicket app |
| | | GitBlitWebApp.class |
| | | } |
| | | ) |
| | | public class DaggerModule { |
| | | |
| | | final GitBlit gitblit; |
| | | |
| | | // HACK but necessary for now |
| | | public DaggerModule(GitBlit gitblit) { |
| | | this.gitblit = gitblit; |
| | | } |
| | | |
| | | @Provides @Singleton IStoredSettings provideSettings() { |
| | | return new FileSettings(); |
| | |
| | | |
| | | @Provides @Singleton IRuntimeManager provideRuntimeManager(IStoredSettings settings) { |
| | | return new RuntimeManager(settings); |
| | | } |
| | | |
| | | @Provides @Singleton IPluginManager providePluginManager(IRuntimeManager runtimeManager) { |
| | | return new PluginManager(runtimeManager); |
| | | } |
| | | |
| | | @Provides @Singleton INotificationManager provideNotificationManager(IStoredSettings settings) { |
| | |
| | | return new UserManager(runtimeManager); |
| | | } |
| | | |
| | | @Provides @Singleton ISessionManager provideSessionManager( |
| | | @Provides @Singleton IAuthenticationManager provideAuthenticationManager( |
| | | IRuntimeManager runtimeManager, |
| | | IUserManager userManager) { |
| | | |
| | | return new SessionManager( |
| | | return new AuthenticationManager( |
| | | runtimeManager, |
| | | userManager); |
| | | } |
| | | |
| | | @Provides @Singleton IPublicKeyManager providePublicKeyManager( |
| | | IStoredSettings settings, |
| | | IRuntimeManager runtimeManager) { |
| | | |
| | | String clazz = settings.getString(Keys.git.sshKeysManager, FileKeyManager.class.getName()); |
| | | if (StringUtils.isEmpty(clazz)) { |
| | | clazz = FileKeyManager.class.getName(); |
| | | } |
| | | if (FileKeyManager.class.getName().equals(clazz)) { |
| | | return new FileKeyManager(runtimeManager); |
| | | } else if (NullKeyManager.class.getName().equals(clazz)) { |
| | | return new NullKeyManager(); |
| | | } else if (MemoryKeyManager.class.getName().equals(clazz)) { |
| | | return new MemoryKeyManager(); |
| | | } else { |
| | | try { |
| | | Class<?> mgrClass = Class.forName(clazz); |
| | | return (IPublicKeyManager) mgrClass.newInstance(); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Provides @Singleton IRepositoryManager provideRepositoryManager( |
| | |
| | | userManager); |
| | | } |
| | | |
| | | @Provides @Singleton IProjectManager provideProjectManager() { |
| | | return gitblit; |
| | | @Provides @Singleton IProjectManager provideProjectManager( |
| | | IRuntimeManager runtimeManager, |
| | | IUserManager userManager, |
| | | IRepositoryManager repositoryManager) { |
| | | |
| | | return new ProjectManager( |
| | | runtimeManager, |
| | | userManager, |
| | | repositoryManager); |
| | | } |
| | | |
| | | @Provides @Singleton IGitblitManager provideGitblitManager() { |
| | | return gitblit; |
| | | } |
| | | |
| | | @Provides @Singleton IFederationManager provideFederationManager() { |
| | | return gitblit; |
| | | } |
| | | |
| | | @Provides @Singleton Gitblit provideGitblit( |
| | | @Provides @Singleton IFederationManager provideFederationManager( |
| | | IRuntimeManager runtimeManager, |
| | | INotificationManager notificationManager, |
| | | IUserManager userManager, |
| | | ISessionManager sessionManager, |
| | | IRepositoryManager repositoryManager, |
| | | IProjectManager projectManager, |
| | | IGitblitManager gitblitManager, |
| | | IFederationManager federationManager) { |
| | | IRepositoryManager repositoryManager) { |
| | | |
| | | return new Gitblit( |
| | | return new FederationManager( |
| | | runtimeManager, |
| | | notificationManager, |
| | | userManager, |
| | | sessionManager, |
| | | repositoryManager, |
| | | projectManager, |
| | | federationManager, |
| | | gitblitManager); |
| | | repositoryManager); |
| | | } |
| | | |
| | | @Provides @Singleton WebApplication provideWebApplication( |
| | | @Provides @Singleton IGitblit provideGitblit( |
| | | IRuntimeManager runtimeManager, |
| | | IPluginManager pluginManager, |
| | | INotificationManager notificationManager, |
| | | IUserManager userManager, |
| | | IAuthenticationManager authenticationManager, |
| | | IPublicKeyManager publicKeyManager, |
| | | IRepositoryManager repositoryManager, |
| | | IProjectManager projectManager, |
| | | IFederationManager federationManager) { |
| | | |
| | | return new GitBlit( |
| | | runtimeManager, |
| | | pluginManager, |
| | | notificationManager, |
| | | userManager, |
| | | authenticationManager, |
| | | publicKeyManager, |
| | | repositoryManager, |
| | | projectManager, |
| | | federationManager); |
| | | } |
| | | |
| | | @Provides @Singleton GitBlitWebApp provideWebApplication( |
| | | IRuntimeManager runtimeManager, |
| | | INotificationManager notificationManager, |
| | | IUserManager userManager, |
| | | ISessionManager sessionManager, |
| | | IAuthenticationManager authenticationManager, |
| | | IPublicKeyManager publicKeyManager, |
| | | IRepositoryManager repositoryManager, |
| | | IProjectManager projectManager, |
| | | IGitblitManager gitblitManager, |
| | | IFederationManager federationManager) { |
| | | IFederationManager federationManager, |
| | | IGitblit gitblit) { |
| | | |
| | | return new GitBlitWebApp( |
| | | runtimeManager, |
| | | notificationManager, |
| | | userManager, |
| | | sessionManager, |
| | | authenticationManager, |
| | | publicKeyManager, |
| | | repositoryManager, |
| | | projectManager, |
| | | gitblitManager, |
| | | federationManager); |
| | | federationManager, |
| | | gitblit); |
| | | } |
| | | } |