public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if(method.getDeclaringClass()==IReadResolve.class) { // readResolve on the proxy. // if we are going back to where we came from, replace the proxy by the real object if(goingHome) return channel.getExportedObject(oid); else return proxy; } if(channel==null) throw new IllegalStateException("proxy is not connected to a channel"); if(args==null) args = EMPTY_ARRAY; Class<?> dc = method.getDeclaringClass(); if(dc ==Object.class) { // handle equals and hashCode by ourselves try { return method.invoke(this,args); } catch (InvocationTargetException e) { throw e.getTargetException(); } } // delegate the rest of the methods to the remote object if(userProxy) return channel.call(new RPCRequest(oid,method,args,dc.getClassLoader())); else return new RPCRequest(oid,method,args).call(channel); }
protected Serializable perform(@Nonnull Channel channel) throws Throwable { Object o = channel.getExportedObject(oid); Class[] clazz = channel.getExportedTypes(oid); try { Method m = choose(clazz); if(m==null) throw new IllegalStateException("Unable to call " + methodName + ". No matching method found in " + Arrays.toString(clazz) + " for " + o); m.setAccessible(true); // in case the class is not public Object r; try { r = m.invoke(o, arguments); } catch (IllegalArgumentException x) { throw new RemotingSystemException("failed to invoke " + m + " on " + o + Arrays.toString(arguments), x); } if (r==null || r instanceof Serializable) return (Serializable) r; else throw new RemotingSystemException(new ClassCastException(r.getClass()+" is returned from "+m+" on "+o.getClass()+" but it's not serializable")); } catch (InvocationTargetException e) { throw e.getTargetException(); } }
public static void main(String[] args) throws Exception { File f = new File("/home/kohsuke/ws/hudson/investigations/javafx-windows-hang/out.log"); DataInputStream fin = new DataInputStream(new FileInputStream(f)); fin.readFully(new byte[4]); // skip preamble ObjectInputStream ois = new ObjectInputStream(fin); for (int n=0; ; n++) { Command o = (Command)ois.readObject(); System.out.println("#"+n+" : "+o); if (o instanceof RPCRequest) { RPCRequest request = (RPCRequest) o; System.out.print(" ("); boolean first=true; for (Object argument : request.getArguments()) { if(first) first=false; else System.out.print(","); System.out.print(argument); } System.out.println(")"); } if (o.createdAt!=null) o.createdAt.printStackTrace(System.out); } } }
RPCRequest req = userSpace ? new UserRPCRequest(oid, method, args, userProxy ? dc.getClassLoader() : null, recordCreatedAt) : new RPCRequest(oid, method, args, userProxy ? dc.getClassLoader() : null, recordCreatedAt); try { if(userProxy) { else return channelOrFail().call(req); } else { if (async) req.callAsync(channelOrFail()); else return req.call(channelOrFail());
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if(method.getDeclaringClass()==IReadResolve.class) { // readResolve on the proxy. // if we are going back to where we came from, replace the proxy by the real object if(goingHome) return channel.getExportedObject(oid); else return proxy; } if(channel==null) throw new IllegalStateException("proxy is not connected to a channel"); if(args==null) args = EMPTY_ARRAY; Class<?> dc = method.getDeclaringClass(); if(dc ==Object.class) { // handle equals and hashCode by ourselves try { return method.invoke(this,args); } catch (InvocationTargetException e) { throw e.getTargetException(); } } // delegate the rest of the methods to the remote object if(userProxy) return channel.call(new RPCRequest(oid,method,args,dc.getClassLoader())); else return new RPCRequest(oid,method,args).call(channel); }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if(method.getDeclaringClass()==IReadResolve.class) { // readResolve on the proxy. // if we are going back to where we came from, replace the proxy by the real object if(goingHome) return channel.getExportedObject(oid); else return proxy; } if(channel==null) throw new IllegalStateException("proxy is not connected to a channel"); if(args==null) args = EMPTY_ARRAY; Class<?> dc = method.getDeclaringClass(); if(dc ==Object.class) { // handle equals and hashCode by ourselves try { return method.invoke(this,args); } catch (InvocationTargetException e) { throw e.getTargetException(); } } // delegate the rest of the methods to the remote object if(userProxy) return channel.call(new RPCRequest(oid,method,args,dc.getClassLoader())); else return new RPCRequest(oid,method,args).call(channel); }
public Serializable call() throws Throwable { return perform(getChannelOrFail()); }
public Serializable call() throws Throwable { return perform(Channel.current()); }
protected Serializable perform(Channel channel) throws Throwable { Object o = channel.getExportedObject(oid); if(o==null) throw new IllegalStateException("Unable to call "+methodName+". Invalid object ID "+oid); try { Method m = choose(o); if(m==null) throw new IllegalStateException("Unable to call "+methodName+". No matching method found on "+o.getClass()); m.setAccessible(true); // in case the class is not public return (Serializable) m.invoke(o,arguments); } catch (InvocationTargetException e) { throw e.getTargetException(); } }
public Serializable call() throws Throwable { return perform(Channel.current()); }
public Serializable call() throws Throwable { return perform(Channel.current()); }
protected Serializable perform(Channel channel) throws Throwable { Object o = channel.getExportedObject(oid); if(o==null) throw new IllegalStateException("Unable to call "+methodName+". Invalid object ID "+oid); try { Method m = choose(o); if(m==null) throw new IllegalStateException("Unable to call "+methodName+". No matching method found on "+o.getClass()); m.setAccessible(true); // in case the class is not public return (Serializable) m.invoke(o,arguments); } catch (InvocationTargetException e) { throw e.getTargetException(); } }
protected Serializable perform(Channel channel) throws Throwable { Object o = channel.getExportedObject(oid); if(o==null) throw new IllegalStateException("Unable to call "+methodName+". Invalid object ID "+oid); try { Method m = choose(o); if(m==null) throw new IllegalStateException("Unable to call "+methodName+". No matching method found on "+o.getClass()); m.setAccessible(true); // in case the class is not public return (Serializable) m.invoke(o,arguments); } catch (InvocationTargetException e) { throw e.getTargetException(); } }
@Override public void checkIfCanBeExecutedOnChannel(Channel channel) throws IOException { // Default check for all requests super.checkIfCanBeExecutedOnChannel(channel); // We also do not want to run UserRequests when the channel is being closed if (channel.isClosingOrClosed()) { throw new ChannelClosedException("The request cannot be executed on channel " + channel + ". " + "The channel is closing down or has closed down", channel.getCloseRequestCause()); } } }