User: starksm
Date: 01/11/12 11:32:56
Modified: src/main/org/jboss/metadata Tag: Branch_2_4
BeanMetaData.java ResourceRefMetaData.java
WebMetaData.java
Log:
Add support for resource-env-ref to WebMetaData and AbstractWebContainer.
Added an empty importXml(Element) method to AbstractWebContainer so that
subclasses can import arbitrary configuration data.
Revision Changes Path
No revision
No revision
1.23.2.3 +220 -169 jboss/src/main/org/jboss/metadata/BeanMetaData.java
Index: BeanMetaData.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/metadata/BeanMetaData.java,v
retrieving revision 1.23.2.2
retrieving revision 1.23.2.3
diff -u -r1.23.2.2 -r1.23.2.3
--- BeanMetaData.java 2001/11/02 08:42:36 1.23.2.2
+++ BeanMetaData.java 2001/11/12 19:32:56 1.23.2.3
@@ -23,58 +23,58 @@
/**
* A common meta data class for the entity, message-driven and session beans.
- *
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel OConnor</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>.
- * @author <a href="mailto:[EMAIL PROTECTED]">Ole Husgaard</a>
- * @version $Revision: 1.23.2.2 $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Ole Husgaard</a>
+ * @version $Revision: 1.23.2.3 $
*/
public abstract class BeanMetaData
- extends MetaData
+extends MetaData
{
// Constants -----------------------------------------------------
-
+
public static final char SESSION_TYPE = 'S';
public static final char ENTITY_TYPE = 'E';
public static final char MDB_TYPE = 'M';
-
+
// Attributes ----------------------------------------------------
private ApplicationMetaData application;
-
+
// from ejb-jar.xml
/** The ejb-name element specifies an enterprise bean�s name. This name is
- assigned by the ejb-jar file producer to name the enterprise bean in
- the ejb-jar file�s deployment descriptor. The name must be unique
- among the names of the enterprise beans in the same ejb-jar file.
- */
+ assigned by the ejb-jar file producer to name the enterprise bean in
+ the ejb-jar file�s deployment descriptor. The name must be unique
+ among the names of the enterprise beans in the same ejb-jar file.
+ */
private String ejbName;
/** The home element contains the fully-qualified name of the enterprise
- bean�s home interface. */
+ bean�s home interface. */
private String homeClass;
/** The remote element contains the fully-qualified name of the enterprise
- bean�s remote interface. */
+ bean�s remote interface. */
private String remoteClass;
/** The local-home element contains the fully-qualified name of the enterprise
- bean�s local home interface. */
+ bean�s local home interface. */
private String localHomeClass;
/** The local element contains the fully-qualified name of the enterprise
- bean�s local interface */
+ bean�s local interface */
private String localClass;
/** The ejb-class element contains the fully-qualified name of the enter-prise
- bean�s class. */
+ bean�s class. */
private String ejbClass;
/** The type of bean: ENTITY_TYPE, SESSION_TYPE, MDB_TYPE */
protected char beanType;
/** Is this bean's transactions managed by the container? */
protected boolean containerManagedTx = true;
-
+
/** The The env-entry element(s) contains the declaration of an enterprise
- bean�s environment entry */
+ bean�s environment entry */
private ArrayList environmentEntries = new ArrayList();
/** The The ejb-ref element(s) for the declaration of a reference to an
- enterprise bean�s home */
+ enterprise bean�s home */
private HashMap ejbReferences = new HashMap();
/** The ejb-local-ref element(s) info */
private HashMap ejbLocalReferences = new HashMap();
@@ -92,128 +92,155 @@
private ArrayList transactionMethods = new ArrayList();
/** The assembly-descriptor/exclude-list method(s) */
private ArrayList excludedMethods = new ArrayList();
-
+
// from jboss.xml
-
+
/** The JNDI name under with the home interface should be bound */
private String jndiName;
-
+
/** The JNDI name under with the local home interface should be bound */
private String localJndiName;
protected String configurationName;
private ConfigurationMetaData configuration;
private String securityProxy;
-
+
// Static --------------------------------------------------------
-
+
// Constructors --------------------------------------------------
public BeanMetaData(ApplicationMetaData app, char beanType)
{
application = app;
this.beanType = beanType;
}
-
+
// Public --------------------------------------------------------
- public boolean isSession() { return beanType == SESSION_TYPE; }
-
- public boolean isMessageDriven() { return beanType == MDB_TYPE; }
-
- public boolean isEntity() { return beanType == ENTITY_TYPE; }
-
- public String getHome() { return homeClass; }
-
- public String getRemote() { return remoteClass; }
-
- public String getLocalHome() { return localHomeClass; }
-
- public String getLocal() { return localClass; }
-
- public String getEjbClass() { return ejbClass; }
-
- public String getEjbName() { return ejbName; }
-
- public boolean isContainerManagedTx() { return containerManagedTx; }
-
- public boolean isBeanManagedTx() { return !containerManagedTx; }
-
- public Iterator getEjbReferences() { return ejbReferences.values().iterator(); }
-
- public Iterator getEjbLocalReferences() { return
ejbLocalReferences.values().iterator(); }
-
+ public boolean isSession()
+ { return beanType == SESSION_TYPE; }
+
+ public boolean isMessageDriven()
+ { return beanType == MDB_TYPE; }
+
+ public boolean isEntity()
+ { return beanType == ENTITY_TYPE; }
+
+ public String getHome()
+ { return homeClass; }
+
+ public String getRemote()
+ { return remoteClass; }
+
+ public String getLocalHome()
+ { return localHomeClass; }
+
+ public String getLocal()
+ { return localClass; }
+
+ public String getEjbClass()
+ { return ejbClass; }
+
+ public String getEjbName()
+ { return ejbName; }
+
+ public boolean isContainerManagedTx()
+ { return containerManagedTx; }
+
+ public boolean isBeanManagedTx()
+ { return !containerManagedTx; }
+
+ public Iterator getEjbReferences()
+ { return ejbReferences.values().iterator(); }
+
+ public Iterator getEjbLocalReferences()
+ { return ejbLocalReferences.values().iterator(); }
+
public EjbRefMetaData getEjbRefByName(String name)
{
return (EjbRefMetaData)ejbReferences.get(name);
}
-
+
public EjbLocalRefMetaData getEjbLocalRefByName(String name)
{
return (EjbLocalRefMetaData)ejbLocalReferences.get(name);
- }
-
- public Iterator getEnvironmentEntries() { return environmentEntries.iterator(); }
-
- public Iterator getSecurityRoleReferences() { return
securityRoleReferences.iterator(); }
-
- public Iterator getResourceReferences() { return
resourceReferences.values().iterator(); }
- public Iterator getResourceEnvReferences() { return
resourceEnvReferences.values().iterator(); }
-
+ }
+
+ public Iterator getEnvironmentEntries()
+ { return environmentEntries.iterator(); }
+
+ public Iterator getSecurityRoleReferences()
+ { return securityRoleReferences.iterator(); }
+
+ public Iterator getResourceReferences()
+ { return resourceReferences.values().iterator(); }
+ public Iterator getResourceEnvReferences()
+ { return resourceEnvReferences.values().iterator(); }
+
public String getJndiName()
- {
+ {
// jndiName may be set in jboss.xml
- if (jndiName == null) {
+ if (jndiName == null)
+ {
jndiName = ejbName;
}
return jndiName;
}
-
- /**
+
+ /**
* Gets the JNDI name under with the local home interface should be bound.
* The default is local/<ejbName>
*/
- public String getLocalJndiName() {
- if (localJndiName == null) {
+ public String getLocalJndiName()
+ {
+ if (localJndiName == null)
+ {
localJndiName = "local/" + ejbName;
}
return localJndiName;
}
-
+
public String getConfigurationName()
{
- if (configurationName == null) {
+ if (configurationName == null)
+ {
configurationName = getDefaultConfigurationName();
}
return configurationName;
}
-
+
public ConfigurationMetaData getContainerConfiguration()
{
- if (configuration == null) {
+ if (configuration == null)
+ {
configuration =
application.getConfigurationMetaDataByName(getConfigurationName());
}
return configuration;
}
-
- public String getSecurityProxy() { return securityProxy; }
+
+ public String getSecurityProxy()
+ { return securityProxy; }
public SecurityIdentityMetaData getSecurityIdentityMetaData()
{
return securityIdentity;
}
-
- public ApplicationMetaData getApplicationMetaData() { return application; }
-
+
+ public ApplicationMetaData getApplicationMetaData()
+ { return application; }
+
public abstract String getDefaultConfigurationName();
-
- public Iterator getTransactionMethods() { return transactionMethods.iterator(); }
-
- public Iterator getPermissionMethods() { return permissionMethods.iterator(); }
- public Iterator getExcludedMethods() { return excludedMethods.iterator(); }
-
-
+
+ public Iterator getTransactionMethods()
+ { return transactionMethods.iterator(); }
+
+ public Iterator getPermissionMethods()
+ { return permissionMethods.iterator(); }
+ public Iterator getExcludedMethods()
+ { return excludedMethods.iterator(); }
+
+
public void addTransactionMethod(MethodMetaData method)
- {
+ {
transactionMethods.add(method);
}
-
+
public void addPermissionMethod(MethodMetaData method)
{
// Insert unchecked methods into the front of the list to speed up their
validation
@@ -222,32 +249,34 @@
else
permissionMethods.add(method);
}
-
+
public void addExcludedMethod(MethodMetaData method)
- {
+ {
excludedMethods.add(method);
}
-
+
public byte getMethodTransactionType(String methodName, Class[] params,
- boolean remote)
+ boolean remote)
{
// default value
byte result = TX_UNKNOWN;
-
+
Iterator iterator = getTransactionMethods();
- while (iterator.hasNext()) {
+ while (iterator.hasNext())
+ {
MethodMetaData m = (MethodMetaData)iterator.next();
- if (m.patternMatches(methodName, params, remote)) {
+ if (m.patternMatches(methodName, params, remote))
+ {
result = m.getTransactionType();
-
+
// if it is an exact match, break, if it is the wildcard continue to
look for a finer match
if (!"*".equals(m.getMethodName())) break;
}
}
-
+
return result;
}
-
+
/**
* A somewhat tedious method that builds a Set<Principal> of the roles
* that have been assigned permission to execute the indicated method. The
@@ -260,35 +289,39 @@
* caller principal's are to be validated against.
* @see org.jboss.ejb.Container#getMethodPermissions(Method, boolean)
*/
- public Set getMethodPermissions(String methodName, Class[] params,
- boolean remote)
+ public Set getMethodPermissions(String methodName, Class[] params, boolean
remote)
{
Set result = new HashSet();
// First check the excluded method list as this takes priority over all other
assignments
Iterator iterator = getExcludedMethods();
- while (iterator.hasNext()) {
+ while (iterator.hasNext())
+ {
MethodMetaData m = (MethodMetaData) iterator.next();
- if (m.patternMatches(methodName, params, remote)) {
+ if (m.patternMatches(methodName, params, remote))
+ {
/* No one is allowed to execute this method so add a role that
fails to equate to any Principal or Principal name and return.
We don't return null to differentiate between an explicit
assignment of no access and no assignment information.
- */
+ */
result.add(NobodyPrincipal.NOBODY_PRINCIPAL);
return result;
}
}
-
+
// Check the permissioned methods list
iterator = getPermissionMethods();
- while (iterator.hasNext()) {
+ while (iterator.hasNext())
+ {
MethodMetaData m = (MethodMetaData) iterator.next();
- if (m.patternMatches(methodName, params, remote)) {
+ if (m.patternMatches(methodName, params, remote))
+ {
/* If this is an unchecked method anyone can access it so
set the result set to a role that equates to any Principal or
Principal name and return.
- */
- if (m.isUnchecked()) {
+ */
+ if (m.isUnchecked())
+ {
result.clear();
result.add(AnybodyPrincipal.ANYBODY_PRINCIPAL);
break;
@@ -297,107 +330,114 @@
else
{
Iterator rolesIterator = m.getRoles().iterator();
- while (rolesIterator.hasNext()) {
+ while (rolesIterator.hasNext())
+ {
String roleName = (String) rolesIterator.next();
result.add(new SimplePrincipal(roleName));
}
}
}
}
-
+
// If no permissions were assigned to the method return null to indicate no
access
if (result.isEmpty())
result = null;
return result;
}
-
+
public void importEjbJarXml(Element element) throws DeploymentException
{
// set the ejb-name
ejbName = getElementContent(getUniqueChild(element, "ejb-name"));
-
+
// set the classes
// Not for MessageDriven
- if (isMessageDriven() == false) {
+ if (isMessageDriven() == false)
+ {
homeClass = getElementContent(getOptionalChild(element, "home"));
remoteClass = getElementContent(getOptionalChild(element, "remote"));
localHomeClass = getElementContent(getOptionalChild(element,
"local-home"));
localClass = getElementContent(getOptionalChild(element, "local"));
}
ejbClass = getElementContent(getUniqueChild(element, "ejb-class"));
-
+
// set the environment entries
Iterator iterator = getChildrenByTagName(element, "env-entry");
-
- while (iterator.hasNext()) {
+
+ while (iterator.hasNext())
+ {
Element envEntry = (Element)iterator.next();
-
+
EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
envEntryMetaData.importEjbJarXml(envEntry);
-
+
environmentEntries.add(envEntryMetaData);
}
-
+
// set the ejb references
iterator = getChildrenByTagName(element, "ejb-ref");
-
- while (iterator.hasNext()) {
+
+ while (iterator.hasNext())
+ {
Element ejbRef = (Element) iterator.next();
-
+
EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
ejbRefMetaData.importEjbJarXml(ejbRef);
-
+
ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
}
-
+
// set the ejb local references
iterator = getChildrenByTagName(element, "ejb-local-ref");
-
- while (iterator.hasNext()) {
+
+ while (iterator.hasNext())
+ {
Element ejbLocalRef = (Element) iterator.next();
-
+
EjbLocalRefMetaData ejbLocalRefMetaData = new EjbLocalRefMetaData();
ejbLocalRefMetaData.importEjbJarXml(ejbLocalRef);
-
- ejbLocalReferences.put(ejbLocalRefMetaData.getName(),
- ejbLocalRefMetaData);
+
+ ejbLocalReferences.put(ejbLocalRefMetaData.getName(),
+ ejbLocalRefMetaData);
}
-
+
// set the security roles references
iterator = getChildrenByTagName(element, "security-role-ref");
-
- while (iterator.hasNext()) {
+
+ while (iterator.hasNext())
+ {
Element secRoleRef = (Element) iterator.next();
-
+
SecurityRoleRefMetaData securityRoleRefMetaData = new
SecurityRoleRefMetaData();
securityRoleRefMetaData.importEjbJarXml(secRoleRef);
-
+
securityRoleReferences.add(securityRoleRefMetaData);
}
-
+
// The security-identity element
Element securityIdentityElement = getOptionalChild(element,
"security-identity");
- if (securityIdentityElement != null) {
+ if (securityIdentityElement != null)
+ {
securityIdentity = new SecurityIdentityMetaData();
securityIdentity.importEjbJarXml(securityIdentityElement);
}
-
- // set the resource references
+
+ // Parse the resource-ref elements
iterator = getChildrenByTagName(element, "resource-ref");
-
- while (iterator.hasNext()) {
+
+ while (iterator.hasNext())
+ {
Element resourceRef = (Element) iterator.next();
-
ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
resourceRefMetaData.importEjbJarXml(resourceRef);
-
resourceReferences.put(resourceRefMetaData.getRefName(),
resourceRefMetaData);
}
-
+
// Parse the resource-env-ref elements
iterator = getChildrenByTagName(element, "resource-env-ref");
- while (iterator.hasNext()) {
- Element resourceRef = (Element) iterator.next();
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
refMetaData.importEjbJarXml(resourceRef);
resourceEnvReferences.put(refMetaData.getRefName(), refMetaData);
@@ -407,65 +447,76 @@
public void importJbossXml(Element element) throws DeploymentException
{
// we must not set defaults here, this might never be called
-
- // set the jndi name, (optional)
+
+ // set the jndi name, (optional)
jndiName = getElementContent(getOptionalChild(element, "jndi-name"));
-
- // set the JNDI name under with the local home interface should be bound
(optional)
+
+ // set the JNDI name under with the local home interface should be bound
(optional)
localJndiName = getElementContent(getOptionalChild(element,
"local-jndi-name"));
-
+
// set the configuration (optional)
configurationName = getElementContent(getOptionalChild(element,
"configuration-name"));
- if (configurationName != null &&
getApplicationMetaData().getConfigurationMetaDataByName(configurationName) == null) {
- throw new DeploymentException("configuration '" + configurationName + "'
not found in standardjboss.xml or jboss.xml");
+ if (configurationName != null &&
getApplicationMetaData().getConfigurationMetaDataByName(configurationName) == null)
+ {
+ throw new DeploymentException("configuration '" + configurationName
+ + "' not found in standardjboss.xml or jboss.xml");
}
-
+
// Get the security proxy
securityProxy = getElementContent(getOptionalChild(element,
"security-proxy"), securityProxy);
-
+
// update the resource references (optional)
Iterator iterator = getChildrenByTagName(element, "resource-ref");
- while (iterator.hasNext()) {
+ while (iterator.hasNext())
+ {
Element resourceRef = (Element)iterator.next();
String resRefName = getElementContent(getUniqueChild(resourceRef,
"res-ref-name"));
ResourceRefMetaData resourceRefMetaData =
(ResourceRefMetaData)resourceReferences.get(resRefName);
-
- if (resourceRefMetaData == null) {
- throw new DeploymentException("resource-ref " + resRefName + " found in
jboss.xml but not in ejb-jar.xml");
+
+ if (resourceRefMetaData == null)
+ {
+ throw new DeploymentException("resource-ref " + resRefName +
+ " found in jboss.xml but not in ejb-jar.xml");
}
resourceRefMetaData.importJbossXml(resourceRef);
}
-
+
// Set the resource-env-ref deployed jndi names
iterator = getChildrenByTagName(element, "resource-env-ref");
- while (iterator.hasNext()) {
- Element resourceRef = (Element) iterator.next();
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
String resRefName = getElementContent(getUniqueChild(resourceRef,
"resource-env-ref-name"));
ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData)
resourceEnvReferences.get(resRefName);
- if (refMetaData == null) {
- throw new DeploymentException("resource-env-ref " + resRefName + "
found in jboss.xml but not in ejb-jar.xml");
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("resource-env-ref " + resRefName
+ + " found in jboss.xml but not in ejb-jar.xml");
}
refMetaData.importJbossXml(resourceRef);
}
-
+
// set the external ejb-references (optional)
iterator = getChildrenByTagName(element, "ejb-ref");
- while (iterator.hasNext()) {
+ while (iterator.hasNext())
+ {
Element ejbRef = (Element)iterator.next();
String ejbRefName = getElementContent(getUniqueChild(ejbRef,
"ejb-ref-name"));
EjbRefMetaData ejbRefMetaData = getEjbRefByName(ejbRefName);
- if (ejbRefMetaData == null) {
- throw new DeploymentException("ejb-ref " + ejbRefName + " found in
jboss.xml but not in ejb-jar.xml");
+ if (ejbRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-ref " + ejbRefName
+ + " found in jboss.xml but not in ejb-jar.xml");
}
ejbRefMetaData.importJbossXml(ejbRef);
}
}
-
+
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
-
+
// Private -------------------------------------------------------
-
+
// Inner classes -------------------------------------------------
}
1.5.4.2 +124 -107 jboss/src/main/org/jboss/metadata/ResourceRefMetaData.java
Index: ResourceRefMetaData.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/metadata/ResourceRefMetaData.java,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -u -r1.5.4.1 -r1.5.4.2
--- ResourceRefMetaData.java 2001/11/02 08:42:36 1.5.4.1
+++ ResourceRefMetaData.java 2001/11/12 19:32:56 1.5.4.2
@@ -11,45 +11,46 @@
import org.jboss.deployment.DeploymentException;
/** The meta data information for a resource-ref element.
-The resource-ref element contains a declaration of enterprise bean�s
-reference to an external resource. It consists of an optional description,
-the resource manager connection factory reference name, the
-indication of the resource manager connection factory type expected
-by the enterprise bean code, the type of authentication (Application
-or Container), and an optional specification of the shareability of
-connections obtained from the resource (Shareable or Unshareable).
-Used in: entity, message-driven, and session
-
+ The resource-ref element contains a declaration of enterprise bean�s
+ reference to an external resource. It consists of an optional description,
+ the resource manager connection factory reference name, the
+ indication of the resource manager connection factory type expected
+ by the enterprise bean code, the type of authentication (Application
+ or Container), and an optional specification of the shareability of
+ connections obtained from the resource (Shareable or Unshareable).
+ Used in: entity, message-driven, and session
+
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
* @author [EMAIL PROTECTED]
- * @version $Revision: 1.5.4.1 $
+ * @version $Revision: 1.5.4.2 $
*/
-public class ResourceRefMetaData extends MetaData {
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
- /** The ejb-jar/../resource-ref/res-ref-name element used by the bean code.
- The res-ref-name element specifies the name of a resource manager con-nection
+public class ResourceRefMetaData extends MetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+ /** The ejb-jar/../resource-ref/res-ref-name element used by the bean code.
+ The res-ref-name element specifies the name of a resource manager con-nection
factory reference. The name is a JNDI name relative to the
java:comp/env context. The name must be unique within an enterprise
bean.
+ */
+ private String refName;
+ /** The jboss/../resource-ref/resource-name value that maps to a
resource-manager */
+ private String name;
+ /** The jndi name of the deployed resource, or the URL in the case of
+ a java.net.URL resource type. This comes from either the:
+ jboss/../resource-ref/jndi-name element value or the
+ jboss/../resource-ref/res-url element value or the
+ jboss/../resource-manager/res-jndi-name element value
+ jboss/../resource-manager/res-url element value
*/
- private String refName;
- /** The jboss/../resource-ref/resource-name value that maps to a
resource-manager */
- private String name;
- /** The jndi name of the deployed resource, or the URL in the case of
- a java.net.URL resource type. This comes from either the:
- jboss/../resource-ref/jndi-name element value or the
- jboss/../resource-ref/res-url element value or the
- jboss/../resource-manager/res-jndi-name element value
- jboss/../resource-manager/res-url element value
- */
- private String jndiName;
- /** The ejb-jar/../resource-ref/res-type element.
- The res-type element specifies the Java class or interface of the data source
- */
- private String type;
- /** The ejb-jar/../resource-ref/res-auth value.
+ private String jndiName;
+ /** The ejb-jar/../resource-ref/res-type element.
+ The res-type element specifies the Java class or interface of the data source
+ */
+ private String type;
+ /** The ejb-jar/../resource-ref/res-auth value.
The res-auth element specifies whether the enterprise bean code signs
on programmatically to the resource manager, or whether the Container
will sign on to the resource manager on behalf of the enterprise bean.
@@ -58,9 +59,9 @@
The value of this element must be one of the two following:
<res-auth>Application</res-auth>
<res-auth>Container</res-auth>
- */
- private boolean containerAuth;
- /** The ejb-jar/../resource-ref/res-sharing-scope value
+ */
+ private boolean containerAuth;
+ /** The ejb-jar/../resource-ref/res-sharing-scope value
The res-sharing-scope element specifies whether connections obtained
through the given resource manager connection factory reference can
be shared. The value of this element, if specified, must be one of the
@@ -69,76 +70,92 @@
<res-sharing-scope>Unshareable</res-sharing-scope>
The default value is Shareable.
*/
- private boolean isShareable;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
- public ResourceRefMetaData () {
- }
-
- // Public --------------------------------------------------------
-
- public String getRefName() { return refName; }
-
- public String getResourceName() {
- if (name == null) {
- // default is refName
- name = refName;
- }
- return name;
- }
-
- public void setResourceName(String resName) {
- name = resName;
- }
- public String getJndiName() { return jndiName; }
- public String getType() { return type; }
-
- public boolean isContainerAuth() { return containerAuth; }
- public boolean isShareable() { return isShareable; }
-
- public void importEjbJarXml(Element element) throws DeploymentException {
- refName = getElementContent(getUniqueChild(element, "res-ref-name"));
-
- type = getElementContent(getUniqueChild(element, "res-type"));
-
- String auth = getElementContent(getUniqueChild(element, "res-auth"));
- if (auth.equals("Container")) {
- containerAuth = true;
- } else if (auth.equals("Application")) {
- containerAuth = false;
- } else {
- throw new DeploymentException("res-auth tag should be
'Container' or 'Application'");
- }
- // The res-sharing-scope element
- String sharing = getElementContent(getOptionalChild(element,
"res-sharing-scope"), "Shareable");
- isShareable = sharing.equals("Shareable");
- }
-
- public void importJbossXml(Element element) throws DeploymentException {
- // Look for the resource-ref/resource-name element
- Element child = getOptionalChild(element, "resource-name");
- if( child == null )
- {
- // There must be a resource-ref/res-url value if this is a URL resource
- if( type.equals("java.net.URL") )
- jndiName = getElementContent(getUniqueChild(element, "res-url"));
- // There must be a resource-ref/jndi-name value otherwise
- else
- jndiName = getElementContent(getUniqueChild(element, "jndi-name"));
- }
- else
- {
- name = getElementContent(child);
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
+ private boolean isShareable;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ public ResourceRefMetaData()
+ {
+ }
+
+ // Public --------------------------------------------------------
+
+ public String getRefName()
+ { return refName; }
+
+ public String getResourceName()
+ {
+ if (name == null)
+ {
+ // default is refName
+ name = refName;
+ }
+ return name;
+ }
+
+ public void setResourceName(String resName)
+ {
+ name = resName;
+ }
+ public String getJndiName()
+ { return jndiName; }
+ public String getType()
+ { return type; }
+
+ public boolean isContainerAuth()
+ { return containerAuth; }
+ public boolean isShareable()
+ { return isShareable; }
+
+ public void importEjbJarXml(Element element) throws DeploymentException
+ {
+ refName = getElementContent(getUniqueChild(element, "res-ref-name"));
+
+ type = getElementContent(getUniqueChild(element, "res-type"));
+
+ String auth = getElementContent(getUniqueChild(element, "res-auth"));
+ if (auth.equals("Container"))
+ {
+ containerAuth = true;
+ }
+ else if (auth.equals("Application"))
+ {
+ containerAuth = false;
+ }
+ else
+ {
+ throw new DeploymentException("res-auth tag should be 'Container' or
'Application'");
+ }
+ // The res-sharing-scope element
+ String sharing = getElementContent(getOptionalChild(element,
"res-sharing-scope"), "Shareable");
+ isShareable = sharing.equals("Shareable");
+ }
+
+ public void importJbossXml(Element element) throws DeploymentException
+ {
+ // Look for the resource-ref/resource-name element
+ Element child = getOptionalChild(element, "resource-name");
+ if( child == null )
+ {
+ // There must be a resource-ref/res-url value if this is a URL resource
+ if( type.equals("java.net.URL") )
+ jndiName = getElementContent(getUniqueChild(element, "res-url"));
+ // There must be a resource-ref/jndi-name value otherwise
+ else
+ jndiName = getElementContent(getUniqueChild(element, "jndi-name"));
+ }
+ else
+ {
+ name = getElementContent(child);
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
}
1.2.6.2 +161 -126 jboss/src/main/org/jboss/metadata/WebMetaData.java
Index: WebMetaData.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/metadata/WebMetaData.java,v
retrieving revision 1.2.6.1
retrieving revision 1.2.6.2
diff -u -r1.2.6.1 -r1.2.6.2
--- WebMetaData.java 2001/11/02 08:42:36 1.2.6.1
+++ WebMetaData.java 2001/11/12 19:32:56 1.2.6.2
@@ -14,144 +14,179 @@
import org.jboss.deployment.DeploymentException;
-/** A representation of the web-app.xml and jboss-web.xml deployment
+/** A representation of the web.xml and jboss-web.xml deployment
* descriptors as used by the AbstractWebContainer web container integration
* support class.
- *
+ *
* @see XmlLoadable
* @see org.jboss.web.AbstractWebContainer
-
- * @author [EMAIL PROTECTED]
- * @version $Revision: 1.2.6.1 $
+
+ * @author [EMAIL PROTECTED]
+ * @version $Revision: 1.2.6.2 $
*/
public class WebMetaData implements XmlLoadable
{
- private HashMap resourceReferences = new HashMap();
- private ArrayList environmentEntries = new ArrayList();
- private HashMap ejbReferences = new HashMap();
- private ArrayList securityRoleReferences = new ArrayList();
- private String securityDomain;
-
- public WebMetaData()
- {
- }
-
- /** Return an iterator of the env-entry mappings.
+ private HashMap resourceReferences = new HashMap();
+ private HashMap resourceEnvReferences = new HashMap();
+ private ArrayList environmentEntries = new ArrayList();
+ private HashMap ejbReferences = new HashMap();
+ private ArrayList securityRoleReferences = new ArrayList();
+ private String securityDomain;
+
+ public WebMetaData()
+ {
+ }
+
+ /** Return an iterator of the env-entry mappings.
@return Iterator of EnvEntryMetaData objects.
*/
- public Iterator getEnvironmentEntries()
- {
- return environmentEntries.iterator();
- }
- /** Return an iterator of the ejb-ref mappings.
+ public Iterator getEnvironmentEntries()
+ {
+ return environmentEntries.iterator();
+ }
+ /** Return an iterator of the ejb-ref mappings.
@return Iterator of EjbRefMetaData objects.
*/
- public Iterator getEjbReferences()
- {
- return ejbReferences.values().iterator();
- }
- /** Return an iterator of the resource-ref mappings.
+ public Iterator getEjbReferences()
+ {
+ return ejbReferences.values().iterator();
+ }
+ /** Return an iterator of the resource-ref mappings.
@return Iterator of ResourceRefMetaData objects.
*/
- public Iterator getResourceReferences()
- {
- return resourceReferences.values().iterator();
- }
- /** Return the optional security-domain jboss-web.xml element.
+ public Iterator getResourceReferences()
+ {
+ return resourceReferences.values().iterator();
+ }
+ /** Return an iterator of the resource-ref mappings.
+ @return Iterator of ResourceEnvRefMetaData objects.
+ */
+ public Iterator getResourceEnvReferences()
+ {
+ return resourceEnvReferences.values().iterator();
+ }
+
+ /** Return the optional security-domain jboss-web.xml element.
@return The jndiName of the security manager implementation that is
- responsible for security of the web application. May be null if
- there was no security-domain specified in the jboss-web.xml
- descriptor.
- */
- public String getSecurityDomain()
- {
- return securityDomain;
- }
-
- public void importXml(Element element) throws Exception
- {
- String rootTag =
element.getOwnerDocument().getDocumentElement().getTagName();
- if( rootTag.equals("web-app") )
- {
- importWebXml(element);
- }
- else if( rootTag.equals("jboss-web") )
- {
- importJBossWebXml(element);
- }
- }
-
- /** Parse the elements of the web-app element used by the integration layer.
- */
- protected void importWebXml(Element webApp) throws Exception
- {
- // Parse the web-app/resource-ref elements
- Iterator iterator = MetaData.getChildrenByTagName(webApp, "resource-ref");
- while( iterator.hasNext() )
- {
- Element resourceRef = (Element) iterator.next();
- ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
- resourceRefMetaData.importEjbJarXml(resourceRef);
- resourceReferences.put(resourceRefMetaData.getRefName(),
resourceRefMetaData);
- }
-
- // Parse the web-app/env-entry elements
- iterator = MetaData.getChildrenByTagName(webApp, "env-entry");
- while( iterator.hasNext() )
- {
- Element envEntry = (Element) iterator.next();
- EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
- envEntryMetaData.importEjbJarXml(envEntry);
- environmentEntries.add(envEntryMetaData);
- }
-
- // Parse the web-app/ejb-ref elements
- iterator = MetaData.getChildrenByTagName(webApp, "ejb-ref");
- while( iterator.hasNext() )
- {
- Element ejbRef = (Element) iterator.next();
- EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
- ejbRefMetaData.importEjbJarXml(ejbRef);
- ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
- }
- }
-
- /** Parse the elements of the jboss-web element used by the integration layer.
- */
- protected void importJBossWebXml(Element jbossWeb) throws Exception
- {
- // Parse the jboss-web/securityDomain element
- Element securityDomainElement = MetaData.getOptionalChild(jbossWeb,
"security-domain");
- if( securityDomainElement != null )
- securityDomain = MetaData.getElementContent(securityDomainElement);
-
- // Parse the jboss-web/resource-ref elements
- Iterator iterator = MetaData.getChildrenByTagName(jbossWeb, "resource-ref");
- while( iterator.hasNext() )
- {
- Element resourceRef = (Element) iterator.next();
- String resRefName =
MetaData.getElementContent(MetaData.getUniqueChild(resourceRef, "res-ref-name"));
- String jndiName =
MetaData.getElementContent(MetaData.getUniqueChild(resourceRef, "jndi-name"));
- ResourceRefMetaData resourceRefMetaData = (ResourceRefMetaData)
resourceReferences.get(resRefName);
- if( resourceRefMetaData == null )
- {
- throw new DeploymentException("resource-ref " + resRefName + "
found in jboss-web.xml but not in web-app.xml");
- }
- resourceRefMetaData.setResourceName(jndiName);
- }
-
- // Parse the jboss-web/ejb-ref elements
- iterator = MetaData.getChildrenByTagName(jbossWeb, "ejb-ref");
- while( iterator.hasNext() )
- {
- Element ejbRef = (Element) iterator.next();
- String ejbRefName =
MetaData.getElementContent(MetaData.getUniqueChild(ejbRef, "ejb-ref-name"));
- EjbRefMetaData ejbRefMetaData = (EjbRefMetaData)
ejbReferences.get(ejbRefName);
- if( ejbRefMetaData == null )
- {
- throw new DeploymentException("ejb-ref " + ejbRefName + " found in
jboss-web.xml but not in web-app.xml");
- }
- ejbRefMetaData.importJbossXml(ejbRef);
- }
- }
+ responsible for security of the web application. May be null if
+ there was no security-domain specified in the jboss-web.xml
+ descriptor.
+ */
+ public String getSecurityDomain()
+ {
+ return securityDomain;
+ }
+
+ public void importXml(Element element) throws Exception
+ {
+ String rootTag = element.getOwnerDocument().getDocumentElement().getTagName();
+ if( rootTag.equals("web-app") )
+ {
+ importWebXml(element);
+ }
+ else if( rootTag.equals("jboss-web") )
+ {
+ importJBossWebXml(element);
+ }
+ }
+
+ /** Parse the elements of the web-app element used by the integration layer.
+ */
+ protected void importWebXml(Element webApp) throws Exception
+ {
+ // Parse the web-app/resource-ref elements
+ Iterator iterator = MetaData.getChildrenByTagName(webApp, "resource-ref");
+ while( iterator.hasNext() )
+ {
+ Element resourceRef = (Element) iterator.next();
+ ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
+ resourceRefMetaData.importEjbJarXml(resourceRef);
+ resourceReferences.put(resourceRefMetaData.getRefName(),
resourceRefMetaData);
+ }
+
+ // Parse the resource-env-ref elements
+ iterator = MetaData.getChildrenByTagName(webApp, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
+ refMetaData.importEjbJarXml(resourceRef);
+ resourceEnvReferences.put(refMetaData.getRefName(), refMetaData);
+ }
+
+ // Parse the web-app/env-entry elements
+ iterator = MetaData.getChildrenByTagName(webApp, "env-entry");
+ while( iterator.hasNext() )
+ {
+ Element envEntry = (Element) iterator.next();
+ EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
+ envEntryMetaData.importEjbJarXml(envEntry);
+ environmentEntries.add(envEntryMetaData);
+ }
+
+ // Parse the web-app/ejb-ref elements
+ iterator = MetaData.getChildrenByTagName(webApp, "ejb-ref");
+ while( iterator.hasNext() )
+ {
+ Element ejbRef = (Element) iterator.next();
+ EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
+ ejbRefMetaData.importEjbJarXml(ejbRef);
+ ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
+ }
+ }
+
+ /** Parse the elements of the jboss-web element used by the integration layer.
+ */
+ protected void importJBossWebXml(Element jbossWeb) throws Exception
+ {
+ // Parse the jboss-web/securityDomain element
+ Element securityDomainElement = MetaData.getOptionalChild(jbossWeb,
"security-domain");
+ if( securityDomainElement != null )
+ securityDomain = MetaData.getElementContent(securityDomainElement);
+
+ // Parse the jboss-web/resource-ref elements
+ Iterator iterator = MetaData.getChildrenByTagName(jbossWeb, "resource-ref");
+ while( iterator.hasNext() )
+ {
+ Element resourceRef = (Element) iterator.next();
+ String resRefName =
MetaData.getElementContent(MetaData.getUniqueChild(resourceRef, "res-ref-name"));
+ ResourceRefMetaData refMetaData = (ResourceRefMetaData)
resourceReferences.get(resRefName);
+ if( refMetaData == null )
+ {
+ throw new DeploymentException("resource-ref " + resRefName
+ + " found in jboss-web.xml but not in web.xml");
+ }
+ refMetaData.importJbossXml(resourceRef);
+ }
+
+ // Parse the jboss-web/resource-env-ref elements
+ iterator = MetaData.getChildrenByTagName(jbossWeb, "resource-env-ref");
+ while( iterator.hasNext() )
+ {
+ Element resourceRef = (Element) iterator.next();
+ String resRefName =
MetaData.getElementContent(MetaData.getUniqueChild(resourceRef,
"resource-env-ref-name"));
+ ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData)
resourceEnvReferences.get(resRefName);
+ if( refMetaData == null )
+ {
+ throw new DeploymentException("resource-env-ref " + resRefName
+ + " found in jboss-web.xml but not in web.xml");
+ }
+ refMetaData.importJbossXml(resourceRef);
+ }
+
+ // Parse the jboss-web/ejb-ref elements
+ iterator = MetaData.getChildrenByTagName(jbossWeb, "ejb-ref");
+ while( iterator.hasNext() )
+ {
+ Element ejbRef = (Element) iterator.next();
+ String ejbRefName =
MetaData.getElementContent(MetaData.getUniqueChild(ejbRef, "ejb-ref-name"));
+ EjbRefMetaData ejbRefMetaData = (EjbRefMetaData)
ejbReferences.get(ejbRefName);
+ if( ejbRefMetaData == null )
+ {
+ throw new DeploymentException("ejb-ref " + ejbRefName
+ + " found in jboss-web.xml but not in web.xml");
+ }
+ ejbRefMetaData.importJbossXml(ejbRef);
+ }
+ }
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development