1 23 24 package com.sun.enterprise.deployment.node.ejb; 25 26 import java.util.Iterator ; 27 import java.util.Map ; 28 29 import org.w3c.dom.Node ; 30 31 import com.sun.enterprise.deployment.node.XMLElement; 32 import com.sun.enterprise.deployment.node.DescriptorFactory; 33 import com.sun.enterprise.deployment.node.LifecycleCallbackNode; 34 import com.sun.enterprise.deployment.node.MethodNode; 35 36 import com.sun.enterprise.deployment.Descriptor; 37 import com.sun.enterprise.deployment.MethodDescriptor; 38 import com.sun.enterprise.deployment.EjbInitInfo; 39 40 import com.sun.enterprise.deployment.EjbDescriptor; 41 import com.sun.enterprise.deployment.EjbInterceptor; 42 import com.sun.enterprise.deployment.EjbRemovalInfo; 43 import com.sun.enterprise.deployment.EjbBundleDescriptor; 44 import com.sun.enterprise.deployment.EjbSessionDescriptor; 45 import com.sun.enterprise.deployment.EntityManagerReferenceDescriptor; 46 import com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor; 47 import com.sun.enterprise.deployment.LifecycleCallbackDescriptor; 48 import com.sun.enterprise.deployment.xml.EjbTagNames; 49 50 56 public class EjbSessionNode extends InterfaceBasedEjbNode { 57 58 private EjbSessionDescriptor descriptor; 59 60 public EjbSessionNode() { 61 super(); 62 64 registerElementHandler(new XMLElement(EjbTagNames.AROUND_INVOKE_METHOD), AroundInvokeNode.class, "addAroundInvokeDescriptor"); 65 66 registerElementHandler(new XMLElement(EjbTagNames.POST_CONSTRUCT), LifecycleCallbackNode.class, "addPostConstructDescriptor"); 67 68 registerElementHandler(new XMLElement(EjbTagNames.PRE_DESTROY), LifecycleCallbackNode.class, "addPreDestroyDescriptor"); 69 70 registerElementHandler(new XMLElement(EjbTagNames.POST_ACTIVATE_METHOD), LifecycleCallbackNode.class, "addPostActivateDescriptor"); 71 72 registerElementHandler(new XMLElement(EjbTagNames.PRE_PASSIVATE_METHOD), LifecycleCallbackNode.class, "addPrePassivateDescriptor"); 73 74 registerElementHandler(new XMLElement(EjbTagNames.TIMEOUT_METHOD), MethodNode.class, "setEjbTimeoutMethod"); 75 76 registerElementHandler(new XMLElement(EjbTagNames.INIT_METHOD), EjbInitNode.class, "addInitMethod"); 77 78 registerElementHandler(new XMLElement(EjbTagNames.REMOVE_METHOD), EjbRemoveNode.class, "addRemoveMethod"); 79 } 80 81 84 public EjbDescriptor getEjbDescriptor() { 85 86 if (descriptor==null) { 87 descriptor = (EjbSessionDescriptor) DescriptorFactory.getDescriptor(getXMLPath()); 88 descriptor.setEjbBundleDescriptor((EjbBundleDescriptor) getParentNode().getDescriptor()); 89 } 90 return descriptor; 91 } 92 93 99 protected Map getDispatchTable() { 100 Map table = super.getDispatchTable(); 102 table.put(EjbTagNames.SESSION_TYPE, "setSessionType"); 103 table.put(EjbTagNames.TRANSACTION_TYPE, "setTransactionType"); 104 return table; 105 } 106 107 115 public Node writeDescriptor(Node parent, String nodeName, Descriptor descriptor) { 116 if (! (descriptor instanceof EjbSessionDescriptor)) { 117 throw new IllegalArgumentException (getClass() + " cannot handles descriptors of type " + descriptor.getClass()); 118 } 119 EjbSessionDescriptor ejbDesc = (EjbSessionDescriptor) descriptor; 120 121 Node ejbNode = super.writeDescriptor(parent, nodeName, descriptor); 122 writeDisplayableComponentInfo(ejbNode, descriptor); 123 writeCommonHeaderEjbDescriptor(ejbNode, ejbDesc); 124 appendTextChild(ejbNode, EjbTagNames.SESSION_TYPE, ejbDesc.getSessionType()); 125 126 MethodNode methodNode = new MethodNode(); 127 128 if( ejbDesc.isTimedObject() ) { 129 methodNode.writeJavaMethodDescriptor 130 (ejbNode, EjbTagNames.TIMEOUT_METHOD, 131 ejbDesc.getEjbTimeoutMethod()); 132 } 133 134 if( ejbDesc.hasInitMethods() ) { 135 EjbInitNode initNode = new EjbInitNode(); 136 for(EjbInitInfo next : ejbDesc.getInitMethods()) { 137 initNode.writeDescriptor(ejbNode, 138 EjbTagNames.INIT_METHOD, next); 139 } 140 } 141 142 if( ejbDesc.hasRemoveMethods() ) { 143 EjbRemoveNode removeNode = new EjbRemoveNode(); 144 for(EjbRemovalInfo next : ejbDesc.getAllRemovalInfo()) { 145 removeNode.writeDescriptor(ejbNode, 146 EjbTagNames.REMOVE_METHOD, next); 147 } 148 } 149 150 151 appendTextChild(ejbNode, EjbTagNames.TRANSACTION_TYPE, ejbDesc.getTransactionType()); 152 153 writeAroundInvokeDescriptors(ejbNode, ejbDesc.getAroundInvokeDescriptors().iterator()); 155 156 writeEnvEntryDescriptors(ejbNode, ejbDesc.getEnvironmentProperties().iterator()); 158 159 writeEjbReferenceDescriptors(ejbNode, ejbDesc.getEjbReferenceDescriptors().iterator()); 161 162 writeServiceReferenceDescriptors(ejbNode, ejbDesc.getServiceReferenceDescriptors().iterator()); 164 165 writeResourceRefDescriptors(ejbNode, ejbDesc.getResourceReferenceDescriptors().iterator()); 167 168 writeResourceEnvRefDescriptors(ejbNode, ejbDesc.getJmsDestinationReferenceDescriptors().iterator()); 170 171 writeMessageDestinationRefDescriptors(ejbNode, ejbDesc.getMessageDestinationReferenceDescriptors().iterator()); 173 174 writeEntityManagerReferenceDescriptors(ejbNode, ejbDesc.getEntityManagerReferenceDescriptors().iterator()); 176 177 writeEntityManagerFactoryReferenceDescriptors(ejbNode, ejbDesc.getEntityManagerFactoryReferenceDescriptors().iterator()); 179 180 writePostConstructDescriptors(ejbNode, ejbDesc.getPostConstructDescriptors().iterator()); 182 183 writePreDestroyDescriptors(ejbNode, ejbDesc.getPreDestroyDescriptors().iterator()); 185 186 writePostActivateDescriptors(ejbNode, ejbDesc.getPostActivateDescriptors().iterator()); 188 189 writePrePassivateDescriptors(ejbNode, ejbDesc.getPrePassivateDescriptors().iterator()); 191 192 writeRoleReferenceDescriptors(ejbNode, ejbDesc.getRoleReferences().iterator()); 194 195 writeSecurityIdentityDescriptor(ejbNode, ejbDesc); 197 198 return ejbNode; 199 } 200 } 201 | Popular Tags |