1 23 24 37 package com.sun.enterprise.resource; 38 39 import com.sun.enterprise.server.ResourceDeployer; 40 import com.sun.enterprise.config.serverbeans.Resources; 41 42 import com.sun.enterprise.Switch; 43 import com.sun.enterprise.NamingManager; 44 import com.sun.enterprise.resource.ResourceInstaller; 45 import com.sun.enterprise.repository.J2EEResource; 46 import com.sun.enterprise.repository.ExternalJndiResource; 47 import com.sun.enterprise.repository.IASJ2EEResourceFactoryImpl; 48 49 import java.util.logging.Logger ; 50 import java.util.logging.Level ; 51 import com.sun.logging.LogDomains; 52 import com.sun.enterprise.util.i18n.StringManager; 53 54 66 public class ExternalJndiResourceDeployer implements ResourceDeployer { 67 68 69 private static final StringManager localStrings = 70 StringManager.getManager("com.sun.enterprise.resource"); 71 72 private static Logger _logger=LogDomains.getLogger(LogDomains.CORE_LOGGER); 73 74 80 public synchronized void deployResource(Object resource) throws Exception { 81 82 com.sun.enterprise.config.serverbeans.ExternalJndiResource jndiRes = 83 (com.sun.enterprise.config.serverbeans.ExternalJndiResource) resource; 84 85 if (jndiRes.isEnabled()) { 86 J2EEResource j2eeRes = 88 IASJ2EEResourceFactoryImpl.toExternalJndiJ2EEResource(jndiRes); 89 90 ResourceInstaller installer = 92 Switch.getSwitch().getResourceInstaller(); 93 94 installer.installExternalJndiResource( 96 (ExternalJndiResource) j2eeRes); 97 98 installer.addResource(j2eeRes); 100 } else { 101 _logger.log(Level.INFO, "core.resource_disabled", 102 new Object [] {jndiRes.getJndiName(), 103 IASJ2EEResourceFactoryImpl.EXT_JNDI_RES_TYPE}); 104 } 105 106 } 107 108 114 public synchronized void undeployResource(Object resource) 115 throws Exception { 116 117 com.sun.enterprise.config.serverbeans.ExternalJndiResource jndiRes = 118 (com.sun.enterprise.config.serverbeans.ExternalJndiResource) resource; 119 120 J2EEResource j2eeResource = 122 IASJ2EEResourceFactoryImpl.toExternalJndiJ2EEResource(jndiRes); 123 124 ResourceInstaller installer = Switch.getSwitch().getResourceInstaller(); 126 127 installer.uninstallExternalJndiResource(j2eeResource); 129 } 130 131 137 public synchronized void redeployResource(Object resource) 138 throws Exception { 139 140 undeployResource(resource); 141 deployResource(resource); 142 } 143 144 150 public synchronized void enableResource(Object resource) throws Exception { 151 deployResource(resource); 152 } 153 154 160 public synchronized void disableResource(Object resource) throws Exception { 161 undeployResource(resource); 162 } 163 164 165 173 public Object getResource(String name, Resources rbeans) throws Exception { 174 175 Object res = rbeans.getExternalJndiResourceByJndiName(name); 176 177 if (res == null) { 178 String msg = localStrings.getString( 179 "resource.no_resource", name); 180 throw new Exception (msg); 181 } 182 183 return res; 184 } 185 } 186 | Popular Tags |