org.opennms.core.concurrent
Class VMTaskFiber

java.lang.Object
  extended by org.opennms.core.concurrent.VMTaskFiber
All Implemented Interfaces:
java.lang.Runnable, Fiber

public class VMTaskFiber
extends java.lang.Object
implements Fiber, java.lang.Runnable

Author:
Brian Weaver , OpenNMS

Field Summary
 
Fields inherited from interface org.opennms.core.fiber.Fiber
RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED
 
Constructor Summary
VMTaskFiber(java.lang.String taskName, java.lang.String entryClassName, java.lang.String[] entryArguments, java.net.URL[] searchPaths)
          Constructs a new Virtual Macine Task Fiber.
 
Method Summary
 java.lang.String getName()
          Returns the name for the virtual machine task.
 int getStatus()
          Returns the current status of the fiber.
 void run()
          This method invokes the entry method on the main class.
 void start()
          Starts the current fiber running.
 void stop()
          Stops the current fiber.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VMTaskFiber

public VMTaskFiber(java.lang.String taskName,
                   java.lang.String entryClassName,
                   java.lang.String[] entryArguments,
                   java.net.URL[] searchPaths)
            throws java.lang.ClassNotFoundException,
                   java.lang.NoSuchMethodException
Constructs a new Virtual Macine Task Fiber. The task has a name and is passed all the information to invoke the class' main method. When the class is loaded it is allocated a new class loader used to locate all of it's resources.

Parameters:
taskName - The name of the task
entryClassName - The name of the entry class.
entryArguments - The String array passed to main.
searchPaths - The URL's used to locate resources and classes.
Throws:
java.lang.ClassNotFoundException - Thrown if the entry class is not found.
java.lang.NoSuchMethodException - Thrown if the main is not found on the entry class.
See Also:
URLClassLoader
Method Detail

run

public void run()
This method invokes the entry method on the main class. The method is called after the internal thread starts up, and returns when the entry method's thread exits.

Specified by:
run in interface java.lang.Runnable

start

public void start()
Starts the current fiber running.

Specified by:
start in interface Fiber

stop

public void stop()
Stops the current fiber. Since the JVM does not provide way to kill threads, the thread group is interrupted and the status is set to STOP_PENDING. When the main thread exits then the service is considered stopped!

Specified by:
stop in interface Fiber

getStatus

public int getStatus()
Returns the current status of the fiber.

Specified by:
getStatus in interface Fiber
Returns:
The current status of the fiber.

getName

public java.lang.String getName()
Returns the name for the virtual machine task.

Specified by:
getName in interface Fiber
Returns:
The VM Task's name.


Copyright © 2007. All Rights Reserved.