|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.osgi.framework.internal.core.ServiceUse
public class ServiceUse
This class represents the use of a service by a bundle. One is created for each service acquired by a bundle. This class manages the calls to ServiceFactory and the bundle's use count.
Field Summary | |
---|---|
protected BundleContextImpl |
context
BundleContext associated with this service use |
protected ServiceFactory |
factory
ServiceFactory object if the service instance represents a factory, null otherwise |
protected ServiceRegistrationImpl |
registration
ServiceDescription of the registered service |
protected java.lang.Object |
service
Service object either registered or that returned by ServiceFactory.getService() |
protected int |
useCount
bundle's use count for this service |
Constructor Summary | |
---|---|
protected |
ServiceUse(BundleContextImpl context,
ServiceRegistrationImpl registration)
Constructs a service use encapsulating the service object. |
Method Summary | |
---|---|
protected java.lang.Object |
getService()
Get a service's service object. |
protected void |
releaseService()
Release a service's service object. |
protected boolean |
ungetService()
Unget a service's service object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ServiceFactory factory
protected java.lang.Object service
protected BundleContextImpl context
protected ServiceRegistrationImpl registration
protected int useCount
Constructor Detail |
---|
protected ServiceUse(BundleContextImpl context, ServiceRegistrationImpl registration)
context
- bundle getting the serviceregistration
- ServiceRegistration of the serviceMethod Detail |
---|
protected java.lang.Object getService()
getService()
, the context bundle's use count for the service
is incremented by one. Each time the service is release by
ungetService()
, the context bundle's use count
for the service is decremented by one.
When a bundle's use count for a service
drops to zero, the bundle should no longer use the service.
The following steps are followed to get the service object:
ServiceFactory
,
the ServiceFactory.getService
method
is called to create a service object for the context bundle.
This service object is cached by the framework.
While the context bundle's use count for the service is greater than zero,
subsequent calls to get the services's service object for the context bundle
will return the cached service object.
ServiceFactory
is not an instanceof
all the classes named when the service was registered or
the ServiceFactory
throws an exception,
null
is returned and a
FrameworkEvent
of type FrameworkEvent.ERROR
is broadcast.
protected boolean ungetService()
false
. Otherwise, the context bundle's use count for the
service is decremented by one.
The service's service object should no longer be used and all references to it should be destroyed when a bundle's use count for the service drops to zero.
The following steps are followed to unget the service object:
false
is returned.
ServiceFactory
,
the ServiceFactory.ungetService
method
is called to release the service object for the context bundle.
true
is returned.
true
if the context bundle's use count for the service
is zero otherwise false
.protected void releaseService()
ServiceFactory
,
the ServiceFactory.ungetService
method
is called to release the service object for the bundle.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |