[
https://issues.apache.org/jira/browse/FELIX-2923?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13795538#comment-13795538
]
David Humeniuk commented on FELIX-2923:
---------------------------------------
I can try the latest snapshot at some point, but to give a more concrete
example.
We have a component that keeps track of objects in the system and manages data
about each object when created. So call this service/interface
DirectoryService. The DirectoyService is a DS component and it references
services through a factory interface (reference is multiple, dynamic and
optional). Call this service/interface Factory. When Factory services are
then available, they are bound to the DirectoryService and the DirectoryService
registers another interface (call it FactoryDescriptor) so that consumers know
that the factory can be accessed. The consumers don't access the Factory
services directly as the DirectoryService manages data associated with the
objects created by Factory services. Therefore, consumers have DS service
references to the DirectoryService to access the objects as well as a reference
to the FactoryDescriptor service. This way the consumer will not be activated
until the DirectoryService and object it needs is available.
In reality Factory extends the FactoryDescriptor interface so the actual
component is a DS component and is a single component (but the registering of
FactoryDescriptor is delayed until things are hooked up for the
DirectoryService).
I've been thinking of using an OSGi event instead of this case, but that does
mean that I can't have consumers use DS service references to wait for the
Factory service to become usable and will have to come up with a more
complicated DirectoryService to handle the dependencies.
> Get a ServiceFactory.getService() resulted in a cycle message when
> registering a service inside a DS activation method
> -----------------------------------------------------------------------------------------------------------------------
>
> Key: FELIX-2923
> URL: https://issues.apache.org/jira/browse/FELIX-2923
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Reporter: David Humeniuk
>
> I've run into an issue with Felix SCR where I get the message:
> ServiceFactory.getService() resulted in a cycle
> The reason this appers to be occuring is because within an activation method
> of a service component, call it ServiceAImpl (which provides ServiceA), the
> component registers another service, call it ServiceB.
> I have another service component, call it ServiceCImpl, which depends on both
> ServiceA and ServiceB. When ServiceAImpl registers ServiceB, ServiceCImpl is
> attemted to be activated within the call to activate ServiceAImpl. As part
> of the activation, the ServiceCImpl binding methods are called (at least
> attempted). When the binding method for ServiceA is attempted, the cycle is
> detected and the component fails to initialize.
> I guess what doesn't make sense is why the SCR will activate ServiceCImpl
> within the activation method of ServiceAImpl. I wouldn't think that
> ServiceCImpl would be considered satisfied until after the activation method
> has exited. Perhaps this is an issue of using declarative services while
> still registering services directly with the framework?
--
This message was sent by Atlassian JIRA
(v6.1#6144)