From a21f5345df87af6fa54142a1a36404b75217f060 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Thu, 17 Apr 2014 23:08:07 -0400 Subject: [PATCH] [findbugs] Change scope of variable in HistoryPanel --- src/site/plugins_extensions.mkd | 78 +++++++++++++++++++++++++++++++++++++- 1 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/site/plugins_extensions.mkd b/src/site/plugins_extensions.mkd index d7469ac..86d0729 100644 --- a/src/site/plugins_extensions.mkd +++ b/src/site/plugins_extensions.mkd @@ -2,20 +2,73 @@ Gitblit offers several extension points for enhancing and customizing it's runtime behavior. -Each available extension point has a sample implementation in the [gitblit-cookbook-plugin (Maven project)](https://dev.gitblit.com/summary/gitblit-cookbook-plugin.git). +Each available extension point has a sample implementation in the [gitblit-cookbook-plugin (Maven project)](https://github.com/gitblit/gitblit-cookbook-plugin). + +**NOTE:** +Gitblit does not yet offer a comprehensize dependency injection architecture. This will be addressed in a subsequent release. For now you may access all of Gitblit's core managers through a static singleton app context: + +```java +import com.gitblit.extensions.GitblitPlugin; +import com.gitblit.servlet.GitblitContext; +import com.gitblit.manager.IRuntimeManager; +import com.gitblit.manager.IUserManager; +import com.gitblit.manager.IAuthenticationManager; +import com.gitblit.manager.INotificationManager; +import com.gitblit.manager.IRepositoryManager; +import com.gitblit.manager.IProjectManager; +import com.gitblit.manager.IFederationManager; +import com.gitblit.manager.IPluginManager; +import com.gitblit.manager.IGitblit; +import ro.fortsoft.pf4j.Version; + +public class ExamplePlugin extends GitblitPlugin { + + @Override + public void start() { + IRuntimeManager runtime = GitblitContext.getManager(IRuntimeManager.class); + IUserManager users = GitblitContext.getManager(IUserManager.class); + IAuthenticationManager auth = GitblitContext.getManager(IAuthenticationManager.class); + INotificationManager notifications = GitblitContext.getManager(INotificationManager.class); + IRepositoryManager repos = GitblitContext.getManager(IRepositoryManager.class); + IProjectManager projects = GitblitContext.getManager(IProjectManager.class); + IFederationManager federation = GitblitContext.getManager(IFederationManager.class); + IPluginManager plugins = GitblitContext.getManager(IPluginManager.class); + IGitblit gitblit = GitblitContext.getManager(IGitblit.class); + } + + @Override + public void stop() { + } + + @Override + public void onInstall() { + } + + @Override + public void onUpgrade(Version oldVersion) { + } + + @Override + public void onUninstall() { + } +} +``` ### SSH Dispatch Command *SINCE 1.5.0* -You can provide your own custom SSH commands by subclassing the *DispatchCommand* class. +You can provide your own custom SSH command hierarchies by subclassing the *DispatchCommand* class. ```java import ro.fortsoft.pf4j.Extension; - +import org.kohsuke.args4j.Option; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.gitblit.models.UserModel; import com.gitblit.transport.ssh.commands.CommandMetaData; import com.gitblit.transport.ssh.commands.DispatchCommand; +import com.gitblit.transport.ssh.commands.UsageExample; @Extension @CommandMetaData(name = "mycommands", description = "Sample SSH dispatcher") @@ -31,6 +84,25 @@ register(user, SubDispatcher1.class); register(user, SubDispatcher2.class); } + + @CommandMetaData(name = "commanda", aliases = { "ca" }, description = "description of command a") + @UsageExample(syntax = "${cmd} --myflag", description = "description of commanda with --myflag") + public static class CommandA extends SshCommand { + + protected final Logger log = LoggerFactory.getLogger(getClass()); + + @Option(name = "--myflag", aliases = { "-m" }, usage = "enable myflag") + boolean myflag; + + @Override + public void run() throws Failure { + if (myflag) { + log.info("Run with --myflag"); + } else { + log.info("Run without --myflag"); + } + } + } } ``` -- Gitblit v1.9.1