1 2 24 25 package com.sun.enterprise.deployment.node.appclient; 26 27 import java.util.ArrayList ; 28 import java.util.List ; 29 import java.util.Map ; 30 import org.w3c.dom.Node ; 31 32 import com.sun.enterprise.deployment.types.EjbReference; 33 34 import com.sun.enterprise.deployment.EnvironmentProperty; 35 import com.sun.enterprise.deployment.Descriptor; 36 import com.sun.enterprise.deployment.ApplicationClientDescriptor; 37 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 38 import com.sun.enterprise.deployment.EntityManagerReferenceDescriptor; 39 import com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor; 40 import com.sun.enterprise.deployment.JmsDestinationReferenceDescriptor; 41 import com.sun.enterprise.deployment.RunAsIdentityDescriptor; 42 import com.sun.enterprise.deployment.ServiceReferenceDescriptor; 43 import com.sun.enterprise.deployment.xml.TagNames; 44 import com.sun.enterprise.deployment.xml.EjbTagNames; 45 import com.sun.enterprise.deployment.xml.WebServicesTagNames; 46 import com.sun.enterprise.deployment.xml.ApplicationClientTagNames; 47 48 import com.sun.enterprise.deployment.node.DescriptorFactory; 49 import com.sun.enterprise.deployment.node.BundleNode; 50 import com.sun.enterprise.deployment.node.XMLElement; 51 import com.sun.enterprise.deployment.node.RootXMLNode; 52 import com.sun.enterprise.deployment.node.XMLNode; 53 import com.sun.enterprise.deployment.node.EjbReferenceNode; 54 import com.sun.enterprise.deployment.node.EjbLocalReferenceNode; 55 import com.sun.enterprise.deployment.node.ResourceRefNode; 56 import com.sun.enterprise.deployment.node.EnvEntryNode; 57 import com.sun.enterprise.deployment.node.ResourceEnvRefNode; 58 import com.sun.enterprise.deployment.node.MessageDestinationRefNode; 59 import com.sun.enterprise.deployment.node.EntityManagerReferenceNode; 60 import com.sun.enterprise.deployment.node.EntityManagerFactoryReferenceNode; 61 import com.sun.enterprise.deployment.node.ServiceReferenceNode; 62 import com.sun.enterprise.deployment.node.MessageDestinationNode; 63 import com.sun.enterprise.deployment.node.LifecycleCallbackNode; 64 65 import com.sun.enterprise.deployment.util.DOLUtils; 66 67 73 public class AppClientNode extends BundleNode implements RootXMLNode { 74 75 private ApplicationClientDescriptor descriptor; 77 78 public final static String PUBLIC_DTD_ID_12 = "-//Sun Microsystems, Inc.//DTD J2EE Application Client 1.2//EN"; 80 public final static String SYSTEM_ID_12 = "http://java.sun.com/dtd/application-client_1_2.dtd"; 81 82 public final static String PUBLIC_DTD_ID = "-//Sun Microsystems, Inc.//DTD J2EE Application Client 1.3//EN"; 84 public final static String SYSTEM_ID = "http://java.sun.com/dtd/application-client_1_3.dtd"; 85 86 public final static String SCHEMA_ID_14 = "application-client_1_4.xsd"; 87 88 public final static String SCHEMA_ID = "application-client_5.xsd"; 89 public final static String SPEC_VERSION = "5"; 90 private static List <String > systemIDs = null; 91 92 public final static XMLElement tag = new XMLElement(ApplicationClientTagNames.APPLICATION_CLIENT_TAG); 93 94 95 public AppClientNode() { 96 registerElementHandler(new XMLElement(TagNames.ENVIRONMENT_PROPERTY), 97 EnvEntryNode.class, "addEnvironmentProperty"); 98 registerElementHandler(new XMLElement(EjbTagNames.EJB_REFERENCE), EjbReferenceNode.class); 99 registerElementHandler(new XMLElement(EjbTagNames.EJB_LOCAL_REFERENCE), EjbLocalReferenceNode.class); 100 registerElementHandler(new XMLElement(WebServicesTagNames.SERVICE_REF), ServiceReferenceNode.class, "addServiceReferenceDescriptor"); 101 registerElementHandler(new XMLElement(EjbTagNames.RESOURCE_REFERENCE), 102 ResourceRefNode.class, "addResourceReferenceDescriptor"); 103 registerElementHandler(new XMLElement(TagNames.RESOURCE_ENV_REFERENCE), 104 ResourceEnvRefNode.class, "addJmsDestinationReferenceDescriptor"); 105 registerElementHandler(new XMLElement(TagNames.MESSAGE_DESTINATION_REFERENCE), MessageDestinationRefNode.class, "addMessageDestinationReferenceDescriptor"); 106 registerElementHandler(new XMLElement(TagNames.PERSISTENCE_UNIT_REF), EntityManagerFactoryReferenceNode.class, "addEntityManagerFactoryReferenceDescriptor"); 107 registerElementHandler(new XMLElement(TagNames.MESSAGE_DESTINATION), 108 MessageDestinationNode.class, 109 "addMessageDestination"); 110 registerElementHandler(new XMLElement(TagNames.POST_CONSTRUCT), LifecycleCallbackNode.class, "addPostConstructDescriptor"); 111 registerElementHandler(new XMLElement(TagNames.PRE_DESTROY), LifecycleCallbackNode.class, "addPreDestroyDescriptor"); 112 } 113 114 120 public static String registerBundle(Map publicIDToDTD) { 121 publicIDToDTD.put(PUBLIC_DTD_ID, SYSTEM_ID); 122 publicIDToDTD.put(PUBLIC_DTD_ID_12, SYSTEM_ID_12); 123 return tag.getQName(); 124 } 125 126 132 public void addDescriptor(Object newDescriptor) { 133 if (newDescriptor instanceof EjbReference) { 134 DOLUtils.getDefaultLogger().fine("Adding ejb ref " + newDescriptor); 135 ((ApplicationClientDescriptor)getDescriptor()).addEjbReferenceDescriptor( 136 (EjbReference) newDescriptor); 137 } else { 138 super.addDescriptor(newDescriptor); 139 } 140 } 141 142 public Object getDescriptor() { 143 if (descriptor == null) { 144 descriptor = (ApplicationClientDescriptor) DescriptorFactory.getDescriptor(getXMLPath()); 145 } 146 return descriptor; 147 } 148 149 155 protected Map getDispatchTable() { 156 Map table = super.getDispatchTable(); 158 table.put(ApplicationClientTagNames.CALLBACK_HANDLER, "setCallbackHandler"); 159 return table; 160 } 161 162 165 protected XMLElement getXMLRootTag() { 166 return tag; 167 } 168 169 172 public String getDocType() { 173 return null; 174 } 175 176 179 public String getSystemID() { 180 return SCHEMA_ID; 181 } 182 183 186 public List <String > getSystemIDs() { 187 if (systemIDs != null) { 188 return systemIDs; 189 } 190 191 systemIDs = new ArrayList <String >(); 192 systemIDs.add(SCHEMA_ID); 193 systemIDs.add(SCHEMA_ID_14); 194 return systemIDs; 195 } 196 197 198 205 public Node writeDescriptor(Node parent, Descriptor descriptor) { 206 207 if (! (descriptor instanceof ApplicationClientDescriptor)) { 208 throw new IllegalArgumentException (getClass() + " cannot handle descriptors of type " + descriptor.getClass()); 209 } 210 ApplicationClientDescriptor appclientDesc = (ApplicationClientDescriptor) descriptor; 211 Node appclientNode = super.writeDescriptor(parent, appclientDesc); 212 213 writeEnvEntryDescriptors(appclientNode, appclientDesc.getEnvironmentProperties().iterator()); 215 216 writeEjbReferenceDescriptors(appclientNode, appclientDesc.getEjbReferenceDescriptors().iterator()); 218 219 writeServiceReferenceDescriptors(appclientNode, appclientDesc.getServiceReferenceDescriptors().iterator()); 221 222 writeResourceRefDescriptors(appclientNode, appclientDesc.getResourceReferenceDescriptors().iterator()); 224 225 writeResourceEnvRefDescriptors(appclientNode, appclientDesc.getJmsDestinationReferenceDescriptors().iterator()); 227 228 writeMessageDestinationRefDescriptors(appclientNode, appclientDesc.getMessageDestinationReferenceDescriptors().iterator()); 230 231 writeEntityManagerFactoryReferenceDescriptors(appclientNode, appclientDesc.getEntityManagerFactoryReferenceDescriptors().iterator()); 233 234 writePostConstructDescriptors(appclientNode, appclientDesc.getPostConstructDescriptors().iterator()); 236 237 writePreDestroyDescriptors(appclientNode, appclientDesc.getPreDestroyDescriptors().iterator()); 239 240 appendTextChild(appclientNode, ApplicationClientTagNames.CALLBACK_HANDLER, appclientDesc.getCallbackHandler()); 241 242 writeMessageDestinations 244 (appclientNode, appclientDesc.getMessageDestinations().iterator()); 245 246 return appclientNode; 247 248 } 249 250 253 public String getSpecVersion() { 254 return SPEC_VERSION; 255 } 256 257 } 258 | Popular Tags |