Class TopicPermission
- All Implemented Interfaces:
Serializable,Guard
A topic is a slash-separated string that defines a topic.
For example:
org/osgi/service/foo/FooEvent/ACTION
TopicPermission has two actions: publish and
subscribe.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate intThe actions mask.private static final intprivate static final intprivate static final intprivate StringThe actions in canonical form.private Stringprefix if the name is wildcarded.static final StringThe action stringpublish.(package private) static final longstatic final StringThe action stringsubscribe. -
Constructor Summary
ConstructorsConstructorDescriptionTopicPermission(String name, int mask) Package private constructor used by TopicPermissionCollection.TopicPermission(String name, String actions) Defines the authority to publish and/or subscribe to a topic within the EventAdmin service. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines the equality of twoTopicPermissionobjects.Returns the canonical string representation of theTopicPermissionactions.(package private) intReturns the current action mask.inthashCode()Returns the hash code value for this object.booleanDetermines if the specified permission is implied by this object.Returns a newPermissionCollectionobject suitable for storingTopicPermissionobjects.private static intparseActions(String actions) Parse action string into action mask.private voidreadObject is called to restore the state of this permission from a stream.private voidsetTransients(int mask) Called by constructors and when deserialized.private voidWriteObject is called to save the state of this permission object to a stream.Methods inherited from class java.security.Permission
checkGuard, getName, toString
-
Field Details
-
serialVersionUID
static final long serialVersionUID- See Also:
-
PUBLISH
The action stringpublish.- See Also:
-
SUBSCRIBE
The action stringsubscribe.- See Also:
-
ACTION_PUBLISH
private static final int ACTION_PUBLISH- See Also:
-
ACTION_SUBSCRIBE
private static final int ACTION_SUBSCRIBE- See Also:
-
ACTION_ALL
private static final int ACTION_ALL- See Also:
-
ACTION_NONE
private static final int ACTION_NONE- See Also:
-
action_mask
private transient int action_maskThe actions mask. -
prefix
prefix if the name is wildcarded. -
actions
The actions in canonical form.
-
-
Constructor Details
-
TopicPermission
Defines the authority to publish and/or subscribe to a topic within the EventAdmin service.The name is specified as a slash-separated string. Wildcards may be used. For example:
org/osgi/service/fooFooEvent/ACTION com/isv/* *A bundle that needs to publish events on a topic must have the appropriate
TopicPermissionfor that topic; similarly, a bundle that needs to subscribe to events on a topic must have the appropriateTopicPermssionfor that topic.- Parameters:
name- Topic name.actions-publish,subscribe(canonical order).
-
TopicPermission
TopicPermission(String name, int mask) Package private constructor used by TopicPermissionCollection.- Parameters:
name- class namemask- action mask
-
-
Method Details
-
setTransients
private void setTransients(int mask) Called by constructors and when deserialized.- Parameters:
mask- action maskname- topic name
-
getActionsMask
int getActionsMask()Returns the current action mask.Used by the TopicPermissionCollection class.
- Returns:
- Current action mask.
-
parseActions
Parse action string into action mask.- Parameters:
actions- Action string.- Returns:
- action mask.
-
implies
Determines if the specified permission is implied by this object.This method checks that the topic name of the target is implied by the topic name of this object. The list of
TopicPermissionactions must either match or allow for the list of the target object to imply the targetTopicPermissionaction.x/y/*,"publish" -> x/y/z,"publish" is true *,"subscribe" -> x/y,"subscribe" is true *,"publish" -> x/y,"subscribe" is false x/y,"publish" -> x/y/z,"publish" is false- Specified by:
impliesin classPermission- Parameters:
p- The target permission to interrogate.- Returns:
trueif the specifiedTopicPermissionaction is implied by this object;falseotherwise.
-
getActions
Returns the canonical string representation of theTopicPermissionactions.Always returns present
TopicPermissionactions in the following order:publish,subscribe.- Specified by:
getActionsin classPermission- Returns:
- Canonical string representation of the
TopicPermissionactions.
-
newPermissionCollection
Returns a newPermissionCollectionobject suitable for storingTopicPermissionobjects.- Overrides:
newPermissionCollectionin classPermission- Returns:
- A new
PermissionCollectionobject.
-
equals
Determines the equality of twoTopicPermissionobjects. This method checks that specifiedTopicPermissionhas the same topic name and actions as thisTopicPermissionobject.- Specified by:
equalsin classPermission- Parameters:
obj- The object to test for equality with thisTopicPermissionobject.- Returns:
trueifobjis aTopicPermission, and has the same topic name and actions as thisTopicPermissionobject;falseotherwise.
-
hashCode
public int hashCode()Returns the hash code value for this object.- Specified by:
hashCodein classPermission- Returns:
- A hash code value for this object.
-
writeObject
WriteObject is called to save the state of this permission object to a stream. The actions are serialized, and the superclass takes care of the name.- Throws:
IOException
-
readObject
readObject is called to restore the state of this permission from a stream.- Throws:
IOExceptionClassNotFoundException
-