Refactored demo section to single app layout.
This commit is contained in:
parent
b3635cf64d
commit
4bd244f4e5
337 changed files with 1630 additions and 1883 deletions
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.core;
|
||||
|
||||
/**
|
||||
* VascTechDemoBuildInfo provides interfaces for build system so we have version and build date.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 1, 2012
|
||||
*/
|
||||
public interface VascTechDemoBuildInfo {
|
||||
|
||||
/**
|
||||
* @return Returns the build version.
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* @return Returns the build date.
|
||||
*/
|
||||
String getBuildDate();
|
||||
}
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.core;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascControllerProvider;
|
||||
import net.forwardfire.vasc.core.VascEntryConfigControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.export.generic.VascEntryExportWriterCsv;
|
||||
import net.forwardfire.vasc.export.generic.VascEntryExportWriterXml;
|
||||
import net.forwardfire.vasc.export.jr4o.VascEntryExportWriterJR4O;
|
||||
import net.forwardfire.vasc.export.json.VascEntryExportWriterJson;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.impl.entry.DefaultVascEntryExport;
|
||||
|
||||
/**
|
||||
* DemoVascControllerProvider gets the static local jvm vasc controller for this tech demo.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2012
|
||||
*/
|
||||
public class VascTechDemoControllerConfig implements VascControllerProvider {
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascControllerProvider#getVascController()
|
||||
*/
|
||||
public VascController getVascController() {
|
||||
|
||||
try {
|
||||
VascController vascController = DefaultVascFactory.getDefaultVascController();
|
||||
|
||||
VascEntryConfigControllerLocal vecc = (VascEntryConfigControllerLocal)vascController.getVascEntryConfigController();
|
||||
|
||||
// Config all report export engines for demo.
|
||||
// Add all exporters in reverse ORDER
|
||||
|
||||
DefaultVascEntryExport export;
|
||||
|
||||
export = new DefaultVascEntryExport();
|
||||
export.setExportWriterClass(VascEntryExportWriterXml.class.getName());
|
||||
export.setId("xml");
|
||||
vecc.addVascEntryExporter(export);
|
||||
|
||||
export = new DefaultVascEntryExport();
|
||||
export.setExportWriterClass(VascEntryExportWriterXml.class.getName());
|
||||
export.addWriterParameter("xmltree", "true");
|
||||
export.setId("xmltree");
|
||||
vecc.addVascEntryExporter(export);
|
||||
|
||||
export = new DefaultVascEntryExport();
|
||||
export.setExportWriterClass(VascEntryExportWriterCsv.class.getName());
|
||||
export.setId("csv");
|
||||
vecc.addVascEntryExporter(export);
|
||||
|
||||
export = new DefaultVascEntryExport();
|
||||
export.setExportWriterClass(VascEntryExportWriterJR4O.class.getName());
|
||||
export.addWriterParameter("reportType", "PDF");
|
||||
export.addWriterParameter("reportName", "generic-landscape");
|
||||
export.addWriterParameter("reportResource", "net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml");
|
||||
export.setId("jrPdfLandscape");
|
||||
vecc.addVascEntryExporter(export);
|
||||
|
||||
export = new DefaultVascEntryExport();
|
||||
export.setExportWriterClass(VascEntryExportWriterJR4O.class.getName());
|
||||
export.addWriterParameter("reportType", "PDF");
|
||||
export.addWriterParameter("reportName", "generic-portrait");
|
||||
export.addWriterParameter("reportResource", "net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml");
|
||||
export.setId("jrPdfPortrait");
|
||||
vecc.addVascEntryExporter(export);
|
||||
|
||||
export = new DefaultVascEntryExport();
|
||||
export.setExportWriterClass(VascEntryExportWriterJR4O.class.getName());
|
||||
export.addWriterParameter("reportType", "RTF");
|
||||
export.addWriterParameter("reportName", "generic-landscape");
|
||||
export.addWriterParameter("reportResource", "net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml");
|
||||
export.setId("jrRtf");
|
||||
vecc.addVascEntryExporter(export);
|
||||
|
||||
export = new DefaultVascEntryExport();
|
||||
export.setExportWriterClass(VascEntryExportWriterJR4O.class.getName());
|
||||
export.addWriterParameter("reportType", "XLS");
|
||||
export.addWriterParameter("reportName", "generic-landscape");
|
||||
export.addWriterParameter("reportResource", "net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml");
|
||||
export.setId("jrXls");
|
||||
vecc.addVascEntryExporter(export);
|
||||
|
||||
export = new DefaultVascEntryExport();
|
||||
export.setExportWriterClass(VascEntryExportWriterJR4O.class.getName());
|
||||
export.addWriterParameter("reportType", "XML");
|
||||
export.addWriterParameter("reportName", "generic-landscape");
|
||||
export.addWriterParameter("reportResource", "net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml");
|
||||
export.setId("jrXml");
|
||||
vecc.addVascEntryExporter(export);
|
||||
|
||||
export = new DefaultVascEntryExport();
|
||||
export.setExportWriterClass(VascEntryExportWriterJR4O.class.getName());
|
||||
export.addWriterParameter("reportType", "CSV");
|
||||
export.addWriterParameter("reportName", "generic-landscape");
|
||||
export.addWriterParameter("reportResource", "net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml");
|
||||
export.setId("jrCsv");
|
||||
vecc.addVascEntryExporter(export);
|
||||
|
||||
export = new DefaultVascEntryExport();
|
||||
export.setExportWriterClass(VascEntryExportWriterJson.class.getName());
|
||||
export.setId("json");
|
||||
vecc.addVascEntryExporter(export);
|
||||
|
||||
// Config root bundle to load all resources.
|
||||
vecc.setResourceBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle");
|
||||
|
||||
// Increase some config defaults
|
||||
vecc.getMasterVascBackendState().setPageSize(200);
|
||||
vecc.getMasterVascBackendState().setPageSizeMax(2000);
|
||||
|
||||
return vascController;
|
||||
} catch (VascException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,273 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.slf4j.bridge.SLF4JBridgeHandler;
|
||||
|
||||
import net.forwardfire.vasc.demo.server.core.service.DatabaseService;
|
||||
import net.forwardfire.vasc.demo.server.core.service.ServerConfigService;
|
||||
import net.forwardfire.vasc.demo.server.core.service.ServerGuiService;
|
||||
import net.forwardfire.vasc.demo.server.core.service.VascControllerService;
|
||||
import net.forwardfire.vasc.demo.server.core.service.ServerConfigService.ServerConfigKey;
|
||||
import net.forwardfire.vasc.demo.server.tomcat.TomcatService;
|
||||
|
||||
/**
|
||||
* VascTechDemo init and starts the VascTechDemo
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 3, 2012
|
||||
*/
|
||||
public class VascTechDemoStartup {
|
||||
|
||||
private Logger logger = null;
|
||||
private ServerConfigService serverConfigService = null;
|
||||
private DatabaseService databaseService = null;
|
||||
private TomcatService tomcatService = null;
|
||||
private VascControllerService vascControllerService = null;
|
||||
private ServerGuiService swingGuiService = null;
|
||||
private VascTechDemoBuildInfo buildInfo = null;
|
||||
static private VascTechDemoStartup instance = null;
|
||||
|
||||
/**
|
||||
* Starts this VascTechDemo instance
|
||||
* @param args
|
||||
*/
|
||||
static public void main(String[] args) {
|
||||
instance = new VascTechDemoStartup();
|
||||
instance.initialize(args);
|
||||
instance.startup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy copfig/etc directory stucture to root of project in maven/eclipse run.
|
||||
* @throws IOException
|
||||
*/
|
||||
private void setupAutoDir() throws IOException {
|
||||
|
||||
//File deployDir = new File("deploy");
|
||||
File workDir = new File("workdir");
|
||||
File workDirTmp = new File("workdir/tmp");
|
||||
//if (deployDir.exists()==false) {
|
||||
// deployDir.mkdir();
|
||||
//}
|
||||
if (workDir.exists()==false) {
|
||||
workDir.mkdir();
|
||||
}
|
||||
if (workDirTmp.exists()==false) {
|
||||
workDirTmp.mkdir();
|
||||
}
|
||||
System.setProperty("java.io.tmpdir", workDirTmp.getAbsolutePath());
|
||||
File tmpFile = File.createTempFile("test", "new-tmp");
|
||||
if (tmpFile.getAbsolutePath().contains(workDirTmp.getName())==false) {
|
||||
// Cant change tmp location.
|
||||
}
|
||||
tmpFile.delete();
|
||||
|
||||
File confDir = new File("conf");
|
||||
if (confDir.exists()) {
|
||||
return;
|
||||
}
|
||||
if (isMavenRun()==false) {
|
||||
throw new RuntimeException("Can't start without conf dir.");
|
||||
}
|
||||
FileUtils.copyDirectory(new File("../vasc-demo-server-build/src/main/directory/"), new File("."));
|
||||
}
|
||||
|
||||
/**
|
||||
* Config logging and setup logger object.
|
||||
*/
|
||||
private void setupLogging() {
|
||||
|
||||
// Set Config file property
|
||||
if (System.getProperty("logback.configurationFile")==null) {
|
||||
File logConfig = null;
|
||||
if (isMavenRun()) {
|
||||
logConfig = new File("conf/logback-server-console.xml");
|
||||
} else {
|
||||
logConfig = new File("conf/logback-server.xml");
|
||||
}
|
||||
try {
|
||||
System.setProperty("logback.configurationFile", logConfig.toURI().toURL().toExternalForm());
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Logger rootLogger = Logger.getAnonymousLogger();
|
||||
while (rootLogger.getParent()!=null) {
|
||||
rootLogger = rootLogger.getParent();
|
||||
}
|
||||
for (Handler h:rootLogger.getHandlers()) {
|
||||
rootLogger.removeHandler(h);
|
||||
}
|
||||
rootLogger.addHandler(new SLF4JBridgeHandler()); // This does also the init for us.
|
||||
|
||||
// Logback offical init method.
|
||||
//LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
//StatusPrinter.print(lc);
|
||||
|
||||
// Create an JUL logger for our application.
|
||||
logger = Logger.getLogger(VascTechDemoStartup.class.getName());
|
||||
logger.info("Logging is ready for application log;");
|
||||
}
|
||||
|
||||
|
||||
private void setupBuildInfo() {
|
||||
if (buildInfo!=null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Class<?> infoClass = Class.forName(VascTechDemoBuildInfo.class.getPackage().getName()+"."+VascTechDemoBuildInfo.class.getSimpleName()+"Impl");
|
||||
buildInfo = (VascTechDemoBuildInfo)infoClass.newInstance();
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
logger.warning("Could not load build info impl fallback to local one.");
|
||||
}
|
||||
buildInfo = new VascTechDemoBuildInfo() {
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "0.0.0-dev";
|
||||
}
|
||||
@Override
|
||||
public String getBuildDate() {
|
||||
return new Date().toString();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Init all demo service beans.
|
||||
* @param argu
|
||||
*/
|
||||
protected void initialize(String[] argu) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
try {
|
||||
Thread.currentThread().setName("startup");
|
||||
System.setProperty("java.security.auth.login.config", "file:conf/login.config");
|
||||
setupAutoDir();
|
||||
setupLogging();
|
||||
setupBuildInfo();
|
||||
logger.info("VascTechDemo initializing ...");
|
||||
databaseService = new DatabaseService();
|
||||
tomcatService = new TomcatService();
|
||||
serverConfigService = new ServerConfigService();
|
||||
vascControllerService = new VascControllerService();
|
||||
swingGuiService = new ServerGuiService();
|
||||
long stopTime = System.currentTimeMillis();
|
||||
logger.info("VascTechDemo initialized in "+(stopTime-startTime)+" ms.");
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Startup and deploy all service beans.
|
||||
*/
|
||||
protected void startup() {
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
//if (serverConfigService.isServerConfigValueTrue(ServerConfigKey.START_GUI)) {
|
||||
swingGuiService.start();
|
||||
//}
|
||||
databaseService.start();
|
||||
tomcatService.start();
|
||||
serverConfigService.start();
|
||||
vascControllerService.start();
|
||||
if (serverConfigService.isServerConfigValueTrue(ServerConfigKey.START_EDITOR)) {
|
||||
vascControllerService.startEditor();
|
||||
}
|
||||
tomcatService.deploy(serverConfigService.getServerConfigValue(ServerConfigKey.DEPLOY_PATH));
|
||||
if (serverConfigService.isServerConfigValueTrue(ServerConfigKey.DEPLOY_DEBUG)) {
|
||||
tomcatService.deployDebug();
|
||||
}
|
||||
//if (serverConfigService.isServerConfigValueTrue(ServerConfigKey.START_GUI)) {
|
||||
swingGuiService.startDone();
|
||||
//}
|
||||
long stopTime = System.currentTimeMillis();
|
||||
logger.info("VascTechDemo startup in "+(stopTime-startTime)+" ms.");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
if (instance==null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
vascControllerService.stop();
|
||||
serverConfigService.stop();
|
||||
tomcatService.stop();
|
||||
databaseService.stop();
|
||||
swingGuiService.stop();
|
||||
long stopTime = System.currentTimeMillis();
|
||||
logger.info("VascTechDemo shutdown in "+(stopTime-startTime)+" ms.");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
} finally {
|
||||
instance = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
t.setName("shutdown");
|
||||
t.start();
|
||||
}
|
||||
|
||||
static public VascTechDemoStartup getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean isMavenRun() {
|
||||
return System.getProperty("java.class.path").contains("classes");
|
||||
}
|
||||
|
||||
public VascControllerService getVascControllerService() {
|
||||
return vascControllerService;
|
||||
}
|
||||
|
||||
public TomcatService getTomcatService() {
|
||||
return tomcatService;
|
||||
}
|
||||
|
||||
public ServerGuiService getSwingGuiService() {
|
||||
return swingGuiService;
|
||||
}
|
||||
|
||||
public VascTechDemoBuildInfo getBuildInfo() {
|
||||
return buildInfo;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.core.service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.h2.tools.Server;
|
||||
|
||||
/**
|
||||
* DatabaseService starts and stops the embedded H2 demo database.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 13, 2012
|
||||
*/
|
||||
public class DatabaseService {
|
||||
|
||||
private Logger logger = null;
|
||||
private Server server = null;
|
||||
|
||||
public DatabaseService() {
|
||||
logger = Logger.getLogger(DatabaseService.class.getName());
|
||||
}
|
||||
|
||||
public void start() {
|
||||
List<String> argu = new ArrayList<String>(10);
|
||||
argu.add("-tcp");
|
||||
argu.add("-tcpPort"); argu.add("9092");
|
||||
argu.add("-tcpPassword"); argu.add("stopSecret");
|
||||
argu.add("-baseDir"); argu.add("data/db");
|
||||
String[] args = new String[argu.size()];
|
||||
args = argu.toArray(args);
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (String a:args) {
|
||||
buf.append(a);
|
||||
buf.append(" ");
|
||||
}
|
||||
logger.info("Start H2 Server with: "+buf);
|
||||
try {
|
||||
server = Server.createTcpServer(args).start();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (server.isRunning(true)) {
|
||||
initDB();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (server==null) {
|
||||
return;
|
||||
}
|
||||
logger.info("Stopping H2 Server");
|
||||
server.stop();
|
||||
}
|
||||
|
||||
private void initDB() {
|
||||
Connection conn = null;
|
||||
try {
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
if (cl==null) {
|
||||
cl = this.getClass().getClassLoader();
|
||||
}
|
||||
cl.loadClass("org.h2.Driver");
|
||||
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9092/vasc-demo");
|
||||
|
||||
ResultSet rs = conn.prepareStatement("show tables").executeQuery();
|
||||
if (rs.next()) {
|
||||
logger.info("Tables found so skipping auto init.");
|
||||
rs.close();
|
||||
return;
|
||||
}
|
||||
rs.close();
|
||||
|
||||
String allSql = readResourceAsString("net/forwardfire/vasc/demo/server/core/service/resources/init-db.sql");
|
||||
String[] allSqlData = allSql.split(";");
|
||||
for(String sql:allSqlData) {
|
||||
sql = sql.trim();
|
||||
if (sql.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
//logger.info("exe init sql:"+sql);
|
||||
conn.prepareStatement(sql+";").executeUpdate();
|
||||
}
|
||||
logger.info("Done auto init total statements done: "+allSqlData.length);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (conn!=null) {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String readResourceAsString(String resource) throws IOException {
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
if (cl==null) {
|
||||
cl = this.getClass().getClassLoader();
|
||||
}
|
||||
StringBuffer fileData = new StringBuffer(1000);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(cl.getResourceAsStream(resource)));
|
||||
try {
|
||||
char[] buf = new char[1024];
|
||||
int numRead=0;
|
||||
while((numRead=reader.read(buf)) != -1){
|
||||
String readData = String.valueOf(buf, 0, numRead);
|
||||
fileData.append(readData);
|
||||
buf = new char[1024];
|
||||
}
|
||||
} finally {
|
||||
if (reader!=null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
return fileData.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.core.service;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup;
|
||||
|
||||
/**
|
||||
* ServerConfigService reads demo server config parameters from jndi.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 19, 2012
|
||||
*/
|
||||
public class ServerConfigService {
|
||||
|
||||
public ServerConfigService() {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
}
|
||||
|
||||
private Object readConfigKey(ServerConfigKey key) {
|
||||
try {
|
||||
Context context = VascTechDemoStartup.getInstance().getTomcatService().getServer().getGlobalNamingContext();
|
||||
return context.lookup("config/"+key.name());
|
||||
} catch (NamingException e) {
|
||||
throw new IllegalStateException("Naming error:"+e.getMessage()+" from key: "+key.name(),e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getServerConfigValue(ServerConfigKey key) {
|
||||
if (key==null) {
|
||||
throw new NullPointerException("Can't get value for null key.");
|
||||
}
|
||||
Object v = readConfigKey(key);
|
||||
if (v==null) {
|
||||
return key.getDefaultValue();
|
||||
}
|
||||
return v.toString();
|
||||
}
|
||||
|
||||
public boolean isServerConfigValueTrue(ServerConfigKey key) {
|
||||
String value = getServerConfigValue(key);
|
||||
return "true".equalsIgnoreCase(value);
|
||||
}
|
||||
|
||||
public enum ServerConfigKey {
|
||||
|
||||
START_GUI("true"),
|
||||
START_EDITOR("true"),
|
||||
DEPLOY_DEBUG("true"),
|
||||
DEPLOY_PATH("/demo");
|
||||
|
||||
private String defaultValue = null;
|
||||
private ServerConfigKey(String defaultValue) {
|
||||
this.defaultValue=defaultValue;
|
||||
}
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.core.service;
|
||||
|
||||
import net.forwardfire.vasc.demo.server.ui.ServerGuiApplication;
|
||||
import org.jdesktop.application.Application;
|
||||
|
||||
/**
|
||||
* SwingGuiService Shows the demo swing gui and vasc swing frontend.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 19, 2012
|
||||
*/
|
||||
public class ServerGuiService {
|
||||
|
||||
public void start() {
|
||||
Application.launch(ServerGuiApplication.class, new String[] {});
|
||||
}
|
||||
public void startDone() {
|
||||
ServerGuiApplication instance = ServerGuiApplication.getInstance();
|
||||
instance.startupDone();
|
||||
}
|
||||
public void stop() {
|
||||
ServerGuiApplication instance = ServerGuiApplication.getInstance();
|
||||
instance.stop();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,234 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.core.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.x4o.xml.io.X4OReader;
|
||||
|
||||
import com.sun.faces.application.ApplicationAssociate;
|
||||
import com.sun.faces.application.ApplicationResourceBundle;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascEntryGroup;
|
||||
import net.forwardfire.vasc.core.VascEventChannelControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascEventControllerListener;
|
||||
import net.forwardfire.vasc.core.VascEventControllerType;
|
||||
import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.impl.x4o.VascDriver;
|
||||
import net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle;
|
||||
import net.forwardfire.vasc.test.i18n.VascBundleCheckEntryKeys;
|
||||
|
||||
/**
|
||||
* VascControllerService manages the demo vasc controller which gets init by jndi factory.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 18, 2012
|
||||
*/
|
||||
public class VascControllerService {
|
||||
|
||||
private Logger logger = null;
|
||||
private VascController vascController = null;
|
||||
|
||||
public VascControllerService() {
|
||||
logger = Logger.getLogger(VascControllerService.class.getName());
|
||||
}
|
||||
|
||||
public void start() {
|
||||
logger.finer("Starting vascmanager");
|
||||
if (vascController!=null) {
|
||||
throw new RuntimeException("VascManager is already started.");
|
||||
}
|
||||
try {
|
||||
// Fetch from jndi
|
||||
vascController = (VascController)VascTechDemoStartup.getInstance().getTomcatService().getServer().getGlobalNamingContext().lookup("vasc/server-tech");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
VascEventChannelControllerLocal ev = (VascEventChannelControllerLocal)vascController.getVascEventChannelController();
|
||||
ev.addVascEventControllerListener(new I18NVascEventControllerListener());
|
||||
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (vascController==null) {
|
||||
return;
|
||||
}
|
||||
VascBackendControllerLocal backends = (VascBackendControllerLocal)vascController.getVascBackendController();
|
||||
backends.clearAndStopBackends();
|
||||
|
||||
vascController = null;
|
||||
logger.info("Stop manager, cleared all.");
|
||||
}
|
||||
|
||||
public void startEditor() {
|
||||
try {
|
||||
vascController.getVascEventChannelController().fireEvent(VascEventControllerType.LOAD_ENTRIES_BEFORE, vascController);
|
||||
|
||||
VascDriver driver = VascDriver.getInstance();
|
||||
X4OReader<VascController> reader = driver.createReader();
|
||||
driver.addVascController(reader, vascController);
|
||||
reader.readResource("net/forwardfire/vasc/lib/editor/vasc-edit.xml");
|
||||
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascController.getVascEntryController(), vascController);
|
||||
vascController.getVascEventChannelController().fireEvent(VascEventControllerType.LOAD_ENTRIES_AFTER, vascController);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
//fireChangeEvent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public VascController getVascController() {
|
||||
return vascController;
|
||||
}
|
||||
|
||||
class I18NVascEventControllerListener implements VascEventControllerListener {
|
||||
|
||||
@Override
|
||||
public VascEventControllerType[] getVascEventControllerTypes() {
|
||||
return new VascEventControllerType[] {VascEventControllerType.LOAD_ENTRIES_AFTER};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void controllerEvent(VascEventControllerType type,Object eventObject) {
|
||||
|
||||
logger.info("Regenerating resource bundle keys...");
|
||||
|
||||
Map<String,String> keys = new HashMap<String,String>(300);
|
||||
VascBundleCheckEntryKeys checker = new VascBundleCheckEntryKeys(ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle"));
|
||||
for (String veId:vascController.getVascEntryController().getVascEntryIds()) {
|
||||
VascEntry ve = vascController.getVascEntryController().getVascEntryById(veId);
|
||||
keys.putAll(checker.generateMissingKeys(ve));
|
||||
}
|
||||
for (String groupId:vascController.getVascEntryController().getVascEntryGroupIds()) {
|
||||
VascEntryGroup veg = vascController.getVascEntryController().getVascEntryGroupById(groupId);
|
||||
keys.putAll(checker.generateMissingKeys(veg));
|
||||
}
|
||||
if (keys.isEmpty()==false) {
|
||||
Properties p = new Properties();
|
||||
File dataDir = new File("data");
|
||||
|
||||
if (dataDir.exists()==false) {
|
||||
dataDir.mkdirs();
|
||||
}
|
||||
File resourceFile = new File("data/vasc-bundle.properties");
|
||||
if (resourceFile.exists()) {
|
||||
readPropertiesFile(p,resourceFile);
|
||||
}
|
||||
for (String key:keys.keySet()) {
|
||||
if (key==null) {
|
||||
continue;
|
||||
}
|
||||
if (keys.get(key)==null) {
|
||||
continue;
|
||||
}
|
||||
p.put(key, keys.get(key));
|
||||
}
|
||||
writePropertiesFile(p,resourceFile);
|
||||
|
||||
ResourceBundle.clearCache();
|
||||
|
||||
//ApplicationResourceBundle appBundle = ApplicationAssociate.getCurrentInstance().getResourceBundles().get(RootApplicationBundle.class.getName());
|
||||
//Map<Locale, ResourceBundle> resources = getFieldValue(appBundle, "resources");
|
||||
//resources.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T getFieldValue(Object object, String fieldName) {
|
||||
try {
|
||||
Field field = object.getClass().getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
return (T) field.get(object);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void writePropertiesFile(Properties p,File file) {
|
||||
try {
|
||||
writePropertiesStream(p,new FileOutputStream(file));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void readPropertiesFile(Properties p,File file) {
|
||||
try {
|
||||
readPropertiesStream(p,new FileInputStream(file));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writePropertiesStream(Properties p,OutputStream out) {
|
||||
try {
|
||||
p.store(out, "Saved by vasc auto i18n.");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not load properties error: "+e.getMessage(),e);
|
||||
} finally {
|
||||
if (out!=null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void readPropertiesStream(Properties p,InputStream in) {
|
||||
try {
|
||||
p.load(in);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not load properties error: "+e.getMessage(),e);
|
||||
} finally {
|
||||
if (in!=null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.tomcat;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.catalina.connector.Request;
|
||||
import org.apache.catalina.connector.Response;
|
||||
import org.apache.catalina.valves.ValveBase;
|
||||
|
||||
/**
|
||||
* AuthSessionTimeoutValve sets sessions timeout for Sessions which has user pricaiap.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 27, 2012
|
||||
*/
|
||||
public class AuthSessionTimeoutValve extends ValveBase {
|
||||
|
||||
private boolean logInfo = false;
|
||||
private int minTimeout = 60;
|
||||
private int maxTimeout = 60*60;
|
||||
private int authTimeout = 60*20;
|
||||
|
||||
/**
|
||||
* The descriptive information about this implementation.
|
||||
*/
|
||||
protected static final String info = AuthSessionTimeoutValve.class.getName()+"/1.0";
|
||||
|
||||
@Override
|
||||
public void invoke(Request request, Response response) throws IOException,ServletException {
|
||||
getNext().invoke(request, response);
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session==null) {
|
||||
return;
|
||||
}
|
||||
int curSessionTimeout = session.getMaxInactiveInterval();
|
||||
int newSessionTimeout = curSessionTimeout;
|
||||
if (curSessionTimeout < minTimeout) {
|
||||
newSessionTimeout = minTimeout;
|
||||
}
|
||||
if (curSessionTimeout > maxTimeout) {
|
||||
newSessionTimeout = maxTimeout;
|
||||
}
|
||||
if (request.getUserPrincipal()!=null) {
|
||||
newSessionTimeout = authTimeout;
|
||||
}
|
||||
if (curSessionTimeout != newSessionTimeout) {
|
||||
session.setMaxInactiveInterval(newSessionTimeout);
|
||||
logChange(session.getId(),curSessionTimeout,newSessionTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
private void logChange(String sessionId,int curSessionTimeout,int newSessionTimeout) {
|
||||
String log = "Changed session: "+sessionId+" from timeout: "+curSessionTimeout+" to: "+newSessionTimeout;
|
||||
if (logInfo) {
|
||||
getContainer().getLogger().info(log);
|
||||
} else {
|
||||
getContainer().getLogger().debug(log);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minTimeout
|
||||
*/
|
||||
public int getMinTimeout() {
|
||||
return minTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param minTimeout the minTimeout to set
|
||||
*/
|
||||
public void setMinTimeout(int minTimeout) {
|
||||
this.minTimeout = minTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maxTimeout
|
||||
*/
|
||||
public int getMaxTimeout() {
|
||||
return maxTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxTimeout the maxTimeout to set
|
||||
*/
|
||||
public void setMaxTimeout(int maxTimeout) {
|
||||
this.maxTimeout = maxTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the authTimeout
|
||||
*/
|
||||
public int getAuthTimeout() {
|
||||
return authTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param authTimeout the authTimeout to set
|
||||
*/
|
||||
public void setAuthTimeout(int authTimeout) {
|
||||
this.authTimeout = authTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the logInfo
|
||||
*/
|
||||
public boolean isLogInfo() {
|
||||
return logInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param logInfo the logInfo to set
|
||||
*/
|
||||
public void setLogInfo(boolean logInfo) {
|
||||
this.logInfo = logInfo;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
package net.forwardfire.vasc.demo.server.tomcat;
|
||||
|
||||
import javax.naming.NameClassPair;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
public class JdniTreePrinter {
|
||||
|
||||
boolean printXml = true;
|
||||
|
||||
public JdniTreePrinter(boolean printXml) {
|
||||
this.printXml=printXml;
|
||||
}
|
||||
|
||||
public void printJNDITree(javax.naming.Context context,String ct,StringBuffer buf) {
|
||||
if (printXml) {
|
||||
buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
||||
buf.append("<NamingRoot name=\""+ct+"\">\n");
|
||||
}
|
||||
printTree(context,ct,buf);
|
||||
if (printXml) {
|
||||
buf.append("</NamingRoot>\n");
|
||||
}
|
||||
}
|
||||
|
||||
public void printTree(javax.naming.Context context,String ct,StringBuffer buf) {
|
||||
try {
|
||||
printNE(context,context.list(ct), ct,buf);
|
||||
} catch (NamingException e) {
|
||||
//ignore leaf node exception
|
||||
}
|
||||
}
|
||||
|
||||
private void printNE(javax.naming.Context context,javax.naming.NamingEnumeration<?> ne, String parentctx,StringBuffer buf) throws NamingException {
|
||||
if (ne==null) {
|
||||
return;
|
||||
}
|
||||
while (ne.hasMoreElements()) {
|
||||
NameClassPair next = (NameClassPair) ne.nextElement();
|
||||
if (printXml) {
|
||||
printIndent(buf);
|
||||
buf.append("<NamingRoot name=\""+next.getName()+"\" className=\""+next.getClassName()+"\">\n");
|
||||
increaseIndent();
|
||||
printTree(context,(parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName(),buf);
|
||||
decreaseIndent();
|
||||
|
||||
printIndent(buf);
|
||||
buf.append("</NamingRoot>\n");
|
||||
} else {
|
||||
printEntry(next,buf);
|
||||
increaseIndent();
|
||||
printTree(context,(parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName(),buf);
|
||||
decreaseIndent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void printEntry(javax.naming.NameClassPair next,StringBuffer buf) {
|
||||
printIndent(buf);
|
||||
buf.append("-->");
|
||||
buf.append(next);
|
||||
buf.append("\n");
|
||||
}
|
||||
|
||||
|
||||
private int indentLevel = 0;
|
||||
|
||||
private void increaseIndent() {
|
||||
indentLevel += 4;
|
||||
}
|
||||
|
||||
private void decreaseIndent() {
|
||||
indentLevel -= 4;
|
||||
}
|
||||
|
||||
private void printIndent(StringBuffer buf) {
|
||||
for (int i = 0; i < indentLevel; i++) {
|
||||
buf.append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package net.forwardfire.vasc.demo.server.tomcat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.openejb.loader.SystemInstance;
|
||||
import org.apache.openejb.spi.ContainerSystem;
|
||||
|
||||
import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup;
|
||||
|
||||
public class JndiDebugServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = -7624183395089913214L;
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
|
||||
try {
|
||||
Context context = null;
|
||||
if (req.getRequestURI().endsWith("global")) {
|
||||
context = VascTechDemoStartup.getInstance().getTomcatService().getServer().getGlobalNamingContext();
|
||||
} else if (req.getRequestURI().endsWith("openejb")) {
|
||||
ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
|
||||
context = containerSystem.getJNDIContext();
|
||||
} else if (req.getRequestURI().endsWith("java")) {
|
||||
context = new InitialContext();
|
||||
}
|
||||
StringBuffer buf = new StringBuffer();
|
||||
JdniTreePrinter printer = null;
|
||||
if ("text".equals(req.getParameter("type"))) {
|
||||
printer = new JdniTreePrinter(false);
|
||||
} else {
|
||||
printer = new JdniTreePrinter(true);
|
||||
}
|
||||
if (req.getRequestURI().endsWith("global")) {
|
||||
printer.printJNDITree(context,"",buf);
|
||||
} else if (req.getRequestURI().endsWith("openejb")) {
|
||||
printer.printJNDITree(context,"",buf);
|
||||
} else if (req.getRequestURI().endsWith("java")) {
|
||||
printer.printJNDITree(context,"java:",buf);
|
||||
} else {
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
buf.append("Unknown uri postfix.");
|
||||
}
|
||||
PrintWriter out = response.getWriter();
|
||||
out.append(buf.toString());
|
||||
out.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,275 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.tomcat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascEventControllerType;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.impl.x4o.VascDriver;
|
||||
|
||||
import org.apache.catalina.Server;
|
||||
import org.apache.naming.ContextBindings;
|
||||
import org.x4o.xml.io.X4OReader;
|
||||
|
||||
/**
|
||||
* VascDeployService parses "deploy/*.xml" automaticly for hotdeployments.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 10, 2012
|
||||
*/
|
||||
public class JndiVascDeployer {
|
||||
|
||||
private Server server = null;
|
||||
private VascController vascController = null;
|
||||
private Logger logger = null;
|
||||
private File deployDir = null;
|
||||
private int scanPeriod = 3;
|
||||
private AutoDeployManager autoDeployManager = null;
|
||||
private Map<File,String> fileCheckSums = null;
|
||||
|
||||
public JndiVascDeployer() {
|
||||
logger = Logger.getLogger(JndiVascDeployer.class.getName());
|
||||
fileCheckSums = new HashMap<File,String>(20);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (vascController==null) {
|
||||
throw new NullPointerException("Can't deploy with null vascController.");
|
||||
}
|
||||
if (server==null) {
|
||||
throw new NullPointerException("Can't deploy with null server.");
|
||||
}
|
||||
if (deployDir==null) {
|
||||
throw new NullPointerException("Can't deploy with null deployDir.");
|
||||
}
|
||||
if (deployDir.exists()==false) {
|
||||
throw new IllegalStateException("Can't deploy with non-existing deployDir.");
|
||||
}
|
||||
if (deployDir.isDirectory()==false) {
|
||||
throw new IllegalStateException("Can't deploy with non-directory deployDir.");
|
||||
}
|
||||
|
||||
// Start scan thread for auto (re)deployments
|
||||
Thread scanThread = new Thread(new AutoDeployManager());
|
||||
scanThread.setName("hotdeploy-scanner");
|
||||
scanThread.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (autoDeployManager==null) {
|
||||
return;
|
||||
}
|
||||
autoDeployManager.stop();
|
||||
}
|
||||
|
||||
|
||||
public String createMd5Sum(File file) throws IOException, NoSuchAlgorithmException {
|
||||
FileInputStream in = new FileInputStream(file.getAbsolutePath());
|
||||
try {
|
||||
byte[] b = new byte[1024 * 64];
|
||||
int num = 0;
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
while ((num = in.read(b)) != -1) {
|
||||
md.update(b, 0, num);
|
||||
}
|
||||
byte[] hashBytes = md.digest();
|
||||
BigInteger hashResult = new BigInteger(hashBytes);
|
||||
String hashString = hashResult.toString(16);
|
||||
return hashString;
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void hotDeployVasc() throws NoSuchAlgorithmException, IOException {
|
||||
int deployed = 0;
|
||||
long startTime = System.currentTimeMillis();
|
||||
for (File file:deployDir.listFiles()) {
|
||||
if (file.canRead()==false) {
|
||||
continue;
|
||||
}
|
||||
if (file.getName().endsWith("xml")==false) {
|
||||
continue;
|
||||
}
|
||||
String md5File = createMd5Sum(file);
|
||||
String md5Deploy = fileCheckSums.get(file);
|
||||
if (md5Deploy!=null && md5Deploy.equals(md5File)) {
|
||||
continue;
|
||||
}
|
||||
fileCheckSums.put(file, md5File);
|
||||
deployed++;
|
||||
parseVascFile(file);
|
||||
}
|
||||
if (deployed > 0) {
|
||||
long stopTime = System.currentTimeMillis();
|
||||
logger.info("Done deploying total files read: "+deployed+" in "+(stopTime-startTime)+" ms.");
|
||||
}
|
||||
}
|
||||
|
||||
public void parseVascFile(File file) {
|
||||
logger.info("Vasc open file: "+file.getAbsoluteFile());
|
||||
try {
|
||||
VascDriver driver = VascDriver.getInstance();
|
||||
X4OReader<VascController> reader = driver.createReader();
|
||||
driver.addVascController(reader,vascController);
|
||||
|
||||
//File f = File.createTempFile("test-vasc", ".xml");
|
||||
//parser.setDebugOutputStream(new FileOutputStream(f));
|
||||
|
||||
vascController.getVascEventChannelController().fireEvent(VascEventControllerType.LOAD_ENTRIES_BEFORE, vascController);
|
||||
reader.readFile(file);
|
||||
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascController.getVascEntryController(), vascController);
|
||||
vascController.getVascEventChannelController().fireEvent(VascEventControllerType.LOAD_ENTRIES_AFTER, vascController);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
//fireChangeEvent();
|
||||
}
|
||||
}
|
||||
|
||||
protected class AutoDeployManager implements Runnable {
|
||||
private volatile boolean run = true;
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(2000); // let gui+tomcat start
|
||||
logger.info("AutoDeployManager started");
|
||||
|
||||
//Server server = VascTechDemoStartup.getInstance().getTomcatService().getServer();
|
||||
Object token = "secretToken";
|
||||
String bindName = "autoDeployThread";
|
||||
try {
|
||||
ContextBindings.bindContext(bindName, server.getGlobalNamingContext(),token);
|
||||
ContextBindings.bindThread(bindName,token);
|
||||
} catch (NamingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
while(run) {
|
||||
try {
|
||||
hotDeployVasc();
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"Error while depoying: "+e.getMessage(),e);
|
||||
}
|
||||
|
||||
if (scanPeriod == 0) {
|
||||
scanPeriod = 1;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000*scanPeriod);
|
||||
} catch (InterruptedException ie) {
|
||||
logger.info("Interrupted sleep");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ContextBindings.unbindThread(bindName,token);
|
||||
ContextBindings.unbindContext(bindName,token);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE,"Error in run: "+e.getMessage(),e);
|
||||
} finally {
|
||||
logger.info("AutoDeployManager stoped");
|
||||
}
|
||||
}
|
||||
public void stop() {
|
||||
run = false;
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the deployDir
|
||||
*/
|
||||
public File getDeployDir() {
|
||||
return deployDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param deployDir the deployDir to set
|
||||
*/
|
||||
public void setDeployDir(File deployDir) {
|
||||
this.deployDir = deployDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scanPeriod
|
||||
*/
|
||||
public int getScanPeriod() {
|
||||
return scanPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scanPeriod the scanPeriod to set
|
||||
*/
|
||||
public void setScanPeriod(int scanPeriod) {
|
||||
this.scanPeriod = scanPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the server
|
||||
*/
|
||||
public Server getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param server the server to set
|
||||
*/
|
||||
public void setServer(Server server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascController
|
||||
*/
|
||||
public VascController getVascController() {
|
||||
return vascController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascController the vascController to set
|
||||
*/
|
||||
public void setVascController(VascController vascController) {
|
||||
this.vascController = vascController;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
package net.forwardfire.vasc.demo.server.tomcat;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
|
||||
import org.apache.catalina.Lifecycle;
|
||||
import org.apache.catalina.LifecycleEvent;
|
||||
import org.apache.catalina.LifecycleListener;
|
||||
import org.apache.catalina.core.StandardServer;
|
||||
|
||||
public class JndiVascDeployerListener implements LifecycleListener {
|
||||
|
||||
private Logger logger = Logger.getLogger(JndiVascDeployerListener.class.getName());
|
||||
private JndiVascDeployer deployer = null;
|
||||
private String vascControllerName = null;
|
||||
private String scanPath = null;
|
||||
private int scanTime = 3;
|
||||
|
||||
public void lifecycleEvent(LifecycleEvent event) {
|
||||
if ((event.getSource() instanceof StandardServer)==false) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if ( Lifecycle.AFTER_START_EVENT.equals(event.getType())) {
|
||||
startDeployer((StandardServer)event.getSource());
|
||||
}
|
||||
if ( Lifecycle.BEFORE_STOP_EVENT.equals(event.getType())) {
|
||||
stopDeployer();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, this.getClass().getSimpleName()+" can't control deployer: "+e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void startDeployer(StandardServer server) throws NamingException {
|
||||
if (deployer!=null) {
|
||||
throw new IllegalStateException("Can't start deployer when it is already started.");
|
||||
}
|
||||
if (getScanPath()==null) {
|
||||
throw new NullPointerException("Can't start deployer with null scanPath.");
|
||||
}
|
||||
File deployDir = new File(getScanPath());
|
||||
|
||||
|
||||
VascController vascController = (VascController)server.getGlobalNamingContext().lookup(getVascControllerName());
|
||||
if (vascController == null) {
|
||||
throw new NullPointerException("Cannot lookup vascController: "+getVascControllerName());
|
||||
}
|
||||
|
||||
deployer = new JndiVascDeployer();
|
||||
deployer.setDeployDir(deployDir);
|
||||
deployer.setScanPeriod(getScanTime());
|
||||
deployer.setServer(server);
|
||||
deployer.setVascController(vascController);
|
||||
deployer.start();
|
||||
}
|
||||
|
||||
private void stopDeployer() {
|
||||
if (deployer==null) {
|
||||
return;
|
||||
}
|
||||
deployer.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascControllerName
|
||||
*/
|
||||
public String getVascControllerName() {
|
||||
return vascControllerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascControllerName the vascControllerName to set
|
||||
*/
|
||||
public void setVascControllerName(String vascControllerName) {
|
||||
this.vascControllerName = vascControllerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scanPath
|
||||
*/
|
||||
public String getScanPath() {
|
||||
return scanPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scanPath the scanPath to set
|
||||
*/
|
||||
public void setScanPath(String scanPath) {
|
||||
this.scanPath = scanPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scanTime
|
||||
*/
|
||||
public int getScanTime() {
|
||||
return scanTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scanTime the scanTime to set
|
||||
*/
|
||||
public void setScanTime(int scanTime) {
|
||||
this.scanTime = scanTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,343 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.tomcat;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.Principal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.catalina.LifecycleException;
|
||||
import org.apache.catalina.realm.GenericPrincipal;
|
||||
import org.apache.catalina.realm.RealmBase;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DB;
|
||||
import com.mongodb.DBCollection;
|
||||
import com.mongodb.DBCursor;
|
||||
import com.mongodb.DBObject;
|
||||
import com.mongodb.Mongo;
|
||||
import com.mongodb.MongoOptions;
|
||||
import com.mongodb.ServerAddress;
|
||||
|
||||
/**
|
||||
* MongoRealm does auth to mongo collections.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 13, 2012
|
||||
*/
|
||||
public class MongoRealm extends RealmBase {
|
||||
|
||||
private Logger logger = Logger.getLogger(MongoRealm.class.getName());
|
||||
private String hostname = "localhost";
|
||||
private int port = 27017;
|
||||
private String database = null;
|
||||
private String authUser = null;
|
||||
private String authPass = null;
|
||||
private String userCollection = null;
|
||||
private String userField = "username";
|
||||
private String userPassField = "password";
|
||||
private String roleCollection = null;
|
||||
private String roleField = "role";
|
||||
private String roleUserField = userField;
|
||||
private boolean roleUserIdRef = false;
|
||||
private Mongo mongo = null;
|
||||
private DB db = null;
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPassword(String username) {
|
||||
DBObject user = getUser(username);
|
||||
if (user==null) {
|
||||
return null;
|
||||
}
|
||||
String password = (String) user.get(getUserPassField());
|
||||
return password;
|
||||
}
|
||||
|
||||
protected DBObject getUser(String username) {
|
||||
DBCollection coll = db.getCollection(getUserCollection());
|
||||
DBObject query = new BasicDBObject();
|
||||
query.put(getUserField(), username);
|
||||
DBCursor cur = coll.find(query);
|
||||
if (cur.hasNext()==false) {
|
||||
return null;
|
||||
}
|
||||
DBObject user = cur.next();
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Principal getPrincipal(String username) {
|
||||
String password = getPassword(username);
|
||||
if (password==null) {
|
||||
return null;
|
||||
}
|
||||
DBCollection coll = db.getCollection(getRoleCollection());
|
||||
DBObject query = new BasicDBObject();
|
||||
if (isRoleUserIdRef()) {
|
||||
DBObject user = getUser(username);
|
||||
query.put(getRoleUserField(), user.get("_id"));
|
||||
} else {
|
||||
query.put(getRoleUserField(), username);
|
||||
}
|
||||
DBCursor cur = coll.find(query);
|
||||
if (cur.hasNext()==false) {
|
||||
return null;
|
||||
}
|
||||
List<String> roles = new ArrayList<String>(30);
|
||||
while (cur.hasNext()) {
|
||||
DBObject row = cur.next();
|
||||
String role = (String)row.get(getRoleField());
|
||||
roles.add(role);
|
||||
}
|
||||
return new GenericPrincipal(username, password, roles);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.catalina.realm.RealmBase#startInternal()
|
||||
*/
|
||||
@Override
|
||||
protected void startInternal() throws LifecycleException {
|
||||
super.startInternal();
|
||||
if (database==null) {
|
||||
throw new LifecycleException("database is null.");
|
||||
}
|
||||
if (userCollection==null) {
|
||||
throw new LifecycleException("userCollection is null.");
|
||||
}
|
||||
if (roleCollection==null) {
|
||||
throw new LifecycleException("roleCollection is null.");
|
||||
}
|
||||
createMongoConnection();
|
||||
logger.fine("Started mongo realm to database: "+getDatabase());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.catalina.realm.RealmBase#stopInternal()
|
||||
*/
|
||||
@Override
|
||||
protected void stopInternal() throws LifecycleException {
|
||||
super.stopInternal();
|
||||
if (mongo==null) {
|
||||
return;
|
||||
}
|
||||
mongo.close();
|
||||
logger.fine("Stopped mongo realm.");
|
||||
}
|
||||
|
||||
private void createMongoConnection() throws LifecycleException {
|
||||
ServerAddress server;
|
||||
try {
|
||||
server = new ServerAddress(hostname,port);
|
||||
} catch (UnknownHostException e) {
|
||||
throw new LifecycleException(e);
|
||||
}
|
||||
MongoOptions options = new MongoOptions();
|
||||
mongo = new Mongo(server,options);
|
||||
db = mongo.getDB(database);
|
||||
if (authUser!=null && authUser.isEmpty()==false && authPass!=null && authPass.isEmpty()==false) {
|
||||
boolean auth = db.authenticate(authUser, authPass.toCharArray());
|
||||
authPass = null;
|
||||
if (auth==false) {
|
||||
throw new LifecycleException("Could not auth to db: "+database+" with username: "+authUser);
|
||||
}
|
||||
|
||||
}
|
||||
db.setReadOnly(true);
|
||||
logger.finer("Connection to: "+db.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hostname
|
||||
*/
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hostname the hostname to set
|
||||
*/
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the port
|
||||
*/
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param port the port to set
|
||||
*/
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the database
|
||||
*/
|
||||
public String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param database the database to set
|
||||
*/
|
||||
public void setDatabase(String database) {
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the authUser
|
||||
*/
|
||||
public String getAuthUser() {
|
||||
return authUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param authUser the authUser to set
|
||||
*/
|
||||
public void setAuthUser(String authUser) {
|
||||
this.authUser = authUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the authPass
|
||||
*/
|
||||
public String getAuthPass() {
|
||||
return authPass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param authPass the authPass to set
|
||||
*/
|
||||
public void setAuthPass(String authPass) {
|
||||
this.authPass = authPass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the userCollection
|
||||
*/
|
||||
public String getUserCollection() {
|
||||
return userCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userCollection the userCollection to set
|
||||
*/
|
||||
public void setUserCollection(String userCollection) {
|
||||
this.userCollection = userCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the userField
|
||||
*/
|
||||
public String getUserField() {
|
||||
return userField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userField the userField to set
|
||||
*/
|
||||
public void setUserField(String userField) {
|
||||
this.userField = userField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the roleCollection
|
||||
*/
|
||||
public String getRoleCollection() {
|
||||
return roleCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param roleCollection the roleCollection to set
|
||||
*/
|
||||
public void setRoleCollection(String roleCollection) {
|
||||
this.roleCollection = roleCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the roleField
|
||||
*/
|
||||
public String getRoleField() {
|
||||
return roleField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param roleField the roleField to set
|
||||
*/
|
||||
public void setRoleField(String roleField) {
|
||||
this.roleField = roleField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the roleUserField
|
||||
*/
|
||||
public String getRoleUserField() {
|
||||
return roleUserField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param roleUserField the roleUserField to set
|
||||
*/
|
||||
public void setRoleUserField(String roleUserField) {
|
||||
this.roleUserField = roleUserField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the userPassField
|
||||
*/
|
||||
public String getUserPassField() {
|
||||
return userPassField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userPassField the userPassField to set
|
||||
*/
|
||||
public void setUserPassField(String userPassField) {
|
||||
this.userPassField = userPassField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the roleUserIdRef
|
||||
*/
|
||||
public boolean isRoleUserIdRef() {
|
||||
return roleUserIdRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param roleUserIdRef the roleUserIdRef to set
|
||||
*/
|
||||
public void setRoleUserIdRef(boolean roleUserIdRef) {
|
||||
this.roleUserIdRef = roleUserIdRef;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,221 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.tomcat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup;
|
||||
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.catalina.Host;
|
||||
import org.apache.catalina.Server;
|
||||
import org.apache.catalina.Service;
|
||||
import org.apache.catalina.Wrapper;
|
||||
import org.apache.catalina.core.StandardContext;
|
||||
import org.apache.catalina.startup.Bootstrap;
|
||||
import org.apache.catalina.startup.ContextConfig;
|
||||
import org.apache.naming.resources.VirtualDirContext;
|
||||
|
||||
|
||||
/**
|
||||
* TomcatService config and starts Tomcat in semi embedded mode.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 10, 2012
|
||||
*/
|
||||
public class TomcatService {
|
||||
|
||||
private Logger logger = null;
|
||||
private Server server = null;
|
||||
private ClassLoader commonLoader = null;
|
||||
private Context applicationContext = null;
|
||||
|
||||
public TomcatService() {
|
||||
logger = Logger.getLogger(TomcatService.class.getName());
|
||||
}
|
||||
|
||||
public void start() throws Exception {
|
||||
|
||||
/*
|
||||
// List all ejb-jar.xml resources.
|
||||
Enumeration<URL> ejbJars = this.getClass().getClassLoader().getResources("META-INF/ejb-jar.xml");
|
||||
while (ejbJars.hasMoreElements()) {
|
||||
URL url = ejbJars.nextElement();
|
||||
System.out.println("app = " + url);
|
||||
}
|
||||
*/
|
||||
|
||||
//we use org.apache.tomee.catalina.ServerListener
|
||||
System.setProperty("openejb.servicemanager.enabled", "true");
|
||||
|
||||
Bootstrap boot = new Bootstrap();
|
||||
boot.setCatalinaHome(System.getProperty("user.dir"));
|
||||
boot.init();
|
||||
boot.start();
|
||||
|
||||
/// After startup get the server object from private method.
|
||||
for (Method m:boot.getClass().getDeclaredMethods()) {
|
||||
if (m.getName().equals("getServer")) {
|
||||
m.setAccessible(true);
|
||||
server = (Server)m.invoke(boot);
|
||||
}
|
||||
}
|
||||
if (server==null) {
|
||||
throw new RuntimeException("Could not get server by reflection from BootStrap.");
|
||||
}
|
||||
for (Field f:boot.getClass().getDeclaredFields()) {
|
||||
if (f.getName().equals("commonLoader")) {
|
||||
f.setAccessible(true);
|
||||
commonLoader = (ClassLoader)f.get(boot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deploy(String deployContext) throws Exception {
|
||||
Service service = server.findService("Catalina");
|
||||
Host host = (Host)service.getContainer().findChild("localhost");
|
||||
|
||||
String deployPath = null;
|
||||
if (VascTechDemoStartup.getInstance().isMavenRun()) {
|
||||
String webappPathLocation = "../vasc-demo-tech-web/src/main/webapp/";
|
||||
deployPath = new File(webappPathLocation).getAbsolutePath();
|
||||
logger.info("Deploy demo app from workspace path: "+deployPath);
|
||||
} else {
|
||||
|
||||
File techWarFile = null;
|
||||
for (File file:new File("libs").listFiles()) {
|
||||
if (file.getName().contains("vasc-demo-tech-web")) {
|
||||
techWarFile = file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (techWarFile==null) {
|
||||
throw new NullPointerException("Could not locate war file in lib directory.");
|
||||
}
|
||||
File destDir = new File("workdir","tomcat.wars"+File.separator+deployContext); //techWarFile.getName()
|
||||
|
||||
if (destDir.exists()==false) {
|
||||
destDir.mkdirs();
|
||||
JarFile jar = new JarFile(techWarFile);
|
||||
Enumeration<JarEntry> jars = jar.entries();
|
||||
while (jars.hasMoreElements()) {
|
||||
JarEntry file = jars.nextElement();
|
||||
File f = new File(destDir+File.separator+file.getName());
|
||||
if (file.isDirectory()) {
|
||||
f.mkdir();
|
||||
continue;
|
||||
}
|
||||
InputStream is = jar.getInputStream(file);
|
||||
FileOutputStream fos = new FileOutputStream(f);
|
||||
while (is.available() > 0) {
|
||||
fos.write(is.read()); // slow copy
|
||||
}
|
||||
fos.close();
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
deployPath = destDir.getAbsolutePath();
|
||||
logger.info("Deploy war path: "+deployPath);
|
||||
}
|
||||
|
||||
Context ctx = new StandardContext();
|
||||
ctx.setName(deployContext);
|
||||
ctx.setPath(deployContext);
|
||||
ctx.setDocBase(deployPath);
|
||||
//ctx.setParentClassLoader(commonLoader);
|
||||
ctx.setConfigured(true);
|
||||
|
||||
ContextConfig ctxCfg = new ContextConfig();
|
||||
ctx.addLifecycleListener(ctxCfg);
|
||||
|
||||
//VirtualDirContext vDir = new VirtualDirContext();
|
||||
//vDir.setExtraResourcePaths("../vasc-demo-tech-web/target/classes;");
|
||||
//ctx.setResources(vDir);
|
||||
|
||||
host.addChild(ctx);
|
||||
|
||||
applicationContext = ctx;
|
||||
}
|
||||
|
||||
public void deployDebug() throws Exception {
|
||||
if (applicationContext==null) {
|
||||
throw new NullPointerException("Can only deploy debug after deploy.");
|
||||
//return;
|
||||
}
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
addServlet(applicationContext,"jdbcConsole","org.h2.server.web.WebServlet");
|
||||
applicationContext.addServletMapping("/debug/jdbc/console/*", "jdbcConsole");
|
||||
|
||||
addServlet(applicationContext,"jndiView","net.forwardfire.vasc.demo.server.tomcat.JndiDebugServlet");
|
||||
applicationContext.addServletMapping("/debug/jndi/view", "jndiView");
|
||||
applicationContext.addServletMapping("/debug/jndi/view/*", "jndiView");
|
||||
|
||||
addServlet(applicationContext,"logbackClassicStatus","ch.qos.logback.classic.ViewStatusMessagesServlet");
|
||||
applicationContext.addServletMapping("/debug/logback/status/classic", "logbackClassicStatus");
|
||||
|
||||
addServlet(applicationContext,"logbackAccessStatus","ch.qos.logback.access.ViewStatusMessagesServlet");
|
||||
applicationContext.addServletMapping("/debug/logback/status/access", "logbackAccessStatus");
|
||||
|
||||
long stopTime = System.currentTimeMillis();
|
||||
logger.info("Deployed all debug resources in: "+(stopTime-startTime)+" ms.");
|
||||
}
|
||||
|
||||
public Wrapper addServlet(Context ctx,String servletName,String servletClass) {
|
||||
Wrapper sw = ctx.createWrapper();
|
||||
sw.setServletClass(servletClass);
|
||||
sw.setName(servletName);
|
||||
ctx.addChild(sw);
|
||||
return sw;
|
||||
}
|
||||
|
||||
public void stop() throws Exception {
|
||||
if (server==null) {
|
||||
return;
|
||||
}
|
||||
server.stop();
|
||||
}
|
||||
|
||||
public ClassLoader getClassLoaderCommon() {
|
||||
return commonLoader;
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the applicationContext
|
||||
*/
|
||||
public Context getApplicationContext() {
|
||||
return applicationContext;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui;
|
||||
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.SimpleFormatter;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SpringLayout;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
* JConsolePanel binds to JUL and display log messages in texteara.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2012
|
||||
*/
|
||||
public class JConsolePanel extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = 485766723433479054L;
|
||||
private UILogHandler logHandler = null;
|
||||
private JTextArea logTextArea = null;
|
||||
private int logLinesMax = 255;
|
||||
|
||||
public JConsolePanel() {
|
||||
setLayout(new SpringLayout());
|
||||
setBorder(new JFireBorder("Console Log",this));
|
||||
add(createEditor());
|
||||
SpringLayoutGrid.makeCompactGrid(this, 1, 1, 6, 6, 6, 6);
|
||||
|
||||
Logger rootLogger = Logger.getAnonymousLogger();
|
||||
while (rootLogger.getParent()!=null) {
|
||||
rootLogger = rootLogger.getParent();
|
||||
}
|
||||
|
||||
logHandler = new UILogHandler();
|
||||
logHandler.setFormatter(new SimpleFormatter());
|
||||
rootLogger.addHandler(logHandler);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This needs release if playing the the this tab add/removal very multiple times.
|
||||
*/
|
||||
public void release() {
|
||||
Logger rootLogger = Logger.getAnonymousLogger();
|
||||
while (rootLogger.getParent()!=null) {
|
||||
rootLogger = rootLogger.getParent();
|
||||
}
|
||||
rootLogger.removeHandler(logHandler);
|
||||
}
|
||||
|
||||
private JComponent createEditor() {
|
||||
logTextArea = new JTextArea(6, 80);
|
||||
logTextArea.setAutoscrolls(true);
|
||||
logTextArea.setEditable(false);
|
||||
JScrollPane scrollPane = new JScrollPane(logTextArea);
|
||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
return scrollPane;
|
||||
}
|
||||
|
||||
class UILogHandler extends Handler {
|
||||
@Override
|
||||
public void close() throws SecurityException {
|
||||
}
|
||||
@Override
|
||||
public void flush() {
|
||||
}
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
final String recordStr = getFormatter().format(record);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
logTextArea.append(recordStr);
|
||||
if (logTextArea.getLineCount() > logLinesMax) {
|
||||
String t = logTextArea.getText();
|
||||
int l = 0;
|
||||
int rm = logLinesMax/2;
|
||||
for (int i=0;i<rm;i++) {
|
||||
int ll = t.indexOf('\n',l+1);
|
||||
if (ll==-1) {
|
||||
break;
|
||||
}
|
||||
l = ll;
|
||||
}
|
||||
String tt = t.substring(l,t.length());
|
||||
logTextArea.setText(tt);
|
||||
}
|
||||
logTextArea.setCaretPosition(logTextArea.getText().length());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
package net.forwardfire.vasc.demo.server.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Insets;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.Border;
|
||||
|
||||
/**
|
||||
* JFireBorder
|
||||
*
|
||||
* @author Willem Cazander
|
||||
*/
|
||||
public class JFireBorder implements Border,MouseListener {
|
||||
|
||||
private int radius;
|
||||
boolean entered = false;
|
||||
private JComponent comp = null;
|
||||
private String title;
|
||||
static private JFireBorder lastFireBorder = null;
|
||||
private GradientPaint gradientNormal = null;
|
||||
private GradientPaint gradientEntered = null;
|
||||
private int gradientWidth = 0;
|
||||
|
||||
public JFireBorder(String title,JComponent comp) {
|
||||
this.radius = 10;
|
||||
this.comp=comp;
|
||||
this.title = title;
|
||||
comp.addMouseListener(this);
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return new Insets(getTitleHeight(c)+1, 1, radius-2, 1);
|
||||
}
|
||||
|
||||
public boolean isBorderOpaque() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
int titleHeight = getTitleHeight(c);
|
||||
|
||||
if (gradientWidth!=width) {
|
||||
gradientNormal = null;
|
||||
gradientEntered = null;
|
||||
}
|
||||
gradientWidth = width;
|
||||
|
||||
Color endColor = UIManager.getColor("control");
|
||||
if (endColor==null) {
|
||||
endColor = c.getBackground();
|
||||
}
|
||||
Color startColor = UIManager.getColor("nimbusBorder");
|
||||
if (startColor==null) {
|
||||
startColor = c.getForeground();
|
||||
}
|
||||
|
||||
//BufferedImage titleImage = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT);
|
||||
if (gradientNormal==null) {
|
||||
gradientNormal = new GradientPaint(
|
||||
0, 0, startColor,
|
||||
titleHeight*5, width/3,endColor,
|
||||
false);
|
||||
}
|
||||
if (gradientEntered==null) {
|
||||
startColor = UIManager.getColor("nimbusFocus");
|
||||
if (startColor==null) {
|
||||
startColor = c.getForeground();
|
||||
}
|
||||
gradientEntered = new GradientPaint(
|
||||
0, 0, startColor,
|
||||
titleHeight*5, width/3,endColor,
|
||||
false);
|
||||
}
|
||||
if (entered) {
|
||||
g2.setPaint(gradientEntered);
|
||||
} else {
|
||||
g2.setPaint(gradientNormal);
|
||||
}
|
||||
g2.fillRoundRect(x, y, width, titleHeight, radius, radius);
|
||||
g2.fillRect(x,titleHeight/2,radius+1, titleHeight/2);
|
||||
g2.drawRoundRect(x,y,width-1,height-1,radius,radius);
|
||||
|
||||
if (title==null) {
|
||||
return;
|
||||
}
|
||||
Font font = UIManager.getFont("TitledBorder.font");
|
||||
g2.setColor(c.getForeground());
|
||||
FontMetrics metrics = c.getFontMetrics(font);
|
||||
g2.setFont(font);
|
||||
g2.drawString(title,x+8,y+(titleHeight-metrics.getHeight())/2 +metrics.getAscent());
|
||||
}
|
||||
|
||||
protected int getTitleHeight(Component c) {
|
||||
Font font = UIManager.getFont("TitledBorder.font");
|
||||
FontMetrics metrics = c.getFontMetrics(font);
|
||||
return (int)(metrics.getHeight() * 1.40);
|
||||
}
|
||||
|
||||
public GradientPaint getGradient() {
|
||||
if (entered) {
|
||||
return gradientEntered;
|
||||
} else {
|
||||
return gradientNormal;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
if (entered==true && lastFireBorder==this) {
|
||||
return;
|
||||
}
|
||||
entered = true;
|
||||
if (comp!=null) {
|
||||
comp.repaint();
|
||||
if (lastFireBorder!=null) {
|
||||
lastFireBorder.entered = false;
|
||||
lastFireBorder.comp.repaint();
|
||||
}
|
||||
lastFireBorder = this;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,324 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.ThreadInfo;
|
||||
import java.lang.management.ThreadMXBean;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.catalina.Server;
|
||||
import org.apache.catalina.Service;
|
||||
import org.apache.catalina.connector.Connector;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup;
|
||||
import net.forwardfire.vasc.demo.server.ui.load.JLoadDialog;
|
||||
import net.forwardfire.vasc.demo.server.ui.load.JLoadDialog.LoadType;
|
||||
|
||||
/**
|
||||
* JStatusPanel is the main panel/window of this demo.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2012
|
||||
*/
|
||||
public class JStatusPanel extends JPanel implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = 5834715323973411147L;
|
||||
private JButton stopButton = null;
|
||||
private JButton playButton = null;
|
||||
private JButton shutdownButton = null;
|
||||
private JButton restartButton = null;
|
||||
private JButton importJdbcButton = null;
|
||||
private JButton importMongoButton = null;
|
||||
private JButton importDataFileButton = null;
|
||||
private JButton importDataPathButton = null;
|
||||
private JLabel infoStatus = null;
|
||||
private JLabel infoThreads = null;
|
||||
private JLabel infoWorkers = null;
|
||||
private JLabel infoSessions = null;
|
||||
private JLabel infoHttpPort = null;
|
||||
private JLabel infoVascGroups = null;
|
||||
private JLabel infoVascEntries = null;
|
||||
private JLabel infoVascBackends= null;
|
||||
|
||||
public JStatusPanel() {
|
||||
setLayout(new SpringLayout());
|
||||
|
||||
JPanel main = new JPanel();
|
||||
main.setLayout(new SpringLayout());
|
||||
main.add(createPanelInfoServer());
|
||||
main.add(createPanelInfoVasc());
|
||||
main.add(createPanelAction());
|
||||
main.add(createPanelImport());
|
||||
SpringLayoutGrid.makeCompactGrid(main, 2,2,0,0,6,6);
|
||||
|
||||
JConsolePanel consolePanel = new JConsolePanel();
|
||||
add(main);
|
||||
add(consolePanel);
|
||||
SpringLayoutGrid.makeCompactGrid(this, 2,1,6,6,0,0);
|
||||
}
|
||||
|
||||
private JPanel createPanelInfoVasc() {
|
||||
JPanel statusPanel = new JPanel();
|
||||
statusPanel.setBorder(new JFireBorder("Info Vasc",statusPanel));
|
||||
statusPanel.setLayout(new SpringLayout());
|
||||
|
||||
infoVascGroups = new JLabel("0");
|
||||
infoVascEntries = new JLabel("0");
|
||||
infoVascBackends = new JLabel("0");
|
||||
|
||||
statusPanel.add(new JLabel("Artifact:"));
|
||||
statusPanel.add(new JLabel("vasc-demo-server-core"));
|
||||
|
||||
statusPanel.add(new JLabel("Version:"));
|
||||
statusPanel.add(new JLabel(VascTechDemoStartup.getInstance().getBuildInfo().getVersion()));
|
||||
|
||||
statusPanel.add(new JLabel("Groups:"));
|
||||
statusPanel.add(infoVascGroups);
|
||||
|
||||
statusPanel.add(new JLabel("Entries:"));
|
||||
statusPanel.add(infoVascEntries);
|
||||
|
||||
statusPanel.add(new JLabel("Backends:"));
|
||||
statusPanel.add(infoVascBackends);
|
||||
|
||||
SpringLayoutGrid.makeCompactGrid(statusPanel, 5, 2);
|
||||
return statusPanel;
|
||||
}
|
||||
|
||||
private JPanel createPanelInfoServer() {
|
||||
JPanel statusPanel = new JPanel();
|
||||
statusPanel.setBorder(new JFireBorder("Info Server",statusPanel));
|
||||
statusPanel.setLayout(new SpringLayout());
|
||||
|
||||
infoStatus = new JLabel("booting");
|
||||
infoThreads = new JLabel("0");
|
||||
infoWorkers = new JLabel("0");
|
||||
infoSessions = new JLabel("0");
|
||||
infoHttpPort = new JLabel("0");
|
||||
|
||||
statusPanel.add(new JLabel("Running:"));
|
||||
statusPanel.add(infoStatus);
|
||||
|
||||
statusPanel.add(new JLabel("HttpPort:"));
|
||||
statusPanel.add(infoHttpPort);
|
||||
|
||||
statusPanel.add(new JLabel("Threads:"));
|
||||
statusPanel.add(infoThreads);
|
||||
|
||||
statusPanel.add(new JLabel("Workers:"));
|
||||
statusPanel.add(infoWorkers);
|
||||
|
||||
statusPanel.add(new JLabel("Sessions:"));
|
||||
statusPanel.add(infoSessions);
|
||||
|
||||
SpringLayoutGrid.makeCompactGrid(statusPanel, 5, 2);
|
||||
return statusPanel;
|
||||
}
|
||||
|
||||
private JPanel createPanelImport() {
|
||||
JPanel statusPanel = new JPanel();
|
||||
statusPanel.setBorder(new JFireBorder("Import",statusPanel));
|
||||
statusPanel.setLayout(new SpringLayout());
|
||||
|
||||
importJdbcButton = new JButton("Jdbc");
|
||||
importMongoButton = new JButton("Mongo");
|
||||
importDataFileButton = new JButton("DataFile");
|
||||
importDataPathButton = new JButton("DataPath");
|
||||
|
||||
importJdbcButton.addActionListener(this);
|
||||
importMongoButton.addActionListener(this);
|
||||
importDataFileButton.addActionListener(this);
|
||||
importDataPathButton.addActionListener(this);
|
||||
|
||||
importJdbcButton.setEnabled(false);
|
||||
importMongoButton.setEnabled(false);
|
||||
importDataFileButton.setEnabled(false);
|
||||
importDataPathButton.setEnabled(false);
|
||||
|
||||
statusPanel.add(new JLabel("Import Jdbc:"));
|
||||
statusPanel.add(importJdbcButton);
|
||||
|
||||
statusPanel.add(new JLabel("Import Mongo:"));
|
||||
statusPanel.add(importMongoButton);
|
||||
|
||||
statusPanel.add(new JLabel("Import File:"));
|
||||
statusPanel.add(importDataFileButton);
|
||||
|
||||
statusPanel.add(new JLabel("Data Directory:"));
|
||||
statusPanel.add(importDataPathButton);
|
||||
|
||||
SpringLayoutGrid.makeCompactGrid(statusPanel,2,4,6,6,0,0);
|
||||
return statusPanel;
|
||||
}
|
||||
|
||||
private JPanel createPanelAction() {
|
||||
JPanel actionPanel = new JPanel();
|
||||
actionPanel.setBorder(new JFireBorder("Actions",actionPanel));
|
||||
actionPanel.setLayout(new SpringLayout());
|
||||
|
||||
actionPanel.add(new JLabel("Catalina:"));
|
||||
|
||||
playButton = new JButton("Play");
|
||||
playButton.setEnabled(false);
|
||||
playButton.addActionListener(this);
|
||||
actionPanel.add(playButton);
|
||||
|
||||
stopButton = new JButton("Stop");
|
||||
stopButton.setEnabled(false);
|
||||
stopButton.addActionListener(this);
|
||||
actionPanel.add(stopButton);
|
||||
|
||||
actionPanel.add(new JLabel("Application:"));
|
||||
|
||||
restartButton = new JButton("Restart");
|
||||
restartButton.setEnabled(false);
|
||||
restartButton.addActionListener(this);
|
||||
actionPanel.add(restartButton);
|
||||
|
||||
shutdownButton = new JButton("Shutdown");
|
||||
shutdownButton.setEnabled(false);
|
||||
shutdownButton.addActionListener(this);
|
||||
actionPanel.add(shutdownButton);
|
||||
|
||||
SpringLayoutGrid.makeCompactGrid(actionPanel,2,3,6,6,0,0);
|
||||
return actionPanel;
|
||||
}
|
||||
|
||||
public void startupDone() {
|
||||
infoStatus.setText("running");
|
||||
|
||||
//restartButton.setEnabled(true);
|
||||
shutdownButton.setEnabled(true);
|
||||
|
||||
importJdbcButton.setEnabled(true);
|
||||
importMongoButton.setEnabled(true);
|
||||
//importDataFileButton.setEnabled(true);
|
||||
//importDataPathButton.setEnabled(true);
|
||||
|
||||
updateInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource().equals(shutdownButton)) {
|
||||
int confirmResult = JOptionPane.showConfirmDialog(ServerGuiApplication.getInstance().getMainFrame(), "Are you sure to exit ?");
|
||||
if (confirmResult==JOptionPane.YES_OPTION) {
|
||||
VascTechDemoStartup.getInstance().shutdown();
|
||||
}
|
||||
return;
|
||||
} else if (e.getSource().equals(importJdbcButton)) {
|
||||
JLoadDialog dialog = new JLoadDialog(ServerGuiApplication.getInstance().getMainFrame(),LoadType.JDBC);
|
||||
dialog.setVisible(true);
|
||||
} else if (e.getSource().equals(importMongoButton)) {
|
||||
JLoadDialog dialog = new JLoadDialog(ServerGuiApplication.getInstance().getMainFrame(),LoadType.MONGODB);
|
||||
dialog.setVisible(true);
|
||||
} else if (e.getSource().equals(importDataFileButton)) {
|
||||
JLoadDialog dialog = new JLoadDialog(ServerGuiApplication.getInstance().getMainFrame(),LoadType.JDBC);
|
||||
dialog.setVisible(true);
|
||||
} else if (e.getSource().equals(importDataPathButton)) {
|
||||
JLoadDialog dialog = new JLoadDialog(ServerGuiApplication.getInstance().getMainFrame(),LoadType.JDBC);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateInfo() {
|
||||
|
||||
VascController vc = VascTechDemoStartup.getInstance().getVascControllerService().getVascController();
|
||||
if (vc==null) {
|
||||
return;
|
||||
}
|
||||
Server server = VascTechDemoStartup.getInstance().getTomcatService().getServer();
|
||||
if (server==null) {
|
||||
return; // still booting
|
||||
}
|
||||
Service service = server.findService("Catalina");
|
||||
if (service==null) {
|
||||
return;
|
||||
}
|
||||
Context demoContext = VascTechDemoStartup.getInstance().getTomcatService().getApplicationContext();
|
||||
|
||||
infoVascGroups.setText(""+vc.getVascEntryController().getVascEntryGroupIds().size());
|
||||
infoVascEntries.setText(""+vc.getVascEntryController().getVascEntryIds().size());
|
||||
infoVascBackends.setText(""+vc.getVascBackendController().getVascBackendIds().size());
|
||||
|
||||
Connector[] connectors = service.findConnectors();
|
||||
if (connectors.length>0) {
|
||||
int httpPort = connectors[0].getPort();
|
||||
infoHttpPort.setText(""+httpPort);
|
||||
}
|
||||
infoThreads.setText(""+Thread.activeCount());
|
||||
|
||||
int sessions = 0;
|
||||
int workers = 0;
|
||||
|
||||
if (demoContext!=null) {
|
||||
sessions = demoContext.getManager().getActiveSessions();
|
||||
}
|
||||
|
||||
ThreadMXBean man = ManagementFactory.getThreadMXBean();
|
||||
ThreadInfo[] infos = man.getThreadInfo(man.getAllThreadIds());
|
||||
for (ThreadInfo info:infos) {
|
||||
if (info.getThreadName()!=null && info.getThreadName().startsWith("http")) {
|
||||
workers++;
|
||||
}
|
||||
}
|
||||
|
||||
infoWorkers.setText(""+workers);
|
||||
infoSessions.setText(""+sessions);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
||||
JMenuItem openXmlItem = new JMenuItem("Import Xml");
|
||||
openXmlItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
final JFileChooser fc = new JFileChooser();
|
||||
//fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
int returnVal = fc.showOpenDialog((JMenuItem)e.getSource());
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fc.getSelectedFile();
|
||||
//VascTechDemoStartup.getInstance().getVascControllerService().openFile(file);
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
*/
|
||||
}
|
||||
|
|
@ -0,0 +1,277 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.SystemTray;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup;
|
||||
|
||||
import org.jdesktop.application.FrameView;
|
||||
import org.jdesktop.application.SingleFrameApplication;
|
||||
|
||||
/**
|
||||
* SwingGuiService Shows the demo swing gui and vasc swing frontend.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 19, 2012
|
||||
*/
|
||||
public class ServerGuiApplication extends SingleFrameApplication {
|
||||
|
||||
private Logger logger = null;
|
||||
private JStatusPanel statusPanel = null;
|
||||
private ImageIcon serverIcon = null;
|
||||
private UpdateInfoTask updateInfoTask = null;
|
||||
|
||||
public ServerGuiApplication() {
|
||||
logger = Logger.getLogger(ServerGuiApplication.class.getName());
|
||||
}
|
||||
|
||||
protected void startup() {
|
||||
installColorsLaF();
|
||||
addExitListener(new CloseWindowExitListener());
|
||||
serverIcon = createImageIcon("/net/forwardfire/vasc/demo/server/ui/resources/icon.png", "Vasc Icon");
|
||||
statusPanel = new JStatusPanel();
|
||||
FrameView mainView = getMainView();
|
||||
mainView.setComponent(statusPanel);
|
||||
mainView.getFrame().setMinimumSize(new Dimension(640,480));
|
||||
mainView.getFrame().setMaximumSize(new Dimension(800,600));
|
||||
mainView.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
|
||||
show(mainView);
|
||||
startSystemTray();
|
||||
|
||||
updateInfoTask = new UpdateInfoTask();
|
||||
Thread t = new Thread(updateInfoTask);
|
||||
t.setName(UpdateInfoTask.class.getSimpleName());
|
||||
t.start();
|
||||
}
|
||||
|
||||
class UpdateInfoTask implements Runnable {
|
||||
volatile public boolean run = true;
|
||||
volatile public boolean doUpdate = true;
|
||||
@Override
|
||||
public void run() {
|
||||
logger.finest("Updating thread started.");
|
||||
while(run) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
if (doUpdate) {
|
||||
statusPanel.updateInfo();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
logger.finest("Updating thread stopped.");
|
||||
}
|
||||
}
|
||||
|
||||
class CloseWindowExitListener implements ExitListener {
|
||||
@Override
|
||||
public boolean canExit(EventObject event) {
|
||||
if (event!=null && event.getSource().equals(ServerGuiApplication.this)) {
|
||||
updateInfoTask.run=false; // app will exit so stop update
|
||||
return true;
|
||||
} else {
|
||||
logger.finer("Closing application window.");
|
||||
updateInfoTask.doUpdate=false; // close window
|
||||
ServerGuiApplication.getInstance().getMainFrame().setVisible(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void willExit(EventObject event) {
|
||||
}
|
||||
}
|
||||
|
||||
public void startupDone() {
|
||||
try {
|
||||
statusPanel.startupDone();
|
||||
} finally {
|
||||
getMainFrame().setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop if requested from service
|
||||
*/
|
||||
public void stop() {
|
||||
//shutdown();
|
||||
exit(new EventObject(this));
|
||||
}
|
||||
|
||||
public ImageIcon getServerIcon() {
|
||||
return serverIcon;
|
||||
}
|
||||
|
||||
static public ServerGuiApplication getInstance() {
|
||||
return getInstance(ServerGuiApplication.class);
|
||||
}
|
||||
|
||||
private void startSystemTray() {
|
||||
if (!SystemTray.isSupported()) {
|
||||
return;
|
||||
}
|
||||
final PopupMenu popup = new PopupMenu();
|
||||
final TrayIcon trayIcon = new TrayIcon(createImageIcon("/net/forwardfire/vasc/demo/server/ui/resources/tray-icon.png", "tray icon").getImage());
|
||||
final SystemTray tray = SystemTray.getSystemTray();
|
||||
|
||||
MenuItem aboutItem = new MenuItem("About");
|
||||
aboutItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
logger.finer("Systray show about.");
|
||||
JOptionPane.showMessageDialog(ServerGuiApplication.getInstance().getMainFrame(), "Vasc Demo Tech Server:\nIs build to test and demo different parts of the vasc package.", "About Vasc Demo", JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
});
|
||||
MenuItem statusItem = new MenuItem("Open Status");
|
||||
statusItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
logger.finer("Systray open status window.");
|
||||
updateInfoTask.doUpdate=true;
|
||||
getMainFrame().setVisible(true);
|
||||
}
|
||||
});
|
||||
MenuItem exitItem = new MenuItem("Exit");
|
||||
exitItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
logger.finer("Systray exit application.");
|
||||
VascTechDemoStartup.getInstance().shutdown();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
popup.add(exitItem);
|
||||
popup.addSeparator();
|
||||
popup.add(aboutItem);
|
||||
popup.add(statusItem);
|
||||
|
||||
trayIcon.setPopupMenu(popup);
|
||||
|
||||
try {
|
||||
tray.add(trayIcon);
|
||||
} catch (AWTException e) {
|
||||
System.out.println("TrayIcon could not be added.");
|
||||
}
|
||||
}
|
||||
|
||||
protected static ImageIcon createImageIcon(String path, String description) {
|
||||
URL imageURL = ServerGuiApplication.class.getResource(path);
|
||||
if (imageURL == null) {
|
||||
throw new NullPointerException("Could not find resource: "+path);
|
||||
}
|
||||
return new ImageIcon(imageURL, description);
|
||||
}
|
||||
|
||||
private String installColorsLaF() {
|
||||
UIManager.put("TabbedPane.font", Font.decode("SansSerif-BOLD-12"));
|
||||
UIManager.put("TitledBorder.font", Font.decode("SansSerif-BOLD-16"));
|
||||
UIManager.put("FireDial.font", Font.decode("SansSerif-9"));
|
||||
|
||||
String colorName = "laf-colors";
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
if (cl==null) {
|
||||
cl = this.getClass().getClassLoader();
|
||||
}
|
||||
InputStream in = cl.getResourceAsStream("net/forwardfire/vasc/demo/server/ui/resources/"+colorName+".properties");
|
||||
if (in==null) {
|
||||
logger.warning("Color schema not found: "+colorName);
|
||||
return "unknown";
|
||||
}
|
||||
try {
|
||||
Properties p = new Properties();
|
||||
p.load(in);
|
||||
for (Object key:p.keySet()) {
|
||||
String value = p.getProperty(key.toString());
|
||||
Color colorValue = Color.decode(value);
|
||||
UIManager.put(key,colorValue);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.warning("Could not load color schema: "+colorName+" error: "+e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
// Invert focus painters
|
||||
List<Object> keys = new ArrayList<Object>(UIManager.getLookAndFeelDefaults().keySet());
|
||||
for (Object keyObj:keys) {
|
||||
if ((keyObj instanceof String)==false) {
|
||||
continue;
|
||||
}
|
||||
String key = (String)keyObj;
|
||||
|
||||
if (key.endsWith("[Focused].backgroundPainter")==false & key.endsWith("[Focused].iconPainter")==false) {
|
||||
continue;
|
||||
}
|
||||
String preKey = key.substring(0,key.indexOf("["));
|
||||
String postKey = "backgroundPainter";
|
||||
if (key.contains("iconPainter")) {
|
||||
postKey = "iconPainter";
|
||||
}
|
||||
|
||||
logger.finer("Flipping painters of key: "+preKey);
|
||||
|
||||
Object focusPainter = UIManager.getLookAndFeelDefaults().get(preKey+"[Focused]."+postKey);
|
||||
Object mouseOverPainter = UIManager.getLookAndFeelDefaults().get(preKey+"[MouseOver]."+postKey);
|
||||
UIManager.getLookAndFeelDefaults().put(preKey+"[Focused]."+postKey,mouseOverPainter);
|
||||
UIManager.getLookAndFeelDefaults().put(preKey+"[MouseOver]."+postKey,focusPainter);
|
||||
|
||||
if (key.contains("iconPainter")) {
|
||||
Object focusPainterSelected = UIManager.getLookAndFeelDefaults().get(preKey+"[Focused+Selected]."+postKey);
|
||||
Object mouseOverPainterSelected = UIManager.getLookAndFeelDefaults().get(preKey+"[MouseOver+Selected]."+postKey);
|
||||
UIManager.getLookAndFeelDefaults().put(preKey+"[Focused+Selected]."+postKey,mouseOverPainterSelected);
|
||||
UIManager.getLookAndFeelDefaults().put(preKey+"[MouseOver+Selected]."+postKey,focusPainterSelected);
|
||||
}
|
||||
}
|
||||
|
||||
return colorName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,214 @@
|
|||
/*
|
||||
* Copyright (c) 2011, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
|
||||
import javax.swing.Spring;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
|
||||
/**
|
||||
* SpringLayoutGrid, someone should create an JCP to get these functions into
|
||||
* SpringLayout object because this code is to much duplicated on many projects.
|
||||
*
|
||||
* A 1.4 file that provides utility methods for creating form- or grid-style
|
||||
* layouts with SpringLayout. These utilities are used by several programs, such
|
||||
* as SpringBox and SpringCompactGrid.
|
||||
*/
|
||||
public class SpringLayoutGrid {
|
||||
|
||||
|
||||
/**
|
||||
* Aligns the first <code>rows</code>*<code>cols</code> components of
|
||||
* <code>parent</code> in a grid. Each component is as big as the maximum
|
||||
* preferred width and height of the components. The parent is made just big
|
||||
* enough to fit them all.
|
||||
*
|
||||
* @param rows
|
||||
* number of rows
|
||||
* @param cols
|
||||
* number of columns
|
||||
* @param initialX
|
||||
* x location to start the grid at
|
||||
* @param initialY
|
||||
* y location to start the grid at
|
||||
* @param xPad
|
||||
* x padding between cells
|
||||
* @param yPad
|
||||
* y padding between cells
|
||||
*/
|
||||
public static void makeGrid(Container parent, int rows, int cols,int initialX, int initialY, int xPad, int yPad) {
|
||||
SpringLayout layout;
|
||||
try {
|
||||
layout = (SpringLayout) parent.getLayout();
|
||||
} catch (ClassCastException exc) {
|
||||
throw new IllegalArgumentException("parent container has not StringLayout layoutmanager.");
|
||||
}
|
||||
|
||||
Spring xPadSpring = Spring.constant(xPad);
|
||||
Spring yPadSpring = Spring.constant(yPad);
|
||||
Spring initialXSpring = Spring.constant(initialX);
|
||||
Spring initialYSpring = Spring.constant(initialY);
|
||||
int max = rows * cols;
|
||||
|
||||
//Calculate Springs that are the max of the width/height so that all
|
||||
//cells have the same size.
|
||||
Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0))
|
||||
.getWidth();
|
||||
Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0))
|
||||
.getWidth();
|
||||
for (int i = 1; i < max; i++) {
|
||||
SpringLayout.Constraints cons = layout.getConstraints(parent
|
||||
.getComponent(i));
|
||||
|
||||
maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
|
||||
maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
|
||||
}
|
||||
|
||||
//Apply the new width/height Spring. This forces all the
|
||||
//components to have the same size.
|
||||
for (int i = 0; i < max; i++) {
|
||||
SpringLayout.Constraints cons = layout.getConstraints(parent
|
||||
.getComponent(i));
|
||||
|
||||
cons.setWidth(maxWidthSpring);
|
||||
cons.setHeight(maxHeightSpring);
|
||||
}
|
||||
|
||||
//Then adjust the x/y constraints of all the cells so that they
|
||||
//are aligned in a grid.
|
||||
SpringLayout.Constraints lastCons = null;
|
||||
SpringLayout.Constraints lastRowCons = null;
|
||||
for (int i = 0; i < max; i++) {
|
||||
SpringLayout.Constraints cons = layout.getConstraints(parent
|
||||
.getComponent(i));
|
||||
if (i % cols == 0) { //start of new row
|
||||
lastRowCons = lastCons;
|
||||
cons.setX(initialXSpring);
|
||||
} else { //x position depends on previous component
|
||||
cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST),
|
||||
xPadSpring));
|
||||
}
|
||||
|
||||
if (i / cols == 0) { //first row
|
||||
cons.setY(initialYSpring);
|
||||
} else { //y position depends on previous row
|
||||
cons.setY(Spring.sum(lastRowCons
|
||||
.getConstraint(SpringLayout.SOUTH), yPadSpring));
|
||||
}
|
||||
lastCons = cons;
|
||||
}
|
||||
|
||||
//Set the parent's size.
|
||||
SpringLayout.Constraints pCons = layout.getConstraints(parent);
|
||||
pCons.setConstraint(SpringLayout.SOUTH, Spring.sum(Spring
|
||||
.constant(yPad), lastCons.getConstraint(SpringLayout.SOUTH)));
|
||||
pCons.setConstraint(SpringLayout.EAST, Spring.sum(
|
||||
Spring.constant(xPad), lastCons
|
||||
.getConstraint(SpringLayout.EAST)));
|
||||
}
|
||||
|
||||
/* Used by makeCompactGrid. */
|
||||
private static SpringLayout.Constraints getConstraintsForCell(int row,
|
||||
int col, Container parent, int cols) {
|
||||
SpringLayout layout = (SpringLayout) parent.getLayout();
|
||||
Component c = parent.getComponent(row * cols + col);
|
||||
return layout.getConstraints(c);
|
||||
}
|
||||
|
||||
|
||||
public static void makeCompactGrid(Container parent, int rows, int cols) {
|
||||
makeCompactGrid(parent,rows,cols,6,6,6,6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aligns the first <code>rows</code>*<code>cols</code> components of
|
||||
* <code>parent</code> in a grid. Each component in a column is as wide as
|
||||
* the maximum preferred width of the components in that column; height is
|
||||
* similarly determined for each row. The parent is made just big enough to
|
||||
* fit them all.
|
||||
*
|
||||
* @param rows
|
||||
* number of rows
|
||||
* @param cols
|
||||
* number of columns
|
||||
* @param initialX
|
||||
* x location to start the grid at
|
||||
* @param initialY
|
||||
* y location to start the grid at
|
||||
* @param xPad
|
||||
* x padding between cells
|
||||
* @param yPad
|
||||
* y padding between cells
|
||||
*/
|
||||
public static void makeCompactGrid(Container parent, int rows, int cols,int initialX, int initialY, int xPad, int yPad) {
|
||||
SpringLayout layout;
|
||||
try {
|
||||
layout = (SpringLayout) parent.getLayout();
|
||||
} catch (ClassCastException exc) {
|
||||
throw new IllegalArgumentException("parent container has not StringLayout layoutmanager.");
|
||||
}
|
||||
|
||||
//Align all cells in each column and make them the same width.
|
||||
Spring x = Spring.constant(initialX);
|
||||
for (int c = 0; c < cols; c++) {
|
||||
Spring width = Spring.constant(0);
|
||||
for (int r = 0; r < rows; r++) {
|
||||
width = Spring.max(width, getConstraintsForCell(r, c, parent,
|
||||
cols).getWidth());
|
||||
}
|
||||
for (int r = 0; r < rows; r++) {
|
||||
SpringLayout.Constraints constraints = getConstraintsForCell(r,
|
||||
c, parent, cols);
|
||||
constraints.setX(x);
|
||||
constraints.setWidth(width);
|
||||
}
|
||||
x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
|
||||
}
|
||||
|
||||
//Align all cells in each row and make them the same height.
|
||||
Spring y = Spring.constant(initialY);
|
||||
for (int r = 0; r < rows; r++) {
|
||||
Spring height = Spring.constant(0);
|
||||
for (int c = 0; c < cols; c++) {
|
||||
height = Spring.max(height, getConstraintsForCell(r, c, parent,
|
||||
cols).getHeight());
|
||||
}
|
||||
for (int c = 0; c < cols; c++) {
|
||||
SpringLayout.Constraints constraints = getConstraintsForCell(r,
|
||||
c, parent, cols);
|
||||
constraints.setY(y);
|
||||
constraints.setHeight(height);
|
||||
}
|
||||
y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
|
||||
}
|
||||
|
||||
//Set the parent's size.
|
||||
SpringLayout.Constraints pCons = layout.getConstraints(parent);
|
||||
pCons.setConstraint(SpringLayout.SOUTH, y);
|
||||
pCons.setConstraint(SpringLayout.EAST, x);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui.load;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import org.eobjects.metamodel.jdbc.JdbcDataContext;
|
||||
import org.eobjects.metamodel.mongodb.MongoDbDataContext;
|
||||
|
||||
import net.forwardfire.vasc.demo.server.ui.JFireBorder;
|
||||
import net.forwardfire.vasc.demo.server.ui.ServerGuiApplication;
|
||||
|
||||
/**
|
||||
* JLoadDialog mini wizzard for loading.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class JLoadDialog extends JDialog implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -8638394652416472734L;
|
||||
private JButton prev = null;
|
||||
private JButton next = null;
|
||||
private JButton cancel = null;
|
||||
private List<LoadStep> steps = null;
|
||||
private int currentStep = 0;
|
||||
private LoadStepData model = null;
|
||||
private JPanel centerPanel = null;
|
||||
private JLabel topLabel = null;
|
||||
|
||||
public enum LoadType {
|
||||
CSV,
|
||||
JDBC,
|
||||
MONGODB
|
||||
}
|
||||
|
||||
public JLoadDialog(Frame aFrame,LoadType type) {
|
||||
setTitle("Load Edit Data");
|
||||
setIconImage(ServerGuiApplication.getInstance().getServerIcon().getImage());
|
||||
setMinimumSize(new Dimension(640,400));
|
||||
setPreferredSize(new Dimension(640,400));
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent we) {
|
||||
clearAndHide();
|
||||
}
|
||||
});
|
||||
JPanel mainPanel = new JPanel();
|
||||
// mainPanel.setBorder();
|
||||
// mainPanel.setLayout(new SpringLayout());
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
mainPanel.add(createPanelTop(),BorderLayout.PAGE_START);
|
||||
|
||||
JPanel wrap = new JPanel();
|
||||
wrap.setLayout(new GridLayout(1,1));
|
||||
wrap.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
||||
|
||||
centerPanel = new JPanel();
|
||||
//centerPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
centerPanel.setLayout(new GridLayout(1,1));
|
||||
centerPanel.setBorder(new JFireBorder(null,centerPanel));
|
||||
|
||||
wrap.add(centerPanel);
|
||||
mainPanel.add(wrap,BorderLayout.CENTER);
|
||||
|
||||
model = new LoadStepData();
|
||||
steps = new ArrayList<LoadStep>(10);
|
||||
|
||||
switch(type) {
|
||||
case CSV:
|
||||
break;
|
||||
case JDBC:
|
||||
steps.add(new JLoadStepMetaJdbc());
|
||||
break;
|
||||
case MONGODB:
|
||||
steps.add(new JLoadStepMetaMongodb());
|
||||
break;
|
||||
}
|
||||
steps.add(new JLoadStepSelectTables());
|
||||
steps.add(new JLoadStepMiscInfo());
|
||||
steps.add(new JLoadStepWriteFile());
|
||||
|
||||
centerPanel.add(steps.get(0).getPanel());
|
||||
|
||||
mainPanel.add(createPanelBottom(),BorderLayout.PAGE_END);
|
||||
//SpringLayoutGrid.makeCompactGrid(mainPanel, 3, 1,6,6,6,6);
|
||||
getContentPane().add(mainPanel);
|
||||
pack();
|
||||
setLocationRelativeTo(aFrame);
|
||||
}
|
||||
|
||||
public void clearAndHide() {
|
||||
setVisible(false);
|
||||
|
||||
// clean up connection
|
||||
if (model.dc instanceof JdbcDataContext) {
|
||||
JdbcDataContext dc = (JdbcDataContext)model.dc;
|
||||
try {
|
||||
dc.getConnection().close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (model.dc instanceof MongoDbDataContext) {
|
||||
MongoDbDataContext dc = (MongoDbDataContext)model.dc;
|
||||
dc.getMongoDb().getMongo().close();
|
||||
}
|
||||
}
|
||||
|
||||
public JPanel createPanelTop() {
|
||||
JPanel top = new JPanel();
|
||||
top.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
||||
top.setLayout(new GridLayout(1,1));
|
||||
JPanel wrap = new JPanel();
|
||||
wrap.setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
wrap.setBorder(new JFireBorder("Load",top));
|
||||
topLabel = new JLabel("Load data to edit...");
|
||||
wrap.add(topLabel);
|
||||
top.add(wrap);
|
||||
return top;
|
||||
}
|
||||
|
||||
public JPanel createPanelBottom() {
|
||||
JPanel bottom = new JPanel();
|
||||
bottom.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
|
||||
prev = new JButton("Prev");
|
||||
next = new JButton("Next");
|
||||
cancel = new JButton("Cancel");
|
||||
|
||||
prev.addActionListener(this);
|
||||
next.addActionListener(this);
|
||||
cancel.addActionListener(this);
|
||||
|
||||
prev.setEnabled(false);
|
||||
|
||||
bottom.add(prev);
|
||||
bottom.add(next);
|
||||
bottom.add(cancel);
|
||||
|
||||
return bottom;
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource().equals(prev)) {
|
||||
gotoStepPrev();
|
||||
} else if (e.getSource().equals(next)) {
|
||||
gotoStepNext();
|
||||
} if (e.getSource().equals(cancel)) {
|
||||
clearAndHide();
|
||||
}
|
||||
}
|
||||
|
||||
public void gotoStepPrev() {
|
||||
if (currentStep <= 0) {
|
||||
return;
|
||||
}
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
try {
|
||||
currentStep--;
|
||||
centerPanel.removeAll();
|
||||
LoadStep step = steps.get(currentStep);
|
||||
centerPanel.add(step.getPanel());
|
||||
topLabel.setText(step.getStepTitle());
|
||||
step.setupStep(model);
|
||||
SwingUtilities.updateComponentTreeUI(centerPanel);
|
||||
if (currentStep==0) {
|
||||
prev.setEnabled(false);
|
||||
}
|
||||
next.setText("Next");
|
||||
} finally {
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
}
|
||||
|
||||
public void gotoStepNext() {
|
||||
if (currentStep == steps.size()-1) {
|
||||
// perform last step
|
||||
LoadStep step = steps.get(currentStep);
|
||||
boolean result = step.performStep(model);
|
||||
if (result==false) {
|
||||
return;
|
||||
}
|
||||
clearAndHide();
|
||||
return;
|
||||
}
|
||||
if (currentStep > steps.size()-1) {
|
||||
return;
|
||||
}
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
try {
|
||||
LoadStep step = steps.get(currentStep);
|
||||
boolean result = step.performStep(model);
|
||||
if (result==false) {
|
||||
return;
|
||||
}
|
||||
currentStep++;
|
||||
centerPanel.removeAll();
|
||||
step = steps.get(currentStep);
|
||||
centerPanel.add(step.getPanel());
|
||||
topLabel.setText(step.getStepTitle());
|
||||
step.setupStep(model);
|
||||
SwingUtilities.updateComponentTreeUI(centerPanel);
|
||||
if (currentStep==steps.size()-1) {
|
||||
next.setText("Finish");
|
||||
}
|
||||
prev.setEnabled(true);
|
||||
} finally {
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui.load;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextCsv;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry;
|
||||
|
||||
/**
|
||||
* JDialogMetaCsv Add and runs MetaModel Schema Auto Entry code.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class JLoadStepMetaCsv extends JPanel implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -8638394652416472734L;
|
||||
|
||||
public JLoadStepMetaCsv(Frame aFrame) {
|
||||
//setTitle("Add csv file");
|
||||
setMinimumSize(new Dimension(640,480));
|
||||
setPreferredSize(new Dimension(999,666));
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
//mainPanel.add(createPanelTop(),BorderLayout.NORTH);
|
||||
mainPanel.add(createPanelCenter(),BorderLayout.CENTER);
|
||||
//mainPanel.add(createPanelBottom(),BorderLayout.SOUTH);
|
||||
add(mainPanel);
|
||||
}
|
||||
|
||||
public void clearAndHide() {
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
public JPanel createPanelCenter() {
|
||||
JPanel result = new JPanel();
|
||||
//result.setLayout(new SpringLayout());
|
||||
|
||||
result.add(new JLabel("File"));
|
||||
JButton fileButton = new JButton("Open");
|
||||
fileButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final JFileChooser fc = new JFileChooser();
|
||||
int returnVal = fc.showOpenDialog((JButton)e.getSource());
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fc.getSelectedFile();
|
||||
MetaModelDataContextCsv ds = new MetaModelDataContextCsv();
|
||||
ds.setFile(file.getAbsolutePath());
|
||||
|
||||
MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry();
|
||||
schema.setDataContextProvider(ds);
|
||||
schema.setEntryPrefix(file.getName());
|
||||
//schema.autoCreateEntries(VascTechDemoStartup.getInstance().getVascControllerService().getVascController());
|
||||
//VascTechDemoStartup.getInstance().getVascControllerService().fireChangeEvent();
|
||||
}
|
||||
}
|
||||
});
|
||||
result.add(fileButton);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui.load;
|
||||
|
||||
import java.awt.FlowLayout;
|
||||
import java.sql.Connection;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
import org.eobjects.metamodel.jdbc.JdbcDataContext;
|
||||
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc;
|
||||
import net.forwardfire.vasc.demo.server.ui.SpringLayoutGrid;
|
||||
|
||||
/**
|
||||
* JDialogMetaJdbc Add and runs MetaModel Schema Auto Entry code.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class JLoadStepMetaJdbc extends JPanel implements LoadStep {
|
||||
|
||||
private static final long serialVersionUID = -8638394652416472734L;
|
||||
private JComboBox driverClassBox = null;
|
||||
private JTextField connectUrlField = null;
|
||||
private JTextField usernameField = null;
|
||||
private JTextField passwordField = null;
|
||||
|
||||
|
||||
public JLoadStepMetaJdbc() {
|
||||
setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
add(createPanelCenter());
|
||||
}
|
||||
|
||||
public String getStepTitle() {
|
||||
return "Connect to database.";
|
||||
}
|
||||
|
||||
public JPanel getPanel() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public JPanel createPanelCenter() {
|
||||
JPanel result = new JPanel();
|
||||
result.setLayout(new SpringLayout());
|
||||
|
||||
result.add(new JLabel("Driver"));
|
||||
driverClassBox = new JComboBox(new String[] {"org.postgresql.Driver","com.mysql.jdbc.Driver","org.apache.derby.jdbc.EmbeddedDriver","org.hsqldb.jdbcDriver","org.sqlite.JDBC"});
|
||||
driverClassBox.setSelectedIndex(0);
|
||||
result.add(driverClassBox);
|
||||
|
||||
result.add(new JLabel("Url"));
|
||||
connectUrlField = new JTextField("jdbc:postgresql://localhost/dellstore2");
|
||||
result.add(connectUrlField);
|
||||
|
||||
result.add(new JLabel("Username"));
|
||||
usernameField = new JTextField("postgres");
|
||||
result.add(usernameField);
|
||||
|
||||
result.add(new JLabel("Password"));
|
||||
passwordField = new JTextField("postgresql");
|
||||
result.add(passwordField);
|
||||
|
||||
SpringLayoutGrid.makeCompactGrid(result, 4, 2);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setupStep(LoadStepData model) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performStep(LoadStepData model) {
|
||||
String url = connectUrlField.getText();
|
||||
MetaModelDataContextJdbc ds = new MetaModelDataContextJdbc();
|
||||
ds.setDriverClass((String)driverClassBox.getSelectedItem());
|
||||
ds.setConnectUrl(url);
|
||||
ds.setUsername(usernameField.getText());
|
||||
ds.setPassword(passwordField.getText());
|
||||
String dbName = url.substring(url.lastIndexOf('/')+1,url.length());
|
||||
|
||||
try {
|
||||
Connection c = ds.getConnection();
|
||||
c.close();
|
||||
|
||||
if (model.dc instanceof JdbcDataContext) {
|
||||
JdbcDataContext dc = (JdbcDataContext)model.dc;
|
||||
dc.getConnection().close();
|
||||
}
|
||||
|
||||
model.dcProvider = ds;
|
||||
model.dc=ds.getDataContext();
|
||||
model.name=dbName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "Fatal connect error:\n"+e.getMessage(), "Jdbc Connect Error", JOptionPane.ERROR_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui.load;
|
||||
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
import org.eobjects.metamodel.mongodb.MongoDbDataContext;
|
||||
|
||||
import com.mongodb.DB;
|
||||
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextMongodb;
|
||||
import net.forwardfire.vasc.demo.server.ui.SpringLayoutGrid;
|
||||
|
||||
/**
|
||||
* JLoadStepMetaMongodb Add and runs MetaModel Schema Auto Entry code.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class JLoadStepMetaMongodb extends JPanel implements LoadStep,ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -8638394652416472734L;
|
||||
private JTextField hostNameField = null;
|
||||
private JTextField hostPortField = null;
|
||||
private JTextField databaseField = null;
|
||||
|
||||
public JLoadStepMetaMongodb() {
|
||||
setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
add(createPanelCenter());
|
||||
}
|
||||
|
||||
public String getStepTitle() {
|
||||
return "Connect to mongodb.";
|
||||
}
|
||||
|
||||
public JPanel getPanel() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public JPanel createPanelCenter() {
|
||||
JPanel result = new JPanel();
|
||||
result.setLayout(new SpringLayout());
|
||||
|
||||
result.add(new JLabel("Hostname"));
|
||||
hostNameField = new JTextField("localhost",25);
|
||||
result.add(hostNameField);
|
||||
|
||||
result.add(new JLabel("Port"));
|
||||
hostPortField = new JTextField("27017");
|
||||
result.add(hostPortField);
|
||||
|
||||
result.add(new JLabel("Database"));
|
||||
databaseField = new JTextField("lefiona");
|
||||
result.add(databaseField);
|
||||
|
||||
SpringLayoutGrid.makeCompactGrid(result, 3, 2);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void setupStep(LoadStepData model) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performStep(LoadStepData model) {
|
||||
|
||||
MetaModelDataContextMongodb ds = new MetaModelDataContextMongodb();
|
||||
ds.setHostname(hostNameField.getText());
|
||||
ds.setPort(new Integer(hostPortField.getText()));
|
||||
ds.setDatabase(databaseField.getText());
|
||||
|
||||
try {
|
||||
DB mongoDB = ds.getMongodbConnection();
|
||||
mongoDB.getMongo().close();
|
||||
|
||||
if (model.dc instanceof MongoDbDataContext) {
|
||||
MongoDbDataContext dc = (MongoDbDataContext)model.dc;
|
||||
dc.getMongoDb().getMongo().close();
|
||||
}
|
||||
|
||||
model.dcProvider = ds;
|
||||
model.dc=ds.getDataContext();
|
||||
model.name=ds.getDatabase();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "Fatal connect error:\n"+e.getMessage(), "Jdbc Connect Error", JOptionPane.ERROR_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui.load;
|
||||
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
import net.forwardfire.vasc.demo.server.ui.SpringLayoutGrid;
|
||||
|
||||
/**
|
||||
* JLoadStepMiscInfo
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 21, 2012
|
||||
*/
|
||||
public class JLoadStepMiscInfo extends JPanel implements LoadStep {
|
||||
|
||||
private static final long serialVersionUID = -8638394652416472734L;
|
||||
private JTextField filenameField = null;
|
||||
private JTextField groupIdField = null;
|
||||
private JTextField rolesGroupField = null;
|
||||
private JTextField rolesEntryField = null;
|
||||
|
||||
public JLoadStepMiscInfo() {
|
||||
setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
add(createPanelCenter());
|
||||
}
|
||||
|
||||
public String getStepTitle() {
|
||||
return "Select Info";
|
||||
}
|
||||
|
||||
public JPanel getPanel() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public JPanel createPanelCenter() {
|
||||
JPanel result = new JPanel();
|
||||
result.setLayout(new SpringLayout());
|
||||
|
||||
filenameField = new JTextField();
|
||||
groupIdField = new JTextField();
|
||||
rolesGroupField = new JTextField();
|
||||
rolesEntryField = new JTextField();
|
||||
|
||||
result.add(new JLabel("Filename:"));
|
||||
result.add(filenameField);
|
||||
result.add(new JLabel("groupId:"));
|
||||
result.add(groupIdField);
|
||||
result.add(new JLabel("rolesGroup:"));
|
||||
result.add(rolesGroupField);
|
||||
result.add(new JLabel("rolesEntry:"));
|
||||
result.add(rolesEntryField);
|
||||
|
||||
SpringLayoutGrid.makeCompactGrid(result, 4, 2);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setupStep(LoadStepData model) {
|
||||
filenameField.setText(model.name+".xml");
|
||||
groupIdField.setText(model.name);
|
||||
rolesGroupField.setText("login,admin");
|
||||
rolesEntryField.setText("login,admin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performStep(LoadStepData model) {
|
||||
model.filename = filenameField.getText();
|
||||
model.groupId = groupIdField.getText();
|
||||
model.rolesGroup = rolesGroupField.getText();
|
||||
model.rolesEntry = rolesEntryField.getText();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui.load;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SpringLayout;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
|
||||
import net.forwardfire.vasc.demo.server.ui.SpringLayoutGrid;
|
||||
|
||||
|
||||
/**
|
||||
* JLoadStepSelectTables select tables to load.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class JLoadStepSelectTables extends JPanel implements LoadStep {
|
||||
|
||||
private static final long serialVersionUID = -8638394652416472734L;
|
||||
private JTable table = null;
|
||||
private MetaModelTableModel tableModel = null;
|
||||
private DataContext dcOld = null;
|
||||
|
||||
public JLoadStepSelectTables() {
|
||||
setLayout(new SpringLayout());
|
||||
add(createPanelCenter());
|
||||
SpringLayoutGrid.makeCompactGrid(this, 1, 1, 6, 6, 6, 6);
|
||||
}
|
||||
|
||||
public String getStepTitle() {
|
||||
return "Select Tables";
|
||||
}
|
||||
|
||||
public JPanel getPanel() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public JComponent createPanelCenter() {
|
||||
tableModel = new MetaModelTableModel();
|
||||
table = new JTable(tableModel);
|
||||
table.setFillsViewportHeight(true);
|
||||
table.setShowHorizontalLines(true);
|
||||
table.setAutoscrolls(true);
|
||||
//((JComponent) table.getDefaultRenderer(Boolean.class)).setOpaque(true);// let backgroup color work correctly
|
||||
JScrollPane scrollPane = new JScrollPane(table);
|
||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
return scrollPane;
|
||||
}
|
||||
|
||||
public void setupStep(LoadStepData model) {
|
||||
if (model.tables.isEmpty() | (dcOld!=null && dcOld!=model.dc)) {
|
||||
tableModel.setData(Arrays.asList(model.dc.getDefaultSchema().getTableNames()));
|
||||
dcOld = model.dc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean performStep(LoadStepData model) {
|
||||
model.tables.clear();
|
||||
for (TableRow row:tableModel.getData()) {
|
||||
if (row.load) {
|
||||
model.tables.add(row.table);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
class TableRow {
|
||||
String table;
|
||||
boolean load = true;
|
||||
}
|
||||
|
||||
class MetaModelTableModel extends AbstractTableModel {
|
||||
|
||||
private static final long serialVersionUID = 5487313677918103654L;
|
||||
private List<TableRow> data = new ArrayList<TableRow>();
|
||||
|
||||
public void setData(List<String> tables) {
|
||||
data.clear();
|
||||
for (String table:tables) {
|
||||
TableRow row = new TableRow();
|
||||
row.table=table;
|
||||
data.add(row);
|
||||
}
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public List<TableRow> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
if (columnIndex==0) {
|
||||
return String.class;
|
||||
} else {
|
||||
return Boolean.class;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
if (columnIndex==0) {
|
||||
return "TableName";
|
||||
} else {
|
||||
return "Import";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
TableRow row = data.get(rowIndex);
|
||||
if (columnIndex==0) {
|
||||
return row.table;
|
||||
} else {
|
||||
return new Boolean(row.load);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return columnIndex>0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueAt(Object value, int rowIndex, int columnIndex) {
|
||||
if (columnIndex==1) {
|
||||
TableRow row = data.get(rowIndex);
|
||||
if (value instanceof Boolean) {
|
||||
row.load = (Boolean)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui.load;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
import org.x4o.xml.io.sax.ext.ContentWriterXml;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup;
|
||||
import net.forwardfire.vasc.demo.server.ui.SpringLayoutGrid;
|
||||
|
||||
/**
|
||||
* JLoadStepWriteFile writes the file.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 21, 2012
|
||||
*/
|
||||
public class JLoadStepWriteFile extends JPanel implements LoadStep,ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -8638394652416472734L;
|
||||
private JTextArea text = null;
|
||||
|
||||
public JLoadStepWriteFile() {
|
||||
setLayout(new SpringLayout());
|
||||
add(createPanelCenter());
|
||||
SpringLayoutGrid.makeCompactGrid(this, 1, 1, 6, 6, 6, 6);
|
||||
}
|
||||
|
||||
public String getStepTitle() {
|
||||
return "Write xml to file.";
|
||||
}
|
||||
|
||||
public JPanel getPanel() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public JComponent createPanelCenter() {
|
||||
text = new JTextArea(13,45);
|
||||
text.setAutoscrolls(true);
|
||||
JScrollPane scrollPane = new JScrollPane(text);
|
||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
return scrollPane;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void setupStep(LoadStepData model) {
|
||||
try {
|
||||
VascController vc = VascTechDemoStartup.getInstance().getVascControllerService().getVascController();
|
||||
StringWriter out = new StringWriter();
|
||||
ContentWriterXml outXml = new ContentWriterXml(out);
|
||||
LoadVascXmlWriter writer = new LoadVascXmlWriter(outXml,vc);
|
||||
writer.writeXml(model);
|
||||
|
||||
text.setText(out.getBuffer().toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "Fatal error:\n"+e.getMessage(), "Generate xml error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performStep(LoadStepData model) {
|
||||
try {
|
||||
File writeFile = new File("conf/vasc.d/"+model.filename);
|
||||
System.out.println("write to : "+writeFile);
|
||||
Writer out = new OutputStreamWriter(new FileOutputStream(writeFile));
|
||||
out.append(text.getText());
|
||||
out.flush();
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "Fatal error:\n"+e.getMessage(), "Write file error", JOptionPane.ERROR_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* LoadStep are the load wizzard steps.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 21, 2012
|
||||
*/
|
||||
package net.forwardfire.vasc.demo.server.ui.load;
|
||||
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public interface LoadStep {
|
||||
|
||||
JPanel getPanel();
|
||||
|
||||
String getStepTitle();
|
||||
|
||||
void setupStep(LoadStepData model);
|
||||
|
||||
boolean performStep(LoadStepData model);
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui.load;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextProvider;
|
||||
|
||||
/**
|
||||
* LoadStepData Simple model to load wizzard steps.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 21, 2012
|
||||
*/
|
||||
public class LoadStepData {
|
||||
|
||||
public String name = null;
|
||||
public MetaModelDataContextProvider dcProvider = null;
|
||||
public DataContext dc = null;
|
||||
|
||||
public String filename = null;
|
||||
public String groupId = null;
|
||||
public String rolesGroup = null;
|
||||
public String rolesEntry = null;
|
||||
public List<String> tables = new ArrayList<String>();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.ui.load;
|
||||
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextMongodb;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelVascBackend;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascEntryFieldType;
|
||||
import net.forwardfire.vasc.core.VascEntryLink;
|
||||
import net.forwardfire.vasc.core.VascEntryLinkType;
|
||||
import net.forwardfire.vasc.impl.ui.VascSelectItemModelEntry;
|
||||
|
||||
import org.x4o.xml.io.sax.ext.ContentWriterXml;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.ext.DefaultHandler2;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
/**
|
||||
* LoadVascXmlWriter writes the xml tags.
|
||||
* note: need to move this to x4o
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 22, 2012
|
||||
*/
|
||||
public class LoadVascXmlWriter {
|
||||
|
||||
private VascController vc = null;
|
||||
private ContentWriterXml xmlWriter = null;
|
||||
|
||||
static private final String URI_VASC_ROOT = "http://vasc.forwardfire.net/xml/ns/vasc-root";
|
||||
static private final String URI_VASC_LANG = "http://vasc.forwardfire.net/xml/ns/vasc-lang";
|
||||
static private final String URI_META_MODEL = "http://vasc.forwardfire.net/xml/ns/vasc-backend-metamodel";
|
||||
static private final String URI_VASC_DEMO = "http://vasc.forwardfire.net/xml/ns/vasc-tech-demo";
|
||||
|
||||
public LoadVascXmlWriter(ContentWriterXml xmlWriter,VascController vc) {
|
||||
this.xmlWriter=xmlWriter;
|
||||
this.vc=vc;
|
||||
}
|
||||
|
||||
public void writeXml(LoadStepData model) throws SAXException {
|
||||
|
||||
MetaModelSchemaAutoEntry autoEntry = new MetaModelSchemaAutoEntry();
|
||||
autoEntry.setVascGroupId(model.groupId);
|
||||
autoEntry.setEntryPrefix(model.name);
|
||||
autoEntry.setDataContextProvider(model.dcProvider);
|
||||
autoEntry.getTables().addAll(model.tables);
|
||||
|
||||
autoEntry.autoFillResult(vc);
|
||||
|
||||
xmlWriter.startDocument();
|
||||
|
||||
char[] msg;
|
||||
msg = "\n".toCharArray();
|
||||
xmlWriter.ignorableWhitespace(msg,0,msg.length);
|
||||
|
||||
xmlWriter.startPrefixMapping("vasc", URI_VASC_ROOT);
|
||||
xmlWriter.startPrefixMapping("v", URI_VASC_LANG);
|
||||
xmlWriter.startPrefixMapping("mm", URI_META_MODEL);
|
||||
xmlWriter.startPrefixMapping("td", URI_VASC_DEMO);
|
||||
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
xmlWriter.startElement (URI_VASC_ROOT, "root", "", atts);
|
||||
|
||||
msg = "Auto generated vasc xml example.".toCharArray();
|
||||
xmlWriter.comment(msg,0,msg.length);
|
||||
|
||||
writeGroup(model.groupId,model.rolesGroup);
|
||||
writeMetaProvider(model);
|
||||
|
||||
for (MetaModelVascBackend vb:autoEntry.getResultBackends()) {
|
||||
writeEntryBackend(vb,model);
|
||||
}
|
||||
for (VascEntry ve:autoEntry.getResultEntries()) {
|
||||
writeEntry(ve,model);
|
||||
}
|
||||
|
||||
|
||||
xmlWriter.endElement(URI_VASC_ROOT, "root", "");
|
||||
xmlWriter.endDocument();
|
||||
}
|
||||
|
||||
private void writeMetaProvider(LoadStepData model) throws SAXException {
|
||||
AttributesImpl atts = null;
|
||||
if (model.dcProvider instanceof MetaModelDataContextMongodb) {
|
||||
MetaModelDataContextMongodb mongo = (MetaModelDataContextMongodb)model.dcProvider;
|
||||
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "el.id", "", "", model.name+"DC");
|
||||
if (mongo.getHostname()!=null) {
|
||||
atts.addAttribute ("", "hostname", "", "", mongo.getHostname());
|
||||
}
|
||||
if (mongo.getDatabase()!=null) {
|
||||
atts.addAttribute ("", "database", "", "", mongo.getDatabase());
|
||||
}
|
||||
if (mongo.getUsername()!=null) {
|
||||
atts.addAttribute ("", "username", "", "", mongo.getUsername());
|
||||
}
|
||||
if (mongo.getPassword()!=null) {
|
||||
atts.addAttribute ("", "password", "", "", mongo.getPassword());
|
||||
}
|
||||
atts.addAttribute ("", "port", "", "", ""+mongo.getPort());
|
||||
|
||||
xmlWriter.startElement (URI_META_MODEL, "mongodbDataContext", "", atts);
|
||||
xmlWriter.endElement(URI_META_MODEL, "mongodbDataContext", "");
|
||||
|
||||
} else if (model.dcProvider instanceof MetaModelDataContextJdbc) {
|
||||
MetaModelDataContextJdbc jdbc = (MetaModelDataContextJdbc)model.dcProvider;
|
||||
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "name", "", "", "jdbc/load/"+model.name+"DS");
|
||||
atts.addAttribute ("", "auth", "", "", "Container");
|
||||
atts.addAttribute ("", "type", "", "", "javax.sql.DataSource");
|
||||
atts.addAttribute ("", "factory", "", "", "org.apache.tomcat.jdbc.pool.DataSourceFactory");
|
||||
atts.addAttribute ("", "initialSize", "", "", "1");
|
||||
atts.addAttribute ("", "minIdle", "", "", "1");
|
||||
atts.addAttribute ("", "username", "", "", jdbc.getUsername());
|
||||
atts.addAttribute ("", "password", "", "", jdbc.getPassword());
|
||||
atts.addAttribute ("", "driverClassName", "", "", jdbc.getDriverClass());
|
||||
atts.addAttribute ("", "url", "", "", jdbc.getConnectUrl());
|
||||
xmlWriter.startElement (URI_VASC_DEMO, "tomcatResource", "", atts);
|
||||
xmlWriter.endElement(URI_VASC_DEMO, "tomcatResource", "");
|
||||
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "el.id", "", "", model.name+"DC");
|
||||
atts.addAttribute ("", "jndiName", "", "", "java:jdbc/load/"+model.name+"DS");
|
||||
xmlWriter.startElement (URI_META_MODEL, "jndiDataSourceDataContext", "", atts);
|
||||
xmlWriter.endElement(URI_META_MODEL, "jndiDataSourceDataContext", "");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeGroup(String groupId,String roles) throws SAXException {
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "id", "", "", groupId);
|
||||
atts.addAttribute ("", "rolesView", "", "", roles);
|
||||
xmlWriter.startElement (URI_VASC_LANG, "entryGroup", "", atts);
|
||||
xmlWriter.endElement(URI_VASC_LANG, "entryGroup", "");
|
||||
}
|
||||
|
||||
private void writeEntryBackend(MetaModelVascBackend vb,LoadStepData model) throws SAXException {
|
||||
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "id", "", "", vb.getId());
|
||||
atts.addAttribute ("", "dataContextProvider", "", "", "${"+model.name+ "DC}");
|
||||
atts.addAttribute ("", "table", "", "", vb.getTable());
|
||||
atts.addAttribute ("", "tableId", "", "", vb.getTableId());
|
||||
|
||||
xmlWriter.startElement (URI_META_MODEL, "metaModelBackend", "", atts);
|
||||
xmlWriter.endElement(URI_META_MODEL, "metaModelBackend", "");
|
||||
}
|
||||
|
||||
private void writeEntry(VascEntry ve,LoadStepData model) throws SAXException {
|
||||
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "id", "", "", ve.getId());
|
||||
atts.addAttribute ("", "backendId", "", "", ve.getBackendId());
|
||||
atts.addAttribute ("", "primaryKeyFieldId", "", "", ve.getPrimaryKeyFieldId());
|
||||
if (ve.getDisplayNameFieldId()!=null) {
|
||||
atts.addAttribute ("", "displayNameFieldId", "", "", ve.getDisplayNameFieldId());
|
||||
}
|
||||
if (ve.getVascGroupId()!=null) {
|
||||
atts.addAttribute ("", "vascGroupId", "", "", ve.getVascGroupId());
|
||||
}
|
||||
if (ve.getAccessType()!=null) {
|
||||
atts.addAttribute ("", "accessType", "", "", ve.getAccessType().name());
|
||||
}
|
||||
xmlWriter.startElement (URI_VASC_LANG, "entry", "", atts);
|
||||
createFields(ve);
|
||||
|
||||
for (VascEntryLink vel:ve.getVascEntryLinks()) {
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "id", "", "", vel.getId());
|
||||
if (vel.getVascEntryLinkType()!=null && vel.getVascEntryLinkType()!=VascEntryLinkType.DEFAULT_TYPE) {
|
||||
atts.addAttribute ("", "vascEntryLinkType", "", "", ""+vel.getVascEntryLinkType());
|
||||
}
|
||||
atts.addAttribute ("", "vascEntryId", "", "", vel.getVascEntryId());
|
||||
xmlWriter.startElement (URI_VASC_LANG, "link", "", atts);
|
||||
|
||||
for (String key:vel.getEntryParameterFieldIdKeys()) {
|
||||
String value = vel.getEntryParameterFieldId(key);
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "name", "", "", key);
|
||||
atts.addAttribute ("", "valueFieldId", "", "", value);
|
||||
xmlWriter.startElement (URI_VASC_LANG, "linkParameter", "", atts);
|
||||
xmlWriter.endElement(URI_VASC_LANG, "linkParameter", "");
|
||||
}
|
||||
xmlWriter.endElement(URI_VASC_LANG, "link", "");
|
||||
}
|
||||
xmlWriter.endElement(URI_VASC_LANG, "entry", "");
|
||||
}
|
||||
|
||||
private void createFields(VascEntry ve) throws SAXException {
|
||||
for (VascEntryField f:ve.getVascEntryFields()) {
|
||||
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "id", "", "", f.getId());
|
||||
VascEntryFieldType type = f.getVascEntryFieldType();
|
||||
if (type!=null) {
|
||||
atts.addAttribute ("", "vascEntryFieldType", "", "", type.getId());
|
||||
}
|
||||
if (f.getEditReadOnly()!=null) {
|
||||
atts.addAttribute ("", "editReadOnly", "", "", ""+f.getEditReadOnly());
|
||||
}
|
||||
if (f.getDefaultValue()!=null) {
|
||||
atts.addAttribute ("", "defaultValue", "", "", ""+f.getDefaultValue());
|
||||
}
|
||||
if (f.getList()!=null) {
|
||||
atts.addAttribute ("", "list", "", "", ""+f.getList());
|
||||
}
|
||||
if (f.getEdit()!=null) {
|
||||
atts.addAttribute ("", "edit", "", "", ""+f.getEdit());
|
||||
}
|
||||
if (f.getCreate()!=null) {
|
||||
atts.addAttribute ("", "create", "", "", ""+f.getCreate());
|
||||
}
|
||||
|
||||
//atts.addAttribute ("", "vascGroupId", "", "", model.groupId);
|
||||
xmlWriter.startElement (URI_VASC_LANG, "field", "", atts);
|
||||
|
||||
if (type!=null && "ListField".equals(type.getId())) {
|
||||
VascSelectItemModelEntry link = (VascSelectItemModelEntry)type.getDataObject();
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "entryId", "", "", ""+link.getEntryId());
|
||||
atts.addAttribute ("", "displayFieldId", "", "", ""+link.getDisplayFieldId());
|
||||
xmlWriter.startElement (URI_VASC_LANG, "vascSelectItemModel", "", atts);
|
||||
xmlWriter.endElement(URI_VASC_LANG, "vascSelectItemModel", "");
|
||||
}
|
||||
|
||||
|
||||
xmlWriter.endElement(URI_VASC_LANG, "field", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.server.x4o;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup;
|
||||
import net.forwardfire.vasc.demo.server.tomcat.TomcatService;
|
||||
|
||||
import org.apache.catalina.Server;
|
||||
import org.apache.catalina.deploy.ContextResource;
|
||||
import org.apache.catalina.deploy.NamingResources;
|
||||
import org.x4o.xml.element.AbstractElement;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
|
||||
/**
|
||||
* TomcatResourceElement Add a global DataSource to tomcat jndi context.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 13, 2012
|
||||
*/
|
||||
public class TomcatResourceElement extends AbstractElement {
|
||||
|
||||
private Logger logger = Logger.getLogger(TomcatResourceElement.class.getName());
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElement#doElementRun()
|
||||
*/
|
||||
@Override
|
||||
public void doElementRun() throws ElementException {
|
||||
|
||||
// Check needed attributes
|
||||
Map<String,String> attr = getAttributes();
|
||||
if (attr.containsKey("name")==false) {
|
||||
throw new ElementException("No attribute name found.");
|
||||
}
|
||||
if (attr.containsKey("auth")==false) {
|
||||
throw new ElementException("No attribute auth found.");
|
||||
}
|
||||
if (attr.containsKey("type")==false) {
|
||||
throw new ElementException("No attribute type found.");
|
||||
}
|
||||
|
||||
// Set resource object fields.
|
||||
ContextResource resource = new ContextResource();
|
||||
String name = attr.remove("name");
|
||||
resource.setName(name);
|
||||
String auth = attr.remove("auth");
|
||||
resource.setAuth(auth);
|
||||
String type = attr.remove("type");
|
||||
resource.setType(type);
|
||||
String scope = attr.remove("scope");
|
||||
if (scope!=null) {
|
||||
resource.setScope(scope);
|
||||
}
|
||||
String closeMethod = attr.remove("closeMethod");
|
||||
if (closeMethod!=null) {
|
||||
resource.setCloseMethod(closeMethod);
|
||||
}
|
||||
String singleton = attr.remove("singleton");
|
||||
if (singleton!=null) {
|
||||
resource.setSingleton("true".equalsIgnoreCase(singleton));
|
||||
}
|
||||
String description = attr.remove("description");
|
||||
if (description!=null) {
|
||||
resource.setDescription(description);
|
||||
}
|
||||
|
||||
// copy other stuff
|
||||
for (String key:attr.keySet()) {
|
||||
String value = attr.get(key);
|
||||
resource.setProperty(key, value);
|
||||
}
|
||||
|
||||
// add to tomcat
|
||||
TomcatService tm = VascTechDemoStartup.getInstance().getTomcatService();
|
||||
Server server = tm.getServer();
|
||||
NamingResources jndiContext = server.getGlobalNamingResources();
|
||||
jndiContext.addResource(resource);
|
||||
logger.info("Added jndi global resource: "+resource.getName());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
config.charset=UTF-8
|
||||
config.bundles=bundle1,bundle2
|
||||
|
||||
# bundle list to merge and load
|
||||
bundle1.uri=net.forwardfire.vasc.demo.server.ui.resources.ServerGuiApplication
|
||||
|
||||
bundle2.uri=data/vasc-bundle.properties
|
||||
bundle2.type=FILE
|
||||
bundle2.optional=true
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<modules version="1.0"
|
||||
xmlns="http://language.x4o.org/xml/ns/modules"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://language.x4o.org/xml/ns/modules http://language.x4o.org/xml/ns/modules-1.0.xsd"
|
||||
>
|
||||
<language version="1.0">
|
||||
<eld-resource>vasc-tech-demo.eld</eld-resource>
|
||||
</language>
|
||||
</modules>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<root:module
|
||||
xmlns="http://eld.x4o.org/xml/ns/eld-lang"
|
||||
xmlns:root="http://eld.x4o.org/xml/ns/eld-root"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
|
||||
providerHost="vasc.forwardfire.net"
|
||||
providerName="Vasc Tomcat Resource binding"
|
||||
id="vasc-tech-demo"
|
||||
>
|
||||
<namespace uri="http://vasc.forwardfire.net/xml/ns/vasc-tech-demo"
|
||||
schemaUri="http://vasc.forwardfire.net/xml/ns/vasc-tech-demo-1.0.xsd"
|
||||
schemaResource="vasc-tech-demo-1.0.xsd"
|
||||
schemaPrefix="td"
|
||||
name="Vasc Tech Demo"
|
||||
id="ns-vasc-demo-server"
|
||||
>
|
||||
<element tag="tomcatResource" elementClass="net.forwardfire.vasc.demo.server.x4o.TomcatResourceElement"/>
|
||||
</namespace>
|
||||
</root:module>
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
--
|
||||
-- Create vasc demo database.
|
||||
--
|
||||
|
||||
CREATE TABLE vasc_user (
|
||||
id IDENTITY not null primary key,
|
||||
username varchar not null,
|
||||
password varchar not null,
|
||||
description varchar not null,
|
||||
);
|
||||
CREATE UNIQUE INDEX vasc_user_username_idx ON vasc_user(username);
|
||||
|
||||
CREATE TABLE vasc_user_role (
|
||||
id IDENTITY not null primary key,
|
||||
username varchar not null,
|
||||
role varchar not null
|
||||
);
|
||||
CREATE INDEX vasc_user_role_username_idx ON vasc_user_role(username);
|
||||
|
||||
CREATE TABLE vasc_user_change_field (
|
||||
id IDENTITY not null primary key,
|
||||
field varchar not null,
|
||||
name varchar not null,
|
||||
active boolean not null
|
||||
);
|
||||
CREATE INDEX vasc_user_change_field_active_idx ON vasc_user_change_field(active);
|
||||
|
||||
CREATE TABLE vasc_user_change_log (
|
||||
id IDENTITY not null primary key,
|
||||
user_id integer not null,
|
||||
change_field_id integer not null,
|
||||
value_old varchar not null,
|
||||
value_new varchar not null
|
||||
);
|
||||
CREATE INDEX vasc_user_change_log_user_id_idx ON vasc_user_change_log(user_id);
|
||||
CREATE INDEX vasc_user_change_log_id_idx ON vasc_user_change_log(user_id);
|
||||
|
||||
CREATE TABLE vasc_page (
|
||||
id IDENTITY not null primary key,
|
||||
slug varchar not null,
|
||||
title varchar not null,
|
||||
active boolean not null,
|
||||
sitemap boolean not null,
|
||||
roles varchar not null
|
||||
);
|
||||
CREATE INDEX vasc_page_slug_idx ON vasc_page(slug);
|
||||
CREATE INDEX vasc_page_sitemap_idx ON vasc_page(sitemap);
|
||||
|
||||
CREATE TABLE vasc_page_part (
|
||||
id IDENTITY not null primary key,
|
||||
page_id integer not null,
|
||||
title varchar not null,
|
||||
text varchar not null,
|
||||
active boolean not null,
|
||||
sitemap boolean not null,
|
||||
part_order integer not null,
|
||||
part_type varchar not null,
|
||||
roles varchar not null
|
||||
);
|
||||
CREATE INDEX vasc_page_part_page_id_idx ON vasc_page_part(page_id);
|
||||
CREATE INDEX vasc_page_part_active_idx ON vasc_page_part(active);
|
||||
CREATE INDEX vasc_page_part_sitemap_idx ON vasc_page_part(sitemap);
|
||||
|
||||
CREATE TABLE vasc_menu_web (
|
||||
id IDENTITY not null primary key,
|
||||
href varchar not null,
|
||||
title varchar not null,
|
||||
target varchar not null,
|
||||
active BOOLEAN NOT NULL,
|
||||
roles varchar not null,
|
||||
menu_order integer not null,
|
||||
menu_type varchar not null
|
||||
);
|
||||
CREATE INDEX vasc_menu_web_active_idx ON vasc_menu_web(active);
|
||||
CREATE INDEX vasc_menu_web_type_idx ON vasc_menu_web(menu_type);
|
||||
|
||||
--
|
||||
-- Insert demo data.
|
||||
--
|
||||
|
||||
INSERT INTO vasc_user VALUES(1, 'admin','admin123','Demo Admin user');
|
||||
INSERT INTO vasc_user VALUES(2, 'demo', 'demo123', 'Demo user');
|
||||
|
||||
INSERT INTO vasc_user_role VALUES(1, 'admin', 'login');
|
||||
INSERT INTO vasc_user_role VALUES(2, 'admin', 'admin');
|
||||
INSERT INTO vasc_user_role VALUES(3, 'demo', 'login');
|
||||
|
||||
INSERT INTO vasc_user_change_field VALUES(1,'Username', 'username', TRUE);
|
||||
INSERT INTO vasc_user_change_field VALUES(2,'Password', 'password', TRUE);
|
||||
INSERT INTO vasc_user_change_field VALUES(3,'Description', 'description', TRUE);
|
||||
INSERT INTO vasc_user_change_field VALUES(4,'Birthdate', 'date_age', TRUE);
|
||||
|
||||
-- ID SLUG TITLE ATIVE SITEMAP
|
||||
INSERT INTO vasc_page VALUES(1, 'contact', 'Contact', TRUE, TRUE, '');
|
||||
INSERT INTO vasc_page VALUES(2, 'techno', 'Techno', TRUE, TRUE, '');
|
||||
INSERT INTO vasc_page VALUES(3, 'help', 'Help', TRUE, TRUE, '');
|
||||
INSERT INTO vasc_page VALUES(4, 'config', 'Config', TRUE, FALSE, '');
|
||||
|
||||
INSERT INTO vasc_page_part VALUES(1, 1, 'Project', 'The vasc project is build for amazing ease of editing data.', TRUE,TRUE,1,'HTML', '');
|
||||
INSERT INTO vasc_page_part VALUES(2, 1, 'Website', 'VASC: <a href="http://vasc.forwardfire.net">Website</a>', TRUE,TRUE,2,'HTML', '');
|
||||
|
||||
INSERT INTO vasc_page_part VALUES(3, 2, 'Used technologies.', 'Example: XML,JSF,JDBC,etc', TRUE,TRUE,1,'HTML', '');
|
||||
INSERT INTO vasc_page_part VALUES(4, 2, 'Used liberies', 'Todo make long list ?', TRUE,TRUE,2,'HTML', '');
|
||||
|
||||
INSERT INTO vasc_page_part VALUES(5, 3, 'Documenation.', 'See docs directory.', TRUE,TRUE,1,'HTML', '');
|
||||
INSERT INTO vasc_page_part VALUES(6, 3, 'Mailing list.', 'Goto some page to see.', TRUE,TRUE,2,'HTML', '');
|
||||
|
||||
INSERT INTO vasc_page_part VALUES(10, 4, 'Vasc', 'Config entries in conf/vasc.d directory.', TRUE,TRUE,1,'HTML', '');
|
||||
INSERT INTO vasc_page_part VALUES(11, 4, 'Jdbc', 'Config in vasc xml or context.xml', TRUE,TRUE,2,'HTML', '');
|
||||
INSERT INTO vasc_page_part VALUES(12, 4, 'Jndi', 'Example of data source.', TRUE,TRUE,3,'HTML', '');
|
||||
INSERT INTO vasc_page_part VALUES(13, 4, 'Logback', 'Change logging options.', TRUE,TRUE,3,'HTML', '');
|
||||
|
||||
|
||||
|
||||
-- INSERT INTO vasc_page VALUES(1, 'home','home','Welcome to the vasc demo, please login as admin to view all stuff.');
|
||||
|
||||
INSERT INTO vasc_menu_web VALUES(1, '/html/index.jsf','Home', '',true,'' ,1,'BAR_LEFT');
|
||||
INSERT INTO vasc_menu_web VALUES(2, '/html/admin/debug.jsf','Debug','',true,'admin' ,2,'BAR_LEFT');
|
||||
INSERT INTO vasc_menu_web VALUES(3, '/html/admin/index.jsf','Admin','',true,'admin' ,3,'BAR_LEFT');
|
||||
|
||||
INSERT INTO vasc_menu_web VALUES(4, '/html/index.jsf', 'Home', '',true,'' ,1,'BAR_BOTTOM');
|
||||
INSERT INTO vasc_menu_web VALUES(5, '/page/contact', 'Contact', '',true,'' ,2,'BAR_BOTTOM');
|
||||
INSERT INTO vasc_menu_web VALUES(6, '/page/help', 'Help', '',true,'' ,3,'BAR_BOTTOM');
|
||||
INSERT INTO vasc_menu_web VALUES(7, '/page/techno', 'Techno', '',true,'' ,4,'BAR_BOTTOM');
|
||||
|
||||
INSERT INTO vasc_menu_web VALUES(8, '/page/contact', 'Contact', '',true,'' ,1,'BAR_RIGHT');
|
||||
INSERT INTO vasc_menu_web VALUES(9, '/page/help', 'Help', '',true,'' ,2,'BAR_RIGHT');
|
||||
|
||||
INSERT INTO vasc_menu_web VALUES(10, '/html/user/profile.jsf', 'Profile', '',true,'login',4,'MAIN_MENU_0');
|
||||
INSERT INTO vasc_menu_web VALUES(11, '/vasc/VascEntry/list.jsf', 'VascEntries', '',true,'admin',5,'MAIN_MENU_0');
|
||||
|
||||
INSERT INTO vasc_menu_web VALUES(20, '/vasc/AdminVascUser/list.jsf', 'Users', '',true,'admin',4,'PAGE_ADMIN');
|
||||
INSERT INTO vasc_menu_web VALUES(21, '/vasc/AdminVascUserRole/list.jsf', 'UserRoles', '',true,'admin',5,'PAGE_ADMIN');
|
||||
INSERT INTO vasc_menu_web VALUES(22, '/vasc/AdminVascUserChangeField/list.jsf', 'ChangeField', '',true,'admin',5,'PAGE_ADMIN');
|
||||
INSERT INTO vasc_menu_web VALUES(23, '/vasc/AdminVascUserChangeLog/list.jsf', 'ChangeFieldLog', '',true,'admin',5,'PAGE_ADMIN');
|
||||
INSERT INTO vasc_menu_web VALUES(24, '/vasc/AdminVascPage/list.jsf', 'Pages', '',true,'admin',5,'PAGE_ADMIN');
|
||||
INSERT INTO vasc_menu_web VALUES(25, '/vasc/AdminVascPagePart/list.jsf', 'PageParts', '',true,'admin',5,'PAGE_ADMIN');
|
||||
INSERT INTO vasc_menu_web VALUES(26, '/vasc/AdminVascMenu/list.jsf', 'Menu', '',true,'admin',4,'PAGE_ADMIN');
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
#
|
||||
# Copyright (c) 2011, Willem Cazander
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
# the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
# Application's properties
|
||||
Application.name = Vasc Demo Tech
|
||||
Application.title = VascDemoTech
|
||||
Application.vendor = Willem Cazander
|
||||
Application.homepage = http://vasc.forwardfire.org/
|
||||
Application.vendorId = vasc
|
||||
Application.id = vascdemotech
|
||||
Application.lookAndFeel = com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel
|
||||
Application.icon = icon.png
|
||||
|
||||
Application.web.meta.robots = index, follow
|
||||
Application.web.meta.description = Vasc Tech Demo Web Frontends
|
||||
Application.web.meta.keywords = demo,forwardfire,x4o,vasc,java
|
||||
|
||||
Application.web.header.logo.alt = Vasc Tech Demo Logo
|
||||
Application.web.header.login = Login
|
||||
Application.web.header.logout = Logout
|
||||
|
||||
Application.web.footer.center = Vasc Tech Demo Web Based on JSF and Faclets and Richfaces.
|
||||
Application.web.footer.left = Copyright © 2012
|
||||
Application.web.footer.right = Version 0.4.x<i>(beta)</i>
|
||||
|
||||
generic.all = All
|
||||
generic.active.labelText = active
|
||||
generic.active.toolTipText = active
|
||||
generic.createdDate.labelText = createdDate
|
||||
generic.createdDate.toolTipText = createdDate
|
||||
generic.description.labelText = description
|
||||
generic.description.toolTipText = description
|
||||
generic.id.labelText = id
|
||||
generic.id.toolTipText = id
|
||||
generic.modifiedDate.labelText = modifiedDate
|
||||
generic.modifiedDate.toolTipText = modifiedDate
|
||||
generic.name.labelText = name
|
||||
generic.name.toolTipText = name
|
||||
generic.orderNumber.labelText = orderNumber
|
||||
generic.orderNumber.toolTipText = orderNumber
|
||||
|
||||
menu.mainMenu0.title = Menu
|
||||
menu.mainMenu1.title = Menu
|
||||
menu.mainMenu2.title = Menu
|
||||
|
||||
# hibernate validators
|
||||
validator.assertFalse=assertion failed
|
||||
validator.assertTrue=assertion failed
|
||||
validator.future=Date must lie in the future
|
||||
validator.length=Field must contain between {min} and {max} characters.
|
||||
validator.max=Value must be equal to or lower than {value}
|
||||
validator.min=Value must be equal to or higher than {value}
|
||||
validator.notNull=A value must be entered
|
||||
validator.past=Date must lie in the future
|
||||
validator.pattern=Value must conform to "{regex}"
|
||||
validator.range=Value must lie between {min} and {max}
|
||||
validator.size=There must be between {min} and {max} characters
|
||||
validator.email=The value must be a valid e-mail address
|
||||
|
||||
# vasc validators
|
||||
vasc.validator.VascDateFutureValidator=The date must lie in the future.
|
||||
vasc.validator.VascDatePastValidator=The date must lie in the past.
|
||||
vasc.validator.VascIntSizeValidator=Value must lie between {0} and {1}
|
||||
vasc.validator.VascLongSizeValidator=Value must lie between {0} and {1}
|
||||
vasc.validator.VascObjectNotNullValidator=A value must be entered
|
||||
vasc.validator.VascObjectNullValidator=No value may be entered
|
||||
vasc.validator.VascStringEmailValidator=The value must be a valid e-mail address
|
||||
vasc.validator.VascStringLengthValidator=There must be at least {0} and at most {1} items
|
||||
vasc.validator.VascStringRegexValidator=Value must conform to "{0}"
|
||||
vasc.validator.VascStringZipCodeValidator=Value must be a valid post code.
|
||||
|
||||
# Vasc actions labels
|
||||
vasc.action.addRowAction.description = add a new record
|
||||
vasc.action.addRowAction.name = Add
|
||||
vasc.action.deleteRowAction.description = delete
|
||||
vasc.action.deleteRowAction.name = delete
|
||||
vasc.action.downloadAction.description = Select this record.
|
||||
vasc.action.downloadAction.name = Select
|
||||
vasc.action.editRowAction.description = edit
|
||||
vasc.action.editRowAction.name = Edit
|
||||
|
||||
vasc.action.csvExportAction.description = CSV
|
||||
vasc.action.csvExportAction.name = CSV
|
||||
vasc.action.xmlExportAction.description = XML
|
||||
vasc.action.xmlExportAction.name = XML
|
||||
vasc.action.xmltreeExportAction.description = XMLTree
|
||||
vasc.action.xmltreeExportAction.name = XMLTree
|
||||
vasc.action.jrPdfLandscapeExportAction.description = jrPdfLandscape
|
||||
vasc.action.jrPdfLandscapeExportAction.name = PDF-Landscape
|
||||
vasc.action.jrPdfPortraitExportAction.description = jrPdfPortrait
|
||||
vasc.action.jrPdfPortraitExportAction.name = PDF-Portrait
|
||||
vasc.action.jrRtfExportAction.description = RTF
|
||||
vasc.action.jrRtfExportAction.name = RTF
|
||||
vasc.action.jrXlsExportAction.description = XLS
|
||||
vasc.action.jrXlsExportAction.name = XLS
|
||||
vasc.action.jrXmlExportAction.description = JR-XML
|
||||
vasc.action.jrXmlExportAction.name = JR-XML
|
||||
vasc.action.jrCsvExportAction.description = JR-CSV
|
||||
vasc.action.jrCsvExportAction.name = JR-CSV
|
||||
vasc.action.jsonExportAction.description = JSON
|
||||
vasc.action.jsonExportAction.name = JSON
|
||||
|
||||
# Temp jsf
|
||||
generic.vasc.jsf.listOption.header = Searchoptions
|
||||
generic.vasc.jsf.listOption.search = Searh\:
|
||||
generic.vasc.jsf.listOption.sumbit = Search
|
||||
generic.vasc.jsf.pager.previous = Previous
|
||||
generic.vasc.jsf.pager.next = Next
|
||||
generic.vasc.jsf.table.rows = Row Numbers\:
|
||||
generic.vasc.jsf.table.pagerDirect = Go to\:
|
||||
generic.vasc.jsf.table.downloadDirect = Download\:
|
||||
generic.vasc.jsf.table.resultText = Results {0}-{1} from {2} rows
|
||||
generic.vasc.jsf.table.download.img = Save table data.
|
||||
generic.vasc.jsf.table.printer.img = Shows the table in printer friendly format.
|
||||
generic.vasc.jsf.table.export.select = ...
|
||||
generic.vasc.jsf.table.export.select.alt = Select Export
|
||||
generic.vasc.jsf.table.page.select = ...
|
||||
generic.vasc.jsf.table.page.select.alt = Select Page
|
||||
generic.vasc.jsf.table.page.name = Page:
|
||||
generic.vasc.jsf.table.page.description = Goto page:
|
||||
generic.vasc.jsf.tableHeader.fields = Fields
|
||||
generic.vasc.jsf.tableHeader.links = Links
|
||||
generic.vasc.jsf.tableHeader.actions = Actions
|
||||
generic.vasc.jsf.multiAction.selectAll = Select all:
|
||||
generic.vasc.jsf.multiAction.name = ...
|
||||
generic.vasc.jsf.multiAction.description = Select Action
|
||||
generic.vasc.jsf.action.save = Save
|
||||
generic.vasc.jsf.action.cancel = Cancel
|
||||
generic.vasc.jsf.action.back = Back
|
||||
generic.vasc.jsf.parentSelected = Selected:
|
||||
|
||||
vasc.dialog.edit.message = Edit
|
||||
vasc.dialog.save.name = Save
|
||||
vasc.dialog.cancel.name = Cancel
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 264 B |
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
#
|
||||
# yellow-purple color schema from pulsefire.
|
||||
#
|
||||
text=#FF9900
|
||||
info=#9F3B00
|
||||
control=#5B084C
|
||||
nimbusBase=#3A0053
|
||||
nimbusDisabledText=#3A0053
|
||||
nimbusFocus=#FF6600
|
||||
nimbusLightBackground=#47184D
|
||||
nimbusSelectedText=#47184D
|
||||
nimbusBlueGrey=#661C7D
|
||||
nimbusGreen=#D2C122
|
||||
nimbusBorder=#A018D8
|
||||
nimbusSelectionBackground=#BF6204
|
||||
ComboBox.background=#380030
|
||||
TabbedPane.background=#380030
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 400 B |
Loading…
Add table
Add a link
Reference in a new issue