001: /*
002: * Wi.Ser Framework
003: *
004: * Version: 1.8.1, 20-September-2007
005: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public
009: * License as published by the Free Software Foundation; either
010: * version 2 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public
018: * License along with this library located in GPL.txt in the
019: * license directory; if not, write to the
020: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
021: * Boston, MA 02111-1307, USA.
022: *
023: * If this agreement does not cover your requirements, please contact us
024: * via email to get detailed information about the commercial license
025: * or our service offerings!
026: *
027: */
028: package de.ug2t.channel.runtime.swing;
029:
030: import java.awt.*;
031: import java.awt.event.*;
032: import java.util.*;
033:
034: import javax.swing.*;
035:
036: import de.ug2t.channel.ho.client.swing.*;
037: import de.ug2t.channel.ho.session.*;
038: import de.ug2t.kernel.*;
039: import de.ug2t.kernel.id.*;
040: import de.ug2t.unifiedGui.*;
041: import de.ug2t.unifiedGui.exceptions.*;
042: import de.ug2t.unifiedGui.interfaces.*;
043: import de.ug2t.xmlScript.*;
044:
045: public class RtSwingWebStartClient {
046: private static String pem_file = "environment.xml";
047:
048: public static void start() throws Exception {
049: String l_prod_str = (String) KeEnvironment
050: .pcmf_getParameterFromURI(pem_file, "RtSwingClient",
051: "COM_PRODUCER");
052: if (l_prod_str == null)
053: l_prod_str = "de.ug2t.channel.ho.session.HoTcpIpSessionProducer";
054:
055: de.ug2t.channel.ho.service.HoClientService client = new de.ug2t.channel.ho.service.HoClientService(
056: l_prod_str, pem_file, "RtSwingClient");
057:
058: String l_service = (String) KeEnvironment
059: .pcmf_getParameterFromURI(pem_file, "RtSwingClient",
060: "SERVICE_CLASS");
061: String l_init = (String) KeEnvironment
062: .pcmf_getParameterFromURI(pem_file, "RtSwingClient",
063: "SERVICE_INIT");
064: String l_alias = (String) KeEnvironment
065: .pcmf_getParameterFromURI(pem_file, "RtSwingClient",
066: "SERVICE_ALIAS");
067: String l_cr = (String) KeEnvironment.pcmf_getParameterFromURI(
068: pem_file, "RtSwingClient", "CREATE");
069:
070: // @@
071:
072: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
073: "");
074: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
075: ScXmlScript.pcmf_addProc(l_remCall, null);
076:
077: if (l_cr != null && l_cr.equals("true"))
078: ScXmlScript.pcmf_addDecl(l_remCall, l_alias, l_service,
079: "forever");
080:
081: // @@
082:
083: ScXmlScript.pcmf_addCall(l_remCall, null, l_alias, l_init);
084:
085: String l_lang = (String) KeEnvironment
086: .pcmf_getParameterFromURI(pem_file, "RtSwingClient",
087: IUnApplication.MY_LANGUAGE);
088: if (l_lang == null)
089: l_lang = Locale.getDefault().getLanguage();
090:
091: String l_client = (String) KeEnvironment
092: .pcmf_getParameterFromURI(pem_file, "RtSwingClient",
093: "RtClientType");
094:
095: ScXmlScript.pcmf_addCallPar(l_remCall, l_lang, "false",
096: "java.lang.String");
097:
098: if (l_client != null)
099: ScXmlScript.pcmf_addCallPar(l_remCall, l_client, "false",
100: "java.lang.String");
101:
102: ScXmlScript.pcmf_endAll(l_remCall);
103:
104: IHoSession l_session = client.pcmf_getSession();
105: l_session.pcmf_setClientSide(true,
106: new HoSwingCommandDispatcher());
107: KeRegisteredObject.pcmf_registerGlobal(IHoSession.SESSION_NAME,
108: l_session);
109:
110: l_session.pcmf_call(l_remCall.toString(), null);
111: };
112:
113: public static void main(String[] args) throws Exception {
114: String log_level_s = null;
115:
116: try {
117: if (args.length > 0)
118: pem_file = args[0];
119:
120: if (args.length > 1)
121: KeEnvironment.pcmf_setRootDir(args[1]);
122: else
123: KeEnvironment.pcmf_setRootDir("./");
124:
125: if (args.length > 2)
126: KeEnvironment.pcmf_setTmpDir(KeEnvironment
127: .pcmf_getRootDir()
128: + args[2]);
129: } catch (Exception e) {
130: KeLog
131: .pcmf_log(
132: "N.A.",
133: "error reading command line parameters, assign standard values",
134: null, KeLog.ERROR);
135: pem_file = "environment.xml";
136: KeEnvironment.pcmf_setRootDir("./");
137: }
138:
139: String l_idGen = (String) KeEnvironment
140: .pcmf_getParameterFromURI(pem_file, "runtime", "IDGEN");
141: if (l_idGen != null) {
142: try {
143: IKeIDGenerator l_gen = (IKeIDGenerator) Class.forName(
144: l_idGen).newInstance();
145: KeRegisteredObject.pcmf_setIDGenerator(l_gen);
146: KeLog.pcmf_log("ug2t", "Setting ID Generator class: "
147: + l_gen, null, KeLog.MESSAGE);
148: } catch (Exception e) {
149: KeLog.pcmf_logException("ug2t", null, e);
150: }
151: }
152:
153: String l_derror = (String) KeEnvironment
154: .pcmf_getParameterFromURI(pem_file, "runtime",
155: "DISPATCH_ERROR_HANDLER");
156: if (l_derror != null) {
157: try {
158: IUnDispatchExceptionHandler l_dsp = (IUnDispatchExceptionHandler) Class
159: .forName(l_derror).newInstance();
160: UnComponent.pcmf_setDispatcher(new UnEventDispatcher(
161: l_dsp));
162: KeLog.pcmf_log("ug2t",
163: "Setting dispatch error handler class: "
164: + l_dsp, null, KeLog.MESSAGE);
165: } catch (Exception e) {
166: KeLog.pcmf_logException("ug2t", null, e);
167: }
168: } else
169: UnComponent.pcmf_setDispatcher(new UnEventDispatcher(null));
170:
171: log_level_s = (String) KeEnvironment.pcmf_getParameterFromURI(
172: pem_file, "RtSwingClient", "LOG_LEVEL");
173: if (log_level_s == null)
174: log_level_s = "MESSAGE";
175:
176: String l_logWriter = (String) KeEnvironment
177: .pcmf_getParameterFromURI(pem_file, "RtSwingClient",
178: "LOG_WRITER");
179: try {
180: if (l_logWriter != null)
181: KeLog.pcmf_setLogWriter((IKeLogWriter) Class.forName(
182: l_logWriter).newInstance());
183: } catch (Exception e) {
184: KeLog.pcmf_log("ug2t", "error setting log writer: "
185: + l_logWriter, null, KeLog.ERROR);
186: }
187:
188: if (log_level_s.equals("FATAL"))
189: KeLog.pcmf_setPrio(KeLog.FATAL);
190: else if (log_level_s.equals("ERROR"))
191: KeLog.pcmf_setPrio(KeLog.ERROR);
192: else if (log_level_s.equals("MESSAGE"))
193: KeLog.pcmf_setPrio(KeLog.MESSAGE);
194: else if (log_level_s.equals("DEBUG"))
195: KeLog.pcmf_setPrio(KeLog.DEBUG);
196: else if (log_level_s.equals("STATISTICS"))
197: KeLog.pcmf_setPrio(KeLog.STATISTICS);
198: else if (log_level_s.equals("TRACE"))
199: KeLog.pcmf_setPrio(KeLog.TRACE);
200: else if (log_level_s.equals("APPL"))
201: KeLog.pcmf_setPrio(KeLog.APPL);
202: else if (log_level_s.equals("SILENT"))
203: KeLog.pcmf_setPrio(KeLog.SILENT);
204:
205: // @@
206:
207: start();
208:
209: return;
210: };
211: }
|