KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tm > remoting > Invocation


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.tm.remoting;
23
24 import java.io.Serializable JavaDoc;
25 import java.lang.reflect.Method JavaDoc;
26 import java.rmi.RemoteException JavaDoc;
27
28 import javax.transaction.HeuristicCommitException JavaDoc;
29 import javax.transaction.HeuristicMixedException JavaDoc;
30 import javax.transaction.HeuristicRollbackException JavaDoc;
31
32 import org.jboss.remoting.InvokerLocator;
33 import org.jboss.tm.GlobalId;
34 import org.jboss.tm.remoting.interfaces.Coordinator;
35 import org.jboss.tm.remoting.interfaces.HeuristicHazardException;
36 import org.jboss.tm.remoting.interfaces.RecoveryCoordinator;
37 import org.jboss.tm.remoting.interfaces.Resource;
38 import org.jboss.tm.remoting.interfaces.Status;
39 import org.jboss.tm.remoting.interfaces.Synchronization;
40 import org.jboss.tm.remoting.interfaces.Terminator;
41 import org.jboss.tm.remoting.interfaces.TxPropagationContext;
42 import org.jboss.tm.remoting.interfaces.TransactionFactory;
43 import org.jboss.tm.remoting.interfaces.TransactionInactiveException;
44 import org.jboss.tm.remoting.interfaces.TransactionNotPreparedException;
45 import org.jboss.tm.remoting.interfaces.Vote;
46
47
48 /**
49  * An instance of this class represents a method invocation on any of the
50  * remote interfaces of the transaction service, which are the interfaces
51  * defined in the package <code>org.jboss.tm.remoting.interfaces<code>.
52  *
53  * @author <a HREF="mailto:reverbel@ime.usp.br">Francisco Reverbel</a>
54  * @version $Revision: 37459 $
55  */

56 public class Invocation
57       implements Serializable JavaDoc
58 {
59    static final long serialVersionUID = -7256134284357215230L;
60
61    // Nested interfaces ---------------------------------------------
62

63    /**
64     * Interface of an auxiliary object that knows how to perform an invocation
65     * to a particular method. All the nested interfaces which follow have an
66     * Invoker-valued static final field for each method of the corresponding
67     * transaction service interface. For example, the nested interface
68     * <code>ITransactionFactory</code> (see below) corresponds to the interface
69     * <code>org.jboss.tm.remoting.interfaces.TransactionFactory</code>. It has
70     * an Invoker-valued field <code>CREATE</code> and a method
71     * <code>create</code>, which mirrors the similarly named method in
72     * <code>org.jboss.tm.remoting.interface.TransactionFactory</code>.
73     *
74     * The nested interfaces below should be implemented by one or more servant
75     * objects associated with the <code>ServerInvocationHandler</code>. Note
76     * that all the "mirror methods" in those interfaces take an additional
77     * parameter <code>targetId</code>, which allows a single servant to
78     * incarnate multiple target objects. At each invocation, that parameter
79     * identifies the target object for that invocation.
80     */

81    private static interface Invoker
82    {
83       Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
84             throws Throwable JavaDoc;
85    }
86    
87    /**
88     * This interface mirrors the interface <code>TransactionFactory</code> in
89     * <code>org.jboss.tm.remoting.interfaces</code>. Attention: method id
90     * constants (<code>M_</code>* fields) are indices to an invoker array,
91     * so they must be consecutive integers in the range 0..max_index. They also
92     * must be unique among all mirror interfaces.
93     */

94    public static interface ITransactionFactory
95    {
96       /** Method id for TransactionFactory.create */
97       static final int M_CREATE = 0;
98       
99       /** Method id for TransactionFactory.recreate */
100       static final int M_RECREATE = 1;
101       
102       /** Invoker for TransactionFactory.create */
103       static final Invoker CREATE = new Invoker()
104       {
105          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
106                throws Throwable JavaDoc
107          {
108             int timeout = ((Integer JavaDoc)args[0]).intValue();
109             return ((ITransactionFactory)servant).create(targetId, timeout);
110          }
111       };
112          
113       /** Invoker for TransactionFactory.recreate */
114       static final Invoker RECREATE = new Invoker()
115       {
116          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
117                throws Throwable JavaDoc
118          {
119             TxPropagationContext tpc = (TxPropagationContext)args[0];
120             return ((ITransactionFactory)servant).recreate(targetId, tpc);
121          }
122       };
123       
124       /** Mirror method for TransactionFactory.create */
125       TxPropagationContext create(long targetId, int timeout)
126             throws RemoteException JavaDoc;
127       
128       /** Mirror method for TransactionFactory.recreate */
129       TxPropagationContext recreate(long targetId, TxPropagationContext tpc)
130             throws RemoteException JavaDoc;
131       
132    }
133    
134    /**
135     * This interface mirrors the interface <code>Coordinator</code> in
136     * <code>org.jboss.tm.remoting.interfaces</code>. Attention: method id
137     * constants (<code>M_</code>* fields) are indices to an invoker array,
138     * so they must be consecutive integers in the range 0..max_index. They
139     * also must to be unique among all mirror interfaces.
140     */

141    public static interface ICoordinator
142    {
143       /** Method id for Coordinator.getStatus */
144       static final int M_GET_STATUS = 2;
145
146       /** Method id for Coordinator.isSameTransaction */
147       static final int M_IS_SAME_TRANSACTION = 3;
148       
149       /** Method id for Coordinator.hashTransaction */
150       static final int M_HASH_TRANSACTION = 4;
151       
152       /** Method id for Coordinator.registerResource */
153       static final int M_REGISTER_RESOURCE = 5;
154       
155       /** Method id for Coordinator.registerSynchronization */
156       static final int M_REGISTER_SYNCHRONIZATION = 6;
157       
158       /** Method id for Coordinator.rollbackOnly */
159       static final int M_ROLLBACK_ONLY = 7;
160       
161       /** Method id for Coordinator.getTransactionContext */
162       static final int M_GET_TRANSACTION_CONTEXT = 8;
163       
164       /** Method id for Coordinator.getTransactionId */
165       static final int M_GET_TRANSACTION_ID = 9;
166       
167       /** Invoker for Coordinator.getStatus */
168       static final Invoker GET_STATUS = new Invoker()
169       {
170          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
171                throws Throwable JavaDoc
172          {
173             return ((ICoordinator)servant).getStatus(targetId);
174          }
175       };
176
177       /** Invoker for Coordinator.isSameTransaction */
178       static final Invoker IS_SAME_TRANSACTION = new Invoker()
179       {
180          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
181                throws Throwable JavaDoc
182          {
183             Coordinator other = (Coordinator)args[0];
184             boolean retVal =
185                   ((ICoordinator)servant).isSameTransaction(targetId, other);
186             return Boolean.valueOf(retVal);
187          }
188       };
189       
190       /** Invoker for Coordinator.hashTransaction */
191       static final Invoker HASH_TRANSACTION = new Invoker()
192       {
193          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
194                throws Throwable JavaDoc
195          {
196             int retVal = ((ICoordinator)servant).hashTransaction(targetId);
197             return new Integer JavaDoc(retVal);
198          }
199       };
200
201       /** Invoker for Coordinator.registerResource */
202       static final Invoker REGISTER_RESOURCE = new Invoker()
203       {
204          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
205                throws Throwable JavaDoc
206          {
207             Resource r = (Resource)args[0];
208             return ((ICoordinator)servant).registerResource(targetId, r);
209          }
210       };
211       
212       /** Invoker for Coordinator.registerSynchronization */
213       static final Invoker REGISTER_SYNCHRONIZATION = new Invoker()
214       {
215          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
216                throws Throwable JavaDoc
217          {
218             Synchronization sync = (Synchronization)args[0];
219             ((ICoordinator)servant).registerSynchronization(targetId, sync);
220             return null;
221          }
222       };
223       
224       /** Invoker for Coordinator.rollbackOnly */
225       static final Invoker ROLLBACK_ONLY = new Invoker()
226       {
227          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
228                throws Throwable JavaDoc
229          {
230             ((ICoordinator)servant).rollbackOnly(targetId);
231             return null;
232          }
233       };
234       
235       /** Invoker for Coordinator.getTransactionContext */
236       static final Invoker GET_TRANSACTION_CONTEXT = new Invoker()
237       {
238          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
239                throws Throwable JavaDoc
240          {
241             return ((ICoordinator)servant).getTransactionContext(targetId);
242          }
243       };
244
245       /** Invoker for Coordinator.getTransactionId */
246       static final Invoker GET_TRANSACTION_ID = new Invoker()
247       {
248          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
249                throws Throwable JavaDoc
250          {
251             return ((ICoordinator)servant).getTransactionId(targetId);
252          }
253       };
254
255       /** Mirror method for Coordinator.getStatus */
256       Status getStatus(long targetId)
257             throws RemoteException JavaDoc;
258
259       /** Mirror method for Coordinator.isSameTransaction */
260       boolean isSameTransaction(long targetId, Coordinator c)
261             throws RemoteException JavaDoc;
262
263       /** Mirror method for Coordinator.hashTransaction */
264       int hashTransaction(long targetId)
265             throws RemoteException JavaDoc;
266
267       /** Mirror method for Coordinator.registerResource */
268       RecoveryCoordinator registerResource(long targetId, Resource r)
269             throws RemoteException JavaDoc,
270                    TransactionInactiveException;
271
272       /** Mirror method for Coordinator.registerSynchronization */
273       void registerSynchronization(long targetId, Synchronization sync)
274             throws RemoteException JavaDoc,
275                    TransactionInactiveException;
276
277       /** Mirror method for Coordinator.rollbackOnly */
278       void rollbackOnly(long targetId)
279             throws RemoteException JavaDoc,
280                    TransactionInactiveException;
281
282       /** Mirror method for Coordinator.getTransactionContext */
283       TxPropagationContext getTransactionContext(long targetId)
284             throws RemoteException JavaDoc,
285                    TransactionInactiveException;
286
287       /** Mirror method for Coordinator.getTransactionId */
288       GlobalId getTransactionId(long targetId)
289             throws RemoteException JavaDoc;
290    }
291    
292    /**
293     * This interface mirrors the interface <code>Terminator</code> in
294     * <code>org.jboss.tm.remoting.interfaces</code>. Attention: method id
295     * constants (<code>M_</code>* fields) are indices to an invoker array,
296     * so they must be consecutive integers in the range 0..max_index. They
297     * also must be unique among all mirror interfaces.
298     */

299    public static interface ITerminator
300    {
301       /** Method id for Terminator.commit */
302       static final int M_COMMIT = 10;
303       
304       /** Method id for Terminator.rollback */
305       static final int M_ROLLBACK = 11;
306       
307       /** Invoker for Terminator.commit */
308       static final Invoker COMMIT = new Invoker()
309       {
310          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
311                throws Throwable JavaDoc
312          {
313             boolean reportHeuristics = ((Boolean JavaDoc)args[0]).booleanValue();
314             ((ITerminator)servant).commit(targetId, reportHeuristics);
315             return null;
316          }
317       };
318       
319       /** Invoker for Terminator.rollback */
320       static final Invoker ROLLBACK = new Invoker()
321       {
322          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
323                throws Throwable JavaDoc
324          {
325             ((ITerminator)servant).rollback(targetId);
326             return null;
327          }
328       };
329       
330       /** Mirror method for Terminator.commit */
331       void commit(long targetId, boolean reportHeuristics)
332             throws RemoteException JavaDoc,
333                    HeuristicMixedException JavaDoc,
334                    HeuristicHazardException;
335
336       /** Mirror method for Terminator.commit */
337       void rollback(long targetId)
338             throws RemoteException JavaDoc;
339    }
340    
341    /**
342     * This interface mirrors the interface <code>Resource</code> in
343     * <code>org.jboss.tm.remoting.interfaces</code>. Attention: method id
344     * constants (<code>M_</code>* fields) are indices to an invoker array,
345     * so they must be consecutive integers in the range 0..max_index. They
346     * also must be unique among all mirror interfaces.
347     */

348    public static interface IResource
349    {
350       /** Method id for Resource.prepare */
351       static final int M_PREPARE = 12;
352       
353       /** Method id for Resource.rollback */
354       static final int M_ROLLBACK = 13;
355
356       /** Method id for Resource.commit */
357       static final int M_COMMIT = 14;
358
359       /** Method id for Resource.commitOnePhase */
360       static final int M_COMMIT_ONE_PHASE = 15;
361
362       /** Method id for Resource.forget */
363       static final int M_FORGET = 16;
364       
365       /** Invoker for Resource.prepare */
366       static final Invoker PREPARE = new Invoker()
367       {
368          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
369                throws Throwable JavaDoc
370          {
371             return ((IResource)servant).prepare(targetId);
372          }
373       };
374       
375       /** Invoker for Resource.rollback */
376       static final Invoker ROLLBACK = new Invoker()
377       {
378          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
379                throws Throwable JavaDoc
380          {
381             ((IResource)servant).rollbackResource(targetId);
382             return null;
383          }
384       };
385       
386       /** Invoker for Resource.commit */
387       static final Invoker COMMIT = new Invoker()
388       {
389          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
390                throws Throwable JavaDoc
391          {
392             ((IResource)servant).commit(targetId);
393             return null;
394          }
395       };
396       
397       /** Invoker for Resource.commitOnePhase */
398       static final Invoker COMMIT_ONE_PHASE = new Invoker()
399       {
400          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
401                throws Throwable JavaDoc
402          {
403             ((IResource)servant).commitOnePhase(targetId);
404             return null;
405          }
406       };
407       
408       /** Invoker for Resource.forget */
409       static final Invoker FORGET = new Invoker()
410       {
411          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
412                throws Throwable JavaDoc
413          {
414             ((IResource)servant).forget(targetId);
415             return null;
416          }
417       };
418       
419       /** Mirror method for Resource.prepare */
420       Vote prepare(long targetId)
421             throws RemoteException JavaDoc,
422                    HeuristicMixedException JavaDoc,
423                    HeuristicHazardException;
424
425       /** Mirror method for Resource.rollback -- its name is rollbackResource
426        * (rather than rollback) to avoid the name clash with Terminator.rollback
427        * within the DTMServant class */

428       void rollbackResource(long targetId)
429             throws RemoteException JavaDoc,
430                    HeuristicCommitException JavaDoc,
431                    HeuristicMixedException JavaDoc,
432                    HeuristicHazardException;
433
434       /** Mirror method for Resource.commit */
435       void commit(long targetId)
436             throws RemoteException JavaDoc,
437                    TransactionNotPreparedException,
438                    HeuristicRollbackException JavaDoc,
439                    HeuristicMixedException JavaDoc,
440                    HeuristicHazardException;
441
442       /** Mirror method for Resource.commitOnePhase */
443       void commitOnePhase(long targetId)
444             throws RemoteException JavaDoc,
445                    HeuristicHazardException;
446
447       /** Mirror method for Resource.forget */
448       void forget(long targetId)
449             throws RemoteException JavaDoc;
450    }
451    
452    /**
453     * This interface mirrors the interface <code>RecoveryCoordinator</code>
454     * in <code>org.jboss.tm.remoting.interfaces</code>. Attention: method id
455     * constants (<code>M_</code>* fields) are indices to an invoker array,
456     * so they must be consecutive integers in the range 0..max_index. They
457     * also must be unique among all mirror interfaces.
458     */

459    public static interface IRecoveryCoordinator
460    {
461       /** Method id for RecoveryCoordinator.replayCompletion */
462       static final int M_REPLAY_COMPLETION = 17;
463
464       /** Invoker for RecoveryCoordinator.replayCompletion */
465       static final Invoker REPLAY_COMPLETION = new Invoker()
466       {
467          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
468                throws Throwable JavaDoc
469          {
470             Resource r = (Resource)args[0];
471             return ((IRecoveryCoordinator)servant).replayCompletion(targetId,
472                                                                     r);
473          }
474       };
475       
476       /** Mirror method for RecoveryCoordinator.replayCompletion */
477       Status replayCompletion(long targetId, Resource r)
478             throws RemoteException JavaDoc,
479                    TransactionNotPreparedException;
480    }
481    
482    /**
483     * This interface mirrors the interface <code>Synchronization</code> in
484     * <code>org.jboss.tm.remoting.interfaces</code>. Attention: method id
485     * constants (<code>M_</code>* fields) are indices to an invoker array,
486     * so they must be consecutive integers in the range 0..max_index. They
487     * also must be unique among all mirror interfaces.
488     */

489    public static interface ISynchronization
490    {
491       /** Method id for Synchronization.beforeCompletion */
492       static final int M_BEFORE_COMPLETION = 18;
493
494       /** Method id for Synchronization.afterCompletion */
495       static final int M_AFTER_COMPLETION = 19;
496       
497       /** Invoker for Synchronization.beforeCompletion */
498       static final Invoker BEFORE_COMPLETION = new Invoker()
499       {
500          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
501                throws Throwable JavaDoc
502          {
503             ((ISynchronization)servant).beforeCompletion(targetId);
504             return null;
505          }
506       };
507       
508       /** Invoker for Synchronization.afterCompletion */
509       static final Invoker AFTER_COMPLETION = new Invoker()
510       {
511          public Object JavaDoc invoke(Object JavaDoc servant, long targetId, Object JavaDoc[] args)
512                throws Throwable JavaDoc
513          {
514             ((ISynchronization)servant).afterCompletion(targetId);
515             return null;
516          }
517       };
518       
519       /** Mirror method for Synchronization.beforeCompletion */
520       void beforeCompletion(long targetId);
521       
522       /** Mirror method for Synchronization.afterCompletion */
523       void afterCompletion(long targetId);
524    }
525    
526    // Static field --------------------------------------------------
527

528    /**
529     * Array of <code>Invoker</code> instances ordered by method id.
530     * Used for efficient (non-reflective) invocation of a method, given
531     * its id.
532     */

533    private static final Invoker[] invokerArray =
534    {
535          ITransactionFactory.CREATE,
536          ITransactionFactory.RECREATE,
537          ICoordinator.GET_STATUS,
538          ICoordinator.IS_SAME_TRANSACTION,
539          ICoordinator.HASH_TRANSACTION,
540          ICoordinator.REGISTER_RESOURCE,
541          ICoordinator.REGISTER_SYNCHRONIZATION,
542          ICoordinator.ROLLBACK_ONLY,
543          ICoordinator.GET_TRANSACTION_CONTEXT,
544          ICoordinator.GET_TRANSACTION_ID,
545          ITerminator.COMMIT,
546          ITerminator.ROLLBACK,
547          IResource.PREPARE,
548          IResource.ROLLBACK,
549          IResource.COMMIT,
550          IResource.COMMIT_ONE_PHASE,
551          IResource.FORGET,
552          IRecoveryCoordinator.REPLAY_COMPLETION,
553          ISynchronization.BEFORE_COMPLETION,
554          ISynchronization.AFTER_COMPLETION
555    };
556
557    // Static method--------------------------------------------------
558

559    /**
560     * Return the id of a given method,
561     */

562    private static int getMethodId(Method JavaDoc m)
563    {
564       Class JavaDoc clz = m.getDeclaringClass();
565       
566       if (clz == TransactionFactory.class)
567       {
568          String JavaDoc name = m.getName();
569          
570          if (name.equals("create"))
571             return ITransactionFactory.M_CREATE;
572          else /* name.equals("recreate") */
573             return ITransactionFactory.M_RECREATE;
574       }
575       else if (clz == Coordinator.class)
576       {
577          String JavaDoc name = m.getName();
578          
579          if (name.equals("getStatus"))
580             return ICoordinator.M_GET_STATUS;
581          else if (name.equals("isSameTransaction"))
582             return ICoordinator.M_IS_SAME_TRANSACTION;
583          else if (name.equals("hashTransaction"))
584             return ICoordinator.M_HASH_TRANSACTION;
585          else if (name.equals("registerResource"))
586             return ICoordinator.M_REGISTER_RESOURCE;
587          else if (name.equals("registerSynchronization"))
588             return ICoordinator.M_REGISTER_SYNCHRONIZATION;
589          else if (name.equals("rollbackOnly"))
590             return ICoordinator.M_ROLLBACK_ONLY;
591          else if (name.equals("getTransactionContext"))
592             return ICoordinator.M_GET_TRANSACTION_CONTEXT;
593          else /* name.equals("getTransactionId") */
594             return ICoordinator.M_GET_TRANSACTION_ID;
595       }
596       else if (clz == Terminator JavaDoc.class)
597       {
598          String JavaDoc name = m.getName();
599          
600          if (name.equals("commit"))
601             return ITerminator.M_COMMIT;
602          else /* name.equals("rollback") */
603             return ITerminator.M_ROLLBACK;
604          
605       }
606       else if (clz == Resource.class)
607       {
608          String JavaDoc name = m.getName();
609          
610          if (name.equals("prepare"))
611             return IResource.M_PREPARE;
612          else if (name.equals("rollback"))
613             return IResource.M_ROLLBACK;
614          else if (name.equals("commit"))
615             return IResource.M_COMMIT;
616          else if (name.equals("commitOnePhase"))
617             return IResource.M_COMMIT_ONE_PHASE;
618          else /* name.equals("forget") */
619             return IResource.M_FORGET;
620       }
621       else if (clz == RecoveryCoordinator.class)
622       {
623          return IRecoveryCoordinator.M_REPLAY_COMPLETION;
624       }
625       else if (clz == Synchronization.class)
626       {
627          String JavaDoc name = m.getName();
628          
629          if (name.equals("beforeCompletion"))
630             return ISynchronization.M_BEFORE_COMPLETION;
631          else /* name.equals("afterCompletion") */
632             return ISynchronization.M_AFTER_COMPLETION;
633       }
634       else
635       {
636          throw new RuntimeException JavaDoc("Method " + m + " does not belong to" +
637                                     " a transaction service interface");
638       }
639    }
640    
641    // Attributes ----------------------------------------------------
642

643    /** Specifies the logical target of this <code>Invocation</code>. */
644    private long targetId;
645    
646    /** Specifies the method to be invoked. */
647    private int methodId;
648    
649    /** The arguments for the method invocation. */
650    private Object JavaDoc[] args;
651    
652    // Constructors --------------------------------------------------
653

654    /** Builds a new <code>Invocation</code> instance. */
655    public Invocation(long targetId,
656                      Method JavaDoc method,
657                      Object JavaDoc[] args)
658    {
659       this.targetId = targetId;
660       this.methodId = getMethodId(method);
661       this.args = args;
662    }
663    
664    /** Uses the given servant to perform this <code>Invocation</code>. */
665    public Object JavaDoc perform(InvokerLocator locator, Object JavaDoc servant)
666          throws Throwable JavaDoc
667    {
668       return invokerArray[methodId].invoke(servant, targetId, args);
669    }
670
671 }
672
Popular Tags