/*
* Created on 21.03.2004
*
* date: 21.03.2004
* project: JmcFrame_all
*
* comment:
*/
package de.ug2t.channel.runtime.swing;
import de.ug2t.channel.ho.service.*;
import de.ug2t.kernel.*;
import de.ug2t.kernel.id.*;
import de.ug2t.unifiedGui.*;
import de.ug2t.unifiedGui.exceptions.*;
import de.ug2t.unifiedGui.interfaces.*;
/**
* @author Dirk
*
* date: 21.03.2004 project: JmcFrame_all
*
* <p>
* ...
* </p>
*/
public class RtSwingServer implements IHoServerContainer
{
private static String pem_file = "environment.xml";
private String pem_initScript = null;
private String pem_initProc = null;
private String pem_initClass = null;
private Object pem_staticInitObj = null;
public RtSwingServer()
{
try
{
KeRegisteredObject.pcmf_registerGlobal(IHoServerContainer.SERVER_CONTAINER, this);
pem_initScript = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "initScript", null);
pem_initProc = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "initProc", null);
pem_initClass = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "initClass", null);
if (pem_initScript != null && pem_initProc != null)
KeEnvironment.pcmf_initScript(pem_initScript, pem_initProc);
try
{
if (pem_initClass != null)
pem_staticInitObj = ((IKeExecutable) Class.forName(pem_initClass).newInstance()).pcmf_execObj(null);
}
catch (Exception e)
{
KeLog.pcmf_log("ug2t", "error creating and calling initClass: " + pem_initClass, this, KeLog.ERROR);
}
// external call
String l_call = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "initCall", null);
;
try
{
if (l_call != null)
Runtime.getRuntime().exec(l_call);
}
catch (Exception e)
{
KeLog.pcmf_log("ug2t", "error executing external call: " + l_call, this, KeLog.ERROR);
}
}
catch (Exception e)
{
KeLog.pcmf_log("ug2t", "error initialising C/S application", this, KeLog.ERROR);
}
}
public void pcmf_crswapp(String xLang) throws Exception
{
String l_factpar = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "FACTORY");
String l_main = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "XML_MAIN");
de.ug2t.unifiedGui.UnApplicationFactory.pcmf_setStandAloneMode(false);
UnComponentFactory l_fact = new UnComponentFactory(l_factpar);
de.ug2t.unifiedGui.UnApplicationFactory l_prod = new de.ug2t.unifiedGui.UnApplicationFactory(l_main, l_fact);
try
{
String l_lang = xLang.toUpperCase();
if (l_lang != null)
{
Object l_langMap = KeEnvironment.pcmf_getParameter("environment.xml", IUnApplication.MY_LANGUAGE, l_lang);
if (l_langMap == null)
l_langMap = KeEnvironment.pcmf_getParameter("environment.xml", IUnApplication.MY_LANGUAGE, "DEFAULT");
KeRegisteredObject.pcmf_register(IUnApplication.MY_LANGUAGE_CODE, l_lang.equals("")?new KeStringWrapper("DEFAULT"):new KeStringWrapper(l_lang));
if (l_langMap == null)
throw (new Exception());
KeRegisteredObject.pcmf_register(IUnApplication.MY_LANGUAGE, new KeStringWrapper(l_langMap.toString()));
KeLog.pcmf_log("ug2t", "set language to: " + l_lang + "=>" + l_langMap, this, KeLog.MESSAGE);
}
}
catch (Exception e)
{
KeLog.pcmf_log("ug2t", "no valid language definition found", this, KeLog.MESSAGE);
}
IUnApplication l_swapp = (IUnApplication) l_prod.pcmf_produce(new Integer(UnComponentFactory.HALFOBJECT));
l_swapp.pcmf_execView();
};
public static void main(String[] args) throws Exception
{
try
{
if (args.length > 0)
pem_file = args[0];
if (args.length > 1)
KeEnvironment.pcmf_setRootDir(args[1]);
else
KeEnvironment.pcmf_setRootDir("./");
if (args.length > 2)
KeEnvironment.pcmf_setTmpDir(KeEnvironment.pcmf_getRootDir() + args[2]);
else
KeEnvironment.pcmf_setTmpDir(KeEnvironment.pcmf_getRootDir() + "tmp");
}
catch (Exception e)
{
KeLog.pcmf_log("N.A.", "error reading command line parameters, assign standard values", null, KeLog.ERROR);
pem_file = "environment.xml";
KeEnvironment.pcmf_setRootDir("./");
KeEnvironment.pcmf_setTmpDir(KeEnvironment.pcmf_getRootDir() + "tmp");
}
String l_idGen = (String)KeEnvironment.pcmf_getParameter(pem_file, "runtime", "IDGEN", null);
if (l_idGen != null)
{
try
{
IKeIDGenerator l_gen = (IKeIDGenerator)Class.forName(l_idGen).newInstance();
KeRegisteredObject.pcmf_setIDGenerator(l_gen);
KeLog.pcmf_log("ug2t", "Setting ID Generator class: " + l_gen, null, KeLog.MESSAGE);
}
catch (Exception e)
{
KeLog.pcmf_logException("ug2t", null, e);
}
}
String l_derror = (String)KeEnvironment.pcmf_getParameter(pem_file, "runtime", "DISPATCH_ERROR_HANDLER", null);
if (l_derror != null)
{
try
{
IUnDispatchExceptionHandler l_dsp = (IUnDispatchExceptionHandler)Class.forName(l_derror).newInstance();
UnComponent.pcmf_setDispatcher(new UnEventDispatcher(l_dsp));
KeLog.pcmf_log("ug2t", "Setting dispatch error handler class: " + l_dsp, null, KeLog.MESSAGE);
}
catch (Exception e)
{
KeLog.pcmf_logException("ug2t", null, e);
}
}
else
UnComponent.pcmf_setDispatcher(new UnEventDispatcher(null));
String log_level_s = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "LOG_LEVEL");
if (log_level_s == null)
log_level_s = "MESSAGE";
String l_logWriter = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "LOG_WRITER");
try
{
if (l_logWriter != null)
KeLog.pcmf_setLogWriter((IKeLogWriter)Class.forName(l_logWriter).newInstance());
}
catch (Exception e)
{
KeLog.pcmf_log("ug2t", "error setting log writer: " + l_logWriter, null, KeLog.ERROR);
}
if (log_level_s.equals("FATAL"))
KeLog.pcmf_setPrio(KeLog.FATAL);
else if (log_level_s.equals("ERROR"))
KeLog.pcmf_setPrio(KeLog.ERROR);
else if (log_level_s.equals("MESSAGE"))
KeLog.pcmf_setPrio(KeLog.MESSAGE);
else if (log_level_s.equals("DEBUG"))
KeLog.pcmf_setPrio(KeLog.DEBUG);
else if (log_level_s.equals("STATISTICS"))
KeLog.pcmf_setPrio(KeLog.STATISTICS);
else if (log_level_s.equals("TRACE"))
KeLog.pcmf_setPrio(KeLog.TRACE);
else if (log_level_s.equals("APPL"))
KeLog.pcmf_setPrio(KeLog.APPL);
else if (log_level_s.equals("SILENT"))
KeLog.pcmf_setPrio(KeLog.SILENT);
// @@
int l_port = Integer.parseInt((String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "PORT"));
String l_comp_str = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "COMPRESS");
String l_ssl_str = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "SSL");
String l_coll_str = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "COLLECT_REPLIES");
String l_rec_str = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "RECORD");
String l_recClass_str = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "RECORDER_CLASS");
boolean l_comp = l_comp_str != null && l_comp_str.toUpperCase().equals("TRUE") ? true : false;
boolean l_ssl = l_ssl_str != null && l_ssl_str.toUpperCase().equals("TRUE") ? true : false;
boolean l_coll = l_coll_str != null && l_coll_str.toUpperCase().equals("FALSE") ? false : true;
boolean l_rec = l_rec_str != null && l_rec_str.toUpperCase().equals("TRUE") ? true : false;
new de.ug2t.channel.ho.service.HoServerService(l_port, l_ssl, l_comp, l_coll, l_recClass_str, l_rec);
String l_cr = (String) KeEnvironment.pcmf_getParameter(pem_file, "RtSwingServer", "CREATE");
if (l_cr == null || l_cr.equals("false"))
new RtSwingServer();
return;
};
public Object pcmf_getStaticInitObj()
{
return (this.pem_staticInitObj);
}
}
|