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 ServiceContextaddServiceListener in interface org.osgi.framework.BundleContextlistener - 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 ServiceContextaddServiceListener in interface org.osgi.framework.BundleContextlistener - 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 ServiceContextgetAllServiceReferences in interface org.osgi.framework.BundleContextclazz - 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 ServiceContextgetService in interface org.osgi.framework.BundleContextref - the service referenceServiceContext.getService(org.osgi.framework.ServiceReference)public org.osgi.framework.ServiceReference getServiceReference(java.lang.String clazz)
getServiceReference in interface ServiceContextgetServiceReference in interface org.osgi.framework.BundleContextclazz - 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.BundleContextS - 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.BundleContextS - 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 ServiceContextgetServiceReferences in interface org.osgi.framework.BundleContextclazz - 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 ServiceContextregisterService in interface org.osgi.framework.BundleContextclazzes - 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 ServiceContextregisterService in interface org.osgi.framework.BundleContextclazz - 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 ServiceContextremoveServiceListener in interface org.osgi.framework.BundleContextlistener - the service listener to removeServiceContext.removeServiceListener(org.osgi.framework.ServiceListener)public boolean ungetService(org.osgi.framework.ServiceReference reference)
ungetService in interface ServiceContextungetService in interface org.osgi.framework.BundleContextreference - 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.BundleContextarg0 - : bundle listener to addBundleContext.addBundleListener(org.osgi.framework.BundleListener)public void addFrameworkListener(org.osgi.framework.FrameworkListener arg0)
addFrameworkListener in interface org.osgi.framework.BundleContextarg0 - : 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.BundleContextarg0 - 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.BundleContexts - the namenull if not foundpublic org.osgi.framework.Bundle getBundle()
getBundle in interface org.osgi.framework.BundleContextgetBundle in interface org.osgi.framework.BundleReferenceBundleContext.getBundle()public org.osgi.framework.Bundle getBundle(long bundleId)
getBundle in interface org.osgi.framework.BundleContextbundleId - the bundle idBundleContext.getBundle(long)public org.osgi.framework.Bundle[] getBundles()
getBundles in interface org.osgi.framework.BundleContextBundleContext.getBundles()public java.io.File getDataFile(java.lang.String filename)
getDataFile in interface org.osgi.framework.BundleContextfilename - the File name.BundleContext.getDataFile(java.lang.String)public java.lang.String getProperty(java.lang.String key)
getProperty in interface org.osgi.framework.BundleContextkey - 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.BundleContextlocation - 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.BundleContextlocation - 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.BundleContextlistener - the listener to removeBundleContext.removeBundleListener(org.osgi.framework.BundleListener)public void removeFrameworkListener(org.osgi.framework.FrameworkListener listener)
removeFrameworkListener in interface org.osgi.framework.BundleContextlistener - 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.BundleContextS - the type of serviceclazz - the class objectsvc - the service objectproperties - the propertiesCopyright © 2006-2014 The Apache Software Foundation. All Rights Reserved.