01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.objectserver.control;
06:
07: import com.tc.process.LinkedJavaProcess;
08: import com.tc.test.TestConfigObject;
09: import com.tc.util.Assert;
10:
11: import java.io.File;
12: import java.io.FileNotFoundException;
13: import java.util.Iterator;
14: import java.util.List;
15:
16: public class ExtraL1ProcessControl extends ExtraProcessServerControl {
17:
18: private final Class mainClass;
19: private final String[] mainArgs;
20: private final File directory;
21:
22: public ExtraL1ProcessControl(String l2Host, int dsoPort,
23: Class mainClass, String configFileLoc, String[] mainArgs,
24: File directory, List extraJvmArgs)
25: throws FileNotFoundException {
26: super (new DebugParams(), l2Host, dsoPort, 0, configFileLoc,
27: true, extraJvmArgs);
28: this .mainClass = mainClass;
29: this .mainArgs = mainArgs;
30: this .directory = directory;
31:
32: if (extraJvmArgs != null) {
33: for (Iterator i = extraJvmArgs.iterator(); i.hasNext();) {
34: String next = (String) i.next();
35: this .jvmArgs.add(next);
36: }
37: }
38:
39: setJVMArgs();
40: }
41:
42: public File getJavaHome() {
43: return javaHome;
44: }
45:
46: protected LinkedJavaProcess createLinkedJavaProcess() {
47: LinkedJavaProcess out = super .createLinkedJavaProcess();
48: out.setDirectory(this .directory);
49: return out;
50: }
51:
52: private void setJVMArgs() {
53: try {
54: String bootclasspath = "-Xbootclasspath/p:"
55: + TestConfigObject.getInstance().normalBootJar();
56: System.err.println("Bootclasspath:" + bootclasspath);
57: this .jvmArgs.add("-Dtc.classpath="
58: + System.getProperty("java.class.path"));
59: this .jvmArgs.add(bootclasspath);
60: this .jvmArgs.add("-Dtc.config=" + super .configFileLoc);
61: } catch (Exception e) {
62: throw Assert.failure("Can't set JVM args", e);
63: }
64: }
65:
66: protected String getMainClassName() {
67: return mainClass.getName();
68: }
69:
70: protected String[] getMainClassArguments() {
71: return mainArgs;
72: }
73:
74: public boolean isRunning() {
75: // TODO:: comeback
76: return true;
77: }
78:
79: public void attemptShutdown() throws Exception {
80: // TODO:: comeback
81: process.destroy();
82: }
83: }
|