1 25 26 package org.objectweb.jonas.container; 27 28 import java.util.Enumeration ; 29 import java.util.HashSet ; 30 import java.util.Hashtable ; 31 import java.util.Set ; 32 import java.util.Vector ; 33 34 import org.objectweb.jonas.dbm.DataBaseServiceImpl; 35 import org.objectweb.jonas.mail.MailServiceImpl; 36 import org.objectweb.jonas.management.j2eemanagement.J2EEManagedObject; 37 import org.objectweb.jonas.service.ServiceManager; 38 import org.objectweb.jonas_ejb.container.JFactory; 39 import org.objectweb.jonas_ejb.deployment.api.BeanDesc; 40 import org.objectweb.jonas_ejb.deployment.api.EntityJdbcCmp1Desc; 41 import org.objectweb.jonas_ejb.deployment.api.EntityJdbcCmp2Desc; 42 import org.objectweb.jonas_lib.deployment.api.ResourceEnvRefDesc; 43 import org.objectweb.jonas_lib.deployment.api.ResourceRefDesc; 44 45 50 public class EJB extends J2EEManagedObject { 51 54 protected JFactory ejbToManage = null; 55 protected BeanDesc desc = null; 56 protected String fileName = null; 57 58 public EJB(String objectName, JFactory ejbToManage) { 59 super(objectName); 60 this.ejbToManage = ejbToManage; 61 this.fileName = ejbToManage.getContainer().getExternalFileName(); 62 this.desc = ejbToManage.getDeploymentDescriptor(); 63 } 64 65 66 69 public String getName() { 70 return desc.getEjbName(); 71 } 72 73 76 public String getFileName() { 77 return fileName; 78 } 79 80 83 public Hashtable getAllDataSourceName() { 84 Hashtable result = new Hashtable (); 85 86 DataBaseServiceImpl bdmServ = null; 87 String jndiName = null; 88 Vector jndiNames = new Vector (); 89 String datasourceName = null; 90 91 ResourceRefDesc[] rrDesc = desc.getResourceRefDesc(); 93 for (int i = 0; i < rrDesc.length; i ++) { 94 if (rrDesc[i].isJdbc()) { 95 jndiName = rrDesc[i].getJndiName(); 97 jndiNames.add(jndiName); 98 } 99 } 100 101 if (desc instanceof EntityJdbcCmp1Desc) { 103 EntityJdbcCmp1Desc jdbcCmp1Desc = (EntityJdbcCmp1Desc) desc; 105 jndiName = jdbcCmp1Desc.getDatasourceJndiName(); 106 jndiNames.add(jndiName); 107 } else if (desc instanceof EntityJdbcCmp2Desc) { 108 EntityJdbcCmp2Desc jdbcCmp2Desc = (EntityJdbcCmp2Desc) desc; 110 jndiName = jdbcCmp2Desc.getDatasourceJndiName(); 111 jndiNames.add(jndiName); 112 } 113 114 if (!jndiNames.isEmpty()) { 115 try { 116 ServiceManager sm = ServiceManager.getInstance(); 118 bdmServ = (DataBaseServiceImpl) sm.getDataBaseService(); 119 } catch(Exception e) { 120 return result; 123 } 124 } 125 126 for (Enumeration e = jndiNames.elements() ; e.hasMoreElements() ;) { 127 jndiName = (String )e.nextElement(); 128 datasourceName = bdmServ.getDatasourceName(jndiName); 129 if (datasourceName != null) 130 result.put(jndiName, datasourceName); 131 else 132 result.put(jndiName, ""); 133 } 134 135 return result; 136 } 137 138 139 142 public Set getAllJMSConnectionFactoryName(){ 143 Set result= new HashSet (); 144 ResourceRefDesc[] rrDesc = desc.getResourceRefDesc(); 145 for (int i = 0; i < rrDesc.length; i ++) { 146 if ("javax.jms.TopicConnectionFactory".equals(rrDesc[i].getTypeName()) 147 || "javax.jms.QueueConnectionFactory".equals(rrDesc[i].getTypeName()) 148 || "javax.jms.ConnectionFactory".equals(rrDesc[i].getTypeName())) { 149 result.add(rrDesc[i].getJndiName()); 150 } 151 } 152 return result; 153 } 154 155 159 public Hashtable getAllMailFactorySName(){ 160 Hashtable result = new Hashtable (); 161 MailServiceImpl mailServ = null; 162 try { 163 ServiceManager sm = ServiceManager.getInstance(); 165 mailServ = (MailServiceImpl) sm.getMailService(); 166 } catch(Exception e) { 167 } 169 String jndiName = null; String factoryName = null; 172 ResourceRefDesc[] rrDesc = desc.getResourceRefDesc(); 173 for (int i = 0; i < rrDesc.length; i ++) { 174 if ("javax.mail.Session".equals(rrDesc[i].getTypeName())) { 175 177 jndiName = rrDesc[i].getJndiName(); 179 180 if (mailServ != null) { 182 factoryName = mailServ.getFactoryName(jndiName); 184 if (factoryName != null) 185 result.put(jndiName, factoryName); 186 else 187 result.put(jndiName, ""); 188 } else { 189 result.put(jndiName, ""); 191 } 192 } 193 } 194 return result; 195 } 196 197 201 public Hashtable getAllMailFactoryMName() { 202 Hashtable result = new Hashtable (); 203 MailServiceImpl mailServ = null; 204 try { 205 ServiceManager sm = ServiceManager.getInstance(); 207 mailServ = (MailServiceImpl) sm.getMailService(); 208 } catch(Exception e) { 209 } 211 String jndiName = null; 212 String factoryName = null; 213 214 ResourceRefDesc[] rrDesc = desc.getResourceRefDesc(); 215 for (int i = 0; i < rrDesc.length; i ++) { 216 if ("javax.mail.internet.MimePartDataSource".equals(rrDesc[i].getTypeName())) { 217 219 jndiName = rrDesc[i].getJndiName(); 221 222 if (mailServ != null) { 223 factoryName = mailServ.getFactoryName(jndiName); 225 if (factoryName != null) 226 result.put(jndiName, factoryName); 227 else 228 result.put(jndiName, ""); 229 } else { 230 result.put(jndiName, ""); 232 } 233 } 234 } 235 return result; 236 } 237 238 241 public Set getAllJMSDestinationName(){ 242 Set result= new HashSet (); 243 ResourceEnvRefDesc[] rrDesc = desc.getResourceEnvRefDesc(); 244 for (int i = 0; i < rrDesc.length; i ++) { 245 if ((rrDesc[i].getType() == javax.jms.Topic .class ) 246 ||(rrDesc[i].getType() == javax.jms.Queue .class )) { 247 result.add(rrDesc[i].getJndiName()); 248 } 249 } 250 return result; 251 } 252 253 256 public Set getAllURLs() { 257 Set result= new HashSet (); 258 ResourceRefDesc[] rrDesc = desc.getResourceRefDesc(); 259 for (int i = 0; i < rrDesc.length; i ++) { 260 if ("java.net.URL".equals(rrDesc[i].getTypeName())) { 261 result.add(rrDesc[i].getJndiName()); 262 } 263 } 264 return result; 265 } 266 267 270 public int getCurrentInstancePoolSize(){ 271 return ejbToManage.getPoolSize(); 272 } 273 274 277 public String getEjbClass(){ 278 return desc.getEjbClass().getName(); 279 } 280 281 284 public String getDisplayName() { 285 return desc.getDisplayName() != null ? desc.getDisplayName() : desc.getEjbName(); 286 } 287 288 291 public String getJndiName() { 292 return desc.getJndiName(); 293 } 294 295 298 public String getHomeClass() { 299 if (desc.getHomeClass() != null) { 300 return desc.getHomeClass().getName(); 301 } else { 302 return null; 303 } 304 } 305 306 309 public String getRemoteClass() { 310 if (desc.getRemoteClass() != null) { 311 return desc.getRemoteClass().getName(); 312 } else { 313 return null; 314 } 315 } 316 317 320 public String getLocalHomeClass() { 321 if (desc.getLocalHomeClass() != null) { 322 return desc.getLocalHomeClass().getName(); 323 } else { 324 return null; 325 } 326 } 327 328 331 public String getLocalClass() { 332 if (desc.getLocalClass() != null) { 333 return desc.getLocalClass().getName(); 334 } else { 335 return null; 336 } 337 } 338 339 } 340 | Popular Tags |