wip commit
This commit is contained in:
parent
7c044adb1f
commit
3f31bb8a3a
9 changed files with 118 additions and 51 deletions
|
|
@ -29,10 +29,9 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
|
@ -68,7 +67,7 @@ public class TechUI extends SingleFrameApplication {
|
|||
|
||||
LogFactory.getLog(TechUI.class); // init JULI so reconfig is done once.
|
||||
|
||||
File logConfig = new File("logfile.properties");
|
||||
File logConfig = new File("config/logging.properties");
|
||||
if (logConfig.exists()) {
|
||||
InputStream in = null;
|
||||
try {
|
||||
|
|
@ -124,44 +123,48 @@ public class TechUI extends SingleFrameApplication {
|
|||
// First parse user program arguments.
|
||||
String serverHost = null;
|
||||
String serverPort = null;
|
||||
List<String> arguList = new ArrayList<String>(argu.length);
|
||||
for (String a:argu) {
|
||||
arguList.add(a);
|
||||
}
|
||||
Iterator<String> arguIterator = arguList.iterator();
|
||||
while (arguIterator.hasNext()) {
|
||||
String arg = arguIterator.next();
|
||||
if ("-v".equals(arg)) {
|
||||
System.out.println();
|
||||
System.out.println("Optional:");
|
||||
System.out.println(" -host <ip> Sets the http hostname.");
|
||||
System.out.println(" -port <port> Sets the http port.");
|
||||
System.out.println(" -gui Sets gui mode.");
|
||||
System.out.println(" -h Print help. (this)");
|
||||
System.out.println();
|
||||
System.exit(1);
|
||||
}
|
||||
if ("-gui".equals(arg)) {
|
||||
showGui = true;
|
||||
}
|
||||
if ("-port".equals(arg)) {
|
||||
if (arguIterator.hasNext()==false) {
|
||||
System.out.println("No argument for -port given.");
|
||||
return;
|
||||
String contextPath = null;
|
||||
boolean editor = false;
|
||||
showGui = false;
|
||||
|
||||
File propFile = new File("config/server.properties");
|
||||
if (propFile.exists()) {
|
||||
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = new FileInputStream(propFile);
|
||||
Properties p = new Properties();
|
||||
p.load(in);
|
||||
serverHost = p.getProperty("host");
|
||||
serverPort = p.getProperty("port");
|
||||
contextPath = p.getProperty("contextPath");
|
||||
if ("true".equalsIgnoreCase(p.getProperty("gui"))) {
|
||||
showGui = true;
|
||||
} else {
|
||||
showGui = false;
|
||||
}
|
||||
if ("true".equalsIgnoreCase(p.getProperty("editor"))) {
|
||||
editor = true;
|
||||
} else {
|
||||
editor = false;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (in!=null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
serverPort = arguIterator.next();
|
||||
System.exit(1);
|
||||
}
|
||||
if ("-host".equals(arg)) {
|
||||
if (arguIterator.hasNext()==false) {
|
||||
System.out.println("No argument for -host given.");
|
||||
return;
|
||||
}
|
||||
serverHost = arguIterator.next();
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
serverHost = "localhost";
|
||||
serverPort = "8899";
|
||||
}
|
||||
|
||||
|
||||
setupLogging();
|
||||
logger.info("Starting Vasc-Demo-Tech-UI.");
|
||||
|
||||
|
|
@ -176,9 +179,11 @@ public class TechUI extends SingleFrameApplication {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
vascManager = new DemoVascManager();
|
||||
vascManager.start();
|
||||
if (editor) {
|
||||
vascManager.startEditor();
|
||||
}
|
||||
|
||||
deployManager = new DeployManager();
|
||||
deployManager.setDeployDir(deployDir);
|
||||
|
|
@ -193,6 +198,9 @@ public class TechUI extends SingleFrameApplication {
|
|||
if (serverPort!=null) {
|
||||
tomcatManager.setPort(new Integer(serverPort));
|
||||
}
|
||||
if (contextPath!=null) {
|
||||
tomcatManager.setContextPath(contextPath);
|
||||
}
|
||||
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ import java.util.logging.Logger;
|
|||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
|
||||
import org.apache.catalina.startup.Bootstrap;
|
||||
import org.apache.catalina.startup.Tomcat;
|
||||
import org.apache.catalina.valves.AccessLogValve;
|
||||
|
||||
public class TomcatManager {
|
||||
|
||||
|
|
@ -20,11 +22,13 @@ public class TomcatManager {
|
|||
private String hostname = null;
|
||||
private Integer port = null;
|
||||
private File workDir = null;
|
||||
private String contextPath = null;
|
||||
|
||||
public TomcatManager() {
|
||||
logger = Logger.getLogger(TomcatManager.class.getName());
|
||||
hostname = "localhost";
|
||||
port = 8899;
|
||||
contextPath = "/demo";
|
||||
}
|
||||
|
||||
public void start() throws Exception {
|
||||
|
|
@ -36,11 +40,21 @@ public class TomcatManager {
|
|||
tomcat.setPort(getPort());
|
||||
tomcat.setHostname(getHostname());
|
||||
|
||||
if (System.getProperty("java.class.path").contains("classes")) {
|
||||
tomcat.init();
|
||||
|
||||
if (TechUI.getInstance().isMavenRun()==false) {
|
||||
AccessLogValve accessLog = new AccessLogValve();
|
||||
accessLog.setDirectory("../logs");
|
||||
accessLog.setSuffix(".log");
|
||||
accessLog.setPattern("%h %l %u %t "%r" %s %b");
|
||||
tomcat.getHost().getPipeline().addValve(accessLog);
|
||||
}
|
||||
|
||||
if (TechUI.getInstance().isMavenRun()) {
|
||||
String webappPathLocation = "../vasc-demo-tech-web/src/main/webapp/";
|
||||
String deployPath = new File(webappPathLocation).getAbsolutePath();
|
||||
logger.info("Deploy demo app from workspace path: "+deployPath);
|
||||
tomcat.addWebapp("/demo",deployPath);
|
||||
tomcat.addWebapp(getContextPath(),deployPath);
|
||||
} else {
|
||||
|
||||
File techWarFile = null;
|
||||
|
|
@ -76,7 +90,7 @@ public class TomcatManager {
|
|||
}
|
||||
String deployPath = destDir.getAbsolutePath();
|
||||
logger.info("Deploy war path: "+deployPath);
|
||||
tomcat.addWebapp("/demo",deployPath);
|
||||
tomcat.addWebapp(getContextPath(),deployPath);
|
||||
}
|
||||
tomcat.start();
|
||||
}
|
||||
|
|
@ -143,4 +157,18 @@ public class TomcatManager {
|
|||
public void setWorkDir(File workDir) {
|
||||
this.workDir = workDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the contextPath
|
||||
*/
|
||||
public String getContextPath() {
|
||||
return contextPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contextPath the contextPath to set
|
||||
*/
|
||||
public void setContextPath(String contextPath) {
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -283,12 +283,12 @@ public class JMainPanel extends JPanel {
|
|||
}
|
||||
if (keys.isEmpty()==false) {
|
||||
Properties p = new Properties();
|
||||
File dataDir = new File("auto/data");
|
||||
File dataDir = new File("data");
|
||||
|
||||
if (dataDir.exists()==false) {
|
||||
dataDir.mkdirs();
|
||||
}
|
||||
File resourceFile = new File("auto/data/vasc-bundle.properties");
|
||||
File resourceFile = new File("data/vasc-bundle.properties");
|
||||
if (resourceFile.exists()) {
|
||||
readPropertiesFile(p,resourceFile);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# bundle list to merge and load
|
||||
bundle1.uri=net.forwardfire.vasc.demo.tech.ui.resources.TechUI
|
||||
|
||||
bundle2.uri=auto/data/vasc-bundle.properties
|
||||
bundle2.uri=data/vasc-bundle.properties
|
||||
bundle2.type=FILE
|
||||
bundle2.optional=true
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue