ServicePermission

Syntax

public final class ServicePermission extends
   java.security.BasicPermission

java.lang.Object
  |
  +--java.security.Permission
        |
        +--java.security.BasicPermission
              |
              +--org.osgi.framework.ServicePermission
					

All Implemented Interfaces: java.security.Guard, java.io.Serializable

Description

ServicePermission indicates a bundle's right to register or get a service.

The “register” permission will allow the bundle to register a service on the specified names. The “get” permission allows a bundle to see a service and get it. Permission to get a service is required to see events regarding the service. Untrusted bundles should not be able to detect the presence of certain services unless they have authority to get the specific service.

Member Summary
Fields
public static finalGET
 The action string “get.”
public static finalREGISTER
 The action string “register.”
Constructors
publicServicePermission(String, String)
 Create a new permission for Service.
Methods
public booleanequals(Object)
 Checks two ServicePermission for equality.
public StringgetActions()
 Return the canonical string representation of the actions.
public inthashCode()
 Returns the hash code value for this object.
public booleanimplies(Permission)
 Checks if this ServicePermission object “implies” the specified permission.

Fields

GET
public static final java.lang.String GET
						

The action string “get.”

REGISTER
public static final java.lang.String REGISTER
							

The action string “register.”

Constructors
ServicePermission(String, String)
public ServicePermission(java.lang.String name,
             java.lang.String actions)

Create a new permission for Service. The name of the service is specified as a fully qualified class name.

ClassName ::= <class name> | <class name ending in '*'>

Examples:

org.osgi.service.http.HttpService
org.osgi.service.http.*
org.osgi.service.snmp.*

There are two possible actions: get and register. The get permission allows the owner of this permission to obtain a service with this name. The register permission allows the bundle to register a service under that name.

Parameters:

name— class name

actions— “get,” “register” (canonical order)

Methods
equals(Object)
public boolean equals(java.lang.Object obj)

Checks two ServicePermission for equality. Checks that obj has the same class name and action as this ServicePermission.

Overrides: java.security.BasicPermission.equals(java.lang.Object) in class java.security.BasicPermission

Parameters:

obj— the object to test for equality.

Returns: true if obj is a ServicePermission, and has the same class name and actions as this ServicePermission object. Otherwise, return false.

getActions()
public java.lang.String getActions()

Return the canonical string representation of the actions. Always returns present actions in the following order: get, register.

Overrides: java.security.BasicPermission.getActions() in class java.security.BasicPermission

Returns: The canonical string representation of the actions

hashCode()
public int hashCode()

Returns the hash code value for this object.

Overrides: java.security.BasicPermission.hashCode() in class java.security.BasicPermission

Returns: a hash code value for this object.

implies(Permission)
public boolean implies(java.security.Permission p)

Checks if this ServicePermission object “implies” the specified permission.

Overrides: java.security.BasicPermission.implies(java.security.Permission) in class java.security.BasicPermission

Parameters:

p— the target permission to check.

Returns: true if the specified permission is implied by this object, false if not.

ServiceReference

Syntax
public interface ServiceReference

Description

A reference to a service. The framework returns ServiceReference objects from the BundleContext.getServiceReference(String) and BundleContext.getServiceReferences(String, String) methods.

A ServiceReference may be shared between bundles and can be used to examine the properties of the service and to get the service object (See Bundle-Context.getService(ServiceReference) ). Every registered service has a unique ServiceRegistration object and may have multiple, distinct ServiceReference objects referring to it. ServiceReferences to the same ServiceRegistration instance are considered equal (i.e., their equals() method will return true when compared) and have the same hashCode. If the same service object is registered multiple times, ServiceReferences to different ServiceRegistrations are considered different.

Member Summary
Methods
public BundlegetBundle()
 Return the bundle which registered the service.
public ObjectgetProperty(String)
 Get the value of a service's property.
public StringgetPropertyKeys()
 Get the list of key names for the service's properties.

Methods

getBundle()
public Bundle getBundle()

Return the bundle which registered the service.

This method will always return null when the service has been unregistered. This can be used to determine if the service has been unregistered.

Returns: The bundle which registered the service.

See Also: BundleContext.registerService(String[], Object, Dictionary)

getProperty(String)
public java.lang.Object getProperty(java.lang.String key)

Get the value of a service's property.

This method will continue to return property values after the service has been unregistered. This is so that references to unregistered service can be interrogated. (For example: ServiceReference objects stored in the log.)

Parameters:

key— Name of the property.

Returns: Value of the property or null if there is no property by that name.

getPropertyKeys()
public java.lang.String[] getPropertyKeys()

Get the list of key names for the service's properties.

This method will continue to return the keys after the service has been unregistered. This is so that references to unregistered service can be interrogated. (For example: ServiceReference objects stored in the log.)

Returns: The list of property key names.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.101.109