Version 1

    When developing components that integrates or extends GateIn features, it's good to understand how things fit together during the startup and shutdown of the container. At the top level, an ExoContainer is started, and looks for all classes implementing the Startable interface. Once all those classes are found, the constructors are then analyzed for the dependencies, and the components are instantiated. Once all the components are instantiated, the "start()" method is called in each of the discovered components, sequentially. The sequence is determined based on the dependencies of each component. Similarly, when shutting down, the reverse list of components is iterated over and the "stop()" method is called, also sequentially.

     

    At the time that the "stop()" method is called, the RepositoryContainer is already shutdown. So, if you need to perform any activity that might depend on the container being active, you'd need to implement a ContainerLifecyclePlugin, overriding the "stopContainer(ExoContainer)" method. On this method, you are able to query the container for your component and execute any methods that are required for the shutdown.

     

    A discussion about this behavior can be found on this thread: http://lists.jboss.org/pipermail/gatein-dev/2013-November/001999.html

    More information about the eXo Container can be found on the eXo JCR documentation page: eXo JCR documentation - JBoss Community

     

    The best way to understand how this works is to debug GateIn. Recommended places to put a breakpoint:

    https://github.com/exoplatform/kernel/blob/2.4.6-GA/exo.kernel.container/src/main/java/org/exoplatform/container/LifecycleVisitor.java#L95

     

    Sample component:

    https://github.com/gatein/gatein-portal/blob/3.6.3.Final/wsrp-integration/extension-component/src/main/java/org/gatein/i…