User: patriot1burke
Date: 02/04/09 22:44:46
Modified: src/main/org/jboss/metadata BeanMetaData.java MetaData.java
Added: src/main/org/jboss/metadata MethodAttributes.java
Log:
new meta data for <method-attributes>
Revision Changes Path
1.37 +56 -1 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.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- BeanMetaData.java 14 Jan 2002 02:00:22 -0000 1.36
+++ BeanMetaData.java 10 Apr 2002 05:44:45 -0000 1.37
@@ -31,7 +31,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>.
* @author <a href="mailto:[EMAIL PROTECTED]">Ole Husgaard</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Bill Burke</a>
- * @version $Revision: 1.36 $
+ * @version $Revision: 1.37 $
*
* <p><b>Revisions:</b><br>
* <p><b>2001/10/16: billb</b>
@@ -98,6 +98,9 @@
private HashMap resourceReferences = new HashMap();
/** The resource-env-ref element(s) info */
private HashMap resourceEnvReferences = new HashMap();
+ /** The method attributes */
+ private ArrayList methodAttributes = new ArrayList();
+ private HashMap cachedMethodAttributes = new HashMap();
/** The assembly-descriptor/method-permission element(s) info */
private ArrayList permissionMethods = new ArrayList();
/** The assembly-descriptor/container-transaction element(s) info */
@@ -287,6 +290,40 @@
return result;
}
+
+ /**
+ * Checks meta data to obtain the Method Attributes of a bean's method:
+ * method attributes are read-only, idempotent and potentially other ones as
well.
+ * These jboss-specific method attributes are described in jboss.xml
+ */
+ private MethodAttributes methodAttributesForMethod(String methodName)
+ {
+ MethodAttributes ma =
(MethodAttributes)cachedMethodAttributes.get(methodName);
+ if(ma == null)
+ {
+ Iterator iterator = methodAttributes.iterator();
+ while(iterator.hasNext() && ma == null)
+ {
+ ma = (MethodAttributes)iterator.next();
+ if(!ma.patternMatches(methodName))
+ ma = null;
+ }
+ if(ma == null) ma = MethodAttributes.kDefaultMethodAttributes;
+ if (ma.readOnly) System.out.println("*****" + methodName + " is readonly");
+ if (!ma.readOnly) System.out.println("!!!!!" + methodName + " is write");
+ cachedMethodAttributes.put(methodName, ma);
+ }
+ return ma;
+ }
+
+ /**
+ * Is this method a read-only method described in jboss.xml?
+ */
+ public boolean isMethodReadOnly(String methodName)
+ {
+ return methodAttributesForMethod(methodName).readOnly;
+ }
+
/**
* A somewhat tedious method that builds a Set<Principal> of the roles
* that have been assigned permission to execute the indicated method. The
@@ -504,6 +541,24 @@
}
ejbRefMetaData.importJbossXml(ejbRef);
}
+
+ // Method attributes of the bean
+ Element mas = getOptionalChild(element, "method-attributes");
+ if(mas != null)
+ {
+ // read in the read-only methods
+ iterator = getChildrenByTagName(mas, "method");
+ while (iterator.hasNext())
+ {
+ MethodAttributes ma = new MethodAttributes();
+ Element maNode = (Element)iterator.next();
+ ma.pattern = getElementContent(getUniqueChild(maNode, "method-name"));
+ ma.readOnly = getOptionalChildBooleanContent(maNode, "read-only");
+ ma.idempotent = getOptionalChildBooleanContent(maNode, "idempotent");
+ methodAttributes.add(ma);
+ }
+ }
+
// Has a custom invoker been defined?
//
1.17 +13 -1 jboss/src/main/org/jboss/metadata/MetaData.java
Index: MetaData.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/metadata/MetaData.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- MetaData.java 26 Nov 2001 03:17:48 -0000 1.16
+++ MetaData.java 10 Apr 2002 05:44:45 -0000 1.17
@@ -20,7 +20,7 @@
* An abstract base class for metadata containers.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
- * @version $Revision: 1.16 $
+ * @version $Revision: 1.17 $
*/
public abstract class MetaData
implements XmlLoadable
@@ -216,6 +216,18 @@
return getElementContent(getOptionalChild(element, tagName));
}
+ public static boolean getOptionalChildBooleanContent(Element element, String
name) throws DeploymentException
+ {
+ Element child = getOptionalChild(element, name);
+ if(child != null)
+ {
+ String value = getElementContent(child).toLowerCase();
+ return value.equals("true") || value.equals("yes");
+ }
+
+ return false;
+ }
+
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
1.1 jboss/src/main/org/jboss/metadata/MethodAttributes.java
Index: MethodAttributes.java
===================================================================
package org.jboss.metadata;
/**
*
* Provides meta-data for method-attributes
* <method-attributes>
* <method>
* <method-name>get*</method-name>
* <read-only>true</read-only>
* <idempotent>true</idempotent>
* </method>
* </method-attributes>
*
* @author <a href="[EMAIL PROTECTED]">Peter Murray</a>
*
* @version $Revision: 1.1 $
*
* <p><b>Revisions:</b><br>
* <p><b>2001/04/10: peter</b>
* <ol>
* <li>Initial revision
* </ol>
*/
public class MethodAttributes
{
String pattern;
boolean readOnly;
boolean idempotent;
public static MethodAttributes kDefaultMethodAttributes;
static
{
kDefaultMethodAttributes = new MethodAttributes();
kDefaultMethodAttributes.pattern = "*";
kDefaultMethodAttributes.readOnly = false;
kDefaultMethodAttributes.idempotent = false;
}
public boolean patternMatches(String methodName)
{
int ct, end;
end = pattern.length();
if(end > methodName.length())
return false;
for(ct = 0; ct < end; ct ++)
{
char c = pattern.charAt(ct);
if(c == '*')
return true;
if(c != methodName.charAt(ct))
return false;
}
return ct == methodName.length();
}
public boolean isReadOnly()
{
return readOnly;
}
public boolean isIdempotent()
{
return idempotent;
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development