1 23 24 package com.sun.enterprise.resource; 25 26 import com.sun.enterprise.ManagementObjectManager; 27 import com.sun.enterprise.server.ResourceDeployer; 28 import com.sun.enterprise.config.serverbeans.Resources; 29 import com.sun.enterprise.config.serverbeans.ElementProperty; 30 import com.sun.enterprise.config.serverbeans.AdminObjectResource; 31 import com.sun.enterprise.connectors.ConnectorRuntime; 32 import com.sun.enterprise.connectors.ConnectorConnectionPool; 33 import com.sun.enterprise.deployment.ConnectionDefDescriptor; 34 import com.sun.enterprise.repository.IASJ2EEResourceFactoryImpl; 35 import com.sun.logging.LogDomains; 36 import java.util.Properties ; 37 import java.util.logging.*; 38 39 44 45 public class AdminObjectResourceDeployer extends GlobalResourceDeployer 46 implements ResourceDeployer { 47 48 static Logger _logger = LogDomains.getLogger(LogDomains.CORE_LOGGER); 49 50 56 public synchronized void deployResource(Object resource) throws Exception { 57 58 final AdminObjectResource aor = 59 (com.sun.enterprise.config.serverbeans.AdminObjectResource)resource; 60 final ConnectorRuntime crt = ConnectorRuntime.getRuntime(); 61 62 if (aor.isEnabled()) { 63 final ManagementObjectManager mgr = 65 getAppServerSwitchObject().getManagementObjectManager(); 66 mgr.registerAdminObjectResource(aor.getJndiName(), 67 aor.getResAdapter(), aor.getResType(), 68 getPropNamesAsStrArr(aor.getElementProperty()), 69 getPropValuesAsStrArr(aor.getElementProperty())); 70 } else { 71 _logger.log(Level.INFO, "core.resource_disabled", 72 new Object [] {aor.getJndiName(), 73 IASJ2EEResourceFactoryImpl.JMS_RES_TYPE}); 74 } 75 76 _logger.log(Level.FINE, 77 "Calling backend to add adminObject",aor.getJndiName()); 78 crt.addAdminObject(null,aor.getResAdapter(),aor.getJndiName(), 79 aor.getResType(),transformProps(aor.getElementProperty())); 80 _logger.log(Level.FINE, 81 "Added adminObject in backend",aor.getJndiName()); 82 } 83 84 87 public synchronized void undeployResource(Object resource) 88 throws Exception { 89 90 final AdminObjectResource aor = 91 (com.sun.enterprise.config.serverbeans.AdminObjectResource)resource; 92 final ConnectorRuntime crt = ConnectorRuntime.getRuntime(); 93 94 _logger.log(Level.FINE, 95 "Calling backend to delete adminObject",aor.getJndiName()); 96 crt.deleteAdminObject(aor.getJndiName()); 97 _logger.log(Level.FINE, 98 "Deleted adminObject in backend",aor.getJndiName()); 99 100 final ManagementObjectManager mgr = 102 getAppServerSwitchObject().getManagementObjectManager(); 103 mgr.unregisterAdminObjectResource(aor.getJndiName(), aor.getResType()); 104 105 } 106 107 public synchronized void redeployResource(Object resource) 108 throws Exception { 109 } 110 111 public synchronized void disableResource(Object resource) 112 throws Exception { 113 114 } 115 116 public synchronized void enableResource(Object resource) 117 throws Exception { 118 } 119 120 public Object getResource(String name, Resources rbeans) 121 throws Exception { 122 Object res = rbeans.getAdminObjectResourceByJndiName(name); 123 124 if (res == null) { 125 Exception ex = new Exception ("No such resource"); 126 _logger.log(Level.SEVERE,"no_resource",name); 127 _logger.log(Level.SEVERE,"",ex); 128 throw ex; 129 } 130 131 return res; 132 } 133 134 Properties transformProps(ElementProperty[] domainProps) { 135 136 Properties props = new Properties (); 137 for(int i=0;i<domainProps.length;++i) { 138 props.setProperty( 139 domainProps[i].getName(),domainProps[i].getValue()); 140 } 141 return props; 142 } 143 } 144 | Popular Tags |