You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GitDispatcher.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2009 The Android Open Source Project
  3. * Copyright 2014 gitblit.com.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package com.gitblit.transport.ssh.git;
  18. import com.gitblit.git.GitblitReceivePackFactory;
  19. import com.gitblit.git.GitblitUploadPackFactory;
  20. import com.gitblit.git.RepositoryResolver;
  21. import com.gitblit.manager.IGitblit;
  22. import com.gitblit.transport.ssh.SshDaemonClient;
  23. import com.gitblit.transport.ssh.commands.BaseCommand;
  24. import com.gitblit.transport.ssh.commands.CommandMetaData;
  25. import com.gitblit.transport.ssh.commands.DispatchCommand;
  26. import com.gitblit.transport.ssh.commands.SshCommandContext;
  27. @CommandMetaData(name = "git", description="Git repository commands")
  28. public class GitDispatcher extends DispatchCommand {
  29. protected RepositoryResolver<SshDaemonClient> repositoryResolver;
  30. protected GitblitUploadPackFactory<SshDaemonClient> uploadPackFactory;
  31. protected GitblitReceivePackFactory<SshDaemonClient> receivePackFactory;
  32. @Override
  33. public void setContext(SshCommandContext context) {
  34. super.setContext(context);
  35. IGitblit gitblit = context.getGitblit();
  36. repositoryResolver = new RepositoryResolver<SshDaemonClient>(gitblit);
  37. uploadPackFactory = new GitblitUploadPackFactory<SshDaemonClient>(gitblit);
  38. receivePackFactory = new GitblitReceivePackFactory<SshDaemonClient>(gitblit);
  39. }
  40. @Override
  41. public void destroy() {
  42. super.destroy();
  43. repositoryResolver = null;
  44. receivePackFactory = null;
  45. uploadPackFactory = null;
  46. }
  47. @Override
  48. protected void setup() {
  49. register(Upload.class);
  50. register(Receive.class);
  51. register(GarbageCollectionCommand.class);
  52. }
  53. @Override
  54. protected void provideStateTo(final BaseCommand cmd) {
  55. super.provideStateTo(cmd);
  56. BaseGitCommand a = (BaseGitCommand) cmd;
  57. a.setRepositoryResolver(repositoryResolver);
  58. a.setUploadPackFactory(uploadPackFactory);
  59. a.setReceivePackFactory(receivePackFactory);
  60. }
  61. }