001: /*
002: * Created on 21.03.2004
003: *
004: * date: 21.03.2004
005: * project: JmcFrame_all
006: *
007: * comment:
008: */
009: package de.ug2t.channel.runtime.swing;
010:
011: import java.util.*;
012: import javax.swing.*;
013:
014: import java.awt.*;
015: import java.awt.event.*;
016:
017: import de.ug2t.channel.ho.client.swing.*;
018: import de.ug2t.channel.ho.session.*;
019: import de.ug2t.kernel.*;
020: import de.ug2t.kernel.id.*;
021: import de.ug2t.unifiedGui.*;
022: import de.ug2t.unifiedGui.exceptions.*;
023: import de.ug2t.unifiedGui.interfaces.*;
024: import de.ug2t.xmlScript.*;
025:
026: /**
027: * @author Dirk
028: *
029: * date: 21.03.2004 project: JmcFrame_all
030: *
031: * <p>
032: * ...
033: * </p>
034: */
035: public class RtSwingClient {
036: private static String pem_file = "environment.xml";
037:
038: public static void start() throws Exception {
039: String l_prod_str = (String) KeEnvironment.pcmf_getParameter(
040: pem_file, "RtSwingClient", "COM_PRODUCER");
041: if (l_prod_str == null)
042: l_prod_str = "de.ug2t.channel.ho.session.HoTcpIpSessionProducer";
043:
044: de.ug2t.channel.ho.service.HoClientService client = new de.ug2t.channel.ho.service.HoClientService(
045: l_prod_str, pem_file, "RtSwingClient");
046:
047: String l_service = (String) KeEnvironment.pcmf_getParameter(
048: pem_file, "RtSwingClient", "SERVICE_CLASS");
049: String l_init = (String) KeEnvironment.pcmf_getParameter(
050: pem_file, "RtSwingClient", "SERVICE_INIT");
051: String l_alias = (String) KeEnvironment.pcmf_getParameter(
052: pem_file, "RtSwingClient", "SERVICE_ALIAS");
053: String l_cr = (String) KeEnvironment.pcmf_getParameter(
054: pem_file, "RtSwingClient", "CREATE");
055:
056: // @@
057:
058: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
059: "");
060: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
061: ScXmlScript.pcmf_addProc(l_remCall, null);
062:
063: if (l_cr != null && l_cr.equals("true"))
064: ScXmlScript.pcmf_addDecl(l_remCall, l_alias, l_service,
065: "forever");
066:
067: // @@
068:
069: ScXmlScript.pcmf_addCall(l_remCall, null, l_alias, l_init);
070:
071: String l_lang = (String) KeEnvironment.pcmf_getParameter(
072: pem_file, "RtSwingClient", IUnApplication.MY_LANGUAGE);
073: if (l_lang == null)
074: l_lang = Locale.getDefault().getLanguage();
075:
076: String l_client = (String) KeEnvironment.pcmf_getParameter(
077: pem_file, "RtSwingClient", "RtClientType");
078:
079: ScXmlScript.pcmf_addCallPar(l_remCall, l_lang, "false",
080: "java.lang.String");
081:
082: if (l_client != null)
083: ScXmlScript.pcmf_addCallPar(l_remCall, l_client, "false",
084: "java.lang.String");
085:
086: ScXmlScript.pcmf_endAll(l_remCall);
087:
088: IHoSession l_session = client.pcmf_getSession();
089: l_session.pcmf_setClientSide(true,
090: new HoSwingCommandDispatcher());
091: KeRegisteredObject.pcmf_registerGlobal(IHoSession.SESSION_NAME,
092: l_session);
093:
094: l_session.pcmf_call(l_remCall.toString(), null);
095: };
096:
097: public static void main(String[] args) throws Exception {
098: String log_level_s = null;
099:
100: try {
101: if (args.length > 0)
102: pem_file = args[0];
103:
104: if (args.length > 1)
105: KeEnvironment.pcmf_setRootDir(args[1]);
106: else
107: KeEnvironment.pcmf_setRootDir("./");
108:
109: if (args.length > 2)
110: KeEnvironment.pcmf_setTmpDir(KeEnvironment
111: .pcmf_getRootDir()
112: + args[2]);
113: } catch (Exception e) {
114: KeLog
115: .pcmf_log(
116: "N.A.",
117: "error reading command line parameters, assign standard values",
118: null, KeLog.ERROR);
119: pem_file = "environment.xml";
120: KeEnvironment.pcmf_setRootDir("./");
121: }
122:
123: String l_idGen = (String) KeEnvironment.pcmf_getParameter(
124: pem_file, "runtime", "IDGEN", null);
125: if (l_idGen != null) {
126: try {
127: IKeIDGenerator l_gen = (IKeIDGenerator) Class.forName(
128: l_idGen).newInstance();
129: KeRegisteredObject.pcmf_setIDGenerator(l_gen);
130: KeLog.pcmf_log("ug2t", "Setting ID Generator class: "
131: + l_gen, null, KeLog.MESSAGE);
132: } catch (Exception e) {
133: KeLog.pcmf_logException("ug2t", null, e);
134: }
135: }
136:
137: String l_derror = (String) KeEnvironment.pcmf_getParameter(
138: pem_file, "runtime", "DISPATCH_ERROR_HANDLER", null);
139: if (l_derror != null) {
140: try {
141: IUnDispatchExceptionHandler l_dsp = (IUnDispatchExceptionHandler) Class
142: .forName(l_derror).newInstance();
143: UnComponent.pcmf_setDispatcher(new UnEventDispatcher(
144: l_dsp));
145: KeLog.pcmf_log("ug2t",
146: "Setting dispatch error handler class: "
147: + l_dsp, null, KeLog.MESSAGE);
148: } catch (Exception e) {
149: KeLog.pcmf_logException("ug2t", null, e);
150: }
151: } else
152: UnComponent.pcmf_setDispatcher(new UnEventDispatcher(null));
153:
154: log_level_s = (String) KeEnvironment.pcmf_getParameter(
155: pem_file, "RtSwingClient", "LOG_LEVEL");
156: if (log_level_s == null)
157: log_level_s = "MESSAGE";
158:
159: String l_logWriter = (String) KeEnvironment.pcmf_getParameter(
160: pem_file, "RtSwingClient", "LOG_WRITER");
161: try {
162: if (l_logWriter != null)
163: KeLog.pcmf_setLogWriter((IKeLogWriter) Class.forName(
164: l_logWriter).newInstance());
165: } catch (Exception e) {
166: KeLog.pcmf_log("ug2t", "error setting log writer: "
167: + l_logWriter, null, KeLog.ERROR);
168: }
169:
170: if (log_level_s.equals("FATAL"))
171: KeLog.pcmf_setPrio(KeLog.FATAL);
172: else if (log_level_s.equals("ERROR"))
173: KeLog.pcmf_setPrio(KeLog.ERROR);
174: else if (log_level_s.equals("MESSAGE"))
175: KeLog.pcmf_setPrio(KeLog.MESSAGE);
176: else if (log_level_s.equals("DEBUG"))
177: KeLog.pcmf_setPrio(KeLog.DEBUG);
178: else if (log_level_s.equals("STATISTICS"))
179: KeLog.pcmf_setPrio(KeLog.STATISTICS);
180: else if (log_level_s.equals("TRACE"))
181: KeLog.pcmf_setPrio(KeLog.TRACE);
182: else if (log_level_s.equals("APPL"))
183: KeLog.pcmf_setPrio(KeLog.APPL);
184: else if (log_level_s.equals("SILENT"))
185: KeLog.pcmf_setPrio(KeLog.SILENT);
186:
187: // @@
188:
189: start();
190:
191: return;
192: };
193: }
|