fedora.server.utilities
Class MethodInvokerThread

java.lang.Object
  extended byjava.lang.Thread
      extended byfedora.server.utilities.MethodInvokerThread
All Implemented Interfaces:
java.lang.Runnable

public class MethodInvokerThread
extends java.lang.Thread

Title: MethodInvokerThread.java

Description: A Thread that invokes a single method, then exits.

This is convenient in situations where some method should run in a separate Thread, but it is either inconvenient or inappropriate to write a Runnable to do the work.

-----------------------------------------------------------------------------

License and Copyright: The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/.

Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.

The entire file consists of original code. Copyright © 2002-2005 by The Rector and Visitors of the University of Virginia and Cornell University. All rights reserved.

-----------------------------------------------------------------------------

Version:
$Id: MethodInvokerThread.java,v 1.6 2005/01/11 20:06:09 cwilper Exp $
Author:
cwilper@cs.cornell.edu

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MethodInvokerThread(java.lang.Object targetObject, java.lang.reflect.Method method, java.lang.Object[] args)
          Constructs a MethodInvokerThread.
MethodInvokerThread(java.lang.Object targetObject, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.String name)
          Constructs a MethodInvokerThread with a name.
MethodInvokerThread(java.lang.Object targetObject, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.ThreadGroup threadGroup, java.lang.String name)
          Constructs a MethodInvokerThread with a ThreadGroup and a name.
 
Method Summary
 java.lang.Object getReturned()
          Gets the Object returned by the invoked Method.
 java.lang.Throwable getThrown()
          Gets the Throwable that resulted if an error occurred while trying to invoke the Method.
 void run()
          Invokes the Method, then exits.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MethodInvokerThread

public MethodInvokerThread(java.lang.Object targetObject,
                           java.lang.reflect.Method method,
                           java.lang.Object[] args)
Constructs a MethodInvokerThread.

Parameters:
targetObject - The object in which the method resides.
method - The Method to invoke.
args - The arguments to the method.

MethodInvokerThread

public MethodInvokerThread(java.lang.Object targetObject,
                           java.lang.reflect.Method method,
                           java.lang.Object[] args,
                           java.lang.String name)
Constructs a MethodInvokerThread with a name.

Parameters:
targetObject - The object in which the method resides.
method - The Method to invoke.
args - The arguments to the method.
name - The thread's name.

MethodInvokerThread

public MethodInvokerThread(java.lang.Object targetObject,
                           java.lang.reflect.Method method,
                           java.lang.Object[] args,
                           java.lang.ThreadGroup threadGroup,
                           java.lang.String name)
Constructs a MethodInvokerThread with a ThreadGroup and a name.

Parameters:
targetObject - The object in which the method resides.
method - The Method to invoke.
args - The arguments to the method.
threadGroup - The ThreadGroup to which the thread should belong.
name - The thread's name.
Method Detail

run

public void run()
Invokes the Method, then exits.


getReturned

public java.lang.Object getReturned()
Gets the Object returned by the invoked Method.

Returns:
The Object, or null if the method has no return type or the method hasn't been invoked yet.

getThrown

public java.lang.Throwable getThrown()
Gets the Throwable that resulted if an error occurred while trying to invoke the Method.

Returns:
The Throwable, or null if the method's invocation did not produce a Throwable or the method hasn't been invoked yet.