1 23 24 25 package com.sun.enterprise.server; 26 27 import com.sun.enterprise.config.serverbeans.*; 29 import com.sun.enterprise.config.ConfigException; 30 import com.sun.enterprise.instance.ConnectorModulesManager; 31 import com.sun.enterprise.Switch; 32 import javax.resource.spi.ManagedConnectionFactory ; 34 36 import java.util.logging.Level ; 38 import java.util.logging.Logger ; 39 import com.sun.logging.LogDomains; 40 42 import com.sun.enterprise.connectors.ConnectorRuntime; 43 import com.sun.enterprise.connectors.ConnectorRuntimeException; 44 45 import javax.management.ObjectName ; 47 import com.sun.enterprise.config.serverbeans.*; 48 import com.sun.enterprise.deployment.io.ApplicationDeploymentDescriptorFile; 49 import com.sun.enterprise.deployment.node.J2EEDocumentBuilder; 50 import com.sun.enterprise.deployment.Application; 51 import com.sun.enterprise.deployment.Descriptor; 52 import com.sun.enterprise.deployment.ConnectorDescriptor; 53 import com.sun.enterprise.instance.InstanceEnvironment; 54 import com.sun.enterprise.deployment.archivist.ConnectorArchivist; 55 import java.io.IOException ; 56 import org.xml.sax.SAXParseException ; 57 import com.sun.enterprise.instance.InstanceEnvironment; 58 import com.sun.enterprise.deployment.node.J2EEDocumentBuilder; 59 import com.sun.enterprise.deployment.io.ConnectorDeploymentDescriptorFile; 60 import javax.management.MBeanException ; 61 import com.sun.enterprise.Switch; 62 import com.sun.enterprise.server.event.ApplicationEvent; 63 64 65 71 72 class ConnectorModuleLoader extends AbstractLoader { 73 74 static Logger _logger=LogDomains.getLogger(LogDomains.LOADER_LOGGER); 76 78 private ConnectorDescriptor connectorDescriptor = null; 79 80 87 ConnectorModuleLoader(String modID, ClassLoader parentClassLoader, 88 ConnectorModulesManager connModulesManager) { 89 90 super(modID,parentClassLoader,connModulesManager); 91 setConnectorDescriptor(modID); 93 } 94 95 100 boolean load() { 102 try{ 103 ConnectorRuntime cr = ConnectorRuntime.getRuntime(); 104 cr.initialize(ConnectorRuntime.SERVER); 105 cr.createActiveResourceAdapter(this.configManager.getLocation(this.id),this.id,this.cascade); 106 return true; 107 }catch(ConfigException e){ 108 _logger.log(Level.WARNING,"loader.configexception",e); 109 return false; 110 } 111 catch(ConnectorRuntimeException ex) { 112 _logger.log(Level.WARNING,"Failed to load the rar",ex); 113 114 return false; 115 116 } 117 } 118 119 125 boolean load(boolean jsr77) { 126 notifyAppEvent(ApplicationEvent.BEFORE_APPLICATION_LOAD); 128 129 if (load()) { 130 try { 131 createLeafMBeans(); 132 } catch (MBeanException mbe) { 133 _logger.log(Level.WARNING,"loader.exception",mbe); 134 } 135 return true; 136 } 137 return false; 138 } 139 140 141 146 boolean unload() { 147 ConnectorRuntime connectorRuntime = ConnectorRuntime.getRuntime(); 148 try { 149 connectorRuntime.destroyActiveResourceAdapter(this.id,cascade); 150 configManager.unregisterDescriptor(id); 151 } 152 catch(ConnectorRuntimeException cre) { 153 return false; 154 } 155 return true; 156 } 157 158 164 boolean unload(boolean jsr77) { 165 if (unload()) { 166 try { 167 deleteLeafMBeans(); 168 } catch (MBeanException mbe) { 169 _logger.log(Level.WARNING,"loader.exception",mbe); 170 } 171 return true; 172 } 173 return false; 174 } 175 176 180 private void setConnectorDescriptor(String modID) { 181 try { 182 this.application = configManager.getDescriptor(modID, null, false); 187 connectorDescriptor = (ConnectorDescriptor) application.getStandaloneBundleDescriptor(); 188 } catch(ConfigException ex) { 190 _logger.log(Level.WARNING,"Failed to get the module directory "); 191 } 192 } 193 194 197 public ConnectorDescriptor getConnectorDescriptor() { 198 return connectorDescriptor; 199 } 200 201 202 205 void createRootMBean() throws MBeanException { 206 207 try { 208 Switch.getSwitch().getManagementObjectManager().createRARModuleMBean( 209 connectorDescriptor, 210 this.configManager.getInstanceEnvironment().getName(), 211 this.configManager.getLocation(this.id)); 212 } catch (Exception e) { 213 throw new MBeanException (e); 214 } 215 } 216 217 218 221 void deleteRootMBean() throws MBeanException { 222 223 Switch.getSwitch().getManagementObjectManager().deleteRARModuleMBean(connectorDescriptor, 224 this.configManager.getInstanceEnvironment().getName()); 225 } 226 227 228 232 void createLeafMBeans() throws MBeanException { 233 Switch.getSwitch().getManagementObjectManager().createRARMBeans(connectorDescriptor, 234 this.configManager.getInstanceEnvironment().getName()); 235 } 236 237 241 void createLeafMBean(Descriptor descriptor) throws MBeanException { 242 ConnectorDescriptor cd = null; 243 try { 244 cd = (ConnectorDescriptor) descriptor; 245 } catch (Exception e) { 246 throw new MBeanException (e); 247 } 248 Switch.getSwitch().getManagementObjectManager().createRARMBean(cd, 249 this.configManager.getInstanceEnvironment().getName()); 250 } 251 252 256 void deleteLeafMBeans() throws MBeanException { 257 Switch.getSwitch().getManagementObjectManager().deleteRARMBeans(connectorDescriptor, 258 this.configManager.getInstanceEnvironment().getName()); 259 } 260 261 265 void deleteLeafMBean(Descriptor descriptor) throws MBeanException { 266 ConnectorDescriptor cd = null; 267 try { 268 cd = (ConnectorDescriptor) descriptor; 269 } catch (Exception e) { 270 throw new MBeanException (e); 271 } 272 Switch.getSwitch().getManagementObjectManager().deleteRARMBean(cd, 273 this.configManager.getInstanceEnvironment().getName()); 274 } 275 276 277 280 void deleteLeafAndRootMBeans() throws MBeanException { 281 deleteLeafMBeans(); 282 deleteRootMBean(); 283 } 284 285 286 289 void setState(int state) throws MBeanException { 290 291 Switch.getSwitch().getManagementObjectManager().setRARModuleState(state, connectorDescriptor, 292 this.configManager.getInstanceEnvironment().getName()); 293 294 } 295 296 } 297 | Popular Tags |