[jboss-cvs] JBossAS SVN: r58207 - in trunk/server/src/main/org/jboss: deployment metadata
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 8 14:56:37 EST 2006
Author: alex.loubyansky at jboss.com
Date: 2006-11-08 14:56:33 -0500 (Wed, 08 Nov 2006)
New Revision: 58207
Modified:
trunk/server/src/main/org/jboss/deployment/EjbJarObjectFactory.java
trunk/server/src/main/org/jboss/metadata/ApplicationMetaData.java
trunk/server/src/main/org/jboss/metadata/MethodMetaData.java
Log:
complete assembly-descriptor support
Modified: trunk/server/src/main/org/jboss/deployment/EjbJarObjectFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EjbJarObjectFactory.java 2006-11-08 19:08:17 UTC (rev 58206)
+++ trunk/server/src/main/org/jboss/deployment/EjbJarObjectFactory.java 2006-11-08 19:56:33 UTC (rev 58207)
@@ -21,15 +21,12 @@
*/
package org.jboss.deployment;
-import java.util.ArrayList;
-import java.util.List;
import org.jboss.logging.Logger;
import org.jboss.metadata.ApplicationMetaData;
import org.jboss.metadata.DDObjectFactory;
import org.jboss.metadata.EntityMetaData;
import org.jboss.metadata.IconMetaData;
-import org.jboss.metadata.MessageDestinationMetaData;
import org.jboss.metadata.MessageDrivenMetaData;
import org.jboss.metadata.MethodMetaData;
import org.jboss.metadata.QueryMetaData;
@@ -38,6 +35,7 @@
import org.jboss.metadata.SecurityIdentityMetaData;
import org.jboss.metadata.SecurityRoleMetaData;
import org.jboss.metadata.SessionMetaData;
+import org.jboss.metadata.BeanMetaData;
import org.jboss.xb.binding.ObjectModelFactory;
import org.jboss.xb.binding.UnmarshallingContext;
import org.xml.sax.Attributes;
@@ -56,23 +54,6 @@
private int ejbVersion = 2;
private int ejbMinorVersion = 0;
- static class AssemblyDescriptor
- {
- static class MethodPermission
- {
- List<MethodMetaData> methods = new ArrayList<MethodMetaData>();
- }
- static class ContainerTransaction
- {
-
- }
- List<SecurityRoleMetaData> securityRoles = new ArrayList<SecurityRoleMetaData>();
- List<MethodPermission> methodPermissions = new ArrayList<MethodPermission>();
- List<ContainerTransaction> transactions = new ArrayList<ContainerTransaction>();
- List<MessageDestinationMetaData> destinations = new ArrayList<MessageDestinationMetaData>();
- List<MethodMetaData> excluded = new ArrayList<MethodMetaData>();
- }
-
public void startDTD(String name, String publicId, String systemId)
{
// Check for a known public Id
@@ -150,7 +131,7 @@
else if (localName.equals("ejb-relation"))
child = new RelationMetaData();
else if( localName.equals("assembly-descriptor"))
- child = new AssemblyDescriptor();
+ child = new AssemblyDescriptor(dd);
else if(localName.equals("icon"))
child = new IconMetaData();
else if (log.isTraceEnabled())
@@ -187,6 +168,7 @@
}
return child;
}
+
public Object newChild(MessageDrivenMetaData mdb, UnmarshallingContext navigator,
String namespaceURI, String localName, Attributes attrs)
{
@@ -202,6 +184,7 @@
}
return child;
}
+
public Object newChild(SessionMetaData session, UnmarshallingContext navigator,
String namespaceURI, String localName, Attributes attrs)
{
@@ -251,6 +234,46 @@
return child;
}
+ public Object newChild(AssemblyDescriptor ad, UnmarshallingContext navigator,
+ String namespaceURI, String localName, Attributes attrs)
+ {
+ if(localName.equals("security-role"))
+ {
+ return ad;
+ }
+ else if(localName.equals("method-permission") ||
+ localName.equals("container-transaction"))
+ {
+ return new MethodMetaData();
+ }
+ else if(localName.equals("method"))
+ {
+ MethodMetaData method = new MethodMetaData();
+ method.setExcluded();
+ return method;
+ }
+ else if(localName.equals("exclude-list"))
+ {
+ return ad;
+ }
+ return null;
+ }
+
+ public Object newChild(MethodMetaData method, UnmarshallingContext navigator,
+ String namespaceURI, String localName, Attributes attrs)
+ {
+ if(localName.equals("method") ||
+ localName.equals("method-params"))
+ {
+ return method;
+ }
+ else if(localName.equals("unchecked"))
+ {
+ method.setUnchecked();
+ }
+ return null;
+ }
+
public void addChild(ApplicationMetaData parent, EntityMetaData entity,
UnmarshallingContext navigator, String namespaceURI, String localName)
{
@@ -275,12 +298,6 @@
parent.addRelationship(relation);
}
- public void addChild(ApplicationMetaData parent, AssemblyDescriptor ad,
- UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- // TODO
- }
-
public void addChild(EntityMetaData parent, CMPFieldMetaData field,
UnmarshallingContext navigator, String namespaceURI, String localName)
{
@@ -307,6 +324,34 @@
}
}
+ public void addChild(AssemblyDescriptor ad, MethodMetaData method,
+ UnmarshallingContext ctx, String namespaceURI, String localName)
+ {
+ if(method.getEjbName() == null)
+ {
+ throw new IllegalStateException("Method permission without ejb-name!");
+ }
+
+ BeanMetaData bean = ad.app.getBeanByEjbName(method.getEjbName());
+ if(bean == null)
+ {
+ throw new IllegalStateException("Bean " + method.getEjbName() + " not found in the application.");
+ }
+
+ if(method.isExcluded())
+ {
+ bean.addExcludedMethod(method);
+ }
+ else if(method.isUnchecked() || !method.getRoles().isEmpty())
+ {
+ bean.addPermissionMethod(method);
+ }
+ else
+ {
+ bean.addTransactionMethod(method);
+ }
+ }
+
/**
* Set text values of ejb-jar/* children
* @param dd
@@ -514,10 +559,62 @@
}
}
+ public void setValue(AssemblyDescriptor ad,
+ UnmarshallingContext navigator, String namespaceURI, String localName,
+ String value)
+ {
+ if(localName.equals("role-name"))
+ {
+ ad.app.getAssemblyDescriptor().addSecurityRoleMetaData(new SecurityRoleMetaData(value));
+ }
+ }
+
+ public void setValue(MethodMetaData method,
+ UnmarshallingContext navigator, String namespaceURI, String localName,
+ String value)
+ {
+ // direct children
+ if(localName.equals("role-name"))
+ {
+ method.getRoles().add(value);
+ }
+ // method children
+ else if(localName.equals("ejb-name"))
+ {
+ method.setEjbName(value);
+ }
+ else if(localName.equals("method-intf"))
+ {
+ method.setInterfaceType(value);
+ }
+ else if(localName.equals("method-name"))
+ {
+ method.setMethodName(value);
+ }
+ else if(localName.equals("method-param"))
+ {
+ method.addParam(value);
+ }
+ else if(localName.equals("trans-attribute"))
+ {
+ method.setTransactionType(value);
+ }
+ }
+
// inner
public static class CMPFieldMetaData
{
String name;
}
+
+ public static class AssemblyDescriptor
+ {
+ ApplicationMetaData app;
+
+ public AssemblyDescriptor(ApplicationMetaData app)
+ {
+ this.app = app;
+ }
+ }
}
Modified: trunk/server/src/main/org/jboss/metadata/ApplicationMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/ApplicationMetaData.java 2006-11-08 19:08:17 UTC (rev 58206)
+++ trunk/server/src/main/org/jboss/metadata/ApplicationMetaData.java 2006-11-08 19:56:33 UTC (rev 58207)
@@ -695,41 +695,9 @@
Element containerTransaction = (Element)iterator.next();
// find the type of the transaction
- byte transactionType;
String type = getElementContent(getUniqueChild(containerTransaction, "trans-attribute"));
+ byte transactionType = MethodMetaData.getTransactionAttribute(type);
- if (type.equalsIgnoreCase("NotSupported") ||
- type.equalsIgnoreCase("Not_Supported"))
- {
- transactionType = TX_NOT_SUPPORTED;
- }
- else if (type.equalsIgnoreCase("Supports"))
- {
- transactionType = TX_SUPPORTS;
- }
- else if (type.equalsIgnoreCase("Required"))
- {
- transactionType = TX_REQUIRED;
- }
- else if (type.equalsIgnoreCase("RequiresNew") ||
- type.equalsIgnoreCase("Requires_New"))
- {
- transactionType = TX_REQUIRES_NEW;
- }
- else if (type.equalsIgnoreCase("Mandatory"))
- {
- transactionType = TX_MANDATORY;
- }
- else if (type.equalsIgnoreCase("Never"))
- {
- transactionType = TX_NEVER;
- }
- else
- {
- throw new DeploymentException("invalid " +
- "<transaction-attribute> : " + type);
- }
-
// find the methods
Iterator methods = getChildrenByTagName(containerTransaction, "method");
while (methods.hasNext())
Modified: trunk/server/src/main/org/jboss/metadata/MethodMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/MethodMetaData.java 2006-11-08 19:08:17 UTC (rev 58206)
+++ trunk/server/src/main/org/jboss/metadata/MethodMetaData.java 2006-11-08 19:56:33 UTC (rev 58207)
@@ -141,11 +141,21 @@
return methodName;
}
+ public void setMethodName(String methodName)
+ {
+ this.methodName = methodName;
+ }
+
public String getEjbName()
{
return ejbName;
}
+ public void setEjbName(String ejbName)
+ {
+ this.ejbName = ejbName;
+ }
+
public boolean isHomeMethod()
{
return methodType == InvocationType.HOME;
@@ -192,6 +202,35 @@
return type;
}
+ public void setInterfaceType(String methodIntf)
+ {
+ if (methodIntf.equals("Home"))
+ {
+ methodType = InvocationType.HOME;
+ }
+ else if (methodIntf.equals("Remote"))
+ {
+ methodType = InvocationType.REMOTE;
+ }
+ else if (methodIntf.equals("LocalHome"))
+ {
+ methodType = InvocationType.LOCALHOME;
+ }
+ else if (methodIntf.equals("Local"))
+ {
+ methodType = InvocationType.LOCAL;
+ }
+ else if (methodIntf.equals("ServiceEndpoint"))
+ {
+ methodType = InvocationType.SERVICE_ENDPOINT;
+ }
+ else
+ {
+ throw new IllegalStateException("method-intf tag should be one of: 'Home', 'Remote', 'LocalHome', 'Local', 'ServiceEndpoint'");
+ }
+ intf = true;
+ }
+
public boolean isUnchecked()
{
return unchecked;
@@ -240,6 +279,11 @@
transactionType = type;
}
+ public void setTransactionType(String type)
+ {
+ transactionType = getTransactionAttribute(type);
+ }
+
public Set getRoles()
{
return roles;
@@ -299,8 +343,18 @@
}
}
+ public void addParam(String param)
+ {
+ if(paramList == null)
+ {
+ this.param = true;
+ paramList = new ArrayList();
+ }
+ paramList.add(param);
+ }
+
/**
- * @param a method element
+ * @param element method element
*/
public void importEjbJarXml(Element element) throws DeploymentException
{
@@ -310,32 +364,8 @@
Element intfElement = getOptionalChild(element, "method-intf");
if (intfElement != null)
{
- intf = true;
String methodIntf = getElementContent(intfElement);
- if (methodIntf.equals("Home"))
- {
- methodType = InvocationType.HOME;
- }
- else if (methodIntf.equals("Remote"))
- {
- methodType = InvocationType.REMOTE;
- }
- else if (methodIntf.equals("LocalHome"))
- {
- methodType = InvocationType.LOCALHOME;
- }
- else if (methodIntf.equals("Local"))
- {
- methodType = InvocationType.LOCAL;
- }
- else if (methodIntf.equals("ServiceEndpoint"))
- {
- methodType = InvocationType.SERVICE_ENDPOINT;
- }
- else
- {
- throw new DeploymentException("method-intf tag should be one of: 'Home', 'Remote', 'LocalHome', 'Local', 'ServiceEndpoint'");
- }
+ setInterfaceType(methodIntf);
}
Element paramsElement = getOptionalChild(element, "method-params");
@@ -382,5 +412,37 @@
return true;
}
+ public static byte getTransactionAttribute(String type)
+ {
+ if (type.equalsIgnoreCase("NotSupported") ||
+ type.equalsIgnoreCase("Not_Supported"))
+ {
+ return TX_NOT_SUPPORTED;
+ }
+ else if (type.equalsIgnoreCase("Supports"))
+ {
+ return TX_SUPPORTS;
+ }
+ else if (type.equalsIgnoreCase("Required"))
+ {
+ return TX_REQUIRED;
+ }
+ else if (type.equalsIgnoreCase("RequiresNew") ||
+ type.equalsIgnoreCase("Requires_New"))
+ {
+ return TX_REQUIRES_NEW;
+ }
+ else if (type.equalsIgnoreCase("Mandatory"))
+ {
+ return TX_MANDATORY;
+ }
+ else if (type.equalsIgnoreCase("Never"))
+ {
+ return TX_NEVER;
+ }
+
+ throw new IllegalStateException("invalid <transaction-attribute> : " + type);
+ }
+
// Inner classes -------------------------------------------------
}
More information about the jboss-cvs-commits
mailing list