/** * Handle the invocation of methods defined in the interface {@link CMIProxy}. * @param methodName the method name without the suffix _CMI * @param proxy the proxy to use * @return the result of invocation * @throws CMIInvocationHandlerException */ private Object invokeCMIProxy(final String methodName, final Object proxy) throws CMIInvocationHandlerException { if(methodName.equals("getObjectName")) { return objectName; } else if(methodName.equals("getInterface")) { return itf; } else if(methodName.equals("getProtocolName")) { return protocolName; } else if(methodName.equals(getHandleMethodName())) { return getHandle((CMIProxy) proxy); } else if(methodName.equals("getCurrentCMIRef")) { return currentRef; } else if(methodName.equals("isCMIRefKept")) { return keepCurrentRef; } throw new CMIInvocationHandlerException( "CMIProxy doesn't define the method " + methodName); }
} catch (ObjectNotFoundException e) { logger.error("Cannot retrieve the interface for object with name " + objectName, e); throw new CMIInvocationHandlerException( "Cannot retrieve the interface for object with name " + objectName, e);
} catch (Exception e) { logger.error("Object: {0} - Invoke:{1} > Cannot retrieve data", objectName, method, e); throw new CMIInvocationHandlerException( "Object: " + objectName + " - Invoke: " + methodName + " > Cannot retrieve data", e); logger.error("Object:{0} - Invoke: {1} > No server available! Skipping the invocation...", objectName, methodName); throw new CMIInvocationHandlerException("Object: " + objectName + " - Invoke: " + methodName + " > No server available! Skipping the invocation..."); logger.error("Object: {0} - Invoke: {1} > Cannot get a CMIReference for protocol {2}", objectName, methodName, protocolName, e); throw new CMIInvocationHandlerException( "Object: " + objectName + " - Invoke: " + methodName + " > Cannot get a CMIReference for protocol " + protocolName, e); throw new CMIInvocationHandlerException( "Object: " + objectName + " - Invoke: " + methodName + " > The current manadatory for reference " + cmiReference + "should not be null !"); } catch(Exception e) { logger.error("Object: {0} - Invoke: {1} > onInvokeException.", objectName, methodName, e); throw new CMIInvocationHandlerException( "Object: " + objectName + " - Invoke: " + method + " - Args: " + Arrays.toString(args) + " - Arg types: " + getArgTypes(args)