EjbBundleNodepublic class EjbBundleNode extends com.sun.enterprise.deployment.node.BundleNode implements com.sun.enterprise.deployment.node.RootXMLNodeThis class handles ejb bundle xml files |
Fields Summary |
---|
public static final com.sun.enterprise.deployment.node.XMLElement | tag | public static final String | PUBLIC_DTD_ID | public static final String | PUBLIC_DTD_ID_12 | public static final String | SYSTEM_IDThe system ID of an ejb-jar document. | public static final String | SYSTEM_ID_12 | public static final String | SCHEMA_ID_21 | public static final String | SCHEMA_ID | public static final String | SPEC_VERSION | private static final List | systemIDs | private com.sun.enterprise.deployment.EjbBundleDescriptor | descriptor |
Constructors Summary |
---|
public EjbBundleNode()
super();
// register sub XMLNodes
registerElementHandler(new XMLElement(EjbTagNames.SESSION),
EjbSessionNode.class);
registerElementHandler(new XMLElement(EjbTagNames.ENTITY),
EjbEntityNode.class);
registerElementHandler(new XMLElement(EjbTagNames.MESSAGE_DRIVEN),
MessageDrivenBeanNode.class);
registerElementHandler(new XMLElement(EjbTagNames.METHOD_PERMISSION),
MethodPermissionNode.class);
registerElementHandler(new XMLElement(EjbTagNames.ROLE),
SecurityRoleNode.class, "addRole");
registerElementHandler(new XMLElement(EjbTagNames.CONTAINER_TRANSACTION),
ContainerTransactionNode.class);
registerElementHandler(new XMLElement(EjbTagNames.EXCLUDE_LIST),
ExcludeListNode.class);
registerElementHandler(new XMLElement(EjbTagNames.RELATIONSHIPS),
RelationshipsNode.class);
registerElementHandler(new XMLElement(TagNames.MESSAGE_DESTINATION),
MessageDestinationNode.class,
"addMessageDestination");
registerElementHandler(new XMLElement(EjbTagNames.APPLICATION_EXCEPTION),
EjbApplicationExceptionNode.class,
"addApplicationException");
registerElementHandler(new XMLElement(EjbTagNames.INTERCEPTOR),
EjbInterceptorNode.class,
"addInterceptor");
registerElementHandler(new XMLElement(EjbTagNames.INTERCEPTOR_BINDING),
InterceptorBindingNode.class,
"appendInterceptorBinding");
|
Methods Summary |
---|
public void | addDescriptor(java.lang.Object newDescriptor)Adds a new DOL descriptor instance to the descriptor instance associated with
this XMLNode
if (newDescriptor instanceof EjbDescriptor) {
descriptor.addEjb((EjbDescriptor) newDescriptor);
} else if (newDescriptor instanceof RelationshipDescriptor) {
descriptor.addRelationship((RelationshipDescriptor) newDescriptor);
} else if (newDescriptor instanceof MethodPermissionDescriptor) {
MethodPermissionDescriptor nd = (MethodPermissionDescriptor) newDescriptor;
MethodDescriptor[] array = nd.getMethods();
for (int i=0;i<array.length;i++) {
EjbDescriptor target = descriptor.getEjbByName(array[i].getEjbName());
MethodPermission[] mps = nd.getMethodPermissions();
for (int j=0;j<mps.length;j++) {
DOLUtils.getDefaultLogger().fine("Adding mp " + mps[j] + " to " + array[i] + " for ejb " + array[i].getEjbName());
target.addPermissionedMethod(mps[j], array[i]);
}
}
} else super.addDescriptor(newDescriptor);
| private void | addMethodPermissions(com.sun.enterprise.deployment.EjbDescriptor ejb, java.util.Map mpToMethods, java.util.Vector excludedMethods, MethodPermissionNode mpNode, org.w3c.dom.Node assemblyNode)
if (mpToMethods==null || mpToMethods.size()==0) {
return;
}
for (Iterator mpIterator = mpToMethods.keySet().iterator();mpIterator.hasNext();) {
MethodPermission mp = (MethodPermission) mpIterator.next();
if (mp.isExcluded()) {
// we need to be sure the method descriptors knows who owns them
Set methods = (Set) mpToMethods.get(mp);
excludedMethods.addAll(methods);
} else {
MethodPermissionDescriptor mpd = new MethodPermissionDescriptor();
mpd.addMethodPermission(mp);
mpd.addMethods((Set) mpToMethods.get(mp));
mpNode.writeDescriptor(assemblyNode, EjbTagNames.METHOD_PERMISSION, mpd, ejb);
}
}
| public java.lang.Object | getDescriptor()
if (descriptor==null) {
descriptor = (EjbBundleDescriptor) DescriptorFactory.getDescriptor(getXMLPath());
}
return descriptor;
| protected java.util.Map | getDispatchTable()all sub-implementation of this class can use a dispatch table to map xml element to
method name on the descriptor class for setting the element value.
// no need to be synchronized for now
Map table = super.getDispatchTable();
table.put(EjbTagNames.EJB_CLIENT_JAR, "setEjbClientJarUri");
return table;
| public java.lang.String | getDocType()
return null;
| public java.lang.String | getSpecVersion()
return SPEC_VERSION;
| public java.lang.String | getSystemID()
return SCHEMA_ID;
| public java.util.List | getSystemIDs()
return systemIDs;
| protected com.sun.enterprise.deployment.node.XMLElement | getXMLRootTag()
return tag;
| private static java.util.List | initSystemIDs()
ArrayList<String> systemIDs = new ArrayList<String>();
systemIDs.add(SCHEMA_ID);
systemIDs.add(SCHEMA_ID_21);
return Collections.unmodifiableList(systemIDs);
| public static java.lang.String | registerBundle(java.util.Map publicIDToDTD)register this node as a root node capable of loading entire DD files
publicIDToDTD.put(PUBLIC_DTD_ID, SYSTEM_ID);
publicIDToDTD.put(PUBLIC_DTD_ID_12, SYSTEM_ID_12);
return tag.getQName();
| private void | writeAssemblyDescriptor(org.w3c.dom.Node parentNode, com.sun.enterprise.deployment.EjbBundleDescriptor bundleDescriptor)write assembly-descriptor related xml information to the DOM tree
Node assemblyNode = parentNode.getOwnerDocument().createElement(EjbTagNames.ASSEMBLY_DESCRIPTOR);
// security-role*
SecurityRoleNode roleNode = new SecurityRoleNode();
for (Iterator e = bundleDescriptor.getRoles().iterator();e.hasNext();) {
roleNode.writeDescriptor(assemblyNode, EjbTagNames.ROLE, (Role) e.next());
}
// method-permission*
Map excludedMethodsByEjb = new HashMap();
MethodPermissionNode mpNode = new MethodPermissionNode();
for (Iterator e = bundleDescriptor.getEjbs().iterator();e.hasNext();) {
EjbDescriptor ejbDesc = (EjbDescriptor) e.next();
if (ejbDesc instanceof EjbMessageBeanDescriptor)
continue;
Vector excludedMethods = new Vector();
addMethodPermissions(ejbDesc, ejbDesc.getPermissionedMethodsByPermission(), excludedMethods, mpNode, assemblyNode);
addMethodPermissions(ejbDesc, ejbDesc.getStyledPermissionedMethodsByPermission(), excludedMethods, mpNode, assemblyNode);
if (excludedMethods.size()>0) {
excludedMethodsByEjb.put(ejbDesc, excludedMethods);
}
}
// container-transaction*
ContainerTransactionNode ctNode = new ContainerTransactionNode();
for (Iterator e = bundleDescriptor.getEjbs().iterator();e.hasNext();) {
EjbDescriptor ejbDesc = (EjbDescriptor) e.next();
ctNode.writeDescriptor(assemblyNode, EjbTagNames.CONTAINER_TRANSACTION, ejbDesc);
}
// interceptor-binding*
Set ejbsForInterceptors = bundleDescriptor.getEjbs();
InterceptorBindingNode interceptorBindingNode = new
InterceptorBindingNode();
for(Iterator itr = ejbsForInterceptors.iterator(); itr.hasNext();) {
EjbDescriptor ejbDesc = (EjbDescriptor) itr.next();
if( ejbDesc.getInterceptorClasses().size() > 0 ) {
interceptorBindingNode.writeBindings(assemblyNode,
ejbDesc);
}
}
// message-destination*
writeMessageDestinations
(assemblyNode, bundleDescriptor.getMessageDestinations().iterator());
// exclude-list*
if (excludedMethodsByEjb.size()>0) {
Node excludeListNode = this.appendChild(assemblyNode, EjbTagNames.EXCLUDE_LIST);
for (Iterator ejbs = excludedMethodsByEjb.keySet().iterator(); ejbs.hasNext();) {
EjbDescriptor ejbDesc = (EjbDescriptor) ejbs.next();
Vector excludedMethods = (Vector) excludedMethodsByEjb.get(ejbDesc);
MethodPermissionDescriptor mpd = new MethodPermissionDescriptor();
mpd.addMethodPermission(MethodPermission.getExcludedMethodPermission());
mpd.addMethods(excludedMethods);
mpNode.writeDescriptorInNode(excludeListNode, mpd, ejbDesc);
}
}
for(EjbApplicationExceptionInfo next :
bundleDescriptor.getApplicationExceptions()) {
EjbApplicationExceptionNode node = new EjbApplicationExceptionNode();
node.writeDescriptor(assemblyNode, EjbTagNames.APPLICATION_EXCEPTION,
next);
}
if (assemblyNode.hasChildNodes()) {
parentNode.appendChild(assemblyNode);
}
| public org.w3c.dom.Node | writeDescriptor(org.w3c.dom.Node parent, com.sun.enterprise.deployment.Descriptor descriptor)write the descriptor class to a DOM tree and return it
if (! (descriptor instanceof EjbBundleDescriptor)) {
throw new IllegalArgumentException(getClass() + " cannot handles descriptors of type " + descriptor.getClass());
}
EjbBundleDescriptor ejbDesc = (EjbBundleDescriptor) descriptor;
Node jarNode = super.writeDescriptor(parent, ejbDesc);
Node entrepriseBeansNode = appendChild(jarNode, EjbTagNames.EJBS);
for (Iterator ejbs = ejbDesc.getEjbs().iterator();ejbs.hasNext();) {
EjbDescriptor ejb = (EjbDescriptor) ejbs.next();
if (EjbSessionDescriptor.TYPE.equals(ejb.getType())) {
EjbNode subNode = new EjbSessionNode();
subNode.writeDescriptor(entrepriseBeansNode,
EjbTagNames.SESSION, ejb);
} else if (EjbEntityDescriptor.TYPE.equals(ejb.getType())) {
EjbNode subNode = new EjbEntityNode();
subNode.writeDescriptor(entrepriseBeansNode,
EjbTagNames.ENTITY, ejb);
} else if (EjbMessageBeanDescriptor.TYPE.equals(ejb.getType())) {
EjbNode subNode = new MessageDrivenBeanNode();
subNode.writeDescriptor(entrepriseBeansNode,
EjbTagNames.MESSAGE_DRIVEN, ejb);
} else {
throw new IllegalStateException("Unknow ejb type " + ejb.getType());
}
}
if( ejbDesc.hasInterceptors() ) {
Node interceptorsNode = appendChild(jarNode,
EjbTagNames.INTERCEPTORS);
EjbInterceptorNode interceptorNode = new EjbInterceptorNode();
for(EjbInterceptor next : ejbDesc.getInterceptors()) {
interceptorNode.writeDescriptor( interceptorsNode,
EjbTagNames.INTERCEPTOR, next);
}
}
// relationships*
if (ejbDesc.hasRelationships()) {
(new RelationshipsNode()).writeDescriptor(jarNode, EjbTagNames.RELATIONSHIPS, ejbDesc);
}
// assembly-descriptor
writeAssemblyDescriptor(jarNode, ejbDesc);
appendTextChild(jarNode, EjbTagNames.EJB_CLIENT_JAR, ejbDesc.getEjbClientJarUri());
return jarNode;
|
|