View Javadoc

1   /**
2    *
3    * Copyright 2005 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  package org.apache.geronimo.kernel.config;
18  
19  import org.apache.geronimo.kernel.repository.Artifact;
20  
21  /**
22   * This interface can be used to monitor the progress of an operation on the
23   * configuration manager.  Typically, the monitor will receive a number of
24   * calls to addConfiguration as the configuration manager decides which
25   * configurations will be effected by the operations.  This is followed by a
26   * call to loading, starting, stopping or unloading and then a call to
27   * succeeded or failed for each configuration added.
28   *
29   *
30   * The one notable exception to this is the load operation which calls
31   * addConfiguration and and immediately follows it with a reading and then
32   * succeeded or failed.  This is because the load operation needs to read each
33   * configuration to determine which additional configurations will need to be
34   * loaded.
35   *
36   * When an operation fails, the failed method is called with the cause.  The
37   * configuration manager normally will follow the failure with compensating
38   * actions to bring the server back to the original state.  For example, if it
39   * loaded a configuration, it will unload it.  Each of the compensating
40   * actions will cause events to be fired.
41   *
42   * When the, operation is completed, the finished method will be called.  This
43   *  should be called event if the operation ultimately fails and throws an
44   * exception.  It is recommended that you do not rely the finished method to
45   * be called in the case of an Exception as there are cases that will cause
46   * the configuration manager to immediately return without notification (such
47   * as an AssertionError).
48   * @version $Rev: 410741 $ $Date: 2006-05-31 21:35:48 -0700 (Wed, 31 May 2006) $
49   */
50  public interface LifecycleMonitor {
51      /**
52       * Adds a configuration to be monitored.
53       * @param configurationId the configuration identifier
54       */
55      void addConfiguration(Artifact configurationId);
56  
57      /**
58       * The configuration manager has started reading the specified configuration.
59       * @param configurationId the configuration identifier
60       */
61      void reading(Artifact configurationId);
62  
63      /**
64       * The configuration manager has begun loading the specified configuration.
65       * @param configurationId the configuration identifier
66       */
67      void loading(Artifact configurationId);
68  
69      /**
70       * The configuration manager has begun starting the specified configuration.
71       * @param configurationId the configuration identifier
72       */
73      void starting(Artifact configurationId);
74  
75      /**
76       * The configuration manager has begun stopping the specified configuration.
77       * @param configurationId the configuration identifier
78       */
79      void stopping(Artifact configurationId);
80  
81      /**
82       * The configuration manager has begun unloading the specified configuration.
83       * @param configurationId the configuration identifier
84       */
85      void unloading(Artifact configurationId);
86  
87      /**
88       * The previous operation on the specified configuration has completed successfully.
89       * @param configurationId the configuration identifier
90       */
91      void succeeded(Artifact configurationId);
92  
93      /**
94       * The previous operation on the specified configuration has failed due to the specified exception.
95       * @param configurationId the configuration identifier
96       */
97      void failed(Artifact configurationId, Throwable cause);
98  
99      /**
100      * The operation on the configuration manager has finished.
101      */
102     void finished();
103 }
104