1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43:
44: import ;
45: import ;
46: import ;
47: import ;
48:
49:
54: public class ServiceContext
55: implements IDLEntity
56: {
57:
60: private static final long serialVersionUID = 1;
61:
62:
63: public static final int TransactionService = 0;
64:
65:
69: public static final int CodeSets = 1;
70:
71: public static final int ChainBypassCheck = 2;
72:
73: public static final int ChainBypassInfo = 3;
74:
75: public static final int LogicalThreadId = 4;
76:
77: public static final int BI_DIR_IIOP = 5;
78:
79: public static final int SendingContextRunTime = 6;
80:
81: public static final int INVOCATION_POLICIES = 7;
82:
83: public static final int FORWARDED_IDENTITY = 8;
84:
85:
90: public static final int UnknownExceptionInfo = 9;
91:
92: public static final int RTCorbaPriority = 10;
93:
94: public static final int RTCorbaPriorityRange = 11;
95:
96: public static final int FT_GROUP_VERSION = 12;
97:
98: public static final int FT_REQUEST = 13;
99:
100: public static final int ExceptionDetailMessage = 14;
101:
102: public static final int SecurityAttributeService = 15;
103:
104: public static final int ActivityService = 16;
105:
106:
112: public int context_id;
113:
114:
117: public byte[] context_data;
118:
119:
122: public ServiceContext()
123: {
124: }
125:
126:
129: public ServiceContext(org.omg.IOP.ServiceContext from)
130: {
131: context_id = from.context_id;
132: context_data = from.context_data;
133: }
134:
135:
140: public static ServiceContext read(AbstractCdrInput istream)
141: {
142: int id = istream.read_ulong();
143:
144: switch (id)
145: {
146: case CodeSetServiceContext.ID:
147:
148: CodeSetServiceContext codeset = new CodeSetServiceContext();
149: codeset.readContext(istream);
150: return codeset;
151:
152: default:
153:
154: ServiceContext ctx = new ServiceContext();
155: ctx.context_id = id;
156: ctx.context_data = istream.read_sequence();
157: return ctx;
158: }
159: }
160:
161:
164: public static ServiceContext[] readSequence(AbstractCdrInput istream)
165: {
166: int size = istream.read_long();
167: ServiceContext[] value = new gnu.CORBA.GIOP.ServiceContext[size];
168: for (int i = 0; i < value.length; i++)
169: value[i] = read(istream);
170: return value;
171: }
172:
173:
178: public void write(AbstractCdrOutput ostream)
179: {
180: ostream.write_ulong(context_id);
181: ostream.write_sequence(context_data);
182: }
183:
184:
187: public static void writeSequence(AbstractCdrOutput ostream, ServiceContext[] value)
188: {
189: ostream.write_long(value.length);
190: for (int i = 0; i < value.length; i++)
191: value[i].write(ostream);
192: }
193:
194:
197: public static void add(org.omg.IOP.ServiceContext[] cx,
198: org.omg.IOP.ServiceContext service_context, boolean replace)
199: {
200: int exists = -1;
201:
202: for (int i = 0; i < cx.length; i++)
203: if (cx[i].context_id == service_context.context_id)
204: exists = i;
205:
206: if (exists < 0)
207: {
208:
209: org.omg.IOP.ServiceContext[] n = new org.omg.IOP.ServiceContext[cx.length + 1];
210: for (int i = 0; i < cx.length; i++)
211: n[i] = cx[i];
212: n[cx.length] = service_context;
213: }
214: else
215: {
216:
217: if (!replace)
218: throw new BAD_INV_ORDER("Repetetive setting of the context "
219: + service_context.context_id, 15, CompletionStatus.COMPLETED_NO);
220: else
221: cx[exists] = service_context;
222: }
223: }
224:
225:
228: public static ServiceContext[] add(ServiceContext[] cx,
229: org.omg.IOP.ServiceContext service_context, boolean replace)
230: {
231: int exists = -1;
232:
233: for (int i = 0; i < cx.length; i++)
234: if (cx[i].context_id == service_context.context_id)
235: exists = i;
236:
237: if (exists < 0)
238: {
239:
240: ServiceContext[] n = new ServiceContext[cx.length + 1];
241: for (int i = 0; i < cx.length; i++)
242: n[i] = cx[i];
243: n[cx.length] = new ServiceContext(service_context);
244: return n;
245: }
246: else
247: {
248:
249: if (!replace)
250: throw new BAD_INV_ORDER("Repetetive setting of the context "
251: + service_context.context_id, 15, CompletionStatus.COMPLETED_NO);
252: else
253: cx[exists] = new ServiceContext(service_context);
254: return cx;
255: }
256: }
257:
258:
261: public static org.omg.IOP.ServiceContext findContext(int ctx_name,
262: org.omg.IOP.ServiceContext[] cx)
263: {
264: for (int i = 0; i < cx.length; i++)
265: if (cx[i].context_id == ctx_name)
266: return cx[i];
267: throw new BAD_PARAM("No context with id " + ctx_name);
268: }
269:
270:
274: public static org.omg.IOP.ServiceContext findContext(int ctx_name,
275: ServiceContext[] cx)
276: {
277: for (int i = 0; i < cx.length; i++)
278: if (cx[i].context_id == ctx_name)
279: return new org.omg.IOP.ServiceContext(ctx_name, cx[i].context_data);
280: throw new BAD_PARAM("No context with id " + ctx_name);
281: }
282:
283:
286: public static ServiceContext find(int ctx_name, ServiceContext[] cx)
287: {
288: for (int i = 0; i < cx.length; i++)
289: if (cx[i].context_id == ctx_name)
290: return cx[i];
291: return null;
292: }
293:
294:
297: public String toString()
298: {
299: return "ctx " + context_id + ", size " + context_data.length;
300: }
301: }