|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.ipojo.IPojoContext
public class IPojoContext
The iPOJO Context is a BundleContext implementation allowing the separation between Bundle context and Service (Bundle) Context. This is used inside composition to differentiate the classloading context (i.e. Bundle) and the service registry access. This class delegates calls to the good internal context (either the BundleContext or the ServiceContext) according to the method. If the instance does not have a valid service context, the bundle context is always used.
Constructor Summary | |
---|---|
IPojoContext(BundleContext context)
Creates an iPOJO Context. |
|
IPojoContext(BundleContext bundleContext,
ServiceContext serviceContext)
Creates an iPOJO Context. |
Method Summary | |
---|---|
void |
addBundleListener(BundleListener listener)
Adds a bundle listener. |
void |
addFrameworkListener(FrameworkListener listener)
Adds a framework listener. |
void |
addServiceListener(ServiceListener listener)
Add a service listener. |
void |
addServiceListener(ServiceListener listener,
String filter)
Adds a service listener. |
Filter |
createFilter(String filter)
Creates a filter objects. |
ServiceReference[] |
getAllServiceReferences(String clazz,
String filter)
Gets the service references matching with the given query. |
Bundle |
getBundle()
Gets the current bundle object. |
Bundle |
getBundle(long bundleId)
Gets the bundle object with the given id. |
Bundle[] |
getBundles()
Gets installed bundles. |
File |
getDataFile(String filename)
Gets a data file. |
BundleContext |
getGlobalContext()
Gets the global context, i.e. |
String |
getProperty(String key)
Gets a property value. |
Object |
getService(ServiceReference reference)
Gets a service object. |
ServiceContext |
getServiceContext()
Gets the service context, i.e. |
ServiceReference |
getServiceReference(String clazz)
Gets a service reference for the given interface. |
ServiceReference[] |
getServiceReferences(String clazz,
String filter)
Gets service reference list for the given query. |
Bundle |
installBundle(String location)
Installs a bundle. |
Bundle |
installBundle(String location,
InputStream input)
Installs a bundle. |
ServiceRegistration |
registerService(String[] clazzes,
Object service,
Dictionary properties)
Registers a service. |
ServiceRegistration |
registerService(String clazz,
Object service,
Dictionary properties)
Registers a service. |
void |
removeBundleListener(BundleListener listener)
Removes a bundle listener. |
void |
removeFrameworkListener(FrameworkListener listener)
Removes a framework listener. |
void |
removeServiceListener(ServiceListener listener)
Removes a service listener. |
boolean |
ungetService(ServiceReference reference)
Ungets the service reference. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IPojoContext(BundleContext context)
context
- the bundle contextpublic IPojoContext(BundleContext bundleContext, ServiceContext serviceContext)
bundleContext
- the bundle contextserviceContext
- the service contextMethod Detail |
---|
public void addBundleListener(BundleListener listener)
addBundleListener
in interface BundleContext
listener
- the listener to addBundleContext.addBundleListener(org.osgi.framework.BundleListener)
public void addFrameworkListener(FrameworkListener listener)
addFrameworkListener
in interface BundleContext
listener
- the listener object to addBundleContext.addFrameworkListener(org.osgi.framework.FrameworkListener)
public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException
match(String)
). Finally, if the internal
dispatcher is disabled, it uses the "regular" bundle context.
addServiceListener
in interface ServiceContext
addServiceListener
in interface BundleContext
listener
- the service listener to add.filter
- the LDAP filter
InvalidSyntaxException
- if LDAP filter is malformedBundleContext.addServiceListener(org.osgi.framework.ServiceListener, java.lang.String)
public void addServiceListener(ServiceListener listener)
addServiceListener
in interface ServiceContext
addServiceListener
in interface BundleContext
listener
- the service listener to add.BundleContext.addServiceListener(org.osgi.framework.ServiceListener)
public Filter createFilter(String filter) throws InvalidSyntaxException
createFilter
in interface BundleContext
filter
- the string form of the LDAP filter to create
InvalidSyntaxException
- if the given filter is malformedBundleContext.createFilter(java.lang.String)
public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException
getAllServiceReferences
in interface ServiceContext
getAllServiceReferences
in interface BundleContext
clazz
- the required interfacefilter
- the LDAP filter
InvalidSyntaxException
- if the LDAP filter is malformedBundleContext.getAllServiceReferences(java.lang.String, java.lang.String)
public Bundle getBundle()
getBundle
in interface BundleContext
BundleContext.getBundle()
public Bundle getBundle(long bundleId)
getBundle
in interface BundleContext
bundleId
- the bundle id
BundleContext.getBundle(long)
public Bundle[] getBundles()
getBundles
in interface BundleContext
BundleContext.getBundles()
public File getDataFile(String filename)
getDataFile
in interface BundleContext
filename
- the file name.
BundleContext.getDataFile(java.lang.String)
public String getProperty(String key)
getProperty
in interface BundleContext
key
- the key of the asked property
null
if no
property are associated with the given keyBundleContext.getProperty(java.lang.String)
public Object getService(ServiceReference reference)
IllegalStateException
if the used bundle
context is no more valid (because we're leaving).
getService
in interface ServiceContext
getService
in interface BundleContext
reference
- the required service reference
null
if the service reference
is no more valid or if the service object is not accessible.BundleContext.getService(org.osgi.framework.ServiceReference)
public ServiceReference getServiceReference(String clazz)
getServiceReference
in interface ServiceContext
getServiceReference
in interface BundleContext
clazz
- the required interface name
null
if no providers availableBundleContext.getServiceReference(java.lang.String)
public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
getServiceReferences
in interface ServiceContext
getServiceReferences
in interface BundleContext
clazz
- the name of the required service interfacefilter
- the LDAP filter to apply on service provider
null
if no available providers
InvalidSyntaxException
- if the LDAP filter is malformedBundleContext.getServiceReferences(java.lang.String, java.lang.String)
public Bundle installBundle(String location) throws BundleException
installBundle
in interface BundleContext
location
- the URL of the bundle to install
BundleException
- if the bundle cannot be installed correctlyBundleContext.installBundle(java.lang.String)
public Bundle installBundle(String location, InputStream input) throws BundleException
installBundle
in interface BundleContext
location
- the URL of the bundle to installinput
- the input stream to load the bundle.
BundleException
- if the bundle cannot be installed correctlyBundleContext.installBundle(java.lang.String, java.io.InputStream)
public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties)
registerService
in interface ServiceContext
registerService
in interface BundleContext
clazzes
- the interfaces provided by the service.service
- the service object.properties
- the service properties to publish
ServiceContext.registerService(java.lang.String[], java.lang.Object, java.util.Dictionary)
public ServiceRegistration registerService(String clazz, Object service, Dictionary properties)
registerService
in interface ServiceContext
registerService
in interface 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(BundleListener listener)
removeBundleListener
in interface BundleContext
listener
- the listener to removeBundleContext.removeBundleListener(org.osgi.framework.BundleListener)
public void removeFrameworkListener(FrameworkListener listener)
removeFrameworkListener
in interface BundleContext
listener
- the listener to removeBundleContext.removeFrameworkListener(org.osgi.framework.FrameworkListener)
public void removeServiceListener(ServiceListener listener)
removeServiceListener
in interface ServiceContext
removeServiceListener
in interface BundleContext
listener
- the service listener to removeServiceContext.removeServiceListener(org.osgi.framework.ServiceListener)
,
BundleContext.removeServiceListener(org.osgi.framework.ServiceListener)
public boolean ungetService(ServiceReference reference)
ungetService
in interface ServiceContext
ungetService
in interface BundleContext
reference
- the reference to unget
true
if you are the last user of the referenceBundleContext.ungetService(org.osgi.framework.ServiceReference)
public BundleContext getGlobalContext()
public ServiceContext getServiceContext()
null
if the instance does not live
inside a composite.
null
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |