|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.dependencymanager.impl.ServiceImpl
public class ServiceImpl
Service implementation.
Constructor Summary | |
---|---|
ServiceImpl(DependencyManager dm)
|
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. |
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. |
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. |
void |
removeStateListeners()
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ServiceImpl(DependencyManager dm)
Method Detail |
---|
public Service add(Dependency dependency)
Service
add
in interface Service
dependency
- the dependency to add
public Service remove(Dependency dependency)
Service
remove
in interface Service
dependency
- the dependency to remove
public void addStateListener(ServiceStateListener listener)
Service
addStateListener
in interface Service
listener
- the state listenerpublic void removeStateListener(ServiceStateListener listener)
Service
removeStateListener
in interface Service
listener
- the state listenerpublic void removeStateListeners()
public List getDependencies()
Service
getDependencies
in interface Service
public Object getService()
Service
null
if no service instance is available.
getService
in interface Service
public Dictionary getServiceProperties()
Service
getServiceProperties
in interface Service
null
if there are nonepublic ServiceRegistration getServiceRegistration()
Service
null
if no service registration is
available.
getServiceRegistration
in interface Service
public Service setCallbacks(String init, String start, String stop, String destroy)
Service
setCallbacks
in interface Service
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
public Service setComposition(Object instance, String getMethod)
Service
Object[]
.
setComposition
in interface Service
instance
- the instance that has the methodgetMethod
- the method to invokepublic Service setComposition(String getMethod)
Service
Object[]
.
setComposition
in interface Service
getMethod
- the method to invokepublic Service setFactory(Object factory, String createMethod)
Service
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
.
setFactory
in interface Service
factory
- the factory instance or classcreateMethod
- the name of the create methodpublic Service setFactory(String createMethod)
Service
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.
setFactory
in interface Service
createMethod
- the name of the create methodpublic Service setImplementation(Object implementation)
Service
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
setImplementation
in interface Service
implementation
- the implementation
ServiceStateListener
public Service setInterface(String serviceName, Dictionary properties)
Service
setInterface
in interface Service
serviceName
- the name of the service interfaceproperties
- the properties for this service
public Service setInterface(String[] serviceNames, Dictionary properties)
Service
setInterface
in interface Service
serviceNames
- the names of the service interfaceproperties
- the properties for this service
public void setServiceProperties(Dictionary serviceProperties)
Service
setServiceProperties
in interface Service
serviceProperties
- the propertiespublic void start()
Service
start
in interface Service
public void stop()
Service
stop
in interface Service
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |