@Override protected void finalize() throws Throwable { try { if (gateway.getCallbackClient().isMemoryManagementEnabled() && this.id != Protocol.ENTRY_POINT_OBJECT_ID) { logger.fine("Finalizing python proxy id " + this.id); gateway.getCallbackClient().sendCommand(finalizeCommand, false); } } catch (Exception e) { logger.warning("Python Proxy ID could not send a finalize message: " + this.id); } finally { super.finalize(); } }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { logger.fine("Method " + method.getName() + " called on Python object " + id); StringBuilder sBuilder = new StringBuilder(); sBuilder.append(CALL_PROXY_COMMAND_NAME); sBuilder.append(id); sBuilder.append("\n"); sBuilder.append(method.getName()); sBuilder.append("\n"); if (args != null) { for (Object arg : args) { sBuilder.append(gateway.getReturnObject(arg).getCommandPart()); sBuilder.append("\n"); } } sBuilder.append("e\n"); String returnCommand = gateway.getCallbackClient().sendCommand(sBuilder.toString()); Object output = Protocol.getReturnValue(returnCommand, gateway); Object convertedOutput = convertOutput(method, output); return convertedOutput; }