KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > carol > rmi > jrmp > interceptor > JRMPClientRequestInfoImpl


1 /**
2  * Copyright (C) 2002,2004 - INRIA (www.inria.fr)
3  *
4  * CAROL: Common Architecture for RMI ObjectWeb Layer
5  *
6  * This library is developed inside the ObjectWeb Consortium,
7  * http://www.objectweb.org
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22  * USA
23  *
24  * --------------------------------------------------------------------------
25  * $Id: JRMPClientRequestInfoImpl.java,v 1.6 2004/09/01 11:02:41 benoitf Exp $
26  * --------------------------------------------------------------------------
27  */

28 package org.objectweb.carol.rmi.jrmp.interceptor;
29
30 import java.util.ArrayList JavaDoc;
31 import java.util.Collection JavaDoc;
32 import java.util.Iterator JavaDoc;
33
34 /**
35  * Class <code>JRMPClientRequestInfoImpl</code> is the CAROL JRMP Client
36  * Request info (JClientRequestInfo) Implementation
37  * @see org.objectweb.carol.rmi.jrmp.interceptor.JClientRequestInfo
38  * @author Guillaume Riviere (Guillaume.Riviere@inrialpes.fr)
39  * @version 1.0, 15/07/2002
40  */

41 public class JRMPClientRequestInfoImpl implements JClientRequestInfo {
42
43     /**
44      * Request Service Context HasTable
45      */

46     protected ArrayList JavaDoc scTable = new ArrayList JavaDoc();
47
48     /**
49      * Empty constructor available for Request Information
50      */

51     public JRMPClientRequestInfoImpl() {
52     }
53
54     /**
55      * add a JServicecontext
56      * @param JServiceContext the context to add
57      * @param boolean replace if true replace the existing service context
58      */

59     public void add_request_service_context(JServiceContext jServiceContext) {
60         scTable.add(jServiceContext);
61     }
62
63     /**
64      * Get the context specifie by this id if there is no context corresponding
65      * with this id return null
66      * @param id the context id
67      * @return JServiceContex the specific ServiceContext
68      */

69     public JServiceContext get_request_service_context(int id) {
70         JServiceContext jc = null;
71         for (Iterator JavaDoc i = scTable.iterator(); i.hasNext();) {
72             jc = (JServiceContext) i.next();
73             if (jc.getContextId() == id) {
74                 return jc;
75             }
76         }
77         return null;
78     }
79
80     /**
81      * Get the all the request service context if there is no context return
82      * null
83      * @return Collection the ServiceContexts ArrayList
84      */

85     public Collection JavaDoc get_all_request_service_context() {
86         return scTable;
87     }
88
89     /**
90      * Get the context specifie by this id if there is no context corresponding
91      * with this id return null
92      * @param id the context id
93      * @return JServiceContex the specific ServiceContext
94      */

95     public JServiceContext get_reply_service_context(int id) {
96         JServiceContext jc = null;
97         for (Iterator JavaDoc i = scTable.iterator(); i.hasNext();) {
98             jc = (JServiceContext) i.next();
99             if (jc.getContextId() == id) {
100                 return jc;
101             }
102         }
103         return null;
104     }
105
106     /**
107      * Get the all the reply service context if there is no context return null
108      * @return Collection the ServiceContexts ArrayList
109      */

110     public Collection JavaDoc get_all_reply_service_context() {
111         return scTable;
112     }
113
114     /**
115      * Add the all the request service context
116      * @param c Services contexts
117      */

118     public void add_all_request_service_context(Collection JavaDoc c) {
119         scTable.addAll(c);
120     }
121
122     /**
123      * true if exit one or more context
124      */

125     public boolean hasContexts() {
126         return !(scTable.isEmpty());
127     }
128
129     /**
130      * clear the service contexts table
131      */

132     public void clearAllContexts() {
133         scTable.clear();
134     }
135 }
Popular Tags