001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.mq.il.jvm;
023:
024: import javax.jms.IllegalStateException;
025: import javax.jms.JMSException;
026:
027: import org.jboss.mq.Connection;
028: import org.jboss.mq.ReceiveRequest;
029: import org.jboss.mq.SpyDestination;
030: import org.jboss.mq.il.ClientIL;
031:
032: /**
033: * The RMI implementation of the ConnectionReceiver object
034: *
035: * @author Norbert Lataille (Norbert.Lataille@m4x.org)
036: * @author Hiram Chirino (Cojonudo14@hotmail.com)
037: * @version $Revision: 57198 $
038: * @created August 16, 2001
039: */
040: public class JVMClientIL implements ClientIL {
041:
042: // A reference to the connection
043: Connection connection;
044: // Are we running
045: boolean stopped = true;
046:
047: JVMClientIL(Connection c) {
048: connection = c;
049: }
050:
051: /**
052: * #Description of the Method
053: *
054: * @exception Exception Description of Exception
055: */
056: public void close() throws Exception {
057: if (stopped) {
058: throw new IllegalStateException("The client IL is stopped");
059: }
060: connection.asynchClose();
061: }
062:
063: //One TemporaryDestination has been deleted
064: /**
065: * #Description of the Method
066: *
067: * @param dest Description of Parameter
068: * @exception JMSException Description of Exception
069: */
070: public void deleteTemporaryDestination(SpyDestination dest)
071: throws JMSException {
072: if (stopped) {
073: throw new IllegalStateException("The client IL is stopped");
074: }
075: connection.asynchDeleteTemporaryDestination(dest);
076: }
077:
078: /**
079: * #Description of the Method
080: *
081: * @param messages Description of Parameter
082: * @exception Exception Description of Exception
083: */
084: public void receive(ReceiveRequest messages[]) throws Exception {
085: if (stopped) {
086: throw new IllegalStateException("The client IL is stopped");
087: }
088:
089: //copy messages to avoid server side problems when messages are edited client side.
090: for (int i = 0; i < messages.length; i++) {
091: messages[i].message = messages[i].message.myClone();
092: }
093:
094: connection.asynchDeliver(messages);
095: }
096:
097: /**
098: * pong method comment.
099: *
100: * @param serverTime Description of Parameter
101: * @exception IllegalStateException Description of Exception
102: */
103: public void pong(long serverTime) throws IllegalStateException {
104: if (stopped) {
105: throw new IllegalStateException("The client IL is stopped");
106: }
107: connection.asynchPong(serverTime);
108: }
109: }
|