User: chirino 
  Date: 01/07/10 19:28:34

  Added:       src/main/org/jbossmq/il/oil OILClientIL.java
                        OILClientILService.java OILServerIL.java
                        OILServerILService.java
                        OILServerILServiceMBean.java
  Log:
  This is the il package which now holds interfaces that are more straitfoward to 
understand
  and implement.  Under this package we place the other ils that have been implemented.
  All the ILs are now MBeans and are managed though JMX.
  
  Revision  Changes    Path
  1.1                  jbossmq/src/main/org/jbossmq/il/oil/OILClientIL.java
  
  Index: OILClientIL.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jbossmq.il.oil;
  
  import javax.jms.Destination;
  import javax.jms.JMSException;
  
  import org.jbossmq.ReceiveRequest;
  import org.jbossmq.SpyDestination;
  import org.jbossmq.Connection;
  import org.jbossmq.il.ClientIL;
  
  import java.net.Socket;
  import java.io.ObjectInputStream;
  import java.rmi.RemoteException;
  import java.io.BufferedOutputStream;
  import org.jbossmq.Log;
  import java.io.ObjectOutputStream;
  import java.io.BufferedInputStream;
  import java.net.InetAddress;
  import java.io.IOException;
  
  /**
   *    The RMI implementation of the ConnectionReceiver object
   *      
   *    @author Norbert Lataille ([EMAIL PROTECTED])
   *    @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   *    @version $Revision: 1.1 $
   */
  public class OILClientIL implements ClientIL, java.io.Serializable {
  
  
  
  
  
        public void close() throws Exception {
                checkSocket();
                out.writeByte(m_close);
                waitAnswer();
        }
  
        synchronized public void deleteTemporaryDestination(SpyDestination dest) 
throws Exception
        {
                checkSocket();
                out.writeByte(m_deleteTemporaryDestination);
                out.writeObject(dest);
                waitAnswer();
        }
  
        synchronized public void receive(ReceiveRequest messages[]) throws Exception
        {
                cat.debug("Checking socket");
                checkSocket();
                cat.debug("Writing request");
                out.writeByte(m_receive);
                out.writeObject(messages);
                cat.debug("Waiting for awnser");
                waitAnswer();
                cat.debug("Done");
        }
  
        private InetAddress addr;
        final static org.apache.log4j.Category cat = 
org.apache.log4j.Category.getInstance(OILClientIL.class);
        private transient ObjectInputStream in;
        static final int m_close = 2;
        static final int m_deleteTemporaryDestination = 1;
        static final int m_receive = 3;
        private transient ObjectOutputStream out;
        private int port;
        private transient Socket socket;
  
        OILClientIL(InetAddress addr, int port) {
                this.addr = addr;
                this.port = port;
        }
  
        protected void checkSocket() throws Exception {
                if (socket==null) createConnection();
        }
  
        protected void createConnection() throws RemoteException
        {
                try {                   
                        Log.notice("ConnectionReceiverOILClient is connecting to: 
"+addr.getHostAddress()+":"+port);
                        socket=new Socket(addr,port);
                        out=new ObjectOutputStream(new 
BufferedOutputStream(socket.getOutputStream()));
                        out.flush();
                        in=new ObjectInputStream(new 
BufferedInputStream(socket.getInputStream()));
                } catch (Exception e) {                 
                        Log.error(e);
                        throw new RemoteException("Cannot connect to the 
ConnectionReceiver/Server");
                }
        }
  
        protected void waitAnswer() throws Exception
        {
                Exception throwException=null;
                try {
                        out.reset();
                        out.flush();
                        int val=in.readByte();
                        switch(val) {
                        case 1:                         
                                Exception e=(Exception)in.readObject();
                                throwException = new RemoteException("", e);
                                break;
                        }
                } catch (IOException e) {            
                        throw new RemoteException("Cannot contact the remote 
object",e);
                }
                
                if( throwException != null )
                        throw throwException;
        }
  }
  
  
  1.1                  jbossmq/src/main/org/jbossmq/il/oil/OILClientILService.java
  
  Index: OILClientILService.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jbossmq.il.oil;
  
  import javax.jms.Destination;
  import javax.jms.JMSException;
  
  import org.jbossmq.ReceiveRequest;
  import org.jbossmq.SpyDestination;
  import org.jbossmq.Connection;
  import org.jbossmq.il.ClientIL;
  import org.jbossmq.il.ClientILService;
  
  import java.net.Socket;
  import java.io.ObjectInputStream;
  import java.rmi.RemoteException;
  import org.jbossmq.Log;
  import java.io.BufferedOutputStream;
  import java.io.ObjectOutputStream;
  import java.io.BufferedInputStream;
  import java.net.ServerSocket;
  import java.io.IOException;
  
  /**
   *    The RMI implementation of the ConnectionReceiver object
   *      
   *    @author Norbert Lataille ([EMAIL PROTECTED])
   *    @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   *    @version $Revision: 1.1 $
   */
  public class OILClientILService implements org.jbossmq.il.ClientILService, Runnable {
  
        //the client IL
        OILClientIL clientIL;
  
        /**
         * getClientIL method comment.
         */
        public org.jbossmq.il.ClientIL getClientIL() throws java.lang.Exception {
                return clientIL;
        }
  
        /**
         * init method comment.
         */
        public void init(org.jbossmq.Connection connection, java.util.Properties 
props) throws java.lang.Exception {
                this.connection = connection;
                serverSocket = new ServerSocket(0);
                clientIL= new OILClientIL(java.net.InetAddress.getLocalHost(), 
serverSocket.getLocalPort());
        }
  
        /**
         * start method comment.
         */
        public void start() throws java.lang.Exception {
                
                running = true;
                worker = new Thread(connection.threadGroup, this, 
"UILClientILService");
                worker.setDaemon(true);
                worker.start();         
                
        }
  
        /**
         * 
         */
        public void stop() throws java.lang.Exception {
                running = false;
                worker.interrupt();
        }
  
        //A link on my connection
        private Connection connection;
        // Attributes ----------------------------------------------------
        static final int m_close = 2;
        static final int m_deleteTemporaryDestination = 1;
        static final int m_receive = 3;
        //Should this service be running ?
        private boolean running;
        //The server socket we listen for a connection on
        private ServerSocket serverSocket;
        //The thread that is doing the Socket reading work
        Thread worker;
  
        public void run() {
                Socket socket=null;
                int code = 0;
                ObjectOutputStream out = null;
                ObjectInputStream in = null;
  
                try {
                        Log.log("Waiting for the server to connect to me");
                        // We may close() before we get a connection so we need to
                        // periodicaly check to see if we were !running.
                        serverSocket.setSoTimeout(1000);                        
                        while( socket==null ) {
                                try {                   
                                        socket = serverSocket.accept();
                                } catch (java.io.InterruptedIOException e) {
                                }
                                if( !running )
                                        return;
                        }
                        serverSocket.close();
                        socket.setSoTimeout(30*1000);
                        out = new ObjectOutputStream(new 
BufferedOutputStream(socket.getOutputStream()));
                        out.flush();
                        in = new ObjectInputStream(new 
BufferedInputStream(socket.getInputStream()));
  
                } catch (IOException e) {
                        connection.asynchFailure("Could not initialize the OILClientIL 
Service.", e);
                        return;
                }
  
                while (running) {
  
                        try {
                                Log.log("Waiting for a messgage from the server");
                                code = in.readByte();
                        } catch (java.io.InterruptedIOException e) {
                                continue;
                        } catch (IOException e) {
                                if (!running)
                                        break;
                                        
                                connection.asynchFailure("Connection failure", e);
                                e.printStackTrace();
                                return;
                        }
  
                        try {
  
                                switch (code) {
                                        case m_receive:
                                                
connection.asynchDeliver((org.jbossmq.ReceiveRequest[])in.readObject());
                                                break;
                                        case m_deleteTemporaryDestination:
                                                
connection.asynchDeleteTemporaryDestination((SpyDestination) in.readObject());
                                                break;
                                        case m_close :
                                                connection.asynchClose();
                                                break;
                                        default :
                                                throw new RemoteException("Bad method 
code !");
                                }
  
                                //Everthing was OK
  
                                try {
                                        out.writeByte(0);
                                        out.flush();
                                } catch (IOException e) {
                                        connection.asynchFailure("Connection failure", 
e);
                                        return;
                                }
  
                                
                        } catch (Exception e) {
                                if (!running)
                                        break;
  
                                try {
                                        Log.error(e);
                                        out.writeByte(1);
                                        out.writeObject(e);
                                        out.reset();
                                        out.flush();
                                } catch (IOException e2) {
                                        connection.asynchFailure("Connection failure", 
e2);
                                        return;
                                }
  
                        }
  
                }
                
                try {
                        Log.log("Closing receiver connections.");
                        out.close();
                        in.close();
                } catch (IOException e) {
                        connection.asynchFailure("Connection failure", e);
                        return;
                }
        }
  }
  
  
  1.1                  jbossmq/src/main/org/jbossmq/il/oil/OILServerIL.java
  
  Index: OILServerIL.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jbossmq.il.oil;
  
  import javax.jms.JMSException;
  import javax.jms.Destination;
  import javax.jms.Topic;
  import javax.jms.Queue;
  import javax.jms.TemporaryTopic;
  import javax.jms.TemporaryQueue;
  
  import org.jbossmq.TransactionRequest;
  import org.jbossmq.SpyMessage;
  import org.jbossmq.AcknowledgementRequest;
  import org.jbossmq.SpyDestination;
  import org.jbossmq.ConnectionToken;
  import org.jbossmq.il.ServerIL;
  import org.jbossmq.server.JMSServer;
  
  import org.jbossmq.il.uil.multiplexor.SocketMultiplexor;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.net.InetAddress;
  
  import java.net.Socket;
  import java.io.BufferedOutputStream;
  import java.io.BufferedInputStream;
  
  /**
   *    The JVM implementation of the ServerIL object
   *      
   *    @author Hiram Chirino ([EMAIL PROTECTED])
   *    @author Norbert Lataille ([EMAIL PROTECTED])
   * 
   *    @version $Revision: 1.1 $
   */
  public class OILServerIL implements ServerIL, java.io.Serializable, Cloneable {
  
  
  
        /**
         * Need to clone because there are instance variables tha can get
         * clobbered.  All Multiple connections can NOT share the same JVMServerIL 
object
         */
        public ServerIL cloneServerIL() throws Exception {
                return (ServerIL)clone();
        }
        
        synchronized public void setConnectionToken(ConnectionToken dest) throws 
Exception {
                checkConnection();
                out.writeByte(m_setSpyDistributedConnection);
                out.writeObject(dest);
                waitAnswer();
        }
  
        synchronized public String getID() throws Exception {
                checkConnection();
                out.writeByte(m_getID);
                return (String) waitAnswer();
        }
  
        synchronized public void addMessage(ConnectionToken dc, SpyMessage val) throws 
Exception {
                checkConnection();
                out.writeByte(m_addMessage);
                out.writeObject(val);
                waitAnswer();
        }
  
        synchronized public Topic createTopic(ConnectionToken dc, String dest) throws 
JMSException, Exception {
                checkConnection();
                out.writeByte(m_createTopic);
                out.writeObject(dest);
                return (Topic) waitAnswer();
        }
  
        synchronized public Queue createQueue(ConnectionToken dc, String dest) throws 
JMSException, Exception {
                checkConnection();
                out.writeByte(m_createQueue);
                out.writeObject(dest);
                return (Queue) waitAnswer();
        }
  
        synchronized public void deleteTemporaryDestination(ConnectionToken dc, 
SpyDestination dest) throws JMSException, Exception {
                checkConnection();
                out.writeByte(m_deleteTemporaryDestination);
                out.writeObject(dest);
                waitAnswer();
        }
  
        synchronized public void checkID(String ID) throws JMSException, Exception {
                checkConnection();
                out.writeByte(m_checkID);
                out.writeObject(ID);
                waitAnswer();
        }
  
        synchronized public void connectionClosing(ConnectionToken dc) throws 
JMSException, Exception {
                checkConnection();
                out.writeByte(m_connectionClosing);
                waitAnswer();
        }
  
        synchronized public TemporaryQueue getTemporaryQueue(ConnectionToken dc) 
throws JMSException, Exception {
                checkConnection();
                out.writeByte(m_getTemporaryQueue);
                return (TemporaryQueue) waitAnswer();
        }
  
        synchronized public TemporaryTopic getTemporaryTopic(ConnectionToken dc) 
throws JMSException, Exception {
                checkConnection();
                out.writeByte(m_getTemporaryTopic);
                return (TemporaryTopic) waitAnswer();
        }
  
        synchronized public void acknowledge(ConnectionToken dc, 
AcknowledgementRequest item) throws JMSException, Exception {
                checkConnection();
                out.writeByte(m_acknowledge);
                out.writeObject(item);
                waitAnswer();
        }
  
        synchronized public SpyMessage[] browse(ConnectionToken dc, Destination dest, 
String selector) throws JMSException, Exception {
                checkConnection();
                out.writeByte(m_browse);
                out.writeObject(dest);
                out.writeObject(selector);
                return (SpyMessage[]) waitAnswer();
        }
  
        synchronized public void listenerChange(ConnectionToken dc, int subscriberId, 
boolean state) throws Exception, Exception {
                checkConnection();
                out.writeByte(m_listenerChange);
                out.writeInt(subscriberId);
                out.writeBoolean(state);
                waitAnswer();
        }
  
        synchronized public SpyMessage receive(ConnectionToken dc, int subscriberId, 
long wait) throws Exception, Exception {
                checkConnection();
                out.writeByte(m_receive);
                out.writeInt(subscriberId);
                out.writeLong(wait);
                return (SpyMessage) waitAnswer();
        }
  
        synchronized public void setEnabled(ConnectionToken dc, boolean enabled) 
throws JMSException, Exception {
                checkConnection();
                out.writeByte(m_setEnabled);
                out.writeBoolean(enabled);
                waitAnswer();
        }
  
        synchronized public void unsubscribe(ConnectionToken dc, int subscriptionId ) 
throws JMSException, Exception {
                checkConnection();
                out.writeByte(m_unsubscribe);
                out.writeInt(subscriptionId);
                waitAnswer();
        }
  
        synchronized public String checkUser(String userName, String password) throws 
JMSException, Exception {
                checkConnection();
                out.writeByte(m_checkUser);
                out.writeObject(userName);
                out.writeObject(password);
                return (String)waitAnswer();            
        }
  
        synchronized public void subscribe(ConnectionToken dc, 
org.jbossmq.Subscription s) throws JMSException, Exception {
                checkConnection();
                out.writeByte(m_subscribe);
                out.writeObject(s);
                waitAnswer();
        }
  
        synchronized public void transact(org.jbossmq.ConnectionToken dc, 
TransactionRequest t) throws JMSException, Exception {
                checkConnection();
                out.writeByte(m_transact);
                out.writeObject(t);
                waitAnswer();
        }
  
        protected InetAddress addr;
        protected transient ObjectInputStream in;
        static final int m_acknowledge = 1;
        static final int m_addMessage = 2;
        static final int m_browse = 3;
        static final int m_checkID = 4;
        static final int m_checkUser = 19;
        static final int m_connectionClosing = 5;
        static final int m_createQueue = 6;
        static final int m_createTopic = 7;
        static final int m_deleteTemporaryDestination = 8;
        static final int m_getID = 9;
        static final int m_getTemporaryQueue = 10;
        static final int m_getTemporaryTopic = 11;
        static final int m_listenerChange = 12;
        static final int m_receive = 13;
        static final int m_setEnabled = 14;
        static final int m_setSpyDistributedConnection = 15;
        static final int m_subscribe = 16;
        static final int m_transact = 17;
        static final int m_unsubscribe = 18;
  
        protected transient ObjectOutputStream out;
        //Remote stuff
        protected int port;
  
        protected void checkConnection() throws Exception {
                if (socket == null)
                        createConnection();
        }
  
        public Object clone() throws CloneNotSupportedException {
                return super.clone();
        }
  
        protected void createConnection() throws Exception {
                socket=new Socket(addr,port);
                in=new ObjectInputStream(new 
BufferedInputStream(socket.getInputStream()));
                out=new ObjectOutputStream(new 
BufferedOutputStream(socket.getOutputStream()));
                out.flush();
        }
  
        protected Object waitAnswer() throws Exception {
                out.reset();
                out.flush();
                int val = in.readByte();
                if (val == 0)
                return null;
                if (val == 1) {
                        return in.readObject();
                } else {
                        Exception e = (Exception)in.readObject();
                        throw e;
                }
        }
  
        protected transient Socket socket;
  
        public OILServerIL(InetAddress a, int port) {
                this.addr = a;
                this.port = port;
        }
  }
  
  
  1.1                  jbossmq/src/main/org/jbossmq/il/oil/OILServerILService.java
  
  Index: OILServerILService.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jbossmq.il.oil;
  
  import java.util.Properties;
  import javax.naming.InitialContext;
  import javax.management.*;
  
  import org.jboss.util.ServiceMBeanSupport;
  
  import org.jbossmq.GenericConnectionFactory;
  import org.jbossmq.il.ServerILJMXService;
  import org.jbossmq.il.ServerIL;
  import org.jbossmq.server.JMSServer;
  
  import java.net.Socket;
  import javax.jms.JMSException;
  import javax.jms.Queue;
  import org.jbossmq.SpyMessage;
  import javax.jms.Topic;
  import java.io.ObjectOutputStream;
  import javax.jms.Destination;
  import java.io.BufferedInputStream;
  import java.net.ServerSocket;
  import java.net.InetAddress;
  import org.jbossmq.Subscription;
  import org.jbossmq.ConnectionToken;
  import javax.jms.TemporaryTopic;
  import org.jbossmq.AcknowledgementRequest;
  import org.jbossmq.il.uil.multiplexor.*;
  import java.io.ObjectInputStream;
  import java.rmi.RemoteException;
  import java.io.BufferedOutputStream;
  import javax.jms.TemporaryQueue;
  import org.jbossmq.TransactionRequest;
  import java.io.IOException;
  import org.jbossmq.SpyDestination;
  
  /**
   *    Implements the ServerILJMXService which is used to 
   *  manage the JVM IL.
   *
   *    @author Hiram Chirino ([EMAIL PROTECTED])
   *    @version $Revision: 1.1 $
   */
  public class OILServerILService extends ServerILJMXService implements 
OILServerILServiceMBean, Runnable {
        
        OILServerIL serverIL;
  
        /**
         * Gives this JMX service a name.
         */
        public String getName() {
                return "JBossMQ-OILServerIL";
        }
  
        /**
         * Used to construct the GenericConnectionFactory (bindJNDIReferences() builds 
it)
         *  @returns ServerIL the instance of this IL
         */
        public ServerIL getServerIL() {
                return serverIL;
        }
  
        /**
         * Starts this IL, and binds it to JNDI
         */
        public void startService() throws Exception {
  
                running = true;
                this.server = lookupJMSServer();
  
                serverSocket = new ServerSocket(serverBindPort);
                serverSocket.setSoTimeout(SO_TIMEOUT);
                
                cat.info("JBossMQ OIL service available at : 
"+InetAddress.getLocalHost().getHostAddress()+ ":"+ serverSocket.getLocalPort());
                worker = new Thread(server.threadGroup, this,"OIL Worker");
                worker.start();
                
                serverIL = new OILServerIL(InetAddress.getLocalHost(), 
serverSocket.getLocalPort());
                
                bindJNDIReferences();
  
        }
  
        /**
         * Stops this IL, and unbinds it from JNDI
         */
        public void stopService() {
                try {
                        running = false;
                        unbindJNDIReferences();
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
  
        /**
         * Used to construct the GenericConnectionFactory (bindJNDIReferences() builds 
it)
         * Sets up the connection properties need by a client to use this
         * IL
         */
        public java.util.Properties getClientConnectionProperties() {
                Properties rc= new Properties();
                rc.setProperty(GenericConnectionFactory.CLIENT_IL_SERVICE_KEY, 
"org.jbossmq.il.oil.OILClientILService");
                return rc;
        }
  
        org.apache.log4j.Category cat = 
org.apache.log4j.Category.getInstance(OILServerILService.class);
        static final int m_acknowledge = 1;
        static final int m_addMessage = 2;
        static final int m_browse = 3;
        static final int m_checkID = 4;
        static final int m_checkUser = 19;
        static final int m_connectionClosing = 5;
        static final int m_createQueue = 6;
        static final int m_createTopic = 7;
        static final int m_deleteTemporaryDestination = 8;
        static final int m_getID = 9;
        static final int m_getTemporaryQueue = 10;
        static final int m_getTemporaryTopic = 11;
        static final int m_listenerChange = 12;
        static final int m_receive = 13;
        static final int m_setEnabled = 14;
        static final int m_setSpyDistributedConnection = 15;
        static final int m_subscribe = 16;
        static final int m_transact = 17;
        static final int m_unsubscribe = 18;
        boolean running;
        //The server implementation
        protected static JMSServer server;
        int serverBindPort=0;
        protected ServerSocket serverSocket;
        static final int SO_TIMEOUT = 5000;
        Thread worker;
  
        public void run()
        {
  
                Socket socket = null;
                int code = 0;
                ObjectOutputStream out=null;
                ObjectInputStream in=null;
                ConnectionToken connectionToken=null;
                boolean closed = false;
                      
                try {
                        while( running && socket==null ) {
                                try {
                                socket = serverSocket.accept();
                                } catch ( java.io.InterruptedIOException e ) {
                                }
                        }
                  
                        new Thread(this,"OIL Worker").start();
                        
                        out = new ObjectOutputStream(new 
BufferedOutputStream(socket.getOutputStream()));
                        out.flush();
                        in = new ObjectInputStream(new 
BufferedInputStream(socket.getInputStream()));
  
                } catch (IOException e) {
                        cat.warn("Could not initialize the OILServerIL Service.", e);
                        running = false;
                        return;
                }
  
  
                while (!closed && running) {
  
                        try {
                                
                                //socket.setSoTimeout(SO_TIMEOUT);
                                code=in.readByte();             
                                
                        } catch ( java.io.InterruptedIOException e ) {
                                if( !closed && !running )
                                        continue;
                        } catch (IOException e) {
                                if( closed || !running )
                                        break;
                                        
                                cat.warn("Connection failure (1).", e);
                                break;
                        }
                
                        try {
                                
                                Object result=null;                                    
 
                                
                                switch (code)
                                {
                                        case m_setSpyDistributedConnection:
                                                connectionToken = 
(ConnectionToken)in.readObject();
                                        cat.debug("The UILClientIL Connection is set 
up");
                                                break;                                 
         
                                        case m_acknowledge:
                                                server.acknowledge(connectionToken, 
(AcknowledgementRequest)in.readObject());
                                                break;
                                        case m_addMessage:                             
                 
                                                server.addMessage(connectionToken, 
(SpyMessage)in.readObject());
                                                break;
                                        case m_browse:                                 
         
                                                result=server.browse(connectionToken, 
(Destination)in.readObject(), (String)in.readObject());
                                                break;
                                        case m_checkID: 
                                                
server.checkID((String)in.readObject());
                                                break;
                                        case m_connectionClosing: 
                                                
server.connectionClosing(connectionToken);
                                                closed = true;
                                                break;
                                        case this.m_createQueue: 
                                                
result=(Queue)server.createQueue(connectionToken, (String)in.readObject());
                                                break;
                                        case m_createTopic: 
                                                
result=(Topic)server.createTopic(connectionToken, (String)in.readObject());
                                                break;
                                        case m_deleteTemporaryDestination: 
                                                
server.deleteTemporaryDestination(connectionToken, (SpyDestination)in.readObject());
                                                break;
                                        case this.m_getID: 
                                                result=server.getID();
                                                break;
                                        case m_getTemporaryQueue: 
                                                
result=(TemporaryQueue)server.getTemporaryQueue(connectionToken);
                                                break;
                                        case m_getTemporaryTopic:
                                                
result=(TemporaryTopic)server.getTemporaryTopic(connectionToken);
                                                break;
                                        case m_listenerChange: 
                                                
server.listenerChange(connectionToken,in.readInt(),in.readBoolean());
                                                break;
                                        case m_receive:
                                                
result=server.receive(connectionToken,in.readInt(), in.readLong());
                                                break;
                                        case m_setEnabled :
                                                server.setEnabled(connectionToken, 
in.readBoolean());
                                                break;
                                        case m_subscribe:
                                                server.subscribe(connectionToken, 
(Subscription)in.readObject());
                                                break;
                                        case m_transact:
                                                server.transact(connectionToken, 
(TransactionRequest)in.readObject());
                                                break;
                                        case m_unsubscribe: 
                                                
server.unsubscribe(connectionToken,in.readInt());
                                                break;
                                        case m_checkUser: 
                                                result = 
server.checkUser((String)in.readObject(), (String)in.readObject());
                                                break;
                                        default:
                                                throw new RemoteException("Bad method 
code !");
                                }
                                
                                //Everthing was OK
                                
                                try {
                                        if (result==null) 
                                                out.writeByte(0);
                                        else {
                                                out.writeByte(1);
                                                out.writeObject(result);
                                                out.reset();
                                        }
                                        out.flush();
                                } catch (IOException e) {
                                        if( closed )
                                                break;
                                                
                                        cat.warn("Connection failure (2).", e);
                                        break;                                  
                                }
                                
                        } catch (Exception e) {
                                if( closed )
                                        break;
  
                                try {
                                        out.writeByte(2);
                                        out.writeObject(e);
                                        out.reset();
                                        out.flush();
                                } catch (IOException e2) {
                                        if( closed )
                                                break;
                                                
                                        cat.warn("Connection failure (3).", e);
                                        break;                                  
                                }                               
                        }
                }
  
                try {
                        if( !closed ) {
                                try {
                                        server.connectionClosing(connectionToken);
                                } catch (JMSException e) {
                                }
                        }
                        socket.close();
                } catch (IOException e ) {
                        cat.warn("Connection failure during connection close.", e);
                }
  
        }
  }
  
  
  1.1                  jbossmq/src/main/org/jbossmq/il/oil/OILServerILServiceMBean.java
  
  Index: OILServerILServiceMBean.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jbossmq.il.oil;
  
  import java.lang.Object;
  
  /**
   * This interface is used to define which methods will be exposed
   * via JMX.
   */
  public interface OILServerILServiceMBean extends 
org.jbossmq.il.ServerILJMXServiceMBean
  {
     public static final String OBJECT_NAME = "JBossMQ:service=OILServerIL";
  }
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to