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.

RootDispatcher.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2014 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.transport.ssh.commands;
  17. import java.util.List;
  18. import org.slf4j.Logger;
  19. import org.slf4j.LoggerFactory;
  20. import ro.fortsoft.pf4j.PluginWrapper;
  21. import com.gitblit.manager.IGitblit;
  22. import com.gitblit.transport.ssh.SshDaemonClient;
  23. import com.gitblit.transport.ssh.git.GitDispatcher;
  24. import com.gitblit.transport.ssh.keys.KeysDispatcher;
  25. import com.gitblit.utils.WorkQueue;
  26. /**
  27. * The root dispatcher is the dispatch command that handles registering all
  28. * other commands.
  29. *
  30. */
  31. @CommandMetaData(name = "")
  32. class RootDispatcher extends DispatchCommand {
  33. private Logger log = LoggerFactory.getLogger(getClass());
  34. public RootDispatcher(IGitblit gitblit, SshDaemonClient client, String cmdLine, WorkQueue workQueue) {
  35. super();
  36. setContext(new SshCommandContext(gitblit, client, cmdLine));
  37. setWorkQueue(workQueue);
  38. register(VersionCommand.class);
  39. register(GitDispatcher.class);
  40. register(KeysDispatcher.class);
  41. register(PluginDispatcher.class);
  42. List<DispatchCommand> exts = gitblit.getExtensions(DispatchCommand.class);
  43. for (DispatchCommand ext : exts) {
  44. Class<? extends DispatchCommand> extClass = ext.getClass();
  45. PluginWrapper wrapper = gitblit.whichPlugin(extClass);
  46. String plugin = wrapper.getDescriptor().getPluginId();
  47. CommandMetaData meta = extClass.getAnnotation(CommandMetaData.class);
  48. log.debug("Dispatcher {} is loaded from plugin {}", meta.name(), plugin);
  49. register(ext);
  50. }
  51. }
  52. @Override
  53. protected final void setup() {
  54. }
  55. }