KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ve > luz > ica > jackass > daemon > InstantiatorThread


1 /*
2  * Copyright (c) 2003 by The Jackass Team
3  * Licensed under the Open Software License version 2.0
4  */

5 package ve.luz.ica.jackass.daemon;
6
7 import java.lang.reflect.Method JavaDoc;
8
9 import org.apache.commons.logging.Log;
10 import org.apache.commons.logging.LogFactory;
11
12 /**
13  * This class represents the threads where the inprocess instantiators run
14  * @author Carlos Arévalo
15  */

16 class InstantiatorThread extends Thread JavaDoc
17 {
18     private static final Log LOG = LogFactory.getLog(InstantiatorThread.class);
19
20     private String JavaDoc className;
21     private String JavaDoc[] commandLineParams = null;
22
23     /**
24      * Class constructor
25      * @param name the instantiator class name
26      * @param params the command line parameters
27      */

28     public InstantiatorThread(String JavaDoc name, String JavaDoc[] params)
29     {
30         this.className = name;
31         this.commandLineParams = params;
32    }
33
34     /**
35      * Load the Instantiator class and execute the main method.
36      * @see java.lang.Runnable#run()
37      */

38     public void run()
39     {
40         Class JavaDoc[] params = {String JavaDoc[].class};
41         Class JavaDoc instClass;
42         try
43         {
44             instClass = Class.forName(className);
45             Method JavaDoc mainMethod = instClass.getDeclaredMethod("main", params);
46             mainMethod.invoke(null, new Object JavaDoc[] {commandLineParams});
47         }
48         catch (Exception JavaDoc e)
49         {
50             LOG.error(e.getMessage(), e);
51         }
52     }
53 }
54
Popular Tags