Re: [picocontainer-dev] SynchronizedComponentAdapter ???

Paul Hammant <[email protected]>
Newsgroups gmane.comp.java.picocontainer.devel
Message-ID <[email protected]>
Yeah yeah, I'll revert :-)

On May 22, 2007, at 8:28 AM, Jörg Schaible wrote:

> Hi Paul,
>
> Paul Hammant wrote on Tuesday, May 22, 2007 5:17 PM:
>
>> 'Monster' is relative ;-)
>>
>> One new member var 'lock' (that's final), and ....
>>
>>      public Object getComponentInstance(PicoContainer container)
>>              throws PicoInitializationException,
>> PicoIntrospectionException, AssignabilityRegistrationException,
>> NotConcreteRegistrationException {
>>          if (instanceReference.get() == null) {
>>              Object tmp = super.getComponentInstance(container);
>>              synchronized (lock) {
>>                  if (instanceReference.get() == null) {
>>                      instanceReference.set(tmp);
>>                  }
>>              }
>>          }
>>          return instanceReference.get();
>>      }
>>
>> instead of ....
>>
>>      public Object getComponentInstance(PicoContainer container)
>>              throws PicoInitializationException,
>> PicoIntrospectionException, AssignabilityRegistrationException,
>> NotConcreteRegistrationException {
>>          Object instance = instanceReference.get();
>>          if (instance == null) {
>>              instance = super.getComponentInstance(container);
>>              instanceReference.set(instance);
>>          }
>>          return instance;
>>      }
>>
>> It gets rid of two classes, and is the minimally contentious way in
>> that synchronized could be done for CCA.
>>
>> Thoughts?
>
> So, will you synchronize always (Hint: Why exist StringBuilder)? ;-)
>
> And, will you also add the synchronization to the PoolingCA in  
> consequence (and other CA impls that have some sort of cache that  
> might be initialized twice e.g. ApplicationContextCA or  
> ServletContextCA)?
>
> - Jörg
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.