Top Description Fields Constructors Methods
org.osgi.framework

public final Class BundlePermission

Additional top-level class in compilation unit: BundlePermissionCollection.

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

A bundle's authority to require or provide a bundle or to receive or attach fragments.

A bundle symbolic name defines a unique fully qualified name. Wildcards may be used.

name ::= <symbolic name> | <symbolic name ending in ".*"> | *
Examples:
org.osgi.example.bundle
org.osgi.example.*
*

BundlePermission has four actions: provide, require, host, and fragment. The provide action implies the require action.

Author
$Id: 5d3a115a2622919f564e2a2f46d70090ad9859cb $
Since
1.3

Field Summary

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

The actions mask.

pack-priv static final int
private static final int
private static final int
private volatile String
actions

The actions in canonical form.

public static final String
FRAGMENT

The action string fragment.

public static final String
HOST

The action string host.

public static final String
PROVIDE

The action string provide.

public static final String
REQUIRE

The action string require.

private static final long

Constructor Summary

AccessConstructor and Description
public
BundlePermission(String
The bundle symbolic name.
symbolicName
,
String
provide,require, host, fragment (canonical order).
actions
)

Defines the authority to provide and/or require and or specify a host fragment symbolic name within the OSGi environment.

pack-priv
BundlePermission(String
the bundle symbolic name
symbolicName
,
int
the action mask
mask
)

Package private constructor used by BundlePermissionCollection.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

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

Overrides java.security.BasicPermission.equals.

Determines the equality of two BundlePermission objects.

public String

Returns:

Canonical string representation of the BundlePermission actions.
getActions
()

Overrides java.security.BasicPermission.getActions.

Returns the canonical string representation of the BundlePermission 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
()

Overrides java.security.BasicPermission.hashCode.

Returns the hash code value for this object.

public boolean

Returns:

true if the specified BundlePermission action is implied by this object; false otherwise.
implies
(Permission
The requested permission.
p
)

Overrides java.security.BasicPermission.implies.

Determines if the specified permission is implied by this object.

public PermissionCollection

Returns:

A new PermissionCollection object.
newPermissionCollection
()

Overrides java.security.BasicPermission.newPermissionCollection.

Returns a new PermissionCollection object suitable for storing BundlePermission objects.

private static int

Returns:

action mask.
parseActions
(String
Action string.
actions
)

Parse action string into action mask.

private synchronized void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
s
)

Hides java.security.BasicPermission.readObject.

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

private synchronized void
setTransients(int mask)

Called by constructors and when deserialized.

private synchronized void
writeObject(ObjectOutputStream s)

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

Field Detail

ACTION_ALLback to summary
private static final int ACTION_ALL
ACTION_FRAGMENTback to summary
private static final int ACTION_FRAGMENT
ACTION_HOSTback to summary
private static final int ACTION_HOST
action_maskback to summary
private transient int action_mask

The actions mask.

ACTION_NONEback to summary
pack-priv static final int ACTION_NONE
ACTION_PROVIDEback to summary
private static final int ACTION_PROVIDE
ACTION_REQUIREback to summary
private static final int ACTION_REQUIRE
actionsback to summary
private volatile String actions

The actions in canonical form.

FRAGMENTback to summary
public static final String FRAGMENT

The action string fragment.

HOSTback to summary
public static final String HOST

The action string host.

PROVIDEback to summary
public static final String PROVIDE

The action string provide. The provide action implies the require action.

REQUIREback to summary
public static final String REQUIRE

The action string require. The require action is implied by the provide action.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.security.BasicPermission.serialVersionUID.

Constructor Detail

BundlePermissionback to summary
public BundlePermission(String symbolicName, String actions)

Defines the authority to provide and/or require and or specify a host fragment symbolic name within the OSGi environment.

Bundle Permissions are granted over all possible versions of a bundle. A bundle that needs to provide a bundle must have the appropriate BundlePermission for the symbolic name; a bundle that requires a bundle must have the appropriate BundlePermssion for that symbolic name; a bundle that specifies a fragment host must have the appropriate BundlePermission for that symbolic name.

Parameters
symbolicName:String

The bundle symbolic name.

actions:String

provide,require, host, fragment (canonical order).

BundlePermissionback to summary
pack-priv BundlePermission(String symbolicName, int mask)

Package private constructor used by BundlePermissionCollection.

Parameters
symbolicName:String

the bundle symbolic name

mask:int

the action mask

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.security.BasicPermission.equals.

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

Parameters
obj:Object

The object to test for equality with this BundlePermission object.

Returns:boolean

true if obj is a BundlePermission, and has the same bundle symbolic name and actions as this BundlePermission object; false otherwise.

Annotations
@Override
getActionsback to summary
public String getActions()

Overrides java.security.BasicPermission.getActions.

Returns the canonical string representation of the BundlePermission actions.

Always returns present BundlePermission actions in the following order: provide, require, host, fragment.

Returns:String

Canonical string representation of the BundlePermission actions.

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

Returns the current action mask.

Used by the BundlePermissionCollection class.

Returns:int

Current action mask.

hashCodeback to summary
public int hashCode()

Overrides java.security.BasicPermission.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)

Overrides java.security.BasicPermission.implies.

Determines if the specified permission is implied by this object.

This method checks that the symbolic name of the target is implied by the symbolic name of this object. The list of BundlePermission actions must either match or allow for the list of the target object to imply the target BundlePermission action.

The permission to provide a bundle implies the permission to require the named symbolic name.

      x.y.*,"provide" -> x.y.z,"provide" is true
      *,"require" -> x.y, "require"      is true
      *,"provide" -> x.y, "require"      is true
      x.y,"provide" -> x.y.z, "provide"  is false
Parameters
p:Permission

The requested permission.

Returns:boolean

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

Annotations
@Override
newPermissionCollectionback to summary
public PermissionCollection newPermissionCollection()

Overrides java.security.BasicPermission.newPermissionCollection.

Returns a new PermissionCollection object suitable for storing BundlePermission objects.

Returns:PermissionCollection

A new PermissionCollection object.

Annotations
@Override
parseActionsback to summary
private static int parseActions(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

Hides java.security.BasicPermission.readObject.

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

Parameters
s:ObjectInputStream

Doc from java.security.BasicPermission.readObject.

the ObjectInputStream from which data is read

Exceptions
IOException:

Doc from java.security.BasicPermission.readObject.

if an I/O error occurs

ClassNotFoundException:

Doc from java.security.BasicPermission.readObject.

if a serialized class cannot be loaded

setTransientsback to summary
private synchronized void setTransients(int mask)

Called by constructors and when deserialized.

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

WriteObject is called to save the state of the BundlePermission object to a stream. The actions are serialized, and the superclass takes care of the name.