ServantLocator.java
1.93 KB
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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.omg.PortableServer._ServantLocatorLocalBase
*/
package com.adobe.CORBA.impl;
import java.util.HashMap;
import java.util.Map;
import org.omg.PortableServer.ForwardRequest;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.Servant;
import org.omg.PortableServer.ServantLocatorPackage.CookieHolder;
import org.omg.PortableServer._ServantLocatorLocalBase;
class ServantLocator
extends _ServantLocatorLocalBase {
private Map<Integer, Servant> servantMap = new HashMap<Integer, Servant>();
private int currentKey = 0;
ServantLocator() {
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public Servant preinvoke(byte[] oid, POA adapter, String operation, CookieHolder cookie) throws ForwardRequest {
ServantLocator servantLocator = this;
synchronized (servantLocator) {
return this.servantMap.get(ServantLocator.byteArray2int(oid));
}
}
public void postinvoke(byte[] oid, POA adapter, String operation, Object cookie, Servant servant) {
}
public synchronized byte[] activate_object(Servant servant) {
++this.currentKey;
byte[] key = ServantLocator.int2byteArray(this.currentKey);
this.servantMap.put(this.currentKey, servant);
return key;
}
public synchronized void deactivate_object(byte[] objectKey) {
this.servantMap.remove(ServantLocator.byteArray2int(objectKey));
}
private static byte[] int2byteArray(int i) {
byte[] a = new byte[8];
for (int j = 0; j < 4; ++j) {
a[j] = (byte)(i % 256);
i >>>= 8;
}
return a;
}
private static int byteArray2int(byte[] a) {
int i = 0;
for (int j = 3; j >= 0; --j) {
int b = a[j];
i = (i << 8) + (b >= 0 ? b : 256 + b);
}
return i;
}
}