String methodName, Class[] paramTypes, Object[] args)
throws InvocationTargetException, IllegalAccessException,
SecurityException {
// Find the component we're calling
Component component = Component.forName(serviceIntfName);
if (component == null)
throw new RuntimeException("No such component: " + serviceIntfName);
Object instance = getServiceComponent(serviceIntfName);
Class clz = null;
if (component.getType().isSessionBean()
&& component.getBusinessInterfaces().size() > 0) {
for (Class c : component.getBusinessInterfaces()) {
if (c.isAnnotationPresent(EJB.LOCAL)) {
clz = c;
break;
}
}
if (clz == null)
throw new RuntimeException(
String
.format(
"Type cannot be determined for component [%s]. Please ensure that it has a local interface.",
component));
}
if (clz == null)
clz = component.getBeanClass();
Method method = getMethod(serviceIntfName, methodName, clz, paramTypes);
Object result = method.invoke(instance, args);
return new ReturnedObject(method.getReturnType(), result);