1 23 24 package com.sun.enterprise; 25 26 import java.util.Vector ; 27 import java.util.Hashtable ; 28 import java.util.Timer ; 29 import javax.ejb.spi.HandleDelegate ; 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 ; 35 import com.sun.enterprise.admin.monitor.callflow.Agent; 36 import com.sun.enterprise.naming.ProviderManager; 37 38 42 46 public class Switch { 47 48 private static final String 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 Hashtable containerDescriptorTable = new Hashtable (); 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 timer; 63 private HandleDelegate handleDelegate; 64 private int containerType; 65 private ManagementObjectManager managementObjectManager; 66 private Agent callFlowAgent; 67 private ProviderManager providerManager; 68 69 81 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 168 public Object getDescriptorFor(Object containerContext) 169 { 170 return containerDescriptorTable.get(containerContext); 171 } 172 173 177 public Object setDescriptorFor(Object containerContext, Object desc) 178 { 179 return containerDescriptorTable.put(containerContext, desc); 180 } 181 182 185 public void removeDescriptorFor(Object 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 e) { 195 System.err.println(e); 196 } 197 } 198 return managementObjectManager; 199 } 200 201 public Timer getTimer() { 202 synchronized(this) { 203 if( timer == null ) { 204 timer = new Timer (true); 207 } 208 } 209 return timer; 210 } 211 212 public HandleDelegate 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 |