Package hudson.remoting
Class ChannelBuilder
java.lang.Object
hudson.remoting.ChannelBuilder
- Direct Known Subclasses:
NioChannelBuilder
Factory for
Channel
, including hand-shaking between two sides
and various configuration switches to change the behaviour of Channel
.- Author:
- Kohsuke Kawaguchi
-
Constructor Summary
ConstructorDescriptionChannelBuilder
(String name, ExecutorService executors) Specify the minimum mandatory parameters. -
Method Summary
Modifier and TypeMethodDescriptionbuild
(CommandTransport transport) build
(InputStream is, OutputStream os) Performs a handshake over the communication channel and builds aChannel
.Gets the JAR Cache storage.getMode()
getName()
boolean
boolean
boolean
Deprecated.Test individual features instead.protected CommandTransport
makeTransport
(InputStream is, OutputStream os, Channel.Mode mode, Capability cap) Instantiate a transport.protected CommandTransport
negotiate
(InputStream is, OutputStream os) Performs hand-shaking and creates aCommandTransport
.with
(CallableDecorator decorator) withArbitraryCallableAllowed
(boolean b) If false, this channel only allows the other side to invoke methods on exported objects, but notChannel.call(Callable)
(and its family of methods.) The default istrue
.withBaseLoader
(ClassLoader base) Specify the classloader used for deserializing remote commands.withCapability
(Capability capability) Controls the capabilities that we'll advertise to the other side.withClassFilter
(ClassFilter filter) Replaces theClassFilter
used by the channel.withHeaderStream
(OutputStream header) If non-null, receive the portion of data inis
before the data goes into the "binary mode".withJarCache
(JarCache jarCache) Sets the JAR cache storage.withJarCacheOrDefault
(JarCache jarCache) Sets the JAR cache storage.withMode
(Channel.Mode mode) The encoding to be used over the stream.Resets JAR Cache setting to the default.<T> ChannelBuilder
withProperty
(ChannelProperty<T> key, T value) withProperty
(Object key, Object value) Sets the property.withRemoteClassLoadingAllowed
(boolean b) Controls whether or not this channel is willing to load classes from the other side.withRestricted
(boolean restricted) Deprecated.Control individual features.withRoleChecker
(RoleChecker checker) Installs anotherRoleChecker
.withRoles
(Collection<? extends Role> actual) Convenience method to installRoleChecker
that verifies against the fixed set of roles.Convenience method to installRoleChecker
that verifies against the fixed set of roles.
-
Constructor Details
-
ChannelBuilder
Specify the minimum mandatory parameters.- Parameters:
name
- Human readable name of this channel. Used for debug/logging. Can be anything.executors
- Commands sent from the remote peer will be executed by using thisExecutor
.
-
-
Method Details
-
getName
-
getExecutors
-
withBaseLoader
Specify the classloader used for deserializing remote commands. This is primarily related toChannel.getRemoteProperty(Object)
. Sometimes two parties communicate over a channel and pass objects around as properties, but those types might not be visible from the classloader loading theChannel
class. In such a case, specify a classloader so that those classes resolve. If null,Channel.class.getClassLoader()
is used. -
getBaseLoader
-
withMode
The encoding to be used over the stream. -
getMode
-
withCapability
Controls the capabilities that we'll advertise to the other side. -
getCapability
-
withHeaderStream
If non-null, receive the portion of data inis
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. -
getHeaderStream
-
withRestricted
Deprecated.Control individual features.For compatibility reasons, activates/disables all the security restriction features. -
isRestricted
Deprecated.Test individual features instead. -
withArbitraryCallableAllowed
If false, this channel only allows the other side to invoke methods on exported objects, but notChannel.call(Callable)
(and its family of methods.) The default istrue
.- Since:
- 2.47
-
isArbitraryCallableAllowed
public boolean isArbitraryCallableAllowed()- Since:
- 2.47
-
withRemoteClassLoadingAllowed
Controls whether or not this channel is willing to load classes from the other side. The default istrue
.- Since:
- 2.47
-
isRemoteClassLoadingAllowed
public boolean isRemoteClassLoadingAllowed()- Since:
- 2.47
-
withJarCache
Sets the JAR cache storage.- Parameters:
jarCache
- JAR Cache to be used. If a deprecatednull
value is passed, the behavior will be determined by theChannel
implementation.- Returns:
this
- Since:
- 2.38, 3.12
null
parameter value is deprecated.withoutJarCache()
orwithJarCacheOrDefault(JarCache)
should be used instead.
-
withJarCacheOrDefault
Sets the JAR cache storage.- Parameters:
jarCache
- JAR Cache to be used. Ifnull
, value ofJarCache.getDefault()
will be used.- Returns:
this
- Throws:
IOException
- Default JAR Cache location cannot be initialized- Since:
- 3.12
-
withoutJarCache
Resets JAR Cache setting to the default. The behavior will be determined by theChannel
implementation.- Since:
- 3.12
-
getJarCache
Gets the JAR Cache storage.- Returns:
null
if it is not defined.Channel
implementation defines the behavior in such case.- Since:
- 2.38
-
with
-
getDecorators
-
withRoles
Convenience method to installRoleChecker
that verifies against the fixed set of roles.- Since:
- 2.47
-
withRoles
Convenience method to installRoleChecker
that verifies against the fixed set of roles.- Since:
- 2.47
-
withRoleChecker
Installs anotherRoleChecker
.- Since:
- 2.47
-
withProperty
Sets the property. Properties are modifiable afterChannel
is created, but a property set during channel building is guaranteed to be visible to the other side as soon as the channel is established.- Since:
- 2.47
-
withProperty
- Since:
- 2.47
-
getProperties
- Since:
- 2.47
-
withClassFilter
Replaces theClassFilter
used by the channel. By default,ClassFilter.DEFAULT
is installed.- Since:
- 2.53
-
getClassFilter
- Since:
- 2.53
-
build
Performs a handshake over the communication channel and builds aChannel
.- Parameters:
is
- Stream connected to the remote peer. It's the caller's responsibility to do buffering on this stream, if that's necessary.os
- Stream connected to the remote peer. It's the caller's responsibility to do buffering on this stream, if that's necessary.- Throws:
IOException
-
build
- Throws:
IOException
-
build
- Throws:
IOException
-
build
- Throws:
IOException
-
negotiate
Performs hand-shaking and creates aCommandTransport
. This is an implementation detail of ChannelBuilder and it's protected just so that- Throws:
IOException
-
makeTransport
protected CommandTransport makeTransport(InputStream is, OutputStream os, Channel.Mode mode, Capability cap) throws IOException Instantiate a transport.- Parameters:
is
- The negotiated input stream that hidesos
- the underlying stream.mode
- The mode to create the transport in.cap
- Capabilities of the other side, as determined during the handshaking.- Throws:
IOException
-