summaryrefslogtreecommitdiff
path: root/java/src/Ice/ObjectImpl.java
blob: 7ff5636cc0f440a150e2637627e9389bcec385e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
// **********************************************************************
//
// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

package Ice;

/**
 * Base class for all Slice classes.
 **/
public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io.Serializable
{
    /**
     * Instantiates an Ice object.
     **/
    public
    ObjectImpl()
    {
    }

    /**
     * Returns a copy of the object. The cloned object contains field-for-field copies
     * of the state.
     *
     * @return The cloned object.
     **/
    public java.lang.Object
    clone()
    {
        java.lang.Object o = null;
        try
        {
            o = super.clone();
        }
        catch(java.lang.CloneNotSupportedException ex)
        {
            assert false; // Impossible
        }
        return o;
    }

    /**
     * @deprecated
     **/
    public int
    ice_hash()
    {
        return hashCode();
    }

    public final static String[] __ids =
    {
        "::Ice::Object"
    };

    /**
     * Tests whether this object supports a specific Slice interface.
     *
     * @param s The type ID of the Slice interface to test against.
     * @return The return value is <code>true</code> if <code>s</code> is
     * <code>::Ice::Object</code>.
     **/
    public boolean
    ice_isA(String s)
    {
        return s.equals(__ids[0]);
    }

    /**
     * Tests whether this object supports a specific Slice interface.
     *
     * @param s The type ID of the Slice interface to test against.
     * @param current The current object for the invocation.
     * @return The return value is <code>true</code> if <code>s</code> is
     * <code>::Ice::Object</code>.
     **/
    public boolean
    ice_isA(String s, Current current)
    {
        return s.equals(__ids[0]);
    }

    public static DispatchStatus
    ___ice_isA(Ice.Object __obj, IceInternal.Incoming __inS, Current __current)
    {
        IceInternal.BasicStream __is = __inS.startReadParams();
        String __id = __is.readString();
        __inS.endReadParams();
        boolean __ret = __obj.ice_isA(__id, __current);
        IceInternal.BasicStream __os = __inS.__startWriteParams(Ice.FormatType.DefaultFormat);
        __os.writeBool(__ret);
        __inS.__endWriteParams(true);
        return DispatchStatus.DispatchOK;
    }

    /**
     * Tests whether this object can be reached.
     **/
    public void
    ice_ping()
    {
        // Nothing to do.
    }

    /**
     * Tests whether this object can be reached.
     *
     * @param current The current object for the invocation.
     **/
    public void
    ice_ping(Current current)
    {
        // Nothing to do.
    }

    public static DispatchStatus
    ___ice_ping(Ice.Object __obj, IceInternal.Incoming __inS, Current __current)
    {
        __inS.readEmptyParams();
        __obj.ice_ping(__current);
        __inS.__writeEmptyParams();
        return DispatchStatus.DispatchOK;
    }

    /**
     * Returns the Slice type IDs of the interfaces supported by this object.
     *
     * @return An array whose only element is <code>::Ice::Object</code>.
     **/
    public String[]
    ice_ids()
    {
        return __ids;
    }

    /**
     * Returns the Slice type IDs of the interfaces supported by this object.
     *
     * @param current The current object for the invocation.
     * @return An array whose only element is <code>::Ice::Object</code>.
     **/
    public String[]
    ice_ids(Current current)
    {
        return __ids;
    }

    public static DispatchStatus
    ___ice_ids(Ice.Object __obj, IceInternal.Incoming __inS, Current __current)
    {
        __inS.readEmptyParams();
        String[] __ret = __obj.ice_ids(__current);
        IceInternal.BasicStream __os = __inS.__startWriteParams(Ice.FormatType.DefaultFormat);
        __os.writeStringSeq(__ret);
        __inS.__endWriteParams(true);
        return DispatchStatus.DispatchOK;
    }

    /**
     * Returns the Slice type ID of the most-derived interface supported by this object.
     *
     * @return The return value is always <code>::Ice::Object</code>.
     **/
    public String
    ice_id()
    {
        return __ids[0];
    }

    /**
     * Returns the Slice type ID of the most-derived interface supported by this object.
     *
     * @param current The current object for the invocation.
     * @return The return value is always {@link IceObject}.
     **/
    public String
    ice_id(Current current)
    {
        return __ids[0];
    }

    public static DispatchStatus
    ___ice_id(Ice.Object __obj, IceInternal.Incoming __inS, Current __current)
    {
        __inS.readEmptyParams();
        String __ret = __obj.ice_id(__current);
        IceInternal.BasicStream __os = __inS.__startWriteParams(Ice.FormatType.DefaultFormat);
        __os.writeString(__ret);
        __inS.__endWriteParams(true);
        return DispatchStatus.DispatchOK;
    }

    /**
     * Returns the Slice type ID of the interface supported by this object.
     *
     * @return The return value is always ::Ice::Object.
     **/
    public static String
    ice_staticId()
    {
        return __ids[0];
    }

    /**
     * Returns the Freeze metadata attributes for an operation.
     *
     * @param The name of the operation.
     * @return The least significant bit indicates whether the operation is a read
     * or write operation. If the bit is set, the operation is a write operation.
     * The expression <code>ice_operationAttributes("op") & 0x1</code> is true if
     * the operation has a <code>["freeze:write"]</code> metadata directive.
     * <p>
     * The second- and third least significant bit indicate the transactional mode
     * of the operation. The expression <code>ice_operationAttributes("op") & 0x6 >> 1</code>
     * indicates the transactional mode as follows:
     * <dl>
     *   <dt>0</dt>
     *   <dd><code>["freeze:read:supports"]</code></dd>
     *   <dt>1</dt>
     *   <dd><code>["freeze:read:mandatory"]</code> or <code>["freeze:write:mandatory"]</code></dd>
     *   <dt>2</dt>
     *   <dd><code>["freeze:read:required"]</code> or <code>["freeze:write:required"]</code></dd>
     *   <dt>3</dt>
     *   <dd><code>["freeze:read:never"]</code></dd>
     * </dl>
     *
     * @see Freeze.TransactionalEvictor
     **/
    public int ice_operationAttributes(String operation)
    {
        return 0;
    }

    /**
     * The Ice run time invokes this method prior to marshaling an object's data members. This allows a subclass
     * to override this method in order to validate its data members. This default implementation does nothing.
     **/
    public void
    ice_preMarshal()
    {
    }

    /**
     * This Ice run time invokes this method vafter unmarshaling an object's data members. This allows a
     * subclass to override this method in order to perform additional initialization. This default
     * implementation does nothing.
     **/
    public void
    ice_postUnmarshal()
    {
    }

    private final static String[] __all =
    {
        "ice_id",
        "ice_ids",
        "ice_isA",
        "ice_ping"
    };

    /**
     * Dispatches an invocation to a servant. This method is used by dispatch interceptors to forward an invocation
     * to a servant (or to another interceptor).
     *
     * @param request The details of the invocation.
     * @param cb The callback object for asynchchronous dispatch. For synchronous dispatch, the callback object must
     * be <code>null</code>.
     * @return The dispatch status for the operation.
     *
     * @see DispatchInterceptor
     * @see DispatchInterceptorAsyncCallback
     * @see DispatchStatus
     **/
    public DispatchStatus
    ice_dispatch(Request request, DispatchInterceptorAsyncCallback cb)
    {
        if(request.isCollocated())
        {
            return __collocDispatch((IceInternal.Direct)request);
        }
        else
        {
            IceInternal.Incoming in = (IceInternal.Incoming)request;
            if(cb != null)
            {
                in.push(cb);
            }
            try
            {
                in.startOver(); // may raise ResponseSentException
                return __dispatch(in, in.getCurrent());
            }
            finally
            {
                if(cb != null)
                {
                    in.pop();
                }
            }
        }
    }

    /**
     * Dispatches an invocation to a servant. This method is used by dispatch interceptors to forward an invocation
     * to a servant (or to another interceptor).
     *
     * @param request The details of the invocation.
     * @return The dispatch status for the operation.
     *
     * @see DispatchInterceptor
     * @see DispatchStatus
     **/
    public DispatchStatus
    ice_dispatch(Request request)
    {
        return ice_dispatch(request, null);
    }

    public DispatchStatus
    __dispatch(IceInternal.Incoming in, Current current)
    {
        int pos = java.util.Arrays.binarySearch(__all, current.operation);
        if(pos < 0)
        {
            throw new Ice.OperationNotExistException(current.id, current.facet, current.operation);
        }

        switch(pos)
        {
            case 0:
            {
                return ___ice_id(this, in, current);
            }
            case 1:
            {
                return ___ice_ids(this, in, current);
            }
            case 2:
            {
                return ___ice_isA(this, in, current);
            }
            case 3:
            {
                return ___ice_ping(this, in, current);
            }
        }

        assert(false);
        throw new Ice.OperationNotExistException(current.id, current.facet, current.operation);
    }

    public DispatchStatus
    __collocDispatch(IceInternal.Direct request)
    {
        return request.run(this);
    }

    public void
    __write(IceInternal.BasicStream __os)
    {
    }

    public void
    __writeImpl(IceInternal.BasicStream __os)
    {
    }

    public void
    __read(IceInternal.BasicStream __is)
    {
    }

    public void
    __readImpl(IceInternal.BasicStream __is)
    {
    }

    public void
    __write(Ice.OutputStream __outS)
    {
    }

    public void
    __read(Ice.InputStream __inS)
    {
    }

    private static String
    operationModeToString(OperationMode mode)
    {
        if(mode == Ice.OperationMode.Normal)
        {
            return "::Ice::Normal";
        }
        if(mode == Ice.OperationMode.Nonmutating)
        {
            return "::Ice::Nonmutating";
        }

        if(mode == Ice.OperationMode.Idempotent)
        {
            return "::Ice::Idempotent";
        }

        return "???";
    }

    protected static void
    __checkMode(OperationMode expected, OperationMode received)
    {
        if(expected != received)
        {
            if(expected == Ice.OperationMode.Idempotent
               && received == Ice.OperationMode.Nonmutating)
            {
                //
                // Fine: typically an old client still using the
                // deprecated nonmutating keyword
                //
            }
            else
            {
                Ice.MarshalException ex = new Ice.MarshalException();
                ex.reason = "unexpected operation mode. expected = "
                    + operationModeToString(expected) + " received = "
                    + operationModeToString(received);
                throw ex;
            }
        }
    }

    public static final long serialVersionUID = 0L;
}