public class CompositeServiceContext extends Object implements ServiceContext, TrackerCustomizer
Modifier and Type | Class and Description |
---|---|
private class |
CompositeServiceContext.Record
Structure storing the reference, the factory and the registration.
|
Modifier and Type | Field and Description |
---|---|
private List<CompositeServiceContext.Record> |
m_factories
List of imported factories.
|
private BundleContext |
m_global
Global service context.
|
private ComponentInstance |
m_instance
Component Instance who creates this registry.
|
private ServiceRegistry |
m_registry
Internal service registry.
|
private Tracker |
m_tracker
Tracker tracking Factories to import.
|
Constructor and Description |
---|
CompositeServiceContext(BundleContext context)
Constructor.
|
CompositeServiceContext(BundleContext context,
ComponentInstance instance)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addBundleListener(BundleListener arg0)
Add a bundle listener.
|
void |
addedService(ServiceReference reference)
A matching reference has been added.
|
void |
addFrameworkListener(FrameworkListener arg0)
Add a framework listener.
|
boolean |
addingService(ServiceReference reference)
A new factory is detected.
|
void |
addServiceListener(ServiceListener arg0)
Add a service listener.
|
void |
addServiceListener(ServiceListener arg0,
String arg1)
Add a filtered service listener.
|
private boolean |
containsRef(ServiceReference ref)
Check if the factory list contain the given reference.
|
Filter |
createFilter(String arg0)
Create a LDAP filter.
|
ServiceReference[] |
getAllServiceReferences(String arg0,
String arg1)
Get all service references.
|
Bundle |
getBundle()
Get the current bundle.
|
Bundle |
getBundle(long bundleId)
Get the bundle object with the given id.
|
Bundle |
getBundle(String location) |
Bundle[] |
getBundles()
Get installed bundles.
|
File |
getDataFile(String filename)
Get a data file.
|
String |
getProperty(String key)
Get a property value.
|
Object |
getService(ServiceReference arg0)
Get a service object for the given service reference.
|
<S> <any> |
getServiceReference(Class<S> clazz) |
ServiceReference |
getServiceReference(String arg0)
Get a service reference for the required interface.
|
<S> Collection<<any>> |
getServiceReferences(Class<S> clazz,
String filter) |
ServiceReference[] |
getServiceReferences(String clazz,
String filter)
Get all accessible service reference for the given query.
|
private void |
importFactory(ServiceReference ref)
Import a factory form the parent to the internal registry.
|
Bundle |
installBundle(String location)
Install a bundle.
|
Bundle |
installBundle(String location,
InputStream input)
Install a bundle.
|
void |
modifiedService(ServiceReference reference,
Object service)
An imported factory is modified.
|
<S> <any> |
registerService(Class<S> clazz,
S service,
Dictionary<String,?> properties) |
ServiceRegistration |
registerService(String[] arg0,
Object arg1,
Dictionary arg2)
Register a service inside the composite context.
|
ServiceRegistration |
registerService(String arg0,
Object arg1,
Dictionary arg2)
Register a service inside the composite context.
|
void |
removeBundleListener(BundleListener listener)
Remove a bundle listener.
|
void |
removedService(ServiceReference reference,
Object service)
An imported factory disappears.
|
private void |
removeFactory(ServiceReference ref)
Remove a factory of the available factory list.
|
void |
removeFrameworkListener(FrameworkListener listener)
Remove a framework listener.
|
void |
removeServiceListener(ServiceListener arg0)
Remove a service listener.
|
void |
start()
Start the registry management.
|
void |
stop()
Stop the registry management.
|
boolean |
ungetService(ServiceReference arg0)
Unget a service.
|
private List<CompositeServiceContext.Record> m_factories
private ServiceRegistry m_registry
private ComponentInstance m_instance
private BundleContext m_global
public CompositeServiceContext(BundleContext context)
context
- : the bundle contextpublic CompositeServiceContext(BundleContext context, ComponentInstance instance)
context
- : the bundle contextinstance
- : the component instance owning this contextpublic void addServiceListener(ServiceListener arg0)
addServiceListener
in interface ServiceContext
arg0
- : The service listener to addorg.apache.felix.ipojo.ServiceContext#addServiceListener(org.osgi.framework.ServiceListener)
public void addServiceListener(ServiceListener arg0, String arg1) throws InvalidSyntaxException
addServiceListener
in interface ServiceContext
arg0
- : the service listener object to addarg1
- : the LDAP filter for this listenerInvalidSyntaxException
- : occurs if the LDAP filter is malformedorg.apache.felix.ipojo.ServiceContext#addServiceListener(org.osgi.framework.ServiceListener,
java.lang.String)
public ServiceReference[] getAllServiceReferences(String arg0, String arg1) throws InvalidSyntaxException
getAllServiceReferences
in interface ServiceContext
arg0
- : The required service interface.arg1
- : LDAP filterInvalidSyntaxException
- : occurs when the given filter is malformedServiceContext.getAllServiceReferences(java.lang.String,
java.lang.String)
public Object getService(ServiceReference arg0)
getService
in interface ServiceContext
arg0
- : the service referenceorg.apache.felix.ipojo.ServiceContext#getService(org.osgi.framework.ServiceReference)
public ServiceReference getServiceReference(String arg0)
getServiceReference
in interface ServiceContext
arg0
- : the required interface nameServiceContext.getServiceReference(java.lang.String)
public <S> <any> getServiceReference(Class<S> clazz)
public <S> Collection<<any>> getServiceReferences(Class<S> clazz, String filter) throws InvalidSyntaxException
InvalidSyntaxException
public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
getServiceReferences
in interface ServiceContext
clazz
- : required interfacefilter
- : LDAP filterInvalidSyntaxException
- : occurs when the LDAP filter is malformedServiceContext.getServiceReferences(java.lang.String, java.lang.String)
public ServiceRegistration registerService(String[] arg0, Object arg1, Dictionary arg2)
registerService
in interface ServiceContext
arg0
- : list of interfaces to register.arg1
- : service objectarg2
- : properties listServiceContext.registerService(java.lang.String[], java.lang.Object, java.util.Dictionary)
public ServiceRegistration registerService(String arg0, Object arg1, Dictionary arg2)
registerService
in interface ServiceContext
arg0
- : interface to register.arg1
- : service objectarg2
- : properties listServiceContext.registerService(java.lang.String, java.lang.Object, java.util.Dictionary)
public void removeServiceListener(ServiceListener arg0)
removeServiceListener
in interface ServiceContext
arg0
- : the service listener to removeorg.apache.felix.ipojo.ServiceContext#removeServiceListener(org.osgi.framework.ServiceListener)
public boolean ungetService(ServiceReference arg0)
ungetService
in interface ServiceContext
arg0
- the service reference to ungetorg.apache.felix.ipojo.ServiceContext#ungetService(org.osgi.framework.ServiceReference)
private void importFactory(ServiceReference ref)
ref
- : the reference of the factory to import.private void removeFactory(ServiceReference ref)
ref
- : the reference on the factory to remove.public void start()
public void stop()
private boolean containsRef(ServiceReference ref)
ref
- : the reference to find.public void addBundleListener(BundleListener arg0)
arg0
- : bundle listener to addorg.osgi.framework.BundleContext#addBundleListener(org.osgi.framework.BundleListener)
public void addFrameworkListener(FrameworkListener arg0)
arg0
- : framework listener to add.org.osgi.framework.BundleContext#addFrameworkListener(org.osgi.framework.FrameworkListener)
public Filter createFilter(String arg0) throws InvalidSyntaxException
arg0
- : String-form of the filterInvalidSyntaxException
- : if the given argument is not a valid against the LDAP grammar.org.osgi.framework.BundleContext#createFilter(java.lang.String)
public Bundle getBundle()
org.osgi.framework.BundleContext#getBundle()
public Bundle getBundle(long bundleId)
bundleId
- : bundle idorg.osgi.framework.BundleContext#getBundle(long)
public Bundle[] getBundles()
org.osgi.framework.BundleContext#getBundles()
public File getDataFile(String filename)
filename
- : File name.org.osgi.framework.BundleContext#getDataFile(java.lang.String)
public String getProperty(String key)
key
- : key of the asked propertyorg.osgi.framework.BundleContext#getProperty(java.lang.String)
public Bundle installBundle(String location) throws BundleException
location
- : URL of the bundle to installBundleException
- : if the bundle cannot be installed correctlyorg.osgi.framework.BundleContext#installBundle(java.lang.String)
public Bundle installBundle(String location, InputStream input) throws BundleException
location
- : URL of the bundle to installinput
- :BundleException
- : if the bundle cannot be installed correctlyorg.osgi.framework.BundleContext#installBundle(java.lang.String, java.io.InputStream)
public void removeBundleListener(BundleListener listener)
listener
- : the listener to removeorg.osgi.framework.BundleContext#removeBundleListener(org.osgi.framework.BundleListener)
public void removeFrameworkListener(FrameworkListener listener)
listener
- : the listener to removeorg.osgi.framework.BundleContext#removeFrameworkListener(org.osgi.framework.FrameworkListener)
public <S> <any> registerService(Class<S> clazz, S service, Dictionary<String,?> properties)
public boolean addingService(ServiceReference reference)
addingService
in interface TrackerCustomizer
reference
- : service referenceorg.apache.felix.ipojo.util.TrackerCustomizer#addingService(org.osgi.framework.ServiceReference)
public void addedService(ServiceReference reference)
addedService
in interface TrackerCustomizer
reference
- : the added reference.org.apache.felix.ipojo.util.TrackerCustomizer#addedService(org.osgi.framework.ServiceReference)
public void modifiedService(ServiceReference reference, Object service)
modifiedService
in interface TrackerCustomizer
reference
- : modified referenceservice
- : factory object.org.apache.felix.ipojo.util.TrackerCustomizer#modifiedService(org.osgi.framework.ServiceReference, java.lang.Object)
public void removedService(ServiceReference reference, Object service)
removedService
in interface TrackerCustomizer
reference
- : referenceservice
- : factory object.org.apache.felix.ipojo.util.TrackerCustomizer#removedService(org.osgi.framework.ServiceReference, java.lang.Object)
Copyright © 2014. All rights reserved.