* * Concrete implementations should override this method to implement * their specific application logic. * * @see org.jboss.mx.server.Invocation * @see org.jboss.mx.server.MBeanInvoker * * @param invocation the invocation object send towards the target * resource by the invoker * * @return return value from the target resource * * @throws InvocationException This exception wraps any exceptions thrown * by either the target method of the resource object, or invocation * interceptors in this interceptor chain. The target exception is * unwrapped at the {@link org.jboss.mx.server.MBeanInvoker} instance. */ public Object invoke(Invocation invocation) throws Throwable { Interceptor ic = invocation.nextInterceptor(); // if the invocation object does not provide us with more interceptors, // invoke the dispatcher that lands the invocation to its final target // in the resource object if (ic == null) return invocation.dispatch(); // see if the next interceptor in the chain is shared if (ic.isShared()) { // we require a common interface for all shared interceptors SharedInterceptor shared = (SharedInterceptor)ic; // we invoke shared interceptor it via the MBean server bus, get the // interceptors view to its MBean server MBeanServer server = shared.getMBeanServer(); // And the object name the interceptor is registered under ObjectName name = shared.getObjectName(); return server.invoke( name, "invoke", new Object[] { invocation }, // args new String[] { Invocation.class.getName() } // signature ); } // invoke non-shared interceptor directly via Java reference else { return ic.invoke(invocation); } } public String getName() { return name; } public boolean isShared() { return isShared; } public void setLogger(Logger log) { this.log = log; } public void init() throws Exception {} public void start() {} public void stop() throws Exception {} public void destroy() {} // Object overrides ---------------------------------------------- /** * Returns a string representation of this interceptor instance. * * @return string representation */ public String toString() { String className = getClass().getName(); int index = className.lastIndexOf('.'); return className.substring((index < 0) ? 0 : index) + "[name=" + name + "]"; } }