1 23 24 package com.sun.enterprise.deployment.node.runtime; 25 26 import java.util.Map ; 27 import java.util.Enumeration ; 28 import java.util.Iterator ; 29 import java.util.logging.Level ; 30 import org.w3c.dom.Node ; 31 import org.w3c.dom.Element ; 32 33 import com.sun.enterprise.deployment.node.XMLElement; 34 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 35 import com.sun.enterprise.deployment.node.ServiceReferenceNode; 36 import com.sun.enterprise.deployment.node.WebServiceEndpointNode; 37 import com.sun.enterprise.deployment.Descriptor; 38 import com.sun.enterprise.deployment.EjbDescriptor; 39 import com.sun.enterprise.deployment.EjbCMPEntityDescriptor; 40 import com.sun.enterprise.deployment.IASEjbCMPEntityDescriptor; 41 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor; 42 import com.sun.enterprise.deployment.EjbSessionDescriptor; 43 import com.sun.enterprise.deployment.EjbIORConfigurationDescriptor; 44 import com.sun.enterprise.deployment.EjbBundleDescriptor; 45 import com.sun.enterprise.deployment.runtime.MdbConnectionFactoryDescriptor; 46 import com.sun.enterprise.deployment.runtime.BeanPoolDescriptor; 47 import com.sun.enterprise.deployment.runtime.BeanCacheDescriptor; 48 import com.sun.enterprise.deployment.runtime.FlushAtEndOfMethodDescriptor; 49 import com.sun.enterprise.deployment.runtime.CheckpointAtEndOfMethodDescriptor; 50 import com.sun.enterprise.deployment.QueryDescriptor; 51 import com.sun.enterprise.deployment.Application; 52 import com.sun.enterprise.deployment.RunAsIdentityDescriptor; 53 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 54 import com.sun.enterprise.deployment.JmsDestinationReferenceDescriptor; 55 import com.sun.enterprise.deployment.types.EjbReference; 56 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 57 import com.sun.enterprise.deployment.xml.WebServicesTagNames; 58 import com.sun.enterprise.deployment.util.DOLUtils; 59 60 66 public class EjbNode extends DeploymentDescriptorNode { 67 68 private EjbDescriptor descriptor; 69 private String availEnabled; 70 71 72 public EjbNode() { 73 super(); 74 registerElementHandler(new XMLElement(RuntimeTagNames.RESOURCE_REFERENCE), 75 ResourceRefNode.class); 76 registerElementHandler(new XMLElement(RuntimeTagNames.EJB_REFERENCE), 77 EjbRefNode.class); 78 registerElementHandler(new XMLElement(RuntimeTagNames.RESOURCE_ENV_REFERENCE), 79 ResourceEnvRefNode.class); 80 registerElementHandler(new XMLElement(RuntimeTagNames.MESSAGE_DESTINATION_REFERENCE), 81 MessageDestinationRefNode.class); 82 registerElementHandler(new XMLElement(WebServicesTagNames.SERVICE_REF), 83 ServiceRefNode.class); 84 registerElementHandler(new XMLElement(RuntimeTagNames.CMP), 85 CmpNode.class); 86 registerElementHandler(new XMLElement(RuntimeTagNames.MDB_CONNECTION_FACTORY), 87 MDBConnectionFactoryNode.class); 88 registerElementHandler(new XMLElement(RuntimeTagNames.IOR_CONFIG), 89 IORConfigurationNode.class,"addIORConfigurationDescriptor"); 90 registerElementHandler(new XMLElement(RuntimeTagNames.BEAN_POOL), 91 BeanPoolNode.class); 92 registerElementHandler(new XMLElement(RuntimeTagNames.BEAN_CACHE), 93 BeanCacheNode.class); 94 registerElementHandler(new XMLElement(RuntimeTagNames.MDB_RESOURCE_ADAPTER), 95 MDBResourceAdapterNode.class); 96 registerElementHandler(new XMLElement(WebServicesTagNames.WEB_SERVICE_ENDPOINT), 97 WebServiceEndpointRuntimeNode.class); 98 registerElementHandler(new XMLElement(RuntimeTagNames.FLUSH_AT_END_OF_METHOD), FlushAtEndOfMethodNode.class); 99 registerElementHandler(new XMLElement(RuntimeTagNames.CHECKPOINT_AT_END_OF_METHOD), CheckpointAtEndOfMethodNode.class); 100 } 101 102 105 public Object getDescriptor() { 106 return descriptor; 107 } 108 109 115 public void setElementValue(XMLElement element, String value) { 116 if (RuntimeTagNames.EJB_NAME.equals(element.getQName())) { 117 Object parentDesc = getParentNode().getDescriptor(); 118 if (parentDesc==null) { 119 Object application = getParentNode().getParentNode().getDescriptor(); 123 if (application!=null && application instanceof Application) { 124 descriptor = ((Application) application).getEjbByName(value); 125 } 126 } else { 127 if (parentDesc instanceof EjbBundleDescriptor) { 128 descriptor = ((EjbBundleDescriptor) parentDesc).getEjbByName(value); 129 } 130 } 131 if (descriptor==null) { 132 DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure", 133 new Object []{element , value}); 134 } else { 135 if (availEnabled != null) { 136 descriptor.getIASEjbExtraDescriptors().setAttributeValue(descriptor.getIASEjbExtraDescriptors().AVAILABILITY_ENABLED, availEnabled); 137 } 138 } 139 return; 140 } else if (descriptor==null && ! RuntimeTagNames.AVAILABILITY_ENABLED.equals(element.getQName())) { 141 DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure", 142 new Object [] {element.getQName() , value }); 143 } 144 if (RuntimeTagNames.AVAILABILITY_ENABLED.equals(element.getQName())) { 147 availEnabled = value; 148 } else if (RuntimeTagNames.NAME.equals(element.getQName())) { 149 if (Boolean.FALSE.equals(descriptor.getUsesCallerIdentity()) 151 && descriptor.getRunAsIdentity() != null) { 152 descriptor.getRunAsIdentity().setPrincipal(value); 153 } 154 } else if (RuntimeTagNames.PASS_BY_REFERENCE.equals(element.getQName())) { 155 descriptor.getIASEjbExtraDescriptors().setPassByReference(Boolean.valueOf(value)); 156 } else if (RuntimeTagNames.JMS_MAX_MESSAGES_LOAD.equals(element.getQName())) { 157 descriptor.getIASEjbExtraDescriptors().setJmsMaxMessagesLoad((Integer.valueOf(value)).intValue()); 158 } else if (RuntimeTagNames.IS_READ_ONLY_BEAN.equals(element.getQName())) { 159 descriptor.getIASEjbExtraDescriptors().setIsReadOnlyBean((Boolean.valueOf(value)).booleanValue()); 160 } else if (RuntimeTagNames.REFRESH_PERIOD_IN_SECONDS.equals(element.getQName())) { 161 descriptor.getIASEjbExtraDescriptors().setRefreshPeriodInSeconds((Integer.valueOf(value)).intValue()); 162 } else if (RuntimeTagNames.COMMIT_OPTION.equals(element.getQName())) { 163 descriptor.getIASEjbExtraDescriptors().setCommitOption(value); 164 } else if (RuntimeTagNames.CMT_TIMEOUT_IN_SECONDS.equals(element.getQName())) { 165 descriptor.getIASEjbExtraDescriptors().setCmtTimeoutInSeconds((Integer.valueOf(value)).intValue()); 166 } else if (RuntimeTagNames.USE_THREAD_POOL_ID.equals(element.getQName())) { 167 descriptor.getIASEjbExtraDescriptors().setUseThreadPoolId(value); 168 } else if (RuntimeTagNames.CHECKPOINTED_METHODS.equals( 169 element.getQName())) { 170 descriptor.getIASEjbExtraDescriptors().setCheckpointedMethods( 171 value); 172 } 173 else super.setElementValue(element, value); 174 } 175 176 182 protected Map getDispatchTable() { 183 Map table = super.getDispatchTable(); 184 185 table.put(RuntimeTagNames.JNDI_NAME, "setJndiName"); 186 187 table.put(RuntimeTagNames.REMOTE_IMPL, "setEJBObjectImplClassName"); 189 table.put(RuntimeTagNames.LOCAL_IMPL, "setEJBLocalObjectImplClassName"); 190 table.put(RuntimeTagNames.REMOTE_HOME_IMPL, "setRemoteHomeImplClassName"); 191 table.put(RuntimeTagNames.LOCAL_HOME_IMPL, "setLocalHomeImplClassName"); 192 193 table.put(RuntimeTagNames.DURABLE_SUBSCRIPTION, "setDurableSubscriptionName"); 195 table.put(RuntimeTagNames.MDB_CONNECTION_FACTORY, "setConnectionFactoryName"); 196 table.put(RuntimeTagNames.RESOURCE_ADAPTER_MID, "setResourceAdapterMid"); 197 return table; 198 } 199 200 206 public void addDescriptor(Object newDescriptor) { 207 if (newDescriptor instanceof MdbConnectionFactoryDescriptor) { 208 descriptor.getIASEjbExtraDescriptors().setMdbConnectionFactory( 209 (MdbConnectionFactoryDescriptor) newDescriptor); 210 } else 211 if (newDescriptor instanceof BeanPoolDescriptor) { 212 descriptor.getIASEjbExtraDescriptors().setBeanPool( 213 (BeanPoolDescriptor) newDescriptor); 214 } else 215 if (newDescriptor instanceof BeanCacheDescriptor) { 216 descriptor.getIASEjbExtraDescriptors().setBeanCache( 217 (BeanCacheDescriptor) newDescriptor); 218 } else 219 if (newDescriptor instanceof FlushAtEndOfMethodDescriptor) { 220 descriptor.getIASEjbExtraDescriptors().setFlushAtEndOfMethodDescriptor((FlushAtEndOfMethodDescriptor)newDescriptor); 221 } else 222 if (newDescriptor instanceof CheckpointAtEndOfMethodDescriptor) { 223 descriptor.getIASEjbExtraDescriptors().setCheckpointAtEndOfMethodDescriptor((CheckpointAtEndOfMethodDescriptor)newDescriptor); 224 } 225 } 226 227 235 public Node writeDescriptor(Node parent, String nodeName, EjbDescriptor ejbDescriptor) { 236 Element ejbNode = (Element )super.writeDescriptor(parent, nodeName, ejbDescriptor); 237 appendTextChild(ejbNode, RuntimeTagNames.EJB_NAME, ejbDescriptor.getName()); 238 appendTextChild(ejbNode, RuntimeTagNames.JNDI_NAME, ejbDescriptor.getJndiName()); 239 240 RuntimeDescriptorNode.writeCommonComponentInfo(ejbNode, (Descriptor) ejbDescriptor); 241 242 appendTextChild(ejbNode, RuntimeTagNames.PASS_BY_REFERENCE, 243 String.valueOf(ejbDescriptor.getIASEjbExtraDescriptors().getPassByReference())); 244 245 if (ejbDescriptor instanceof IASEjbCMPEntityDescriptor) { 246 CmpNode cmpNode = new CmpNode(); 247 cmpNode.writeDescriptor(ejbNode, RuntimeTagNames.CMP, (IASEjbCMPEntityDescriptor) ejbDescriptor); 248 } 249 250 if ( Boolean.FALSE.equals(ejbDescriptor.getUsesCallerIdentity()) ) { 252 RunAsIdentityDescriptor raid = ejbDescriptor.getRunAsIdentity(); 253 if ( raid != null && raid.getPrincipal() != null ) { 254 Node principalNode = appendChild(ejbNode, RuntimeTagNames.PRINCIPAL); 255 appendTextChild(principalNode, RuntimeTagNames.NAME,raid.getPrincipal()); 256 } 257 } 258 259 if (ejbDescriptor instanceof EjbMessageBeanDescriptor) { 260 EjbMessageBeanDescriptor msgBeanDesc = (EjbMessageBeanDescriptor) ejbDescriptor; 261 262 if (ejbDescriptor.getIASEjbExtraDescriptors().getMdbConnectionFactory()!=null) { 264 MDBConnectionFactoryNode mcfNode = new MDBConnectionFactoryNode(); 265 mcfNode.writeDescriptor(ejbNode, RuntimeTagNames.MDB_CONNECTION_FACTORY, 266 ejbDescriptor.getIASEjbExtraDescriptors().getMdbConnectionFactory()); 267 } 268 269 if (msgBeanDesc.hasDurableSubscription()) { 271 appendTextChild(ejbNode, RuntimeTagNames.DURABLE_SUBSCRIPTION, 272 msgBeanDesc.getDurableSubscriptionName()); 273 } 274 appendTextChild(ejbNode, RuntimeTagNames.JMS_MAX_MESSAGES_LOAD, 275 String.valueOf(ejbDescriptor.getIASEjbExtraDescriptors().getJmsMaxMessagesLoad())); 276 } 277 278 IORConfigurationNode iorNode = new IORConfigurationNode(); 280 for (Iterator iorIterator = ejbDescriptor.getIORConfigurationDescriptors().iterator(); 281 iorIterator.hasNext();) { 282 iorNode.writeDescriptor(ejbNode,RuntimeTagNames.IOR_CONFIG, (EjbIORConfigurationDescriptor) iorIterator.next()); 283 } 284 285 appendTextChild(ejbNode, RuntimeTagNames.IS_READ_ONLY_BEAN, 286 String.valueOf(ejbDescriptor.getIASEjbExtraDescriptors().isIsReadOnlyBean())); 287 appendTextChild(ejbNode, RuntimeTagNames.REFRESH_PERIOD_IN_SECONDS, 288 String.valueOf(ejbDescriptor.getIASEjbExtraDescriptors().getRefreshPeriodInSeconds())); 289 appendTextChild(ejbNode, RuntimeTagNames.COMMIT_OPTION, 290 ejbDescriptor.getIASEjbExtraDescriptors().getCommitOption()); 291 appendTextChild(ejbNode, RuntimeTagNames.CMT_TIMEOUT_IN_SECONDS, 292 String.valueOf(ejbDescriptor.getIASEjbExtraDescriptors().getCmtTimeoutInSeconds())); 293 appendTextChild(ejbNode, RuntimeTagNames.USE_THREAD_POOL_ID, 294 ejbDescriptor.getIASEjbExtraDescriptors().getUseThreadPoolId()); 295 296 writeGenClasses(ejbNode, ejbDescriptor); 298 299 BeanPoolDescriptor beanPoolDesc = ejbDescriptor.getIASEjbExtraDescriptors().getBeanPool(); 301 if (beanPoolDesc!=null) { 302 BeanPoolNode bpNode = new BeanPoolNode(); 303 bpNode.writeDescriptor(ejbNode, RuntimeTagNames.BEAN_POOL, beanPoolDesc); 304 } 305 306 BeanCacheDescriptor beanCacheDesc = ejbDescriptor.getIASEjbExtraDescriptors().getBeanCache(); 308 if (beanCacheDesc!=null) { 309 BeanCacheNode bcNode = new BeanCacheNode(); 310 bcNode.writeDescriptor(ejbNode, RuntimeTagNames.BEAN_CACHE, beanCacheDesc); 311 } 312 313 if (ejbDescriptor instanceof EjbMessageBeanDescriptor) { 314 EjbMessageBeanDescriptor msgBeanDesc = (EjbMessageBeanDescriptor) ejbDescriptor; 315 if (msgBeanDesc.hasResourceAdapterMid()) { 316 MDBResourceAdapterNode mdb = new MDBResourceAdapterNode(); 317 mdb.writeDescriptor(ejbNode, RuntimeTagNames.MDB_RESOURCE_ADAPTER, msgBeanDesc); 318 } 319 } else if( ejbDescriptor instanceof EjbSessionDescriptor ) { 320 321 WebServiceEndpointRuntimeNode wsRuntime = new WebServiceEndpointRuntimeNode(); 323 wsRuntime.writeWebServiceEndpointInfo(ejbNode, ejbDescriptor); 324 } 325 326 FlushAtEndOfMethodDescriptor flushMethodDesc = ejbDescriptor.getIASEjbExtraDescriptors().getFlushAtEndOfMethodDescriptor(); 328 if (flushMethodDesc!=null) { 329 FlushAtEndOfMethodNode flushNode = new FlushAtEndOfMethodNode(); 330 flushNode.writeDescriptor(ejbNode, RuntimeTagNames.FLUSH_AT_END_OF_METHOD, flushMethodDesc); 331 } 332 333 ejbDescriptor.getIASEjbExtraDescriptors().parseCheckpointedMethods(ejbDescriptor); 335 336 CheckpointAtEndOfMethodDescriptor checkpointMethodDesc = ejbDescriptor.getIASEjbExtraDescriptors().getCheckpointAtEndOfMethodDescriptor(); 338 if (checkpointMethodDesc!=null) { 339 CheckpointAtEndOfMethodNode checkpointNode = 340 new CheckpointAtEndOfMethodNode(); 341 checkpointNode.writeDescriptor(ejbNode, RuntimeTagNames.CHECKPOINT_AT_END_OF_METHOD, checkpointMethodDesc); 342 } 343 344 setAttribute(ejbNode, RuntimeTagNames.AVAILABILITY_ENABLED, (String ) ejbDescriptor.getIASEjbExtraDescriptors().getAttributeValue(ejbDescriptor.getIASEjbExtraDescriptors().AVAILABILITY_ENABLED)); 346 347 return ejbNode; 348 } 349 350 355 private void writeGenClasses(Node parent, EjbDescriptor ejbDescriptor) { 356 Node genClasses = appendChild(parent, RuntimeTagNames.GEN_CLASSES); 358 359 appendTextChild(genClasses, RuntimeTagNames.REMOTE_IMPL, 360 ejbDescriptor.getEJBObjectImplClassName()); 361 362 appendTextChild(genClasses, RuntimeTagNames.LOCAL_IMPL, 363 ejbDescriptor.getEJBLocalObjectImplClassName()); 364 365 appendTextChild(genClasses, RuntimeTagNames.REMOTE_HOME_IMPL, 366 ejbDescriptor.getRemoteHomeImplClassName()); 367 368 appendTextChild(genClasses, RuntimeTagNames.LOCAL_HOME_IMPL, 369 ejbDescriptor.getLocalHomeImplClassName()); 370 371 372 373 } 374 } 375 | Popular Tags |