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
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 final | GET |
The action string “get.” | |
public static final | REGISTER |
The action string “register.” | |
Constructors | |
public | ServicePermission(String, String) |
Create a new permission for Service. | |
Methods | |
public boolean | equals(Object) |
Checks two ServicePermission for equality. | |
public String | getActions() |
Return the canonical string representation of the actions. | |
public int | hashCode() |
Returns the hash code value for this object. | |
public boolean | implies(Permission) |
Checks if this ServicePermission object “implies” the specified permission. |
public static final java.lang.String GET
The action string “get.”
public static final java.lang.String REGISTER
The action string “register.”
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:
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:
Returns: true if obj is a ServicePermission, and has the same class name and actions as this ServicePermission object. Otherwise, return false.
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
public int hashCode()
Returns the hash code value for this object.
Overrides: java.security.BasicPermission.hashCode() in class java.security.BasicPermission
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:
Returns: true if the specified permission is implied by this object, false if not.
public interface ServiceReference
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 Bundle | getBundle() |
Return the bundle which registered the service. | |
public Object | getProperty(String) |
Get the value of a service's property. | |
public String | getPropertyKeys() |
Get the list of key names for the service's properties. |
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)
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:
Returns: Value of the property or null if there is no property by that name.
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.)
18.117.7.131