001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library located in LGPL.txt in the
021: * license directory; if not, write to the
022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023: * Boston, MA 02111-1307, USA.
024: *
025: * If this agreement does not cover your requirements, please contact us
026: * via email to get detailed information about the commercial license
027: * or our service offerings!
028: *
029: */
030: // @@
031: package de.ug2t.channel.ho.session;
032:
033: import java.net.*;
034: import java.util.*;
035:
036: import javax.net.ssl.*;
037:
038: import de.ug2t.kernel.*;
039:
040: public class HoTcpIpSessionProducer implements IHoSessionProducer {
041: protected String pdm_port_str;
042: protected String pdm_host;
043: protected String pdm_comp_str;
044: protected String pdm_ssl_str;
045: protected String pdm_colrep_str;
046: protected String pdm_rec_str;
047: protected String pdm_class_str;
048:
049: public IHoSession pcmf_produce(String xFile, String xBlock,
050: Map xDefault) {
051: try {
052: pdmf_readParams(xFile, xBlock);
053:
054: if (xDefault != null) {
055: if (pdm_comp_str == null)
056: pdm_comp_str = (String) xDefault.get("COMPRESS");
057: if (pdm_port_str == null)
058: pdm_port_str = (String) xDefault.get("PORT");
059: if (pdm_host == null)
060: pdm_host = (String) xDefault.get("HOST");
061: if (pdm_ssl_str == null)
062: pdm_ssl_str = (String) xDefault.get("SSL");
063: if (pdm_comp_str == null)
064: pdm_colrep_str = (String) xDefault
065: .get("COLLECT_REPLIES");
066: if (pdm_rec_str == null)
067: pdm_rec_str = (String) xDefault.get("RECORD");
068: if (pdm_class_str == null)
069: pdm_class_str = (String) xDefault
070: .get("RECORDER_CLASS");
071: }
072:
073: int l_port = Integer.parseInt(pdm_port_str);
074: boolean l_comp = pdm_comp_str != null
075: && pdm_comp_str.equalsIgnoreCase("true") ? true
076: : false;
077: boolean l_ssl = pdm_ssl_str != null
078: && pdm_ssl_str.toUpperCase().equalsIgnoreCase(
079: "true") ? true : false;
080: boolean l_colrep = pdm_colrep_str != null
081: && pdm_colrep_str.toUpperCase().equalsIgnoreCase(
082: "true") ? true : false;
083:
084: InetAddress l_remAdr = java.net.InetAddress
085: .getByName(pdm_host);
086: Socket l_socket = null;
087:
088: // @@
089:
090: l_socket = new Socket(l_remAdr, l_port);
091: l_socket.setSoTimeout(0);
092:
093: boolean l_defaultRec = true;
094: if (pdm_class_str == null)
095: pdm_class_str = "de.ug2t.channel.ho.session.HoToFileSessionRecorder";
096: else
097: l_defaultRec = false;
098:
099: HoTcpIpSession l_session = new HoTcpIpSession(l_socket,
100: l_comp);
101: l_session.pcmf_setCollectReplies(l_colrep);
102: if (pdm_rec_str != null
103: && pdm_rec_str.equalsIgnoreCase("true")) {
104: IHoSessionRecorder l_rec = (IHoSessionRecorder) Class
105: .forName(pdm_class_str).newInstance();
106: l_rec.pcmf_setSession(l_session);
107: l_session.pcmf_setSessionRecorder(l_rec);
108: l_session.pcmf_record(true);
109: } else if (l_defaultRec == false) {
110: IHoSessionRecorder l_rec = (IHoSessionRecorder) Class
111: .forName(pdm_class_str).newInstance();
112: l_rec.pcmf_setSession(l_session);
113: l_session.pcmf_setSessionRecorder(l_rec);
114: }
115:
116: return (l_session);
117: } catch (Exception e) {
118: KeLog.pcmf_log("ug2t", "error reading parameter", this ,
119: KeLog.ERROR);
120: KeLog.pcmf_logException("ug2t", this , e);
121: }
122:
123: return null;
124: }
125:
126: protected void pdmf_readParams(String xFile, String xBlock)
127: throws Exception {
128: pdm_port_str = (String) KeEnvironment.pcmf_getParameter(xFile,
129: xBlock, "PORT");
130: pdm_host = (String) KeEnvironment.pcmf_getParameter(xFile,
131: xBlock, "HOST");
132: pdm_comp_str = (String) KeEnvironment.pcmf_getParameter(xFile,
133: xBlock, "COMPRESS");
134: pdm_ssl_str = (String) KeEnvironment.pcmf_getParameter(xFile,
135: xBlock, "SSL");
136: pdm_colrep_str = (String) KeEnvironment.pcmf_getParameter(
137: xFile, xBlock, "COLLECT_REPLIES");
138: pdm_rec_str = (String) KeEnvironment.pcmf_getParameter(xFile,
139: xBlock, "RECORD");
140: pdm_class_str = (String) KeEnvironment.pcmf_getParameter(xFile,
141: xBlock, "RECORDER_CLASS");
142: }
143: }
|