I am having troubles with v4 and adding function libraries.
I have made my java file with all the appropriate functions and implementations and created a jarfile with FATJar (test.jar). I have modified setenv and setenvClient (%AWARE_HOME%\test.jar😉 and BASServer.props (FunctionLibraryTestJAR=test.TestJAR) and I always get unsupported function.
The question I have is what might I be doing wrong?
It appears that awareIM is still unable to recognize my custom library.
The java file looks like this..
package test;
import java.util.Collection;
import org.openadaptor.util.DateTimeHolder;
import com.bas.shared.data.FunctionDescription;
import com.bas.shared.functions.IFunctionLibrary;
import com.bas.shared.ruleparser.INodeHelper;
import com.bas.shared.ruleparser.ISQLBuilderHelper;
public class TestJAR implements IFunctionLibrary
{
/*
* Default constructor, no global variables or settings to worry about
*/
public TestJAR()
{
}
/*
* Calculate is the name of an expected method by AwareIM
* This method declaration may not be changed
*/
public Object calculate(String arg0, Object[] arg1, INodeHelper arg2)
{
/*
* Prints incoming arguments to screen, this is a good
* way to check values moving to and from AwareIM
*/
for(int i = 0; i < arg1.length; i++)
{
System.out.println(arg1[i].toString());
}
try
{
if(arg0.compareTo("loi") == 0)
{
if(arg1.length != 1)
{
return("-1");
}
return ("loi was here");
}
else
{
return("-2");
}
}
/* Print out caught exception types with errors */
catch (Exception e)
{
System.out.println(e);
}
return ("-2");
}
/*
* EXTRA CODE
* The following is used for integrating into the wrapper class.
* */
public FunctionDescription[] getAvailableFunctions()
{
FunctionDescription [] description = new FunctionDescription[14];
description[0] = new FunctionDescription("loi",
"Get Test." +
"\nParameters:\n- Test Token" +
"\nReturns: String");
return description;
}
public String getName()
{
return("TestJAR");
}
public Class getTypeClass(String arg0, Collection arg1)
{
if(arg0.compareTo("loi") == 0)
{
return(DateTimeHolder.class);
}
else
{
return(String.class);
}
}
public boolean hasFunction(String arg0, int arg1)
{
if(arg0.compareTo("loi") == 0)
{
return(true);
}
else
{
return(false);
}
}
public String toSQL(String arg0, Collection arg1, ISQLBuilderHelper arg2)
{
return null;
}
}
=======================================
and the console spits out this ...
2008-10-28 12:15:27,656 EmailTest#admin -23 Starting execution of rules when creating business object TestLoi 20
2008-10-28 12:15:27,656 EmailTest#admin -29 Started evaluation of rules
2008-10-28 12:15:27,656 EmailTest#admin -22 Evaluating rule 'newtestloi' If TestLoi IS NEW Then TestLoi.Token = loi(AS_STRING('loi'))
2008-10-28 12:15:27,656 EmailTest#admin -6 Evaluating condition TestLoi IS NEW
2008-10-28 12:15:27,671 EmailTest#admin -8 Condition evaluated to true: null=<UNDEFINED>
2008-10-28 12:15:27,671 EmailTest#admin -2 Adding action TestLoi.Token=loi(AS_STRING('loi')) to the agenda
2008-10-28 12:15:27,671 EmailTest#admin -16 Finished rule evaluation
2008-10-28 12:15:27,671 EmailTest#admin -16 Finished evaluation of rules
2008-10-28 12:15:27,671 EmailTest#admin -15 Executing action TestLoi.Token=loi(AS_STRING('loi')) from rules of object TestLoi
2008-10-28 12:15:27,671 EmailTest#admin -Exception while calculating the action TestLoi.Token=loi(AS_STRING('loi'))
2008-10-28 12:15:27,671 EmailTest#admin -16 Finished executing action TestLoi.Token=loi(AS_STRING('loi')) from rules of object TestLoi
2008-10-28 12:15:27,671 EmailTest#admin -25 Started evaluation of rules after data has been changed by the actions
2008-10-28 12:15:27,671 EmailTest#admin -6 Checking rule newtestloi
2008-10-28 12:15:27,671 EmailTest#admin -16 Finished evaluation of rules after data has been changed by the actions
2008-10-28 12:15:27,671 EmailTest#admin -16 Finished execution of rules when creating business object TestLoi 20
2008-10-28 12:15:27,671 EmailTest#admin -17
2008-10-28 12:15:27,671 EmailTest#admin -17
2008-10-28 12:15:27,671 ERROR EmailTest#admin -Execution Exception after starting system process message Operation error. com.bas.shared.ruleparser.ParseException Unsupported function loi
2008-10-28 12:15:27,671 EmailTest#admin -16 Finished creating business object TestLoi
2008-10-28 12:15:27,671 EmailTest#admin -17
2008-10-28 12:15:27,671 EmailTest#admin -17