001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.mx.server;
023:
024: import org.jboss.mx.interceptor.AbstractInterceptor;
025:
026: /**
027: *
028: * @author <a href="mailto:juha@jboss.org">Juha Lindfors</a>.
029: * @version $Revision: 57200 $
030: *
031: */
032: public class Invocation extends InvocationContext {
033: private Object[] args;
034:
035: private InvocationContext ctx;
036:
037: // Constructors --------------------------------------------------
038: public Invocation() {
039: }
040:
041: public Invocation(InvocationContext ic) {
042: addContext(ic);
043: }
044:
045: // Public --------------------------------------------------------
046:
047: public void addContext(final InvocationContext ctx) {
048: super .copy(ctx);
049: this .ctx = ctx;
050: }
051:
052: public void setArgs(Object[] args) {
053: this .args = args;
054: }
055:
056: public Object[] getArgs() {
057: return args;
058: }
059:
060: int ic_counter = 0;
061:
062: public AbstractInterceptor nextInterceptor() {
063: if (interceptors == null)
064: return null;
065:
066: if (ic_counter < interceptors.size())
067: return (AbstractInterceptor) interceptors.get(ic_counter++);
068: else
069: return null;
070: }
071:
072: public Object invoke() throws Throwable {
073: AbstractInterceptor ic = nextInterceptor();
074:
075: if (ic == null)
076: return dispatch();
077: else
078: return ic.invoke(this );
079:
080: }
081:
082: public Object dispatch() throws Throwable {
083: return dispatcher.invoke(this );
084: }
085:
086: Object retVal = null;
087:
088: public String toString() {
089: return getName() + " " + getType();
090: }
091:
092: public Class getAttributeTypeClass() throws ClassNotFoundException {
093: return ctx.getAttributeTypeClass();
094: }
095:
096: public Class getReturnTypeClass() throws ClassNotFoundException {
097: return ctx.getReturnTypeClass();
098: }
099:
100: public Class[] getSignatureClasses() throws ClassNotFoundException {
101: return ctx.getSignatureClasses();
102: }
103: }
|