KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > orb > portableInterceptor > RequestInfoImpl


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1999-2004 Gerald Brose
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) 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  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */

21 package org.jacorb.orb.portableInterceptor;
22
23 import org.omg.IOP.*;
24 import org.omg.CORBA.*;
25 import org.omg.PortableInterceptor.*;
26 import org.omg.Dynamic.Parameter JavaDoc;
27 import java.util.*;
28
29 /**
30  * This is the abstract base class of the two
31  * Info classes, namely ClientRequestInfo and
32  * ServerRequestInfo. <br>
33  * See PI Spec p. 5-41ff
34  *
35  * @author Nicolas Noffke
36  * @version $Id: RequestInfoImpl.java,v 1.9 2004/06/09 05:32:02 andre.spiegel Exp $
37  */

38
39 public abstract class RequestInfoImpl
40     extends org.omg.CORBA.LocalObject JavaDoc
41     implements RequestInfo
42 {
43
44     protected int request_id;
45     protected String JavaDoc operation = null;
46
47     protected Parameter JavaDoc[] arguments = null;
48     protected TypeCode[] exceptions = null;
49     protected Any result = null;
50     protected boolean response_expected;
51     protected org.omg.CORBA.Object JavaDoc forward_reference = null;
52     protected short reply_status;
53     protected org.omg.PortableInterceptor.Current JavaDoc current = null;
54   
55     protected Hashtable request_ctx = null;
56     protected Hashtable reply_ctx = null;
57
58     protected short caller_op = -1;
59     
60     public RequestInfoImpl() {
61         request_ctx = new Hashtable();
62         reply_ctx = new Hashtable();
63     }
64
65     /**
66      * Make the existing request ServiceContexts available to
67      * the interceptors. Only one ServiceContext per id
68      * is allowed.
69      */

70     public void setRequestServiceContexts(ServiceContext[] ctx){
71         for (int _i = 0; _i < ctx.length; _i++)
72             request_ctx.put(new Integer JavaDoc(ctx[_i].context_id), ctx[_i]);
73     }
74
75     /**
76      * Make the existing reply ServiceContexts available to
77      * the interceptors. Only one ServiceContext per id
78      * is allowed.
79      */

80     public void setReplyServiceContexts(ServiceContext[] ctx){
81         for (int _i = 0; _i < ctx.length; _i++)
82             reply_ctx.put(new Integer JavaDoc(ctx[_i].context_id), ctx[_i]);
83     }
84
85     public void setArguments (Parameter JavaDoc[] args) {
86         this.arguments = args;
87     }
88
89     public void setResult (Any result) {
90         this.result = result;
91     }
92
93     public org.omg.PortableInterceptor.Current JavaDoc current() {
94         return current;
95     }
96
97     public void setCurrent (org.omg.PortableInterceptor.Current JavaDoc current) {
98         this.current = current;
99     }
100
101     public void setReplyStatus (short reply_status) {
102         this.reply_status = reply_status;
103     }
104     
105     public void setForwardReference (org.omg.CORBA.Object JavaDoc forward_reference) {
106         this.forward_reference = forward_reference;
107     }
108
109     // implementation of org.omg.PortableInterceptor.RequestInfoOperations interface
110
public Parameter JavaDoc[] arguments() {
111         return arguments;
112     }
113   
114     public String JavaDoc[] contexts() {
115         throw new NO_RESOURCES("JacORB does not support operation contexts",
116                                1, CompletionStatus.COMPLETED_MAYBE);
117     }
118   
119     public TypeCode[] exceptions() {
120         return exceptions;
121     }
122   
123     public org.omg.CORBA.Object JavaDoc forward_reference() {
124         return forward_reference;
125     }
126   
127     public ServiceContext get_reply_service_context(int id) {
128         Integer JavaDoc _id = new Integer JavaDoc(id);
129         if (! reply_ctx.containsKey(_id))
130             throw new BAD_PARAM("No ServiceContext with id " + id, 23,
131                                 CompletionStatus.COMPLETED_MAYBE);
132         else
133             return (ServiceContext) reply_ctx.get(_id);
134     }
135   
136     public ServiceContext get_request_service_context(int id) {
137         Integer JavaDoc _id = new Integer JavaDoc(id);
138         if (! request_ctx.containsKey(_id))
139             throw new BAD_PARAM("No ServiceContext with id " + id, 23,
140                                 CompletionStatus.COMPLETED_MAYBE);
141         else
142             return (ServiceContext) request_ctx.get(_id);
143     }
144   
145     public Any get_slot(int id) throws InvalidSlot {
146         return current.get_slot(id);
147     }
148   
149     public String JavaDoc operation() {
150         return operation;
151     }
152   
153     public String JavaDoc[] operation_context() {
154         throw new NO_RESOURCES("JacORB does not support operation contexts", 1,
155                                CompletionStatus.COMPLETED_MAYBE);
156     }
157   
158     public short reply_status() {
159         return reply_status;
160     }
161   
162     public int request_id() {
163         return request_id;
164     }
165   
166     public boolean response_expected() {
167         return response_expected;
168     }
169   
170     public Any result() {
171         if (result == null)
172             throw new NO_RESOURCES("Stream-based skeletons/stubs do not support this op",
173                                    1, CompletionStatus.COMPLETED_MAYBE);
174         else
175             return result;
176     }
177   
178     public short sync_scope() {
179         return org.omg.Messaging.SYNC_WITH_TRANSPORT.value;
180     }
181 } // RequestInfoImpl
182

183
184
185
186
187
188
Popular Tags