KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > kernel > plugins > dependency > KernelControllerContextActions


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.kernel.plugins.dependency;
23
24 import java.util.HashMap JavaDoc;
25 import java.util.Map JavaDoc;
26
27 import org.jboss.dependency.plugins.AbstractControllerContextActions;
28 import org.jboss.dependency.plugins.spi.action.ControllerContextAction;
29 import org.jboss.dependency.spi.ControllerState;
30
31 /**
32  * The KernelControllerActions.<p>
33  *
34  * When there is a security manager and we are using a native context
35  * we switch to our privileges to run the actions and switch back to callout to beans.<p>
36  *
37  * Otherwise, we just use the caller's privileges.
38  *
39  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
40  * @version $Revision: 46281 $
41  */

42 public class KernelControllerContextActions extends AbstractControllerContextActions
43 {
44    /** The single instance */
45    private static KernelControllerContextActions instance;
46
47    /** Actions without instantiate */
48    private static KernelControllerContextActions noInstantiate;
49    
50    /**
51     * Get the instance
52     *
53     * @return the actions
54     */

55    public static KernelControllerContextActions getInstance()
56    {
57       if (instance == null)
58       {
59          Map JavaDoc<ControllerState, ControllerContextAction> actions = new HashMap JavaDoc<ControllerState, ControllerContextAction>();
60          actions.put(ControllerState.DESCRIBED, new DescribeAction());
61          actions.put(ControllerState.INSTANTIATED, new InstantiateAction());
62          actions.put(ControllerState.CONFIGURED, new ConfigureAction());
63          actions.put(ControllerState.CREATE, new CreateDestroyLifecycleAction());
64          actions.put(ControllerState.START, new StartStopLifecycleAction());
65          actions.put(ControllerState.INSTALLED, new InstallAction());
66          instance = new KernelControllerContextActions(actions);
67       }
68       return instance;
69    }
70    
71    /**
72     * Get no instantiate actions
73     *
74     * @return the actions
75     */

76    public static KernelControllerContextActions getNoInstantiate()
77    {
78       if (noInstantiate == null)
79       {
80          Map JavaDoc<ControllerState, ControllerContextAction> actions = new HashMap JavaDoc<ControllerState, ControllerContextAction>();
81          actions.put(ControllerState.DESCRIBED, new DescribeAction());
82          actions.put(ControllerState.CONFIGURED, new ConfigureAction());
83          actions.put(ControllerState.CREATE, new CreateDestroyLifecycleAction());
84          actions.put(ControllerState.START, new StartStopLifecycleAction());
85          actions.put(ControllerState.INSTALLED, new InstallAction());
86          noInstantiate = new KernelControllerContextActions(actions);
87       }
88       return noInstantiate;
89    }
90    
91    /**
92     * Create a new KernelControllerContextActions.
93     *
94     * @param actions the actions
95     */

96    protected KernelControllerContextActions(Map JavaDoc<ControllerState, ControllerContextAction> actions)
97    {
98       super(actions);
99    }
100 }
101
Popular Tags