In OSGi declarative services, I can create prototype instances declaring a ComponentServiceObjects like this:
@Reference(unbind = "-",
scope=ReferenceScope.PROTOTYPE_REQUIRED)
private ComponentServiceObjects<MyService> serviceProvider;
and then instantiating the service with
service = serviceProvider.getService();
then I can finish the configuration of the instance by setting some other attributes (configuration values or non-OSGi collaborators) with setters. This has the problem, that the activation is performed before the initialization is complete.
Is there a way to inject this attributes before activating the service?
I am using DS in the context of Liferay Portal 7
EDIT
As a clarification I have an example: let's say I have a component DirectoryListener. And I want to initialize several instances of this component, each one with a different directory. I would like to make some initialization during the activation based on this directory.
unbind="-"attribute on@Referencedoes nothing and should be removed. - Neil BartlettDirectoryListener. And I want to initialize several instances of this component, each one with a different directory. I would like to make some initialization during the activation based on this directory. If it is not possible, I will have to use another method which runs after the activation. Or is there a better approach? - AdrianRMDirectoryListenerFactoryinstead. - Neil Bartlett