KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > mom > proxies > StandardConnectionContext


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - 2006 ScalAgent Distributed Technologies
4  * Copyright (C) 1996 - 2000 Dyade
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA.
20  *
21  * Initial developer(s): ScalAgent Distributed Technologies
22  * Created on 15 mai 2006
23  *
24  */

25 package org.objectweb.joram.mom.proxies;
26
27 import org.objectweb.joram.shared.excepts.MomException;
28 import org.objectweb.joram.shared.client.AbstractJmsReply;
29 import org.objectweb.joram.shared.client.AbstractJmsRequest;
30 import org.objectweb.joram.shared.client.MomExceptionReply;
31 import org.objectweb.joram.shared.client.CnxCloseRequest;
32
33 import fr.dyade.aaa.util.Queue;
34
35 /**
36  *
37  */

38 public class StandardConnectionContext
39   implements ConnectionContext, java.io.Serializable JavaDoc {
40
41   private int key;
42
43   private Queue queue;
44   
45   private ProxyImpl proxyImpl;
46   
47   private boolean closed;
48
49   StandardConnectionContext(ProxyImpl proxyImpl, int key) {
50     this.key = key;
51     this.proxyImpl = proxyImpl;
52     queue = new Queue();
53     closed = false;
54   }
55   
56   public int getKey() {
57     return key;
58   }
59   
60   public void send(Object JavaDoc obj) {
61     queue.push(obj);
62   }
63   
64   public Queue getQueue() {
65     return queue;
66   }
67   
68   public void pushReply(AbstractJmsReply reply) {
69     queue.push(reply);
70   }
71   
72   public AbstractJmsRequest getRequest(Object JavaDoc req) {
73     AbstractJmsRequest request = (AbstractJmsRequest) req;
74     if (request instanceof CnxCloseRequest) {
75       closed = true;
76     }
77     return request;
78   }
79   
80   public void pushError(MomException exc) {
81     queue.push(new MomExceptionReply(exc));
82   }
83   
84   public boolean isClosed() {
85     return closed;
86   }
87   
88 }
89
Popular Tags