/** * Creates a new channel. * * @param name Human readable name of this channel. Used for debug/logging. Can be anything. * @param exec Commands sent from the remote peer will be executed by using this {@link Executor}. * @param mode The encoding to be used over the stream. * @param is Stream connected to the remote peer. It's the caller's responsibility to do * buffering on this stream, if that's necessary. * @param os Stream connected to the remote peer. It's the caller's responsibility to do * buffering on this stream, if that's necessary. * @param header If non-null, receive the portion of data in <tt>is</tt> before * the data goes into the "binary mode". This is useful * when the established communication channel might include some data that might * be useful for debugging/trouble-shooting. * @param restricted If true, this channel won't accept {@link Command}s that allow the remote end to execute arbitrary closures * --- instead they can only call methods on objects that are exported by this channel. * This also prevents the remote end from loading classes into JVM. * <p/> * Note that it still allows the remote end to deserialize arbitrary object graph * (provided that all the classes are already available in this JVM), so exactly how * safe the resulting behavior is is up to discussion. */ public Channel(String name, ExecutorService exec, Mode mode, InputStream is, OutputStream os, OutputStream header, boolean restricted) throws IOException { this(name, exec, mode, is, os, header, restricted, new Capability()); }
/** * Creates a new channel. * * @param name Human readable name of this channel. Used for debug/logging. Can be anything. * @param exec Commands sent from the remote peer will be executed by using this {@link Executor}. * @param mode The encoding to be used over the stream. * @param is Stream connected to the remote peer. It's the caller's responsibility to do * buffering on this stream, if that's necessary. * @param os Stream connected to the remote peer. It's the caller's responsibility to do * buffering on this stream, if that's necessary. * @param header If non-null, receive the portion of data in <tt>is</tt> before * the data goes into the "binary mode". This is useful * when the established communication channel might include some data that might * be useful for debugging/trouble-shooting. * @param restricted If true, this channel won't accept {@link Command}s that allow the remote end to execute arbitrary closures * --- instead they can only call methods on objects that are exported by this channel. * This also prevents the remote end from loading classes into JVM. * <p/> * Note that it still allows the remote end to deserialize arbitrary object graph * (provided that all the classes are already available in this JVM), so exactly how * safe the resulting behavior is is up to discussion. */ public Channel(String name, ExecutorService exec, Mode mode, InputStream is, OutputStream os, OutputStream header, boolean restricted) throws IOException { this(name, exec, mode, is, os, header, restricted, new Capability()); }
/** * Creates a new channel. * * @param restricted * See {@link #Channel(String, ExecutorService, Mode, InputStream, OutputStream, OutputStream, boolean, ClassLoader)} * @deprecated as of 2.24 * Use {@link ChannelBuilder} */ @Deprecated public Channel(String name, ExecutorService exec, Mode mode, InputStream is, OutputStream os, OutputStream header, boolean restricted, ClassLoader base) throws IOException { this(name,exec,mode,is,os,header,restricted,base,new Capability()); }
/** * Creates a new channel. * * @param name Human readable name of this channel. Used for debug/logging. Can be anything. * @param exec Commands sent from the remote peer will be executed by using this {@link Executor}. * @param mode The encoding to be used over the stream. * @param is Stream connected to the remote peer. It's the caller's responsibility to do * buffering on this stream, if that's necessary. * @param os Stream connected to the remote peer. It's the caller's responsibility to do * buffering on this stream, if that's necessary. * @param header If non-null, receive the portion of data in <tt>is</tt> before * the data goes into the "binary mode". This is useful * when the established communication channel might include some data that might * be useful for debugging/trouble-shooting. * @param restricted If true, this channel won't accept {@link Command}s that allow the remote end to execute arbitrary closures * --- instead they can only call methods on objects that are exported by this channel. * This also prevents the remote end from loading classes into JVM. * <p/> * Note that it still allows the remote end to deserialize arbitrary object graph * (provided that all the classes are already available in this JVM), so exactly how * safe the resulting behavior is is up to discussion. */ public Channel(String name, ExecutorService exec, Mode mode, InputStream is, OutputStream os, OutputStream header, boolean restricted) throws IOException { this(name, exec, mode, is, os, header, restricted, new Capability()); }
protected Capability createCapability() { return new Capability(); } }
/** * {@inheritDoc} */ @Override public void start() throws IOException { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = AnonymousClassWarnings.checkingObjectOutputStream(BinarySafeStream.wrap(bos)); try { oos.writeObject(new Capability()); } finally { oos.close(); } ByteBuffer buffer = ByteBufferUtils.wrapUTF8(bos.toString("US-ASCII")); write(buffer); } catch (IOException e) { futureChannel.setException(e); } }
byte[][] preambles = new byte[][]{Mode.BINARY.preamble, Mode.TEXT.preamble, Capability.PREAMBLE}; int[] ptr=new int[3]; Capability cap = new Capability(0); // remote capacity that we obtained. If we don't hear from remote, assume no capability
byte[][] preambles = new byte[][]{Mode.BINARY.preamble, Mode.TEXT.preamble, Capability.PREAMBLE}; int[] ptr = new int[3]; Capability cap = new Capability( 0); // remote capacity that we obtained. If we don't hear from remote, assume no capability
byte[][] preambles = new byte[][]{Mode.BINARY.preamble, Mode.TEXT.preamble, Capability.PREAMBLE}; int[] ptr = new int[3]; Capability cap = new Capability( 0); // remote capacity that we obtained. If we don't hear from remote, assume no capability
byte[][] preambles = new byte[][]{Mode.BINARY.preamble, Mode.TEXT.preamble, Capability.PREAMBLE}; int[] ptr = new int[3]; Capability cap = new Capability( 0); // remote capacity that we obtained. If we don't hear from remote, assume no capability