wip commit
This commit is contained in:
parent
7c044adb1f
commit
3f31bb8a3a
|
@ -1,4 +1,30 @@
|
|||
#
|
||||
#
|
||||
# Vasc Demo Tech logging config.
|
||||
#
|
||||
|
||||
# Only log to a file
|
||||
handlers=java.util.logging.FileHandler
|
||||
|
||||
# default file output is in startup directory.
|
||||
java.util.logging.FileHandler.pattern=logs/vasc-demo-tech.log
|
||||
java.util.logging.FileHandler.limit=0
|
||||
java.util.logging.FileHandler.count=1
|
||||
java.util.logging.FileHandler.encoding=UTF8
|
||||
java.util.logging.FileHandler.formatter=net.forwardfire.vasc.demo.tech.ui.PatternLogFormatter
|
||||
|
||||
# The PatternLogFormatter lets you customise the log output;
|
||||
# %d = Formated date string %s =-Source method
|
||||
# %l = Logger level %c = Source Class
|
||||
# %n = Logger name %C = Source Class Simple
|
||||
# %m = Logger message %S = Stacktrace
|
||||
# %t = Thread ID %r = Return/newline
|
||||
#net.forwardfire.vasc.demo.tech.ui.PatternLogFormatter.log_pattern=%d %l [%C.%s] %m%r
|
||||
#net.forwardfire.vasc.demo.tech.ui.PatternLogFormatter.log_error_pattern=%d %l [%C.%s] %m%r%S
|
||||
#net.forwardfire.vasc.demo.tech.ui.PatternLogFormatter.date_pattern=yyyy-MM-dd HH:mm:ss
|
||||
|
||||
# Default global logging level.
|
||||
.level=INFO
|
||||
|
||||
# Different log levels for packages.
|
||||
net.forwardfire.vasc.demo.level=INFO
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
gui=true
|
||||
editor=true
|
||||
contextPath=/demo
|
||||
host=localhost
|
||||
port=8899
|
|
@ -32,7 +32,7 @@ set MAIN_CLASS=net.forwardfire.vasc.demo.tech.ui.TechUI
|
|||
set CP=lib\*
|
||||
|
||||
:: Launch application
|
||||
java %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS% -gui
|
||||
java %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS%
|
||||
|
||||
endlocal
|
||||
:: EOF
|
||||
|
|
|
@ -32,7 +32,7 @@ MAIN_CLASS="net.forwardfire.vasc.demo.tech.ui.TechUI";
|
|||
CP=`echo lib/*.jar | sed 's/ /:/g'`;
|
||||
|
||||
# Launch application
|
||||
$JAVA $JAVA_OPTS -cp $CP $MAIN_CLASS -gui;
|
||||
$JAVA $JAVA_OPTS -cp $CP $MAIN_CLASS;
|
||||
|
||||
# EOF
|
||||
|
||||
|
|
|
@ -75,8 +75,7 @@ public class DemoVascManager {
|
|||
// Config some defaults
|
||||
vecc.setDefaultPageSize(200);
|
||||
vecc.setDefaultPageSizeMax(1500);
|
||||
|
||||
initEditor();
|
||||
|
||||
} catch (VascException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -93,7 +92,7 @@ public class DemoVascManager {
|
|||
logger.info("Stop manager, cleared all.");
|
||||
}
|
||||
|
||||
private void initEditor() {
|
||||
public void startEditor() {
|
||||
try {
|
||||
VascParser parser = new VascParser(vascController);
|
||||
parser.addGlobalELBean("vascController", vascController);
|
||||
|
|
|
@ -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…
Reference in a new issue