|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Service
Service interface.
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. |
List |
getDependencies()
Returns a list of dependencies. |
Object |
getService()
Returns the service instance for this service. |
Dictionary |
getServiceProperties()
Returns the service properties associated with the service. |
org.osgi.framework.ServiceRegistration |
getServiceRegistration()
Returns the service registration for this service. |
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[] serviceNames,
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. |
Method Detail |
---|
Service add(Dependency dependency)
dependency
- the dependency to add
Service remove(Dependency dependency)
dependency
- the dependency to remove
Service setInterface(String serviceName, Dictionary properties)
serviceName
- the name of the service interfaceproperties
- the properties for this service
Service setInterface(String[] serviceNames, Dictionary properties)
serviceNames
- the names of the service interfaceproperties
- the properties for this service
Service setImplementation(Object implementation)
Class
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
implementation
- the implementation
ServiceStateListener
List getDependencies()
org.osgi.framework.ServiceRegistration getServiceRegistration()
null
if no service registration is
available.
Object getService()
null
if no service instance is available.
Dictionary getServiceProperties()
null
if there are nonevoid setServiceProperties(Dictionary serviceProperties)
serviceProperties
- the propertiesService setCallbacks(String init, String start, String stop, String destroy)
init
- the name of the init methodstart
- the name of the start methodstop
- the name of the stop methoddestroy
- the name of the destroy method
void addStateListener(ServiceStateListener listener)
listener
- the state listenervoid removeStateListener(ServiceStateListener listener)
listener
- the state listenervoid dependencyAvailable(Dependency dependency)
dependency
- the dependencyvoid dependencyUnavailable(Dependency dependency)
dependency
- the dependencyvoid dependencyChanged(Dependency dependency)
dependency
- the dependencyvoid start()
void stop()
Service setFactory(Object factory, String createMethod)
setComposition
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
.
factory
- the factory instance or classcreateMethod
- the name of the create methodService setFactory(String createMethod)
setComposition
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.
createMethod
- the name of the create methodService setComposition(Object instance, String getMethod)
Object[]
.
instance
- the instance that has the methodgetMethod
- the method to invokeService setComposition(String getMethod)
Object[]
.
getMethod
- the method to invoke
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |