I'm trying to set "class, default or method meta-data" at run-time, by constructing
the annotation xml by hand, loading it using the SimpleClassMetaDataLoader and then
calling AspectManager.addClassMetaData(ClassMetaDataBinding)
Here is a snapshot of the code
| String tag = "security";
| String className = POJO.class.getName();
| String methodExpr = "java.lang.String getString(java.lang.String)";
| Map attributes = new HashMap();
| attributes.put("user","romeo");
| attributes.put("role","admin");
| String CONJUGATOR = ":";
| StringBuffer annotationXML = new StringBuffer("<annotation ");
| annotationXML.append("tag=\"").append(tag).append("\" ");
| annotationXML.append("class=\"").append(className).append("\" ");
| annotationXML.append(">");
| //annotationXML.append("<method expr=\"").append(methodExpr).append("\">");
| annotationXML.append("<default>");
| for (Iterator iter = attributes.keySet().iterator();iter.hasNext();) {
| String key = (String)iter.next();
| String value = (String)attributes.get(key);
| if (value != null) {
|
annotationXML.append("<").append(key).append(">").append(value).append("</").append(key).append(">");
| }else{
| System.out.println("[addClassMetaData] passed in attribute value
is null for key " + key);
| }
| }
| //annotationXML.append("</method>");
| annotationXML.append("</default>");
| annotationXML.append("</annotation>");
|
| System.out.println("[setMetaData] annotation XML " + annotationXML);
|
| // convert the xml into element
| ByteArrayInputStream bis = new
ByteArrayInputStream(annotationXML.toString().getBytes());
| DocumentBuilderFactory docBuilderFactory =
DocumentBuilderFactory.newInstance();
| DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
| Document doc = docBuilder.parse(bis);
| Element element = doc.getDocumentElement();
|
| String name = tag + CONJUGATOR + className + CONJUGATOR + methodExpr;
| ClassMetaDataLoader loader =
AspectManager.instance().findClassMetaDataLoader(tag);
| ClassMetaDataBinding data = loader.importMetaData(element, name, tag,
className);
| AspectManager.instance().addClassMetaData(data);
|
I could'nt get a hold of the meta-data in the interceptors obviously proving that the
above piece of code is not doing what its supposed to.
Any help/pointers would be greatly appreciated.
Thanks
Rajiv
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3846037#3846037
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3846037
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development