[ 
https://issues.apache.org/jira/browse/FELIX-3864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13567472#comment-13567472
 ] 

Tuomas Kiviaho commented on FELIX-3864:
---------------------------------------

Thanks for the most inclusive response. 

Temporal Service seems to be doing precisely what I was aiming for (excluding 
the small time windows where real service might be removed while proxy invoke 
is taking place) for required dependencies.This way the field injection is 
guaranteed not to happen while component is active. But for optional 
dependencies the is no similar solution. 

I understand that what I originally suggested was not well educated, but 
instead of opening another issue, I propose that temporal services could be 
altered a bit so that they'd fall back to the default implementation instead of 
DM firing the IllegalStateException. These kinds of (zero timeout) temporary 
services could be optional as well and this way I could trust that no field 
injection is to happen while the component is active.
                
> Synchronized injection
> ----------------------
>
>                 Key: FELIX-3864
>                 URL: https://issues.apache.org/jira/browse/FELIX-3864
>             Project: Felix
>          Issue Type: Improvement
>          Components: Dependency Manager
>    Affects Versions: dependencymanager-3.0.0
>            Reporter: Tuomas Kiviaho
>
> I see myself repeating the following pattern quite often
> {code}
>    @ServiceDependency( removed = "removed", required=true  )
>     synchronized void added(LogService logService )
>     {
>         this.logService = logService;
>     }
>     synchronized void removed(LogService logService )
>     {
>         this.logService = null;
>     }
> {code}
> Would it be possible to get optional synchronization support directly from 
> dependency manager. I noticed that there's a sort of synchronization already 
> taking place at ComponentImpl
> {code}
>   private void configureImplementation(Class clazz, Object instance, String 
> instanceName) {
>   ...
>                                       synchronized (SYNC) {
>                                           field.set(serviceInstance, 
> instance);
>                                       }
> {code}
> I propose adding of 'boolean synchronization default false' attribute to 
> @*Dependency which might contain a notion that this applies only to field 
> injection. If syncronization between component's field injections is not 
> needed then SYNC could be replaced with serviceInstance whenever the 
> attribute is set.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to