public Object mapInterfaceTo(Object object, Type type) { checkDisposed(); if (object == null) { return null; } else { String[] oid = new String[1]; object = _java_environment.registerInterface(object, oid, type); if (!proxyFactory.isProxy(object)) { // This branch must be taken iff object either is no proxy at // all or a proxy from some other bridge. There are objects // that behave like objects for this bridge but that are not // detected as such by proxyFactory.isProxy. The only known // case of such objects is com.sun.star.comp.beans.Wrapper, // which implements com.sun.star.lib.uno.Proxy and effectively // is a second proxy around a proxy that can be from this // bridge. For that case, there is no problem, however: Since // the proxies generated by ProxyFactory send each // queryInterface to the original object (i.e., they do not // short-circuit requests for a super-interface to themselves), // there will always be an appropriate ProxyFactory-proxy // registered at the _java_environment, so that the object // returned by _java_environment.registerInterface will never be // a com.sun.star.comp.beans.Wrapper. addRefHolder(object, type, oid[0]); } return oid[0]; } }
} else { String[] oid = new String[1]; object = _java_environment.registerInterface(object, oid, type); if (!proxyFactory.isProxy(object)) {
/** * Maps an object from destination environment to the source environment. * <p> * @return the object in the source environment * @param object the object to map * @param type the interface under which is to be mapped * @see com.sun.star.uno.IBridge#mapInterfaceFrom */ public Object mapInterfaceFrom(Object oId, Type type) { checkDisposed(); // TODO What happens if an exception is thrown after the call to // acquire, but before it is guaranteed that a pairing release will be // called eventually? acquire(); String oid = (String) oId; Object object = _java_environment.getRegisteredInterface(oid, type); if (object == null) { object = _java_environment.registerInterface( proxyFactory.create(oid, type), new String[] { oid }, type); // the proxy sends a release when finalized } else if (!hasRefHolder(oid, type)) { sendInternalRequest(oid, type, "release", null); } return object; }
/** * Maps an object from destination environment to the source environment. * * @param oId the object to map. * @param type the interface under which is to be mapped. * @return the object in the source environment. * * @see com.sun.star.uno.IBridge#mapInterfaceFrom */ public Object mapInterfaceFrom(Object oId, Type type) { checkDisposed(); // TODO What happens if an exception is thrown after the call to // acquire, but before it is guaranteed that a pairing release will be // called eventually? acquire(); String oid = (String) oId; Object object = _java_environment.getRegisteredInterface(oid, type); if (object == null) { object = _java_environment.registerInterface( proxyFactory.create(oid, type), new String[] { oid }, type); // the proxy sends a release when finalized } else if (!hasRefHolder(oid, type)) { sendInternalRequest(oid, type, "release", null); } return object; }