KickJava   Java API By Example, From Geeks To Geeks.

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


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: JRMPServerRequestInfoImpl.java,v 1.5 2004/09/01 11:02:41 benoitf Exp $
26  * --------------------------------------------------------------------------
27  */

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

42 public class JRMPServerRequestInfoImpl implements JServerRequestInfo {
43
44     /**
45      * Request Service Context ArrayList
46      */

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

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

60     public void add_reply_service_context(JServiceContext jServiceContext) {
61         scTable.add(jServiceContext);
62     }
63
64     /**
65      * Add the all the reply service context
66      * @param c Services contexts
67      */

68     public void add_all_reply_service_context(Collection JavaDoc c) {
69         scTable.addAll(c);
70     }
71
72     /**
73      * Get the context specifie by this id if there is no context corresponding
74      * with this id return null
75      * @param id the context id
76      * @return JServiceContex the specific ServiceContext
77      */

78     public JServiceContext get_request_service_context(int id) {
79         JServiceContext jc = null;
80         for (Iterator JavaDoc i = scTable.iterator(); i.hasNext();) {
81             jc = (JServiceContext) i.next();
82             if (jc.getContextId() == id) {
83                 return jc;
84             }
85         }
86         return null;
87     }
88
89     /**
90      * Get the all the request service context if there is no context return
91      * null
92      * @return Collection the ServiceContexts
93      */

94     public Collection JavaDoc get_all_request_service_context() {
95         return scTable;
96     }
97
98     /**
99      * Get the context specifie by this id if there is no context corresponding
100      * with this id return null
101      * @param id the context id
102      * @return JServiceContex the specific ServiceContext
103      */

104     public JServiceContext get_reply_service_context(int id) {
105         JServiceContext jc = null;
106         for (Iterator JavaDoc i = scTable.iterator(); i.hasNext();) {
107             jc = (JServiceContext) i.next();
108             if (jc.getContextId() == id) {
109                 return jc;
110             }
111         }
112         return null;
113     }
114
115     /**
116      * Get the all the reply service context
117      * @return Collection the ServiceContexts
118      */

119     public Collection JavaDoc get_all_reply_service_context() {
120         return scTable;
121     }
122
123     /**
124      * true if exit one or more context
125      */

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

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