*not part of the build*
fix for 86789 git-svn-id: svn://10.0.0.236/trunk@97937 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
@@ -27,20 +27,20 @@ import java.lang.ref.*;
|
||||
|
||||
class ProxyKey {
|
||||
ProxyKey(long _oid, IID _iid) {
|
||||
oid = new Long(_oid);
|
||||
iid = _iid;
|
||||
oid = new Long(_oid);
|
||||
iid = _iid;
|
||||
}
|
||||
public boolean equals(Object obj) {
|
||||
if (! (obj instanceof ProxyKey)) {
|
||||
return false;
|
||||
}
|
||||
return (oid.equals(((ProxyKey)obj).oid) && iid.equals(((ProxyKey)obj).iid));
|
||||
if (! (obj instanceof ProxyKey)) {
|
||||
return false;
|
||||
}
|
||||
return (oid.equals(((ProxyKey)obj).oid) && iid.equals(((ProxyKey)obj).iid));
|
||||
}
|
||||
public int hashCode() {
|
||||
return oid.hashCode();
|
||||
return oid.hashCode();
|
||||
}
|
||||
public String toString() {
|
||||
return "org.mozilla.xpcom.ProxyFactory.ProxyKey "+oid+" "+iid;
|
||||
return "org.mozilla.xpcom.ProxyFactory.ProxyKey "+oid+" "+iid;
|
||||
}
|
||||
Long oid;
|
||||
IID iid;
|
||||
@@ -51,34 +51,34 @@ public class ProxyFactory {
|
||||
Debug.log("--[java] ProxyFactory.getInterface "+iid);
|
||||
return InterfaceRegistry.getInterface(iid);
|
||||
}
|
||||
|
||||
|
||||
public static Object getProxy(long oid, IID iid, long orb) {
|
||||
try {
|
||||
Debug.log("--[java] ProxyFactory.getProxy "+iid);
|
||||
ProxyKey key = new ProxyKey(oid, iid);
|
||||
Object obj = null;
|
||||
Object result = null;
|
||||
if (proxies != null) {
|
||||
obj = proxies.get(key);
|
||||
if (obj != null
|
||||
&& (obj instanceof Reference)) {
|
||||
result = ((Reference)obj).get();
|
||||
Debug.log("--[java] ProxyFactory.getProxy "+iid);
|
||||
ProxyKey key = new ProxyKey(oid, iid);
|
||||
Object obj = null;
|
||||
Object result = null;
|
||||
if (proxies != null) {
|
||||
obj = proxies.get(key);
|
||||
if (obj != null
|
||||
&& (obj instanceof Reference)) {
|
||||
result = ((Reference)obj).get();
|
||||
}
|
||||
} else {
|
||||
proxies = new Hashtable();
|
||||
}
|
||||
} else {
|
||||
proxies = new Hashtable();
|
||||
}
|
||||
if (result == null) {
|
||||
Class inter = getInterface(iid);
|
||||
if (inter == null) {
|
||||
Debug.log("--[java] ProxyFactory.getProxy we did not find interface for iid="+iid+"returing null");
|
||||
return null;
|
||||
if (result == null) {
|
||||
Class inter = getInterface(iid);
|
||||
if (inter == null) {
|
||||
Debug.log("--[java] ProxyFactory.getProxy we did not find interface for iid="+iid+"returing null");
|
||||
return null;
|
||||
}
|
||||
InvocationHandler handler = new ProxyHandler(oid, iid, orb);
|
||||
result = Proxy.newProxyInstance(inter.getClassLoader(), new Class[] {inter},handler);
|
||||
proxies.put(new WeakReference(result), key);
|
||||
}
|
||||
InvocationHandler handler = new ProxyHandler(oid, iid, orb);
|
||||
result = Proxy.newProxyInstance(inter.getClassLoader(), new Class[] {inter},handler);
|
||||
proxies.put(new WeakReference(result), key);
|
||||
}
|
||||
Debug.log("--[java] ProxyFactory.getProxy we got proxy "+result);
|
||||
return result;
|
||||
Debug.log("--[java] ProxyFactory.getProxy we got proxy "+result);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
Debug.log("--[java] ProxyFactory.getProxy we got exception "+e);
|
||||
}
|
||||
|
||||
@@ -25,9 +25,10 @@ import java.lang.reflect.*;
|
||||
|
||||
class ProxyHandler implements InvocationHandler {
|
||||
ProxyHandler(long _oid, IID _iid, long _orb) {
|
||||
oid = _oid;
|
||||
iid = _iid;
|
||||
orb = _orb;
|
||||
oid = _oid;
|
||||
iid = _iid;
|
||||
orb = _orb;
|
||||
Utilities.callMethod(oid, null, iid, orb, null); //it is hack method = null means addref
|
||||
}
|
||||
public Object invoke(Object proxy,
|
||||
Method method,
|
||||
@@ -39,6 +40,7 @@ class ProxyHandler implements InvocationHandler {
|
||||
} else if (str.equals("clone")) {
|
||||
throw new java.lang.CloneNotSupportedException();
|
||||
} else if (str.equals("finalize")) {
|
||||
Utilities.callMethod(oid, method, iid, orb, args);
|
||||
finalize();
|
||||
} else if (str.equals("equals")) {
|
||||
if (args[0] instanceof ProxyHandler) {
|
||||
@@ -64,3 +66,5 @@ class ProxyHandler implements InvocationHandler {
|
||||
private long orb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +74,14 @@ public class Utilities {
|
||||
|
||||
static Object callMethod(long oid, Method method, IID iid, long orb , Object[] args) {
|
||||
Debug.log("--[java]Utilities.callMethod "+method);
|
||||
int mid = InterfaceRegistry.getIndexByMethod(method, iid);
|
||||
int mid;
|
||||
if (method == null) {
|
||||
mid = 1; //it is hack method = null means addref
|
||||
} else if ("finalize".equals(method.getName())) {
|
||||
mid = 2;
|
||||
} else {
|
||||
mid = InterfaceRegistry.getIndexByMethod(method, iid);
|
||||
}
|
||||
if (mid < 0) {
|
||||
Debug.log("--[java]Utilities.callMethod we do not have implementation for "+method);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user