public class PolicyServiceContext extends java.lang.Object implements ServiceContext
Modifier and Type | Field and Description |
---|---|
static int |
GLOBAL
Resolving policy, resolves services inside the global context
only.
|
static int |
LOCAL
Resolving policy, resolves services only in the composite
context (local).
|
static int |
LOCAL_AND_GLOBAL
Resolving policy, resolves services only in the composite
(local) and in the global context.
|
org.osgi.framework.BundleContext |
m_global
The global service registry.
|
ServiceContext |
m_local
The local (Composite) Service Registry.
|
Constructor and Description |
---|
PolicyServiceContext(org.osgi.framework.BundleContext global,
ServiceContext local,
int policy)
Creates a PolicyServiceContext.
|
Modifier and Type | Method and Description |
---|---|
void |
addBundleListener(org.osgi.framework.BundleListener arg0)
Adds a bundle listener.
|
void |
addFrameworkListener(org.osgi.framework.FrameworkListener arg0)
Adds a framework listener.
|
void |
addServiceListener(org.osgi.framework.ServiceListener listener)
Adds a service listener according to the policy.
|
void |
addServiceListener(org.osgi.framework.ServiceListener listener,
java.lang.String filter)
Adds a service listener according to the policy.
|
org.osgi.framework.Filter |
createFilter(java.lang.String arg0)
Creates a LDAP filter.
|
org.osgi.framework.ServiceReference[] |
getAllServiceReferences(java.lang.String clazz,
java.lang.String filter)
Gets all service references.
|
org.osgi.framework.Bundle |
getBundle()
Gets the current bundle.
|
org.osgi.framework.Bundle |
getBundle(long bundleId)
Gets the bundle object with the given id.
|
org.osgi.framework.Bundle |
getBundle(java.lang.String s)
Gets a bundle by name
|
org.osgi.framework.Bundle[] |
getBundles()
Gets installed bundles.
|
java.io.File |
getDataFile(java.lang.String filename)
Gets a data file.
|
java.lang.String |
getProperty(java.lang.String key)
Gets a property value.
|
java.lang.Object |
getService(org.osgi.framework.ServiceReference ref)
Gets the service object for the given references.
|
<S> org.osgi.framework.ServiceReference<S> |
getServiceReference(java.lang.Class<S> sClass)
Gets a service reference.
|
org.osgi.framework.ServiceReference |
getServiceReference(java.lang.String clazz)
Gets a service reference for the required service specification.
|
<S> java.util.Collection<org.osgi.framework.ServiceReference<S>> |
getServiceReferences(java.lang.Class<S> clazz,
java.lang.String filter)
Gets a collection of service references
|
org.osgi.framework.ServiceReference[] |
getServiceReferences(java.lang.String clazz,
java.lang.String filter)
Get a service reference for the required service specification.
|
org.osgi.framework.Bundle |
installBundle(java.lang.String location)
Installs a bundle.
|
org.osgi.framework.Bundle |
installBundle(java.lang.String location,
java.io.InputStream input)
Installs a bundle.
|
<S> org.osgi.framework.ServiceRegistration<S> |
registerService(java.lang.Class<S> clazz,
S svc,
java.util.Dictionary<java.lang.String,?> properties)
Registers a service.
|
org.osgi.framework.ServiceRegistration |
registerService(java.lang.String[] clazzes,
java.lang.Object service,
java.util.Dictionary properties)
This method is not supported.
|
org.osgi.framework.ServiceRegistration |
registerService(java.lang.String clazz,
java.lang.Object service,
java.util.Dictionary properties)
This method is not supported.
|
void |
removeBundleListener(org.osgi.framework.BundleListener listener)
Removes the bundle listener.
|
void |
removeFrameworkListener(org.osgi.framework.FrameworkListener listener)
Removes a framework listener.
|
void |
removeServiceListener(org.osgi.framework.ServiceListener listener)
Removes a service listener.
|
boolean |
ungetService(org.osgi.framework.ServiceReference reference)
Ungets the service reference.
|
public static final int LOCAL
public static final int LOCAL_AND_GLOBAL
public static final int GLOBAL
public org.osgi.framework.BundleContext m_global
public ServiceContext m_local
public PolicyServiceContext(org.osgi.framework.BundleContext global, ServiceContext local, int policy)
GLOBAL
, else use the
given policy.global
- the global bundle contextlocal
- the parent (local) service contextpolicy
- the resolution policypublic void addServiceListener(org.osgi.framework.ServiceListener listener, java.lang.String filter) throws org.osgi.framework.InvalidSyntaxException
LOCAL_AND_GLOBAL
is used.addServiceListener
in interface ServiceContext
addServiceListener
in interface org.osgi.framework.BundleContext
listener
- the listener to addfilter
- the LDAP filterorg.osgi.framework.InvalidSyntaxException
- if the filter is malformed.ServiceContext.addServiceListener(org.osgi.framework.ServiceListener, java.lang.String)
public void addServiceListener(org.osgi.framework.ServiceListener listener)
LOCAL_AND_GLOBAL
is used.addServiceListener
in interface ServiceContext
addServiceListener
in interface org.osgi.framework.BundleContext
listener
- the listener to addServiceContext.addServiceListener(org.osgi.framework.ServiceListener)
public org.osgi.framework.ServiceReference[] getAllServiceReferences(java.lang.String clazz, java.lang.String filter) throws org.osgi.framework.InvalidSyntaxException
getAllServiceReferences
in interface ServiceContext
getAllServiceReferences
in interface org.osgi.framework.BundleContext
clazz
- the required service specification.filter
- the LDAP filternull
if no service availableorg.osgi.framework.InvalidSyntaxException
- if the LDAP filter is malformedServiceContext.getAllServiceReferences(java.lang.String, java.lang.String)
public java.lang.Object getService(org.osgi.framework.ServiceReference ref)
getService
in interface ServiceContext
getService
in interface org.osgi.framework.BundleContext
ref
- the service referenceServiceContext.getService(org.osgi.framework.ServiceReference)
public org.osgi.framework.ServiceReference getServiceReference(java.lang.String clazz)
getServiceReference
in interface ServiceContext
getServiceReference
in interface org.osgi.framework.BundleContext
clazz
- the required service specificationnull
if no matching service availableServiceContext.getServiceReference(java.lang.String)
public <S> org.osgi.framework.ServiceReference<S> getServiceReference(java.lang.Class<S> sClass)
getServiceReference
in interface org.osgi.framework.BundleContext
S
- the service interface classsClass
- the service interface classnull
if not foundgetServiceReference(String)
public <S> java.util.Collection<org.osgi.framework.ServiceReference<S>> getServiceReferences(java.lang.Class<S> clazz, java.lang.String filter) throws org.osgi.framework.InvalidSyntaxException
getServiceReferences
in interface org.osgi.framework.BundleContext
S
- the service interface classclazz
- the service interface classfilter
- the filterorg.osgi.framework.InvalidSyntaxException
- the filter is invalidgetServiceReferences(String, String)
public org.osgi.framework.ServiceReference[] getServiceReferences(java.lang.String clazz, java.lang.String filter) throws org.osgi.framework.InvalidSyntaxException
getServiceReferences
in interface ServiceContext
getServiceReferences
in interface org.osgi.framework.BundleContext
clazz
- the required service specificationfilter
- the LDAP filternull
if not consistent service availableorg.osgi.framework.InvalidSyntaxException
- if the LDAP filter is malformedServiceContext.getServiceReference(java.lang.String)
public org.osgi.framework.ServiceRegistration registerService(java.lang.String[] clazzes, java.lang.Object service, java.util.Dictionary properties)
registerService
in interface ServiceContext
registerService
in interface org.osgi.framework.BundleContext
clazzes
- the specificationsservice
- the service objectproperties
- the service propertiesServiceContext.registerService(java.lang.String[], java.lang.Object, java.util.Dictionary)
public org.osgi.framework.ServiceRegistration registerService(java.lang.String clazz, java.lang.Object service, java.util.Dictionary properties)
registerService
in interface ServiceContext
registerService
in interface org.osgi.framework.BundleContext
clazz
- the specificationservice
- the service objectproperties
- the service properties to publishServiceContext.registerService(java.lang.String, java.lang.Object, java.util.Dictionary)
public void removeServiceListener(org.osgi.framework.ServiceListener listener)
removeServiceListener
in interface ServiceContext
removeServiceListener
in interface org.osgi.framework.BundleContext
listener
- the service listener to removeServiceContext.removeServiceListener(org.osgi.framework.ServiceListener)
public boolean ungetService(org.osgi.framework.ServiceReference reference)
ungetService
in interface ServiceContext
ungetService
in interface org.osgi.framework.BundleContext
reference
- the service reference to unget.true
if the service release if the reference is no more used.ServiceContext.ungetService(org.osgi.framework.ServiceReference)
public void addBundleListener(org.osgi.framework.BundleListener arg0)
addBundleListener
in interface org.osgi.framework.BundleContext
arg0
- : bundle listener to addBundleContext.addBundleListener(org.osgi.framework.BundleListener)
public void addFrameworkListener(org.osgi.framework.FrameworkListener arg0)
addFrameworkListener
in interface org.osgi.framework.BundleContext
arg0
- : framework listener to add.BundleContext.addFrameworkListener(org.osgi.framework.FrameworkListener)
public org.osgi.framework.Filter createFilter(java.lang.String arg0) throws org.osgi.framework.InvalidSyntaxException
createFilter
in interface org.osgi.framework.BundleContext
arg0
- the String-form of the filterorg.osgi.framework.InvalidSyntaxException
- if the given argument is not a valid against the LDAP grammar.BundleContext.createFilter(java.lang.String)
public org.osgi.framework.Bundle getBundle(java.lang.String s)
getBundle
in interface org.osgi.framework.BundleContext
s
- the namenull
if not foundpublic org.osgi.framework.Bundle getBundle()
getBundle
in interface org.osgi.framework.BundleContext
getBundle
in interface org.osgi.framework.BundleReference
BundleContext.getBundle()
public org.osgi.framework.Bundle getBundle(long bundleId)
getBundle
in interface org.osgi.framework.BundleContext
bundleId
- the bundle idBundleContext.getBundle(long)
public org.osgi.framework.Bundle[] getBundles()
getBundles
in interface org.osgi.framework.BundleContext
BundleContext.getBundles()
public java.io.File getDataFile(java.lang.String filename)
getDataFile
in interface org.osgi.framework.BundleContext
filename
- the File name.BundleContext.getDataFile(java.lang.String)
public java.lang.String getProperty(java.lang.String key)
getProperty
in interface org.osgi.framework.BundleContext
key
- the key of the asked propertynull
if no property
are associated with the given keyBundleContext.getProperty(java.lang.String)
public org.osgi.framework.Bundle installBundle(java.lang.String location) throws org.osgi.framework.BundleException
installBundle
in interface org.osgi.framework.BundleContext
location
- the URL of the bundle to installorg.osgi.framework.BundleException
- if the bundle cannot be installed correctlyBundleContext.installBundle(java.lang.String)
public org.osgi.framework.Bundle installBundle(java.lang.String location, java.io.InputStream input) throws org.osgi.framework.BundleException
installBundle
in interface org.osgi.framework.BundleContext
location
- the URL of the bundle to installinput
- the input stream to load the bundle contentorg.osgi.framework.BundleException
- if the bundle cannot be installed correctlyBundleContext.installBundle(java.lang.String, java.io.InputStream)
public void removeBundleListener(org.osgi.framework.BundleListener listener)
removeBundleListener
in interface org.osgi.framework.BundleContext
listener
- the listener to removeBundleContext.removeBundleListener(org.osgi.framework.BundleListener)
public void removeFrameworkListener(org.osgi.framework.FrameworkListener listener)
removeFrameworkListener
in interface org.osgi.framework.BundleContext
listener
- the listener to removeBundleContext.removeFrameworkListener(org.osgi.framework.FrameworkListener)
public <S> org.osgi.framework.ServiceRegistration<S> registerService(java.lang.Class<S> clazz, S svc, java.util.Dictionary<java.lang.String,?> properties)
registerService
in interface org.osgi.framework.BundleContext
S
- the type of serviceclazz
- the class objectsvc
- the service objectproperties
- the propertiesCopyright © 2006-2014 The Apache Software Foundation. All Rights Reserved.