📄 rmijmssessionstub.java
字号:
/**
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "Exolab" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of Exoffice Technologies. For written permission,
* please contact info@exolab.org.
*
* 4. Products derived from this Software may not be called "Exolab"
* nor may "Exolab" appear in their names without prior written
* permission of Exoffice Technologies. Exolab is a registered
* trademark of Exoffice Technologies.
*
* 5. Due credit should be given to the Exolab Project
* (http://www.exolab.org/).
*
* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 2000-2003 (C) Exoffice Technologies Inc. All Rights Reserved.
*
* $Id: RmiJmsSessionStub.java,v 1.28 2003/08/07 13:32:55 tanderson Exp $
*
* Date Author Changes
* 04/18/2000 jima Created
*/
package org.exolab.jms.client.rmi;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.Vector;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
import org.exolab.jms.client.JmsMessageListener;
import org.exolab.jms.client.JmsQueue;
import org.exolab.jms.client.JmsSessionStubIfc;
import org.exolab.jms.client.JmsTopic;
import org.exolab.jms.server.rmi.RemoteJmsServerSessionIfc;
/**
* This class is repsonsible for managing a reference to a remote session
* object in additon to registering itself as an object, with the RMI
* registry. This object is called back by the JMS Server when it has messages
* for it.
* <p>
* The act that it extends UnicastRemoteObject means that it is a server as
* well as a client to other RMI objects
*
* @version $Revision: 1.28 $ $Date: 2003/08/07 13:32:55 $
* @author <a href="mailto:jima@exoffice.com">Jim Alateras</a>
**/
public class RmiJmsSessionStub
extends UnicastRemoteObject
implements JmsSessionStubIfc, RemoteJmsMessageListenerIfc {
/**
* This is the message listener for JMS messages. The MessageListener is
* then responsible for delivering it to the actual consumer. The listener
* is initialised during object construction time
*/
private JmsMessageListener _listener = null;
/**
* This is a remote reference to the session which is initialised at object
* construction time.
*/
private RemoteJmsServerSessionIfc _delegate = null;
/**
* Instantiate an instance of this class using the specified session stub.
* It must then, immediately following, make a call to set the message
* listener for this session
*
* @param RmiJmsServerSession
* @throws JMSException
* @throws RemoteException
*/
protected RmiJmsSessionStub(RemoteJmsServerSessionIfc session)
throws JMSException, RemoteException {
if (session != null) {
_delegate = session;
} else {
throw new JMSException(
"Cannot create session stub with a null session");
}
}
// implementation of JmsSessionStubIfc.getClientId
public String getClientId() throws JMSException {
try {
return _delegate.getClientId();
} catch (RemoteException exception) {
// rethrow as a JMSException
throw new JMSException("Failed to getClientId " + exception);
}
}
// implementation of JmsSessionStubIfc.getSessionId
public String getSessionId() throws JMSException {
try {
return _delegate.getSessionId();
} catch (RemoteException exception) {
// rethrow as a JMSException
throw new JMSException("Failed to getSessionId " + exception);
}
}
// implementation of JmsSessionStubIfc.beforeClose
public void beforeClose() throws JMSException {
}
// implementation of JmsSessionStubIfc.close
public void close() throws JMSException {
try {
_delegate.close();
UnicastRemoteObject.unexportObject(this, true);
_delegate = null;
_listener = null;
// todo. Jimbo to sort these out.
// _delegate = null;
// _listener = null;
} catch (RemoteException exception) {
// rethrow as a JMSException
throw new JMSException("Failed to close " + exception);
}
}
// implementation of JmsSessionStubIfc.acknowledgeMessage
public void acknowledgeMessage(long clientId, String messageId)
throws JMSException {
try {
// Send back the ack to the consumer endpoint that forwarded the
// message.
_delegate.acknowledgeMessage(clientId, messageId);
} catch (RemoteException exception) {
// rethrow as a JMSException
throw new JMSException("Failed to acknowledgeMessage " +
exception);
}
}
// implementation of JmsSessionStubIfc.sendMessage
public void sendMessage(Message message) throws JMSException {
try {
_delegate.sendMessage(message);
} catch (RemoteException exception) {
// rethrow as a JMSException
throw new JMSException("Failed to sendMessage " + exception);
}
}
// implementation of JmsSessionStubIfc.sendMessages
public void sendMessages(Vector messages) throws JMSException {
try {
_delegate.sendMessages(messages);
} catch (RemoteException exception) {
// rethrow as a JMSException
exception.printStackTrace();
throw new JMSException("Failed to sendMessages " + exception);
}
}
// implementation of JmsSessionStubIfc.sendMessage
public Message receiveMessage(long clientId, long wait)
throws JMSException {
try {
return _delegate.receiveMessage(clientId, wait);
} catch (RemoteException exception) {
// rethrow the JMSException
throw new JMSException("Failed to receiveMessage " + exception);
}
}
// implementation of JmsSessionStubIfc.receiveMessages
public Vector receiveMessages(long clientId, int count)
throws JMSException {
try {
return _delegate.receiveMessages(clientId, count);
} catch (RemoteException exception) {
// rethrow the JMSException
throw new JMSException("Failed to receiveMessages " + exception);
}
}
// implementation of JmsSessionStubIfc.createQueue
public void createQueue(JmsQueue queue) throws JMSException {
try {
_delegate.createQueue(queue);
} catch (RemoteException exception) {
// rethrow as a JMSException
throw new JMSException("Failed to createQueue " + exception);
}
}
// implementation of JmsSessionStubIfc.createTopic
public void createTopic(JmsTopic topic) throws JMSException {
try {
_delegate.createTopic(topic);
} catch (RemoteException exception) {
// rethrow as a JMSException
throw new JMSException("Failed to createTopic " + exception);
}
}
// implementation of JmsSessionStubIfc.createReceiver
public void createReceiver(JmsQueue queue, long clientId, String selector)
throws JMSException {
try {
_delegate.createReceiver(queue, clientId, selector);
} catch (RemoteException exception) {
// rethrow as a JMSException
throw new JMSException("Failed to createReceiver " + exception);
}
}
// implementation of JmsSessionStubIfc.createSender
public void createSender(JmsQueue queue) throws JMSException {
try {
_delegate.createSender(queue);
} catch (RemoteException exception) {
// rethrow as a JMSException
throw new JMSException("Failed to createReceiver " + exception);
}
}
// implementation of JmsSessionStubIfc.createBrowser
public void createBrowser(JmsQueue queue, long clientId, String selector)
throws JMSException {
try {
_delegate.createBrowser(queue, clientId, selector);
} catch (RemoteException exception) {
// rethrow as a JMSException
throw new JMSException("Failed to createBrowser " + exception);
}
}
// implementation of JmsSessionStubIfc.deleteReceiver
public void deleteReceiver(long clientId) throws JMSException {
try {
_delegate.deleteReceiver(clientId);
} catch (RemoteException exception) {
// rethrow as a JMSException
throw new JMSException("Failed to deleteReceiver " + exception);
}
}
// implementation of JmsSessionStubIfc.deleteSender
public void deleteSender(long clientId) throws JMSException {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -