Package org.jenkinsci.remoting
Class Role
- java.lang.Object
-
- org.jenkinsci.remoting.Role
-
public final class Role extends Object
Represents different roles two sides of the channel plays.Often the communication on
Channel
is asymmetric (for example, one side acts like a server and the other side acts like a client), and therefore it is useful to be able to markCallable
with the intended parties that are supposed to run them. This in turn allows parties to verify that it is not runningCallable
s that it is not supposed to be executing.Role
s are compared based on the instance equality, so typically they'd be instantiated as singletons. For example, if you are designing a client/server protocol, you would have two role instances like this:public class MyProtocol { public static final Role SERVER = new Role("server"); public static final Role CLIENT = new Role("client"); }
Then the callables that are meant to be run on the client would check
CLIENT
fromRoleSensitive.checkRoles(RoleChecker)
:// from the server channelToClient.call(new Callable<Void,IOException>() { Void call() { ... } void checkRoles(RoleChecker checker) { checker.check(this,MyProtocol.CLIENT); } });
- Author:
- Kohsuke Kawaguchi
- See Also:
RoleSensitive
,RoleChecker
-
-
Field Summary
Fields Modifier and Type Field Description static Role
UNKNOWN
Used as a place holder whenCallable
didn't declare any role.static Collection<Role>
UNKNOWN_SET
Convenience singleton collection that only includeUNKNOWN
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
String
getName()
Gets a human readable name of this role.int
hashCode()
String
toString()
-
-
-
Field Detail
-
UNKNOWN
public static final Role UNKNOWN
Used as a place holder whenCallable
didn't declare any role.
-
UNKNOWN_SET
public static final Collection<Role> UNKNOWN_SET
Convenience singleton collection that only includeUNKNOWN
-
-