public class IPojoContext extends java.lang.Object implements org.osgi.framework.BundleContext, ServiceContext
Constructor and Description |
---|
IPojoContext(org.osgi.framework.BundleContext context)
Creates an iPOJO Context.
|
IPojoContext(org.osgi.framework.BundleContext bundleContext,
ServiceContext serviceContext)
Creates an iPOJO Context.
|
Modifier and Type | Method and Description |
---|---|
void |
addBundleListener(org.osgi.framework.BundleListener listener)
Adds a bundle listener.
|
void |
addFrameworkListener(org.osgi.framework.FrameworkListener listener)
Adds a framework listener.
|
void |
addServiceListener(org.osgi.framework.ServiceListener listener)
Add a service listener.
|
void |
addServiceListener(org.osgi.framework.ServiceListener listener,
java.lang.String filter)
Adds a service listener.
|
org.osgi.framework.Filter |
createFilter(java.lang.String filter)
Creates a filter objects.
|
org.osgi.framework.ServiceReference[] |
getAllServiceReferences(java.lang.String clazz,
java.lang.String filter)
Gets the service references matching with the given query.
|
org.osgi.framework.Bundle |
getBundle()
Gets the current bundle object.
|
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 symbolic name
|
org.osgi.framework.Bundle[] |
getBundles()
Gets installed bundles.
|
java.io.File |
getDataFile(java.lang.String filename)
Gets a data file.
|
org.osgi.framework.BundleContext |
getGlobalContext()
Gets the global context, i.e.
|
java.lang.String |
getProperty(java.lang.String key)
Gets a property value.
|
<S> S |
getService(org.osgi.framework.ServiceReference<S> ref)
Gets a service object.
|
ServiceContext |
getServiceContext()
Gets the service context, i.e.
|
<S> org.osgi.framework.ServiceReference<S> |
getServiceReference(java.lang.Class<S> sClass)
Gets a service reference for the given interface.
|
org.osgi.framework.ServiceReference |
getServiceReference(java.lang.String clazz)
Gets a service reference for the given interface.
|
<S> java.util.Collection<org.osgi.framework.ServiceReference<S>> |
getServiceReferences(java.lang.Class<S> sClass,
java.lang.String filter)
Gets service reference list for the given query.
|
org.osgi.framework.ServiceReference[] |
getServiceReferences(java.lang.String clazz,
java.lang.String filter)
Gets service reference list for the given query.
|
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> sClass,
S s,
java.util.Dictionary<java.lang.String,?> stringDictionary)
Registers a service
|
org.osgi.framework.ServiceRegistration |
registerService(java.lang.String[] clazzes,
java.lang.Object service,
java.util.Dictionary properties)
Registers a service.
|
org.osgi.framework.ServiceRegistration |
registerService(java.lang.String clazz,
java.lang.Object service,
java.util.Dictionary properties)
Registers a service.
|
void |
removeBundleListener(org.osgi.framework.BundleListener listener)
Removes a 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 IPojoContext(org.osgi.framework.BundleContext context)
context
- the bundle contextpublic IPojoContext(org.osgi.framework.BundleContext bundleContext, ServiceContext serviceContext)
bundleContext
- the bundle contextserviceContext
- the service contextpublic void addBundleListener(org.osgi.framework.BundleListener listener)
addBundleListener
in interface org.osgi.framework.BundleContext
listener
- the listener to addBundleContext.addBundleListener(org.osgi.framework.BundleListener)
public void addFrameworkListener(org.osgi.framework.FrameworkListener listener)
addFrameworkListener
in interface org.osgi.framework.BundleContext
listener
- the listener object to addBundleContext.addFrameworkListener(org.osgi.framework.FrameworkListener)
public void addServiceListener(org.osgi.framework.ServiceListener listener, java.lang.String filter) throws org.osgi.framework.InvalidSyntaxException
match(String)
). Finally, if the internal
dispatcher is disabled, it uses the "regular" bundle context.addServiceListener
in interface ServiceContext
addServiceListener
in interface org.osgi.framework.BundleContext
listener
- the service listener to add.filter
- the LDAP filterorg.osgi.framework.InvalidSyntaxException
- if LDAP filter is malformedBundleContext.addServiceListener(org.osgi.framework.ServiceListener, java.lang.String)
public void addServiceListener(org.osgi.framework.ServiceListener listener)
addServiceListener
in interface ServiceContext
addServiceListener
in interface org.osgi.framework.BundleContext
listener
- the service listener to add.BundleContext.addServiceListener(org.osgi.framework.ServiceListener)
public org.osgi.framework.Filter createFilter(java.lang.String filter) throws org.osgi.framework.InvalidSyntaxException
createFilter
in interface org.osgi.framework.BundleContext
filter
- the string form of the LDAP filter to createorg.osgi.framework.InvalidSyntaxException
- if the given filter is malformedBundleContext.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.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 interfacefilter
- the LDAP filterorg.osgi.framework.InvalidSyntaxException
- if the LDAP filter is malformedBundleContext.getAllServiceReferences(java.lang.String, java.lang.String)
public 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 <S> S getService(org.osgi.framework.ServiceReference<S> ref)
IllegalStateException
if the used bundle
context is no more valid (because we're leaving).getService
in interface ServiceContext
getService
in interface org.osgi.framework.BundleContext
ref
- the required service referencenull
if the service reference
is no more valid or if the service object is not accessible.BundleContext.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 interface namenull
if no providers availableBundleContext.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 classsClass
- the required interface classnull
if no providers availableBundleContext.getServiceReference(java.lang.String)
public <S> java.util.Collection<org.osgi.framework.ServiceReference<S>> getServiceReferences(java.lang.Class<S> sClass, java.lang.String filter) throws org.osgi.framework.InvalidSyntaxException
getServiceReferences
in interface org.osgi.framework.BundleContext
S
- the service classsClass
- the name of the required service interfacefilter
- the LDAP filter to apply on service providernull
if no available providersorg.osgi.framework.InvalidSyntaxException
- if the LDAP filter is malformedpublic 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 name of the required service interfacefilter
- the LDAP filter to apply on service providernull
if no available providersorg.osgi.framework.InvalidSyntaxException
- if the LDAP filter is malformedBundleContext.getServiceReferences(java.lang.String, 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.org.osgi.framework.BundleException
- if the bundle cannot be installed correctlyBundleContext.installBundle(java.lang.String, java.io.InputStream)
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 interfaces provided by the service.service
- the service object.properties
- the service properties to publishServiceContext.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 interface provided by the service.service
- the the service object.properties
- the service properties to publish.BundleContext.registerService(java.lang.String, java.lang.Object, java.util.Dictionary)
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> sClass, S s, java.util.Dictionary<java.lang.String,?> stringDictionary)
registerService
in interface org.osgi.framework.BundleContext
S
- the Service Class (specification)sClass
- the service classs
- the service object (must implement sClass)stringDictionary
- service propertiespublic 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)
,
BundleContext.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 reference to ungettrue
if you are the last user of the referenceBundleContext.ungetService(org.osgi.framework.ServiceReference)
public org.osgi.framework.BundleContext getGlobalContext()
public ServiceContext getServiceContext()
null
if the instance does not live
inside a composite.null
.Copyright © 2006-2014 The Apache Software Foundation. All Rights Reserved.