tags:

views:

119

answers:

2

How can I refer a custom function in xml? Suppose that I have a function written in Java and want it to refer by the xml tag, how is this possible?

Current senario: I am using XACML2.0 which contains xml tags and I want to refer some function in Java that will talk to the backend data, I'm unable to refer a function in xacml. Could you help me please?

+1  A: 

You should read up on Reflection in Java.

The following example would invoke the method

myObjectThatContainsMethod#methodNameAsString(Integer arg1, Integer arg2)

Integer[] params = {new Integer(123),new Integer(567)}; 
Class cl=Class.forName("stringParsedFromYourXML"); 
Class[] par=new Class[2]; 
par[0]=Integer.TYPE; 
par[1]=Integer.TYPE; 
Method mthd=cl.getMethod("methodNameAsString", parameterTypes); 
mthd.invoke(new myObjectThatContainsMethod(), params);

hope that helps..

A: 

First, you need to choose an implementation of XACML. You should take one that is written in Java, to make things simpler.

Everything else depends on the chosen implementation. The implementation should document how to add custom functions. If it's not documented, ask the authors.

Roland Illig