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.q2.QBeanSupport;
022import org.jpos.util.NameRegistrar;
023import org.jpos.util.NameRegistrar.NotFoundException;
024
025import javax.naming.InitialContext;
026import javax.naming.NamingException;
027import java.rmi.RemoteException;
028
029/**
030 * Remote Space Proxy Adaptor.
031 *
032 * @author Mark Salter
033 * @author Alwyn Schoeman
034 * @version $Revision: 2854 $ $Date: 2010-01-02 10:34:31 +0000 (Sat, 02 Jan 2010) $
035 */
036
037public class QMUXProxyAdaptor 
038    extends QBeanSupport
039    implements QMUXProxyAdaptorMBean
040{
041    private QMUXProxy qmuxproxy = null;
042    private String qmuxName;
043    private QMUX qmux;
044
045    public QMUXProxyAdaptor () {
046        super ();
047    }
048
049    protected void startService () throws RemoteException, NamingException, NotFoundException {
050        qmux = (QMUX) NameRegistrar.get(qmuxName);
051        qmuxproxy = new QMUXProxy(qmux);
052        InitialContext ctx = new InitialContext ();
053        ctx.rebind (getName (), qmuxproxy);
054    }
055
056    protected void stopService () throws NamingException {
057        InitialContext ctx = new InitialContext ();
058        ctx.unbind(getName());
059    }
060    
061    public synchronized void setQmuxName (String muxName) {
062        this.qmuxName = muxName;
063        setAttr (getAttrs (), "qmuxName", muxName);
064        setModified (true);
065    }
066
067    public String getQmuxName () {
068        return qmuxName;
069    }
070
071}
072
073