|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.felix.dependencymanager.ServiceImpl
public class ServiceImpl
Service implementation.
| Field Summary |
|---|
| Fields inherited from interface org.apache.felix.dependencymanager.ServiceComponent |
|---|
STATE_NAMES, STATE_REGISTERED, STATE_UNREGISTERED |
| Constructor Summary | |
|---|---|
ServiceImpl(BundleContext context,
DependencyManager manager,
Logger logger)
|
|
| Method Summary | |
|---|---|
Service |
add(Dependency dependency)
Adds a new dependency to this service. |
void |
addStateListener(ServiceStateListener listener)
Adds a service state listener to this service. |
void |
dependencyAvailable(Dependency dependency)
Will be called when the dependency becomes available. |
void |
dependencyChanged(Dependency dependency)
Will be called when the dependency becomes unavailable. |
void |
dependencyUnavailable(Dependency dependency)
Will be called when the dependency changes. |
ServiceComponentDependency[] |
getComponentDependencies()
Returns a list of dependencies associated with this service component. |
List |
getDependencies()
Returns a list of dependencies. |
String |
getName()
Returns the name of this service component. |
Object |
getService()
Returns the service instance for this service. |
Dictionary |
getServiceProperties()
Returns the service properties associated with the service. |
ServiceRegistration |
getServiceRegistration()
Returns the service registration for this service. |
int |
getState()
Returns the state of this service component. |
Service |
remove(Dependency dependency)
Removes a dependency from this service. |
void |
removeStateListener(ServiceStateListener listener)
Removes a service state listener from this service. |
Service |
setCallbacks(String init,
String start,
String stop,
String destroy)
Sets the names of the methods used as callbacks. |
Service |
setComposition(Object instance,
String getMethod)
Sets the instance and method to invoke to get back all instances that are part of a composition and need dependencies injected. |
Service |
setComposition(String getMethod)
Sets the method to invoke on the service implementation to get back all instances that are part of a composition and need dependencies injected. |
Service |
setFactory(Object factory,
String createMethod)
Sets the factory to use to create the implementation. |
Service |
setFactory(String createMethod)
Sets the factory to use to create the implementation. |
Service |
setImplementation(Object implementation)
Sets the implementation for this service. |
Service |
setInterface(String[] serviceName,
Dictionary properties)
Sets the public interfaces under which this service should be registered in the OSGi service registry. |
Service |
setInterface(String serviceName,
Dictionary properties)
Sets the public interface under which this service should be registered in the OSGi service registry. |
void |
setServiceProperties(Dictionary serviceProperties)
Sets the service properties associated with the service. |
void |
start()
Starts the service. |
void |
stop()
Stops the service. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ServiceImpl(BundleContext context,
DependencyManager manager,
Logger logger)
| Method Detail |
|---|
public Service add(Dependency dependency)
Service
add in interface Servicedependency - the dependency to add
public Service remove(Dependency dependency)
Service
remove in interface Servicedependency - the dependency to remove
public List getDependencies()
Service
getDependencies in interface Servicepublic ServiceRegistration getServiceRegistration()
Servicenull if no service registration is
available.
getServiceRegistration in interface Servicepublic Object getService()
Servicenull if no service instance is available.
getService in interface Servicepublic void dependencyAvailable(Dependency dependency)
Service
dependencyAvailable in interface Servicedependency - the dependencypublic void dependencyChanged(Dependency dependency)
Service
dependencyChanged in interface Servicedependency - the dependencypublic void dependencyUnavailable(Dependency dependency)
Service
dependencyUnavailable in interface Servicedependency - the dependencypublic void start()
Service
start in interface Servicepublic void stop()
Service
stop in interface Service
public Service setInterface(String serviceName,
Dictionary properties)
Service
setInterface in interface ServiceserviceName - the name of the service interfaceproperties - the properties for this service
public Service setInterface(String[] serviceName,
Dictionary properties)
Service
setInterface in interface ServiceserviceName - the names of the service interfaceproperties - the properties for this service
public Service setCallbacks(String init,
String start,
String stop,
String destroy)
Service
setCallbacks in interface Serviceinit - the name of the init methodstart - the name of the start methodstop - the name of the stop methoddestroy - the name of the destroy method
public Service setImplementation(Object implementation)
ServiceClass
that will be instantiated using its default constructor when the
required dependencies are resolved (effectively giving you a lazy
instantiation mechanism).
There are four special methods that are called when found through
reflection to give you some life-cycle management options:
init() is invoked right after the instance has been
created, and before any dependencies are resolved, and can be used to
initialize the internal state of the instancestart() is invoked after the required dependencies
are resolved and injected, and before the service is registeredstop() is invoked right after the service is
unregistereddestroy() is invoked after all dependencies are
removed
setImplementation in interface Serviceimplementation - the implementation
ServiceStateListener
public Service setFactory(Object factory,
String createMethod)
ServicesetComposition to create a
composition of instances that work together to implement a service. The
factory itself can also be instantiated lazily by not specifying an
instance, but a Class.
setFactory in interface Servicefactory - the factory instance or classcreateMethod - the name of the create methodpublic Service setFactory(String createMethod)
ServicesetComposition to create a composition of instances that
work together to implement a service.
Note that currently, there is no default for the factory, so please use
setFactory(factory, createMethod) instead.
setFactory in interface ServicecreateMethod - the name of the create method
public Service setComposition(Object instance,
String getMethod)
ServiceObject[].
setComposition in interface Serviceinstance - the instance that has the methodgetMethod - the method to invokepublic Service setComposition(String getMethod)
ServiceObject[].
setComposition in interface ServicegetMethod - the method to invokepublic String toString()
toString in class Objectpublic Dictionary getServiceProperties()
Service
getServiceProperties in interface Servicenull if there are nonepublic void setServiceProperties(Dictionary serviceProperties)
Service
setServiceProperties in interface ServiceserviceProperties - the propertiespublic void addStateListener(ServiceStateListener listener)
Service
addStateListener in interface Servicelistener - the state listenerpublic void removeStateListener(ServiceStateListener listener)
Service
removeStateListener in interface Servicelistener - the state listenerpublic ServiceComponentDependency[] getComponentDependencies()
ServiceComponent
getComponentDependencies in interface ServiceComponentpublic String getName()
ServiceComponent
getName in interface ServiceComponentpublic int getState()
ServiceComponent
getState in interface ServiceComponent
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||