KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > objectserver > control > ExtraL1ProcessControl


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.objectserver.control;
5
6 import com.tc.process.LinkedJavaProcess;
7 import com.tc.test.TestConfigObject;
8 import com.tc.util.Assert;
9
10 import java.io.File JavaDoc;
11 import java.io.FileNotFoundException JavaDoc;
12
13 public class ExtraL1ProcessControl extends ExtraProcessServerControl {
14
15   private final Class JavaDoc mainClass;
16   private final String JavaDoc[] mainArgs;
17   private final File JavaDoc directory;
18
19   public ExtraL1ProcessControl(String JavaDoc l2Host, int dsoPort, Class JavaDoc mainClass, String JavaDoc configFileLoc, String JavaDoc[] mainArgs,
20                                File JavaDoc directory) throws FileNotFoundException JavaDoc {
21     super(new DebugParams(), l2Host, dsoPort, 0, configFileLoc, true);
22     this.mainClass = mainClass;
23     this.mainArgs = mainArgs;
24     this.directory = directory;
25
26     setJVMArgs();
27   }
28
29   protected LinkedJavaProcess createLinkedJavaProcess() {
30     LinkedJavaProcess out = super.createLinkedJavaProcess();
31     out.setDirectory(this.directory);
32     return out;
33   }
34
35   private void setJVMArgs() {
36     try {
37       String JavaDoc bootclasspath = "-Xbootclasspath/p:" + TestConfigObject.getInstance().normalBootJar();
38       System.err.println("Bootclasspath:" + bootclasspath);
39       this.jvmArgs.add("-Dtc.classpath=" + System.getProperty("java.class.path"));
40       this.jvmArgs.add(bootclasspath);
41       this.jvmArgs.add("-Dtc.config=" + super.configFileLoc);
42     } catch (Exception JavaDoc e) {
43       throw Assert.failure("Can't set JVM args", e);
44     }
45   }
46
47   protected String JavaDoc getMainClassName() {
48     return mainClass.getName();
49   }
50
51   protected String JavaDoc[] getMainClassArguments() {
52     return mainArgs;
53   }
54
55   public boolean isRunning() {
56     // TODO:: comeback
57
return true;
58   }
59
60   public void attemptShutdown() throws Exception JavaDoc {
61     // TODO:: comeback
62
process.destroy();
63   }
64 }
65
Popular Tags