KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > il > jvm > JVMClientIL


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.mq.il.jvm;
23
24 import javax.jms.IllegalStateException JavaDoc;
25 import javax.jms.JMSException JavaDoc;
26
27 import org.jboss.mq.Connection;
28 import org.jboss.mq.ReceiveRequest;
29 import org.jboss.mq.SpyDestination;
30 import org.jboss.mq.il.ClientIL;
31
32 /**
33  * The RMI implementation of the ConnectionReceiver object
34  *
35  * @author Norbert Lataille (Norbert.Lataille@m4x.org)
36  * @author Hiram Chirino (Cojonudo14@hotmail.com)
37  * @version $Revision: 37459 $
38  * @created August 16, 2001
39  */

40 public class JVMClientIL implements ClientIL
41 {
42
43    // A reference to the connection
44
Connection connection;
45    // Are we running
46
boolean stopped = true;
47
48    JVMClientIL(Connection c)
49    {
50       connection = c;
51    }
52
53    /**
54     * #Description of the Method
55     *
56     * @exception Exception Description of Exception
57     */

58    public void close()
59           throws Exception JavaDoc
60    {
61       if (stopped)
62       {
63          throw new IllegalStateException JavaDoc("The client IL is stopped");
64       }
65       connection.asynchClose();
66    }
67
68    //One TemporaryDestination has been deleted
69
/**
70     * #Description of the Method
71     *
72     * @param dest Description of Parameter
73     * @exception JMSException Description of Exception
74     */

75    public void deleteTemporaryDestination(SpyDestination dest)
76           throws JMSException JavaDoc
77    {
78       if (stopped)
79       {
80          throw new IllegalStateException JavaDoc("The client IL is stopped");
81       }
82       connection.asynchDeleteTemporaryDestination(dest);
83    }
84
85    /**
86     * #Description of the Method
87     *
88     * @param messages Description of Parameter
89     * @exception Exception Description of Exception
90     */

91    public void receive(ReceiveRequest messages[])
92           throws Exception JavaDoc
93    {
94       if (stopped)
95       {
96          throw new IllegalStateException JavaDoc("The client IL is stopped");
97       }
98       
99       //copy messages to avoid server side problems when messages are edited client side.
100
for (int i = 0; i < messages.length; i++)
101       {
102          messages[i].message = messages[i].message.myClone();
103       }
104       
105       connection.asynchDeliver(messages);
106    }
107
108    /**
109     * pong method comment.
110     *
111     * @param serverTime Description of Parameter
112     * @exception IllegalStateException Description of Exception
113     */

114    public void pong(long serverTime)
115           throws IllegalStateException JavaDoc
116    {
117       if (stopped)
118       {
119          throw new IllegalStateException JavaDoc("The client IL is stopped");
120       }
121       connection.asynchPong(serverTime);
122    }
123 }
124
Popular Tags