/** * Returns a string representation for a proxy that uses this invocation * handler. **/ @Override protected String proxyToString(final Object proxy) { return "EJBHomeProxy[" + super.proxyToString(proxy) + ", remoteClass:" + remoteClass.getName() + ", ejbMetada:" + ejbMetaData + "]"; }
/** * @param invocationHandler */ private void unregisterCMIInvocationHandler(final CMIInvocationHandler<?> invocationHandler) { this.service.unregisterDispatcher(invocationHandler.getCMIManagedObjectId()); this.objects.remove(invocationHandler); }
/** * 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); }
registerCMIManagedObject(); checkInitialized(); return invokeObjectMethod(proxy, method, args); return invokeCMIProxy( methodName.substring(0, methodName.length() - 4), proxy); return invokeRemoteMethod(proxy, method, args);
try { cmiReferenceable = getCMIReferenceable(cmiReference); logger.debug("Object: {0} - Invoke: {1} > CMIReferenceable successfully retrieved: {2}", objectName, methodName, cmiReferenceable); preInvokeHook(cmiReferenceable); postInvokeHook(); onExceptionHook(objectName, cmiReferenceable); } 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) + " > onInvokeException.", e); } finally { onFinallyHook(objectName, cmiReferenceable);
/** * Handles remote methods. **/ @Override protected Object invokeRemoteMethod( final Object proxy, final Method method, final Object... args) throws Throwable { // Use the same classloader that during the creation of this object ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(classLoader); setClassLoader(oldClassLoader); try { // Generate a requestId RequestId requestId = new RequestId(sessionId, requestNb); // Set this request in the current context HACurrent.getHACurrent().putNextReq(requestId); Object result = super.invokeRemoteMethod(proxy, method, args); // Update the request number now that all is OK requestNb++; if (onFailover) { onFailover = false; HACurrent.getHACurrent().setOnFailover(false); } return result; } finally { Thread.currentThread().setContextClassLoader(oldClassLoader); } }
private void registerCMIManagedObject() { dispatcher = clusterViewManager.getEventDispatcher(); if(dispatcher != null) { cmiManagedObjectId = "/cmi/" + objectName + "/" + protocolName + "/" + id++; // Register to event component. CMIEventComponent eventComponent = getComponent(CMIEventComponent.class); if (eventComponent != null) { eventComponent.registerCMIManagedObject(this, this.dispatcher); } } }
Object result = super.invokeRemoteMethod(proxy, method, args);
/** * Returns a string representation for a proxy that uses this invocation * handler. **/ @Override protected String proxyToString(final Object proxy) { return "HAEJBObjectProxy[" + super.proxyToString(proxy) + ", homeClass:" + homeClass.getName() + ", ejbHomeProxy:" + ejbHomeProxy + ", sessionId:" + sessionId + ", requestNb:" + requestNb + ", createMethodWrapper:" + createMethodWrapper + ", onFailover:" + onFailover + "]"; }
private void registerCMIInvocationHandler( final CMIInvocationHandler<?> invocationHandler, final IEventDispatcher dispatcher) { this.service.registerDispatcher(invocationHandler.getCMIManagedObjectId(), dispatcher); this.objects.add(invocationHandler); }
/** * Handles java.lang.Object methods. **/ private Object invokeObjectMethod(final Object proxy, final Method method, final Object... args) { String name = method.getName(); if (name.equals("hashCode")) { return Integer.valueOf(hashCode()); } else if (name.equals("equals")) { Object obj = args[0]; boolean b = proxy == obj || (obj != null && Proxy.isProxyClass(obj.getClass()) && equals(Proxy.getInvocationHandler(obj))); return Boolean.valueOf(b); } else if (name.equals("toString")) { return proxyToString(proxy); } else { logger.error("unexpected Object method: {0}", method); throw new IllegalArgumentException("unexpected Object method: " + method); } }