/*
 * Copyright 2014 gitblit.com.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.gitblit.plugin.cookbook;

import ro.fortsoft.pf4j.Extension;
import ro.fortsoft.pf4j.PluginWrapper;

import com.gitblit.extensions.GitblitPlugin;
import com.gitblit.models.UserModel;
import com.gitblit.transport.ssh.commands.CommandMetaData;
import com.gitblit.transport.ssh.commands.DispatchCommand;

public class Plugin extends GitblitPlugin {

  public Plugin(PluginWrapper wrapper) {
    super(wrapper);
  }

  @Override
  public void start() {
    // no op
  }

  @Override
  public void stop() {
    // no op
  }

  /**
   * You must register a dispatcher for your custom commands.  The dispatcher
   * must be annotated with CommandMetaData.  This annotation will assign the
   * plugin command namespace and offer a description.
   *
   */
  @Extension
  @CommandMetaData(name = "cookbook", description = "Example commands")
  public static class CookbookDispatcher extends DispatchCommand {
    @Override
    protected void setup(UserModel user) {
        register(user, HelloWorldCommand.class);
        register(user, StatusCommand.class);
    }
  }
}

@@ -700,16 +700,49 @@
 Wrapper;
+%0Aimport ro.fortsoft.pf4j.Version;
 %0A%0Aimport
@@ -981,18 +981,17 @@
 ugin %7B%0A%0A
-  
+%09
 public P
@@ -1021,20 +1021,18 @@
 pper) %7B%0A
-    
+%09%09
 super(wr
@@ -1039,23 +1039,21 @@
 apper);%0A
-  %7D%0A%0A  
+%09%7D%0A%0A%09
 @Overrid
@@ -1046,34 +1046,33 @@
 %0A%09%7D%0A%0A%09@Override%0A
-  
+%09
 public void star
@@ -1077,36 +1077,168 @@
 art() %7B%0A
-    // no op%0A  %7D%0A%0A  
+%09%09log.info(%22%7B%7D STARTED.%22, getWrapper().getPluginId());%0A%09%7D%0A%0A%09@Override%0A%09public void stop() %7B%0A%09%09log.info(%22%7B%7D STOPPED.%22, getWrapper().getPluginId());%0A%09%7D%0A%0A%09
 @Overrid
@@ -1239,18 +1239,17 @@
 verride%0A
-  
+%09
 public v
@@ -1256,43 +1256,329 @@
 oid 
-stop() %7B%0A    // no op%0A  %7D%0A%0A  
+onInstall() %7B%0A%09%09log.info(%22%7B%7D INSTALLED.%22, getWrapper().getPluginId());%0A%09%7D%0A%0A%09@Override%0A%09public void onUpgrade(Version oldVersion) %7B%0A%09%09log.info(%22%7B%7D UPGRADED from %7B%7D.%22, getWrapper().getPluginId(), oldVersion);%0A%09%7D%0A%0A%09@Override%0A%09public void onUninstall() %7B%0A%09%09log.info(%22%7B%7D UNINSTALLED.%22, getWrapper().getPluginId());%0A%09%7D%0A%0A%0A%09
 /**%0A
-  
+%09
  * Y
@@ -1632,17 +1632,16 @@
 ommands.
- 
  The dis
@@ -1648,18 +1648,17 @@
 patcher%0A
-  
+%09
  * must 
@@ -1691,17 +1691,16 @@
 etaData.
- 
  This an
@@ -1724,18 +1724,17 @@
 ign the%0A
-  
+%09
  * plugi
@@ -1782,21 +1782,18 @@
 on.%0A
-   *%0A  
+%09 *%0A%09
  */%0A
-  
+%09
 @Ext
@@ -1799,18 +1799,17 @@
 tension%0A
-  
+%09
 @Command
@@ -1870,18 +1870,17 @@
 mands%22)%0A
-  
+%09
 public s
@@ -1936,20 +1936,18 @@
 mmand %7B%0A
-    
+%09%09
 @Overrid
@@ -1948,20 +1948,18 @@
 verride%0A
-    
+%09%09
 protecte
@@ -1989,24 +1989,19 @@
 user) %7B%0A
-        
+%09%09%09
 register
@@ -2037,16 +2037,11 @@
 s);%0A
-        
+%09%09%09
 regi
@@ -2077,16 +2077,13 @@
 s);%0A
-    %7D%0A  
+%09%09%7D%0A%09
 %7D%0A%7D%0A

Update for plugin lifecycle methods