KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > kernel > LifeCycleMethod


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.server.kernel;
10
11 import java.util.Iterator JavaDoc;
12
13 import org.jboss.portal.server.kernel.state.State;
14
15 /**
16  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
17  * @version $Revision: 1.2 $
18  */

19 public abstract class LifeCycleMethod
20 {
21
22    protected final Kernel kernel;
23
24    protected LifeCycleMethod(Kernel kernel)
25    {
26       this.kernel = kernel;
27    }
28
29    protected void invokeOnDependsOnMe(Entry entry)
30    {
31 // for (Iterator i = registry.values().iterator(); i.hasNext();)
32
// {
33
// Entry dependsOnMeEntry = (Entry)i.next();
34
// if (dependsOnMeEntry.depends.contains(entry.id))
35
// {
36
// try
37
// {
38
// invokeMethodOnDependsOnMe(dependsOnMeEntry);
39
// }
40
// catch (KernelException e)
41
// {
42
// // We don't bother, just log it
43
// Throwable t = e;
44
// while (t.getCause() != null)
45
// {
46
// t = t.getCause();
47
// }
48
// dependsOnMeEntry.log.error("Exception occured when invoking nested lifecycle method", t);
49
// }
50
// }
51
// }
52
for (Iterator JavaDoc i = entry.dependsOnMe.iterator(); i.hasNext();)
53       {
54          ServiceID dependsOnMeID = (ServiceID)i.next();
55          Entry dependsOnMeEntry = kernel.getEntry(dependsOnMeID);
56          try
57          {
58             invokeMethodOnDependsOnMe(dependsOnMeEntry);
59          }
60          catch (KernelException e)
61          {
62             // We don't bother, just log it
63
Throwable JavaDoc t = e;
64             while (t.getCause() != null)
65             {
66                t = t.getCause();
67             }
68             dependsOnMeEntry.log.error("Exception occured when invoking nested lifecycle method", t);
69          }
70       }
71    }
72
73    public abstract State invoke(Entry entry) throws TransitionNotPossibleException, ServiceFailureException;
74
75    /**
76     * Precheck the state of the service.
77     * @throws TransitionNotPossibleException if the transition is not possible
78     */

79    protected abstract void checkState(Entry entry) throws TransitionNotPossibleException;
80
81    /**
82     * Apply the lifecycle method and do the transition as well.
83     * @throws Exception the possible wrapper runtime exception
84     */

85    protected abstract void invokeMethod(Entry entry) throws Exception JavaDoc;
86
87    /**
88     * Apply the lifecycle method on one of the service that depends on the current service
89     * @throws KernelException thrown by the recursive call
90     */

91    protected abstract void invokeMethodOnDependsOnMe(Entry entry) throws KernelException;
92 }
93
Popular Tags