2
0
Fork 0

wip commit

This commit is contained in:
Willem Cazander 2012-05-14 22:01:04 +02:00
parent 7c044adb1f
commit 3f31bb8a3a
9 changed files with 118 additions and 51 deletions

View file

@ -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

View file

@ -0,0 +1,6 @@
gui=true
editor=true
contextPath=/demo
host=localhost
port=8899

View file

@ -32,7 +32,7 @@ set MAIN_CLASS=net.forwardfire.vasc.demo.tech.ui.TechUI
set CP=lib\* set CP=lib\*
:: Launch application :: Launch application
java %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS% -gui java %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS%
endlocal endlocal
:: EOF :: EOF

View file

@ -32,7 +32,7 @@ MAIN_CLASS="net.forwardfire.vasc.demo.tech.ui.TechUI";
CP=`echo lib/*.jar | sed 's/ /:/g'`; CP=`echo lib/*.jar | sed 's/ /:/g'`;
# Launch application # Launch application
$JAVA $JAVA_OPTS -cp $CP $MAIN_CLASS -gui; $JAVA $JAVA_OPTS -cp $CP $MAIN_CLASS;
# EOF # EOF

View file

@ -75,8 +75,7 @@ public class DemoVascManager {
// Config some defaults // Config some defaults
vecc.setDefaultPageSize(200); vecc.setDefaultPageSize(200);
vecc.setDefaultPageSizeMax(1500); vecc.setDefaultPageSizeMax(1500);
initEditor();
} catch (VascException e) { } catch (VascException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -93,7 +92,7 @@ public class DemoVascManager {
logger.info("Stop manager, cleared all."); logger.info("Stop manager, cleared all.");
} }
private void initEditor() { public void startEditor() {
try { try {
VascParser parser = new VascParser(vascController); VascParser parser = new VascParser(vascController);
parser.addGlobalELBean("vascController", vascController); parser.addGlobalELBean("vascController", vascController);

View file

@ -29,10 +29,9 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.ArrayList;
import java.util.EventObject; import java.util.EventObject;
import java.util.Iterator; import java.util.Properties;
import java.util.List; import java.util.logging.FileHandler;
import java.util.logging.Handler; import java.util.logging.Handler;
import java.util.logging.LogManager; import java.util.logging.LogManager;
import java.util.logging.Logger; 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. 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()) { if (logConfig.exists()) {
InputStream in = null; InputStream in = null;
try { try {
@ -124,44 +123,48 @@ public class TechUI extends SingleFrameApplication {
// First parse user program arguments. // First parse user program arguments.
String serverHost = null; String serverHost = null;
String serverPort = null; String serverPort = null;
List<String> arguList = new ArrayList<String>(argu.length); String contextPath = null;
for (String a:argu) { boolean editor = false;
arguList.add(a); showGui = false;
}
Iterator<String> arguIterator = arguList.iterator(); File propFile = new File("config/server.properties");
while (arguIterator.hasNext()) { if (propFile.exists()) {
String arg = arguIterator.next();
if ("-v".equals(arg)) { InputStream in = null;
System.out.println(); try {
System.out.println("Optional:"); in = new FileInputStream(propFile);
System.out.println(" -host <ip> Sets the http hostname."); Properties p = new Properties();
System.out.println(" -port <port> Sets the http port."); p.load(in);
System.out.println(" -gui Sets gui mode."); serverHost = p.getProperty("host");
System.out.println(" -h Print help. (this)"); serverPort = p.getProperty("port");
System.out.println(); contextPath = p.getProperty("contextPath");
System.exit(1); if ("true".equalsIgnoreCase(p.getProperty("gui"))) {
} showGui = true;
if ("-gui".equals(arg)) { } else {
showGui = true; showGui = false;
} }
if ("-port".equals(arg)) { if ("true".equalsIgnoreCase(p.getProperty("editor"))) {
if (arguIterator.hasNext()==false) { editor = true;
System.out.println("No argument for -port given."); } else {
return; 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(); setupLogging();
logger.info("Starting Vasc-Demo-Tech-UI."); logger.info("Starting Vasc-Demo-Tech-UI.");
@ -176,9 +179,11 @@ public class TechUI extends SingleFrameApplication {
} }
} }
vascManager = new DemoVascManager(); vascManager = new DemoVascManager();
vascManager.start(); vascManager.start();
if (editor) {
vascManager.startEditor();
}
deployManager = new DeployManager(); deployManager = new DeployManager();
deployManager.setDeployDir(deployDir); deployManager.setDeployDir(deployDir);
@ -193,6 +198,9 @@ public class TechUI extends SingleFrameApplication {
if (serverPort!=null) { if (serverPort!=null) {
tomcatManager.setPort(new Integer(serverPort)); tomcatManager.setPort(new Integer(serverPort));
} }
if (contextPath!=null) {
tomcatManager.setContextPath(contextPath);
}
Thread t = new Thread(new Runnable() { Thread t = new Thread(new Runnable() {
public void run() { public void run() {

View file

@ -10,7 +10,9 @@ import java.util.logging.Logger;
import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascController;
import org.apache.catalina.startup.Bootstrap;
import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.valves.AccessLogValve;
public class TomcatManager { public class TomcatManager {
@ -20,11 +22,13 @@ public class TomcatManager {
private String hostname = null; private String hostname = null;
private Integer port = null; private Integer port = null;
private File workDir = null; private File workDir = null;
private String contextPath = null;
public TomcatManager() { public TomcatManager() {
logger = Logger.getLogger(TomcatManager.class.getName()); logger = Logger.getLogger(TomcatManager.class.getName());
hostname = "localhost"; hostname = "localhost";
port = 8899; port = 8899;
contextPath = "/demo";
} }
public void start() throws Exception { public void start() throws Exception {
@ -36,11 +40,21 @@ public class TomcatManager {
tomcat.setPort(getPort()); tomcat.setPort(getPort());
tomcat.setHostname(getHostname()); 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 &quot;%r&quot; %s %b");
tomcat.getHost().getPipeline().addValve(accessLog);
}
if (TechUI.getInstance().isMavenRun()) {
String webappPathLocation = "../vasc-demo-tech-web/src/main/webapp/"; String webappPathLocation = "../vasc-demo-tech-web/src/main/webapp/";
String deployPath = new File(webappPathLocation).getAbsolutePath(); String deployPath = new File(webappPathLocation).getAbsolutePath();
logger.info("Deploy demo app from workspace path: "+deployPath); logger.info("Deploy demo app from workspace path: "+deployPath);
tomcat.addWebapp("/demo",deployPath); tomcat.addWebapp(getContextPath(),deployPath);
} else { } else {
File techWarFile = null; File techWarFile = null;
@ -76,7 +90,7 @@ public class TomcatManager {
} }
String deployPath = destDir.getAbsolutePath(); String deployPath = destDir.getAbsolutePath();
logger.info("Deploy war path: "+deployPath); logger.info("Deploy war path: "+deployPath);
tomcat.addWebapp("/demo",deployPath); tomcat.addWebapp(getContextPath(),deployPath);
} }
tomcat.start(); tomcat.start();
} }
@ -143,4 +157,18 @@ public class TomcatManager {
public void setWorkDir(File workDir) { public void setWorkDir(File workDir) {
this.workDir = 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;
}
} }

View file

@ -283,12 +283,12 @@ public class JMainPanel extends JPanel {
} }
if (keys.isEmpty()==false) { if (keys.isEmpty()==false) {
Properties p = new Properties(); Properties p = new Properties();
File dataDir = new File("auto/data"); File dataDir = new File("data");
if (dataDir.exists()==false) { if (dataDir.exists()==false) {
dataDir.mkdirs(); dataDir.mkdirs();
} }
File resourceFile = new File("auto/data/vasc-bundle.properties"); File resourceFile = new File("data/vasc-bundle.properties");
if (resourceFile.exists()) { if (resourceFile.exists()) {
readPropertiesFile(p,resourceFile); readPropertiesFile(p,resourceFile);
} }

View file

@ -2,7 +2,7 @@
# bundle list to merge and load # bundle list to merge and load
bundle1.uri=net.forwardfire.vasc.demo.tech.ui.resources.TechUI 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.type=FILE
bundle2.optional=true bundle2.optional=true