001/* 002 * jPOS Project [http://jpos.org] 003 * Copyright (C) 2000-2026 jPOS Software SRL 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Affero General Public License as 007 * published by the Free Software Foundation, either version 3 of the 008 * License, or (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Affero General Public License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.jpos.q2.iso; 020 021import org.jpos.core.Configurable; 022import org.jpos.core.Configuration; 023import org.jpos.core.ConfigurationException; 024import org.jpos.iso.ISOException; 025import org.jpos.iso.ISOMsg; 026import org.jpos.iso.ISOResponseListener; 027 028import java.rmi.RemoteException; 029import java.rmi.registry.LocateRegistry; 030import java.rmi.registry.Registry; 031import java.rmi.server.*; 032 033/** 034 * RMI QMUX Proxy 035 * @author Mark Salter 036 * @author Alejandro Revilla 037 * @author Niclas Hedhman 038 * @version $Revision: 2854 $ $Date: 2010-01-02 10:34:31 +0000 (Sat, 02 Jan 2010) $ 039 * @since 1.4.9 040 */ 041public class QMUXProxy implements RemoteQMUX, Configurable { 042 QMUX qmux; 043 private RemoteRef ref; 044 private RemoteStub stub; 045 public QMUXProxy (QMUX qmux) throws RemoteException { 046 super(); 047 this.qmux = qmux; 048 startService (); 049 } 050 private void startService () throws RemoteException 051 { 052 try { 053 LocateRegistry.createRegistry (Registry.REGISTRY_PORT); 054 } catch (ExportException ignored) { 055 // NOPMD registry already exists 056 } 057 stub = UnicastRemoteObject.exportObject (this); 058 ref = stub.getRef(); 059 } 060 public boolean isConnected() { 061 return qmux.isConnected(); 062 } 063 public ISOMsg request(ISOMsg m, long timeout) throws ISOException { 064 return qmux.request(m, timeout); 065 } 066 public void request(ISOMsg m, long timeout, ISOResponseListener rl, 067 Object handBack) throws ISOException { 068 qmux.request(m, timeout, rl, handBack); 069 070 } 071 public void setConfiguration(Configuration cfg) 072 throws ConfigurationException { 073 qmux.setConfiguration(cfg); 074 075 } 076} 077