Package org.jenkinsci.remoting
Class Role
java.lang.Object
org.jenkinsci.remoting.Role
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 mark
Callable
with the intended parties that are supposed to run them. This in turn
allows parties to verify that it is not running Callable
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
from
RoleSensitive.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:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Role
Used as a place holder whenCallable
didn't declare any role.static final Collection<Role>
Convenience singleton collection that only includeUNKNOWN
-
Constructor Summary
-
Method Summary
-
Field Details
-
Constructor Details
-
Role
-
Role
-
-
Method Details
-
getName
Gets a human readable name of this role. Names are not a formal part of the role equality. That is, twoRole
instances are considered different even if they have the same name. -
toString
-
equals
-
hashCode
public int hashCode()
-