[infinispan-dev] Infinispan's dependency injection fwk

Sanne Grinovero sanne.grinovero at gmail.com
Thu Jul 22 12:38:52 EDT 2010


2010/7/22 Mircea Markus <mircea.markus at jboss.com>:
> Hi,
>
> I have this problem with the the dependency injection fwk in infinispan: many times I'd like to declare the injected dependencies as final fields in order to take advantage[1] of "final" semantics in Java's memory model. I cannot/don't know how to do that, can I annotate an constructor with @Inject? If not I think that would be useful.
>
> [1] @Inject methods are called by the thread that starts the CM. The injected dependencies are cached as local fields and will be accessed by a different application thread. So they'd need volatile/synchronise for proper publishing: afaik volatile is less performant that publishing with final.
>
> wdyt?

I was puzzled by this too, I was assuming that you where all aware of
it and that you where guaranteeing that the components would be
"assembled" before the threads servicing the CacheManager, and so the
eventual CacheManager or Cache(s) references would be passed safely to
other user-threads and the different modules would be "safe" as they
would be exposed in an happens-before order by whatever lock they
traverse after initialization.

But now that you ask I'm not sure anymore if it was designed like that :)

>
> Cheers,
> Mircea
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev
>



More information about the infinispan-dev mailing list