Top Description Fields Constructors Methods
org.osgi.service.event

public final Class TopicPermission

Additional top-level class in compilation unit: TopicPermissionCollection.

extends Permission
Class Inheritance
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .ObjectStreamField, java.security.Permission, .PermissionCollection, java.util.ArrayList, .Collections, .Enumeration, .HashMap, .Hashtable, .List, .Map

A bundle's authority to publish or subscribe to event on a topic.

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.

Author
$Id: 14ef62cb63cf763529bcb4ce1db502bb82cc151f $

Field Summary

Modifier and TypeField and Description
private static final int
private transient int
action_mask

The actions mask.

private static final int
private static final int
private static final int
private volatile String
actions

The actions in canonical form.

private transient volatile String
prefix

prefix if the name is wildcarded.

public static final String
PUBLISH

The action string publish.

pack-priv static final long
public static final String
SUBSCRIBE

The action string subscribe.

Constructor Summary

AccessConstructor and Description
public
TopicPermission(String
Topic name.
name
,
String
publish,subscribe (canonical order).
actions
)

Defines the authority to publish and/or subscribe to a topic within the EventAdmin service.

pack-priv
TopicPermission(String
class name
name
,
int
action mask
mask
)

Package private constructor used by TopicPermissionCollection.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if obj is a TopicPermission, and has the same topic name and actions as this TopicPermission object; false otherwise.
equals
(Object
The object to test for equality with this TopicPermission object.
obj
)

Implements abstract java.security.Permission.equals.

Determines the equality of two TopicPermission objects.

public String

Returns:

Canonical string representation of the TopicPermission actions.
getActions
()

Implements abstract java.security.Permission.getActions.

Returns the canonical string representation of the TopicPermission actions.

pack-priv synchronized int

Returns:

Current action mask.
getActionsMask
()

Returns the current action mask.

public int

Returns:

A hash code value for this object.
hashCode
()

Implements abstract java.security.Permission.hashCode.

Returns the hash code value for this object.

public boolean

Returns:

true if the specified TopicPermission action is implied by this object; false otherwise.
implies
(Permission
The target permission to interrogate.
p
)

Implements abstract java.security.Permission.implies.

Determines if the specified permission is implied by this object.

public PermissionCollection

Returns:

A new PermissionCollection object.
newPermissionCollection
()

Overrides java.security.Permission.newPermissionCollection.

Returns a new PermissionCollection object suitable for storing TopicPermission objects.

private static int

Returns:

action mask.
parseActions
(final String
Action string.
actions
)

Parse action string into action mask.

private synchronized void
readObject(ObjectInputStream s)

readObject is called to restore the state of this permission from a stream.

private synchronized void
setTransients(final int
action mask
mask
)

Called by constructors and when deserialized.

private synchronized void
writeObject(ObjectOutputStream s)

WriteObject is called to save the state of this permission object to a stream.

Inherited from java.security.Permission:
checkGuardgetNametoString

Field Detail

ACTION_ALLback to summary
private static final int ACTION_ALL
action_maskback to summary
private transient int action_mask

The actions mask.

ACTION_NONEback to summary
private static final int ACTION_NONE
ACTION_PUBLISHback to summary
private static final int ACTION_PUBLISH
ACTION_SUBSCRIBEback to summary
private static final int ACTION_SUBSCRIBE
actionsback to summary
private volatile String actions

The actions in canonical form.

prefixback to summary
private transient volatile String prefix

prefix if the name is wildcarded.

PUBLISHback to summary
public static final String PUBLISH

The action string publish.

serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides java.security.Permission.serialVersionUID.

SUBSCRIBEback to summary
public static final String SUBSCRIBE

The action string subscribe.

Constructor Detail

TopicPermissionback to summary
public TopicPermission(String name, String actions)

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 TopicPermission for that topic; similarly, a bundle that needs to subscribe to events on a topic must have the appropriate TopicPermssion for that topic.

Parameters
name:String

Topic name.

actions:String

publish,subscribe (canonical order).

TopicPermissionback to summary
pack-priv TopicPermission(String name, int mask)

Package private constructor used by TopicPermissionCollection.

Parameters
name:String

class name

mask:int

action mask

Method Detail

equalsback to summary
public boolean equals(Object obj)

Implements abstract java.security.Permission.equals.

Determines the equality of two TopicPermission objects. This method checks that specified TopicPermission has the same topic name and actions as this TopicPermission object.

Parameters
obj:Object

The object to test for equality with this TopicPermission object.

Returns:boolean

true if obj is a TopicPermission, and has the same topic name and actions as this TopicPermission object; false otherwise.

Annotations
@Override
getActionsback to summary
public String getActions()

Implements abstract java.security.Permission.getActions.

Returns the canonical string representation of the TopicPermission actions.

Always returns present TopicPermission actions in the following order: publish,subscribe.

Returns:String

Canonical string representation of the TopicPermission actions.

Annotations
@Override
getActionsMaskback to summary
pack-priv synchronized int getActionsMask()

Returns the current action mask.

Used by the TopicPermissionCollection class.

Returns:int

Current action mask.

hashCodeback to summary
public int hashCode()

Implements abstract java.security.Permission.hashCode.

Returns the hash code value for this object.

Returns:int

A hash code value for this object.

Annotations
@Override
impliesback to summary
public boolean implies(Permission p)

Implements abstract java.security.Permission.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 TopicPermission actions must either match or allow for the list of the target object to imply the target TopicPermission action.

   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
Parameters
p:Permission

The target permission to interrogate.

Returns:boolean

true if the specified TopicPermission action is implied by this object; false otherwise.

Annotations
@Override
newPermissionCollectionback to summary
public PermissionCollection newPermissionCollection()

Overrides java.security.Permission.newPermissionCollection.

Returns a new PermissionCollection object suitable for storing TopicPermission objects.

Returns:PermissionCollection

A new PermissionCollection object.

Annotations
@Override
parseActionsback to summary
private static int parseActions(final String actions)

Parse action string into action mask.

Parameters
actions:String

Action string.

Returns:int

action mask.

readObjectback to summary
private synchronized void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

readObject is called to restore the state of this permission from a stream.

setTransientsback to summary
private synchronized void setTransients(final int mask)

Called by constructors and when deserialized.

Parameters
mask:int

action mask

writeObjectback to summary
private synchronized void writeObject(ObjectOutputStream s) throws IOException

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.