1 4 package com.tc.test.server.appserver; 5 6 import com.tc.test.server.tcconfig.TerracottaServerConfigGenerator; 7 8 import java.io.File ; 9 import java.util.HashMap ; 10 import java.util.Map ; 11 import java.util.Properties ; 12 13 17 public class StandardAppServerParameters implements AppServerParameters { 18 19 private final Map wars = new HashMap (); 20 private final String instanceName; 21 private final Properties props; 22 private final String tcSessionClasspath; 23 private String jvmArgs = ""; 24 private String classpath = ""; 25 26 public StandardAppServerParameters(String instanceName, Properties props, String tcSessionClasspath) { 27 this.instanceName = instanceName; 28 this.props = props; 29 this.tcSessionClasspath = tcSessionClasspath; 30 } 31 32 public void addWar(String context, File file) { 33 wars.put(context, file); 34 } 35 36 public final void addWar(File war) { 37 String name = war.getName(); 38 addWar(name.substring(0, name.length() - 4), war); 39 } 40 41 public final String jvmArgs() { 42 return jvmArgs; 43 } 44 45 public final void appendJvmArgs(String jvmArgsVar) { 46 this.jvmArgs += jvmArgsVar + " "; 47 } 48 49 public final String classpath() { 50 return classpath; 51 } 52 53 protected final void appendClasspath(String classpathVar) { 54 this.classpath += classpathVar + " "; 55 } 56 57 public final Map wars() { 58 return wars; 59 } 60 61 public final String instanceName() { 62 return instanceName; 63 } 64 65 public final Properties properties() { 66 return props; 67 } 68 69 public final void enableDSO(TerracottaServerConfigGenerator dsoConfig, File bootJar) { 70 StringBuffer sb = new StringBuffer (); 71 sb.append("-Dtc.config='" + dsoConfig.configPath() + "'"); 72 sb.append(' '); 73 sb.append("-Xbootclasspath/p:'" + bootJar + "'"); 74 sb.append(' '); 75 sb.append("-Dtc.classpath='" + System.getProperty("java.class.path") + "'"); 76 sb.append(' '); 77 sb.append("-Dtc.session.classpath='" + tcSessionClasspath + "'"); 78 appendJvmArgs(sb.toString()); 79 } 80 81 public void appendSysProp(String name, int value) { 82 appendSysProp(name, Integer.toString(value)); 83 } 84 85 private void appendSysProp(String name, String value) { 86 if (value == null) appendJvmArgs("-D" + name); 87 else appendJvmArgs("-D" + name + "=" + value); 88 } 89 90 public void appendSysProp(String name) { 91 appendSysProp(name, null); 92 } 93 94 public void appendSysProp(String name, boolean b) { 95 appendSysProp(name, Boolean.toString(b)); 96 } 97 98 } | Popular Tags |