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.CustomResource; 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 72 public class CustomResourceDeployer implements ResourceDeployer { 73 74 75 private static final StringManager localStrings = 76 StringManager.getManager("com.sun.enterprise.resource"); 77 78 79 private static Logger _logger=LogDomains.getLogger(LogDomains.CORE_LOGGER); 80 81 87 public synchronized void deployResource(Object resource) throws Exception { 88 89 com.sun.enterprise.config.serverbeans.CustomResource customRes = 90 (com.sun.enterprise.config.serverbeans.CustomResource) resource; 91 92 if (customRes.isEnabled()) { 93 J2EEResource j2eeResource = 95 IASJ2EEResourceFactoryImpl.toCustomJ2EEResource(customRes); 96 97 ResourceInstaller installer = 99 Switch.getSwitch().getResourceInstaller(); 100 101 installer.installCustomResource((CustomResource) j2eeResource); 103 104 installer.addResource(j2eeResource); 106 } else { 107 _logger.log(Level.INFO, "core.resource_disabled", 108 new Object [] {customRes.getJndiName(), 109 IASJ2EEResourceFactoryImpl.CUSTOM_RES_TYPE}); 110 } 111 } 112 113 119 public synchronized void undeployResource(Object resource) 120 throws Exception { 121 122 NamingManager namingMgr = Switch.getSwitch().getNamingManager(); 124 125 com.sun.enterprise.config.serverbeans.CustomResource customRes = 126 (com.sun.enterprise.config.serverbeans.CustomResource) resource; 127 128 J2EEResource j2eeResource = 130 IASJ2EEResourceFactoryImpl.toCustomJ2EEResource(customRes); 131 132 namingMgr.unpublishObject( j2eeResource.getName() ); 134 135 ResourceInstaller installer = Switch.getSwitch().getResourceInstaller(); 137 138 installer.removeResource(j2eeResource); 140 } 141 142 148 public synchronized void redeployResource(Object resource) 149 throws Exception { 150 151 undeployResource(resource); 152 deployResource(resource); 153 } 154 155 161 public synchronized void enableResource(Object resource) throws Exception { 162 deployResource(resource); 163 } 164 165 171 public synchronized void disableResource(Object resource) throws Exception { 172 undeployResource(resource); 173 } 174 175 176 184 public Object getResource(String name, Resources rbeans) throws Exception { 185 186 Object res = rbeans.getCustomResourceByJndiName(name); 187 188 if (res == null) { 189 String msg = localStrings.getString( 190 "resource.no_resource",name); 191 throw new Exception (msg); 192 } 193 194 return res; 195 } 196 } 197 | Popular Tags |