001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * LGPL Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005-2006 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.service;
032:
033: import java.net.*;
034:
035: import javax.net.ssl.*;
036:
037: import de.ug2t.channel.ho.session.*;
038: import de.ug2t.kernel.*;
039:
040: public class HoClientService {
041: private Socket pem_socket = null;
042: private boolean pem_compress = false;
043: private boolean pem_collect = true;
044:
045: private IHoSessionProducer pem_prod = null;
046: private String pem_file = null;
047: private String pem_block = null;
048:
049: public HoClientService(int xPort, String xHost) {
050: try {
051: InetAddress l_remAdr = java.net.InetAddress
052: .getByName(xHost);
053: pem_socket = new Socket(l_remAdr, xPort);
054: pem_socket.setSoTimeout(0);
055: } catch (Exception e) {
056: KeLog.pcmf_logException("ug2t", this , e);
057: }
058: ;
059:
060: return;
061: };
062:
063: public HoClientService(String xProducer, String xFile, String xBlock) {
064: try {
065: this .pem_prod = (IHoSessionProducer) Class.forName(
066: xProducer).newInstance();
067: this .pem_file = xFile;
068: this .pem_block = xBlock;
069: } catch (Exception e) {
070: KeLog.pcmf_logException("ug2t", this , e);
071: }
072: }
073:
074: public HoClientService(int xPort, String xHost, boolean xSSL,
075: boolean xCompress, boolean xCollect) {
076: this .pem_compress = xCompress;
077: this .pem_collect = xCollect;
078:
079: try {
080: InetAddress l_remAdr = java.net.InetAddress
081: .getByName(xHost);
082:
083: // @@
084:
085: pem_socket = new Socket(l_remAdr, xPort);
086: pem_socket.setSoTimeout(0);
087: } catch (Exception e) {
088: KeLog.pcmf_logException("ug2t", this , e);
089: }
090: ;
091:
092: return;
093: };
094:
095: public IHoSession pcmf_getSession() {
096: IHoSession l_session = null;
097:
098: if (pem_prod != null) {
099: l_session = pem_prod
100: .pcmf_produce(pem_file, pem_block, null);
101: } else {
102: l_session = new HoTcpIpSession(pem_socket,
103: this.pem_compress);
104: l_session.pcmf_setCollectReplies(pem_collect);
105: }
106: l_session.start();
107: return (l_session);
108: }
109: }
|