Merged #79 "Add startup/shutdown lifecycle extension point"
1 files added
3 files modified
| | |
| | | - Fix failure to generate SSH server keys on ARM (issue-426, ticket-70) |
| | | - Fix flotr2 chart generation failure if a label contained a single-quote (ticket-77) |
| | | changes: |
| | | - Added extension points for top nav links, root-level pages, repository nav links, user menu links, and http request filters (ticket-23) |
| | | - Split the pages servlet into a raw servlet and a pages servlet. All raw links now use the raw servlet (issue-413, ticket-49) |
| | | - Drop deprecated --set-upstream syntax for -u (ticket-59) |
| | | - BARNUM: Prune deleted branches on fetch (git fetch -p) (ticket-60) |
| | |
| | | - Add My Tickets page (issue-215, ticket-15) |
| | | - Added CRUD functionality for Ticket Milestones (ticket-17) |
| | | - Implemented Ticket migration tool to move between backends (ticket-19) |
| | | - Added extension points for top nav links, root-level pages, repository nav links, user menu links, and http request filters (ticket-23) |
| | | - Add FORK_REPOSITORY RPC request type (issue-371, pr-161, ticket-65) |
| | | - Add object type (ot) parameter for RSS queries to retrieve tag details (pr-165, ticket-66) |
| | | - Add setting to allow STARTTLS without requiring SMTPS (pr-183) |
| | | - Added an extension point for monitoring onStartup and onShutdown (ticket-79) |
| | | dependencyChanges: |
| | | - Update to javax.mail 1.5.1 (issue-417, ticket-58) |
| | | contributors: |
New file |
| | |
| | | /* |
| | | * 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.extensions; |
| | | |
| | | import ro.fortsoft.pf4j.ExtensionPoint; |
| | | |
| | | /** |
| | | * Extension point to allow plugins to listen to major Gitblit lifecycle events. |
| | | * |
| | | * @author James Moger |
| | | * @since 1.6.0 |
| | | */ |
| | | public abstract class LifeCycleListener implements ExtensionPoint { |
| | | |
| | | /** |
| | | * Called after all internal managers have been started. |
| | | * This may be useful for reporting "server is ready" to a monitoring system. |
| | | * |
| | | * @since 1.6.0 |
| | | */ |
| | | public abstract void onStartup(); |
| | | |
| | | /** |
| | | * Called when the servlet container is gracefully shutting-down the webapp. |
| | | * This is called before the internal managers are stopped. |
| | | * |
| | | * @since 1.6.0 |
| | | */ |
| | | public abstract void onShutdown(); |
| | | } |
| | |
| | | import com.gitblit.Keys; |
| | | import com.gitblit.WebXmlSettings; |
| | | import com.gitblit.dagger.DaggerContext; |
| | | import com.gitblit.extensions.LifeCycleListener; |
| | | import com.gitblit.manager.IAuthenticationManager; |
| | | import com.gitblit.manager.IFederationManager; |
| | | import com.gitblit.manager.IGitblit; |
| | |
| | | logger.info(""); |
| | | logger.info("All managers started."); |
| | | logger.info(""); |
| | | |
| | | IPluginManager pluginManager = injector.get(IPluginManager.class); |
| | | for (LifeCycleListener listener : pluginManager.getExtensions(LifeCycleListener.class)) { |
| | | try { |
| | | listener.onStartup(); |
| | | } catch (Throwable t) { |
| | | logger.error(null, t); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private String lookupBaseFolderFromJndi() { |
| | |
| | | @Override |
| | | protected void destroyContext(ServletContext context) { |
| | | logger.info("Gitblit context destroyed by servlet container."); |
| | | |
| | | IPluginManager pluginManager = getManager(IPluginManager.class); |
| | | for (LifeCycleListener listener : pluginManager.getExtensions(LifeCycleListener.class)) { |
| | | try { |
| | | listener.onShutdown(); |
| | | } catch (Throwable t) { |
| | | logger.error(null, t); |
| | | } |
| | | } |
| | | |
| | | for (IManager manager : managers) { |
| | | logger.debug("stopping {}", manager.getClass().getSimpleName()); |
| | | manager.stop(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * You can also create Webapp plugins that register mounted pages. |
| | | * You can also create Webapp plugins that register pages. |
| | | */ |
| | | public class ExampleWicketPlugin extends GitblitWicketPlugin { |
| | | @Override |
| | |
| | | } |
| | | } |
| | | ``` |
| | | |
| | | ### Lifecycle Listener |
| | | |
| | | *SINCE 1.6.0* |
| | | |
| | | You can provide a lifecycle listener to be notified when Gitblit has completely started and just before Gitblit is gracefully terminated. |
| | | |
| | | ```java |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import ro.fortsoft.pf4j.Extension; |
| | | import com.gitblit.extensions.LifeCycleListener; |
| | | |
| | | @Extension |
| | | public class MyLifeCycleListener extends LifeCycleListener { |
| | | |
| | | final Logger log = LoggerFactory.getLogger(getClass()); |
| | | |
| | | @Override |
| | | public void onStartup() { |
| | | log.info("Gitblit is Ready!!"); |
| | | } |
| | | |
| | | @Override |
| | | public void onShutdown() { |
| | | log.info("Gitblit is Going Down!!"); |
| | | } |
| | | } |
| | | ``` |