LOG.debug("The script engine doesn't contain a binding called '" + bindingName
+ "'. No indirection functions will be generated.");
return;
}
ScriptEngineInitializer initializer = getInitializer((String) scriptEngine.getFactory().getParameter(
ScriptEngine.NAME));
try {
BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass(), Object.class);
MethodDescriptor[] methodDescriptors = beanInfo.getMethodDescriptors();
Map<String, Set<Method>> overloadsPerMethodName = new HashMap<String, Set<Method>>();
for (MethodDescriptor methodDescriptor : methodDescriptors) {
Method method = methodDescriptor.getMethod();
if (shouldIndirect(method)) {
Set<Method> overloads = overloadsPerMethodName.get(method.getName());
if (overloads == null) {
overloads = new HashSet<Method>();
overloadsPerMethodName.put(method.getName(), overloads);
}
overloads.add(method);
}
}
for (Set<Method> overloads : overloadsPerMethodName.values()) {
Set<String> methodDefs = initializer.generateIndirectionMethods(bindingName, overloads);
for (String methodDef : methodDefs) {
try {
scriptEngine.eval(methodDef);
} catch (ScriptException e) {
LOG.warn("Unable to define global function declared as:\n" + methodDef, e);