KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > il > oil2 > OIL2ClientIL


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.mq.il.oil2;
8
9 import java.io.IOException JavaDoc;
10
11 import org.jboss.mq.ReceiveRequest;
12 import org.jboss.mq.SpyDestination;
13 import org.jboss.mq.il.ClientIL;
14
15 /**
16  * The OIL2 implementation of the ClientIL object
17  *
18  * @author <a HREF="mailto:hiram.chirino@jboss.org">Hiram Chirino</a>
19  * @version $Revision:$
20  */

21 public final class OIL2ClientIL
22    implements ClientIL,
23       java.io.Serializable JavaDoc
24 {
25    static final long serialVersionUID = -2671278802714517625L;
26    transient OIL2ServerILService.RequestListner requestListner;
27    transient OIL2SocketHandler socketHandler;
28
29    public void setRequestListner(OIL2ServerILService.RequestListner requestListner)
30    {
31       this.requestListner = requestListner;
32       this.socketHandler = requestListner.getSocketHandler();
33    }
34    
35    /**
36     * #Description of the Method
37     *
38     * @exception Exception Description of Exception
39     */

40    public void close()
41           throws Exception JavaDoc
42    {
43       try {
44          
45          OIL2Request request = new OIL2Request(
46             OIL2Constants.CLIENT_CLOSE,
47             null);
48          OIL2Response response = socketHandler.synchRequest(request);
49          response.evalThrowsException();
50          
51       } catch ( IOException JavaDoc ignore ) {
52          // Server closes the socket before we get a response..
53
// this is ok.
54
}
55       
56       // The close request now went full cycle, from the client
57
// to the server, and back from the server to the client.
58
// Close up the requestListner
59
// This will shut down the sockets and threads.
60
requestListner.close();
61    }
62
63    /**
64     * #Description of the Method
65     *
66     * @param dest Description of Parameter
67     * @exception Exception Description of Exception
68     */

69    public void deleteTemporaryDestination(SpyDestination dest)
70           throws Exception JavaDoc
71    {
72       
73       OIL2Request request = new OIL2Request(
74          OIL2Constants.CLIENT_DELETE_TEMPORARY_DESTINATION,
75          new Object JavaDoc[] {dest});
76       OIL2Response response = socketHandler.synchRequest(request);
77       response.evalThrowsException();
78    }
79
80    /**
81     * #Description of the Method
82     *
83     * @param serverTime Description of Parameter
84     * @exception Exception Description of Exception
85     */

86    public void pong(long serverTime)
87           throws Exception JavaDoc
88    {
89       OIL2Request request = new OIL2Request(
90          OIL2Constants.CLIENT_PONG,
91          new Object JavaDoc[] {new Long JavaDoc(serverTime)});
92       OIL2Response response = socketHandler.synchRequest(request);
93       response.evalThrowsException();
94    }
95
96    /**
97     * #Description of the Method
98     *
99     * @param messages Description of Parameter
100     * @exception Exception Description of Exception
101     */

102    public void receive(ReceiveRequest messages[])
103           throws Exception JavaDoc
104    {
105       
106       OIL2Request request = new OIL2Request(
107          OIL2Constants.CLIENT_RECEIVE,
108          new Object JavaDoc[] {messages});
109       OIL2Response response = socketHandler.synchRequest(request);
110       response.evalThrowsException();
111    }
112    
113 }
114 // vim:expandtab:tabstop=3:shiftwidth=3
115
Popular Tags