KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > Switch


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise;
25
26 import java.util.Vector JavaDoc;
27 import java.util.Hashtable JavaDoc;
28 import java.util.Timer JavaDoc;
29 import javax.ejb.spi.HandleDelegate JavaDoc;
30
31 import com.sun.ejb.*;
32 import com.sun.enterprise.ManagementObjectManager;
33 import com.sun.enterprise.resource.ResourceInstaller;
34 import javax.resource.spi.ConnectionManager JavaDoc;
35 import com.sun.enterprise.admin.monitor.callflow.Agent;
36 import com.sun.enterprise.naming.ProviderManager;
37
38 //IASRI 4717059 BEGIN
39
//import com.sun.ejb.ROBNotifier;
40
//IASRI 4717059 END
41

42 /**
43  * The Switch class holds references to all the components in an EJB
44  * server including Containers, TM, Protocol Manager, etc.
45  */

46 public class Switch {
47
48     private static final String JavaDoc EJB_CONFIG_FILE = "ejbconfig.properties";
49     public static final int APPCLIENT_CONTAINER = 1;
50     public static final int EJBWEB_CONTAINER = 2;
51     private static Switch theSwitch;
52     //private Vector containers = new Vector();
53
private Hashtable JavaDoc containerDescriptorTable = new Hashtable JavaDoc();
54     private ProtocolManager protocolManager;
55     private J2EETransactionManager tm;
56     private ContainerFactory containerFactory;
57     private InvocationManager invocationManager;
58     private NamingManager namingManager;
59     private InjectionManager injectionManager;
60     private PoolManager poolManager;
61     private ResourceInstaller resourceInstaller;
62     private Timer JavaDoc timer;
63     private HandleDelegate JavaDoc handleDelegate;
64     private int containerType;
65     private ManagementObjectManager managementObjectManager;
66     private Agent callFlowAgent;
67     private ProviderManager providerManager;
68     
69     //IASRI 4717059 BEGIN
70
/*
71     private ROBNotifier robNotifier;
72     
73     public ROBNotifier getROBNotifier() {
74         return robNotifier;
75     }
76
77     public void setROBNotifier(ROBNotifier robNotifier) {
78         this.robNotifier = robNotifier;
79     }
80     */

81     //IASRI 4717059 END
82

83     public static Switch getSwitch() {
84     if ( theSwitch == null ) {
85         theSwitch = new Switch();
86         }
87     return theSwitch;
88     }
89     
90     public ProviderManager getProviderManager() {
91     return providerManager;
92     }
93     
94     public void setProviderManager(ProviderManager pf) {
95     providerManager = pf;
96     }
97
98     public ProtocolManager getProtocolManager() {
99     return protocolManager;
100     }
101
102     public void setProtocolManager(ProtocolManager pm) {
103     protocolManager = pm;
104     }
105
106     public NamingManager getNamingManager() {
107     return namingManager;
108     }
109
110     public void setNamingManager(NamingManager nm) {
111     namingManager = nm;
112     }
113
114     public InjectionManager getInjectionManager() {
115         return injectionManager;
116     }
117
118     public void setInjectionManager(InjectionManager im) {
119         injectionManager = im;
120     }
121
122     public J2EETransactionManager getTransactionManager() {
123     return tm;
124     }
125
126     public void setTransactionManager(J2EETransactionManager tm) {
127     this.tm = tm;
128     }
129
130     public PoolManager getPoolManager() {
131         return poolManager;
132     }
133
134     public void setPoolManager(PoolManager poolManager) {
135         this.poolManager = poolManager;
136     }
137
138     public ResourceInstaller getResourceInstaller() {
139         return resourceInstaller;
140     }
141
142     public void setResourceInstaller(ResourceInstaller resourceInstaller) {
143         this.resourceInstaller = resourceInstaller;
144     }
145
146     public InvocationManager getInvocationManager() {
147         return invocationManager;
148     }
149
150     public void setInvocationManager(InvocationManager invocationManager) {
151         this.invocationManager = invocationManager;
152     }
153     
154
155     public ContainerFactory getContainerFactory() {
156         return containerFactory;
157     }
158
159     public void setContainerFactory(ContainerFactory containerFactory) {
160         this.containerFactory = containerFactory;
161     }
162
163     /**
164      * Returns the deployment descriptor for the EJB container or
165      * Servlet context provided. This is used by the Transaction/Naming
166      * Security Managers.
167      */

168     public Object JavaDoc getDescriptorFor(Object JavaDoc containerContext)
169     {
170         return containerDescriptorTable.get(containerContext);
171     }
172
173     /**
174      * Sets the deployment descriptor for the EJB container or
175      * Servlet context provided.
176      */

177     public Object JavaDoc setDescriptorFor(Object JavaDoc containerContext, Object JavaDoc desc)
178     {
179         return containerDescriptorTable.put(containerContext, desc);
180     }
181
182     /**
183      * Remove the descriptor from the hashtable
184      */

185     public void removeDescriptorFor(Object JavaDoc containerContext)
186     {
187         containerDescriptorTable.remove(containerContext);
188     }
189
190     public ManagementObjectManager getManagementObjectManager() {
191         if ( managementObjectManager == null ) {
192                try {
193                 managementObjectManager = (ManagementObjectManager)Class.forName("com.sun.enterprise.management.util.J2EEManagementObjectManager").newInstance();
194             } catch(Exception JavaDoc e) {
195                 System.err.println(e);
196             }
197         }
198         return managementObjectManager;
199     }
200
201     public Timer JavaDoc getTimer() {
202         synchronized(this) {
203             if( timer == null ) {
204                 // Create a scheduler as a daemon so it
205
// won't prevent process from exiting.
206
timer = new Timer JavaDoc(true);
207             }
208         }
209         return timer;
210     }
211  
212     public HandleDelegate JavaDoc getHandleDelegate() {
213         if (handleDelegate == null) {
214             synchronized (this) {
215                 if (handleDelegate == null) {
216                     handleDelegate =
217                         com.sun.enterprise.iiop.IIOPHandleDelegate.getHandleDelegate();
218                 }
219             }
220         }
221         return handleDelegate;
222     }
223     
224     public void setContainerType(int type){
225     containerType = type;
226     }
227     public int getContainerType(){
228     return containerType;
229     }
230
231     public void setCallFlowAgent(Agent callFlowAgent) {
232         this.callFlowAgent = callFlowAgent;
233     }
234         
235     public Agent getCallFlowAgent() {
236         return this.callFlowAgent;
237     }
238 }
239
Popular Tags