1 23 24 package com.sun.enterprise.connectors; 25 import java.util.logging.*; 26 import javax.resource.spi.ResourceAdapter ; 27 import com.sun.logging.LogDomains; 28 import com.sun.enterprise.deployment.ConnectorDescriptor; 29 import com.sun.enterprise.connectors.system.*; 30 31 32 37 public class ActiveRAFactory { 38 static Logger _logger = LogDomains.getLogger(LogDomains.RSR_LOGGER); 39 40 51 public static ActiveResourceAdapter createActiveResourceAdapter( 52 ConnectorDescriptor cd, String moduleName, ClassLoader loader, 53 boolean writeSunDescriptor) throws ConnectorRuntimeException{ 54 55 ActiveResourceAdapter activeResourceAdapter = null; 56 int environment = ConnectorRuntime.getRuntime().getEnviron(); 57 ResourceAdapter ra = null; 58 String raClass = cd.getResourceAdapterClass(); 59 60 try { 61 62 if (raClass != null && !raClass.equals("")) { 64 if(environment == ConnectorRuntime.SERVER) { 65 ra = (ResourceAdapter ) 66 loader.loadClass(raClass).newInstance(); 67 } else { 68 ra = (ResourceAdapter )Class.forName(raClass).newInstance(); 69 } 70 71 } 72 73 82 if (moduleName.equals(ConnectorConstants.DEFAULT_JMS_ADAPTER)) { 83 activeResourceAdapter = new ActiveJmsResourceAdapter( 84 ra,cd,moduleName,loader); 85 } else if (raClass.equals("")) { 86 activeResourceAdapter = new ActiveOutboundResourceAdapter( 87 cd,moduleName,loader,writeSunDescriptor); 88 } else { 89 activeResourceAdapter = new ActiveInboundResourceAdapter( 90 ra,cd,moduleName,loader); 91 } 92 93 } catch (ClassNotFoundException Ex) { 94 ConnectorRuntimeException cre = new ConnectorRuntimeException( 95 "Error in creating active RAR"); 96 cre.initCause(Ex); 97 _logger.log(Level.SEVERE,"rardeployment.class_not_found",raClass); 98 _logger.log(Level.SEVERE,"",cre); 99 throw cre; 100 } catch (InstantiationException Ex) { 101 ConnectorRuntimeException cre = new ConnectorRuntimeException( 102 "Error in creating active RAR"); 103 cre.initCause(Ex); 104 _logger.log(Level.SEVERE,"rardeployment.class_instantiation_error", 105 raClass); 106 _logger.log(Level.SEVERE,"",cre); 107 throw cre; 108 } catch (IllegalAccessException Ex) { 109 ConnectorRuntimeException cre = new ConnectorRuntimeException( 110 "Error in creating active RAR"); 111 cre.initCause(Ex); 112 _logger.log(Level.SEVERE,"rardeployment.illegalaccess_error", 113 raClass); 114 _logger.log(Level.SEVERE,"",cre); 115 throw cre; 116 } 117 118 return activeResourceAdapter; 119 120 } 121 122 123 } 124 | Popular Tags |