1 23 24 package com.sun.enterprise.deployment.node.ejb; 25 26 import java.util.Iterator ; 27 import java.util.Map ; 28 import org.w3c.dom.Node ; 29 import java.util.logging.Level ; 30 31 import com.sun.enterprise.deployment.types.EjbReference; 32 33 import com.sun.enterprise.deployment.node.XMLElement; 34 import com.sun.enterprise.deployment.node.DisplayableComponentNode; 35 import com.sun.enterprise.deployment.node.EnvEntryNode; 36 import com.sun.enterprise.deployment.node.EjbReferenceNode; 37 import com.sun.enterprise.deployment.node.EntityManagerReferenceNode; 38 import com.sun.enterprise.deployment.node.EntityManagerFactoryReferenceNode; 39 import com.sun.enterprise.deployment.node.ServiceReferenceNode; 40 import com.sun.enterprise.deployment.node.EjbLocalReferenceNode; 41 import com.sun.enterprise.deployment.node.ResourceRefNode; 42 import com.sun.enterprise.deployment.node.ResourceEnvRefNode; 43 import com.sun.enterprise.deployment.node.MessageDestinationRefNode; 44 import com.sun.enterprise.deployment.node.LifecycleCallbackNode; 45 46 import com.sun.enterprise.deployment.EnvironmentProperty; 47 import com.sun.enterprise.deployment.Descriptor; 48 import com.sun.enterprise.deployment.EjbDescriptor; 49 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 50 import com.sun.enterprise.deployment.JmsDestinationReferenceDescriptor; 51 import com.sun.enterprise.deployment.MessageDestinationReferenceDescriptor; 52 import com.sun.enterprise.deployment.LifecycleCallbackDescriptor; 53 import com.sun.enterprise.deployment.EjbBundleDescriptor; 54 import com.sun.enterprise.deployment.ServiceReferenceDescriptor; 55 import com.sun.enterprise.deployment.RunAsIdentityDescriptor; 56 import com.sun.enterprise.deployment.xml.TagNames; 57 import com.sun.enterprise.deployment.xml.EjbTagNames; 58 import com.sun.enterprise.deployment.xml.WebServicesTagNames; 59 60 import com.sun.enterprise.deployment.util.DOLUtils; 61 62 69 public abstract class EjbNode extends DisplayableComponentNode { 70 71 72 public EjbNode() { 73 super(); 74 registerElementHandler(new XMLElement(TagNames.ENVIRONMENT_PROPERTY), 75 EnvEntryNode.class, "addEnvironmentProperty"); 76 registerElementHandler(new XMLElement(EjbTagNames.EJB_REFERENCE), EjbReferenceNode.class); 77 registerElementHandler(new XMLElement(EjbTagNames.EJB_LOCAL_REFERENCE), EjbLocalReferenceNode.class); 78 registerElementHandler(new XMLElement(WebServicesTagNames.SERVICE_REF), ServiceReferenceNode.class, "addServiceReferenceDescriptor"); 79 registerElementHandler(new XMLElement(EjbTagNames.RESOURCE_REFERENCE), 80 ResourceRefNode.class, "addResourceReferenceDescriptor"); 81 registerElementHandler(new XMLElement(EjbTagNames.SECURITY_IDENTITY), 82 SecurityIdentityNode.class); 83 registerElementHandler(new XMLElement(TagNames.RESOURCE_ENV_REFERENCE), 84 ResourceEnvRefNode.class, "addJmsDestinationReferenceDescriptor"); 85 registerElementHandler(new XMLElement(TagNames.MESSAGE_DESTINATION_REFERENCE), MessageDestinationRefNode.class); 86 registerElementHandler(new XMLElement(TagNames.PERSISTENCE_CONTEXT_REF), EntityManagerReferenceNode.class, "addEntityManagerReferenceDescriptor"); 87 registerElementHandler(new XMLElement(TagNames.PERSISTENCE_UNIT_REF), EntityManagerFactoryReferenceNode.class, "addEntityManagerFactoryReferenceDescriptor"); 88 89 } 90 91 97 public void addDescriptor(Object newDescriptor) { 98 if (newDescriptor instanceof EjbReference) { 99 if (DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) { 100 DOLUtils.getDefaultLogger().fine("Adding ejb ref " + newDescriptor); 101 } 102 getEjbDescriptor().addEjbReferenceDescriptor( 103 (EjbReference) newDescriptor); 104 } else if (newDescriptor instanceof RunAsIdentityDescriptor) { 105 if (DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) { 106 DOLUtils.getDefaultLogger().fine("Adding security-identity" + newDescriptor); 107 } 108 getEjbDescriptor().setUsesCallerIdentity(false); 109 getEjbDescriptor().setRunAsIdentity((RunAsIdentityDescriptor) newDescriptor); 110 } else if( newDescriptor instanceof 111 MessageDestinationReferenceDescriptor ) { 112 MessageDestinationReferenceDescriptor msgDestRef = 113 (MessageDestinationReferenceDescriptor) newDescriptor; 114 EjbBundleDescriptor ejbBundle = (EjbBundleDescriptor) 115 getParentNode().getDescriptor(); 116 msgDestRef.setReferringBundleDescriptor(ejbBundle); 119 getEjbDescriptor().addMessageDestinationReferenceDescriptor 120 (msgDestRef); 121 } else { 122 super.addDescriptor(newDescriptor); 123 } 124 } 125 126 public Object getDescriptor() { 127 return getEjbDescriptor(); 128 } 129 130 public abstract EjbDescriptor getEjbDescriptor(); 131 132 138 protected Map getDispatchTable() { 139 Map table = super.getDispatchTable(); 141 table.put(EjbTagNames.EJB_NAME, "setName"); 142 table.put(EjbTagNames.EJB_CLASS, "setEjbClassName"); 143 table.put(TagNames.MAPPED_NAME, "setMappedName"); 144 return table; 145 } 146 147 153 protected void writeCommonHeaderEjbDescriptor(Node ejbNode, Descriptor descriptor) { 154 EjbDescriptor ejbDescriptor = (EjbDescriptor)descriptor; 155 appendTextChild(ejbNode, EjbTagNames.EJB_NAME, descriptor.getName()); 156 appendTextChild(ejbNode, TagNames.MAPPED_NAME, ejbDescriptor.getMappedName()); 157 } 158 159 165 protected void writeSecurityIdentityDescriptor(Node parent, EjbDescriptor descriptor) { 166 167 if (!descriptor.getUsesCallerIdentity() && descriptor.getRunAsIdentity()==null) 168 return; 169 170 SecurityIdentityNode node = new SecurityIdentityNode(); 171 node.writeDescriptor(parent, EjbTagNames.SECURITY_IDENTITY, descriptor); 172 } 173 } 174 | Popular Tags |