CVS: plexus-container/src/java/org/apache/plexus/service/repository DefaultComponentRepository.java,1.4,1.5

[email protected] Thu, 12 Jun 2003 11:53:51 -0500
Newsgroups gmane.comp.java.plexus.devel
Message-ID <[email protected]>
Update of /cvsroot/plexus/plexus-container/src/java/org/apache/plexus/service/repository
In directory eng.werken.com:/tmp/cvs-serv17675/src/java/org/apache/plexus/service/repository

Modified Files:
	DefaultComponentRepository.java 
Log Message:
Need to be careful when calling getComponentHousing() as this will
create an instance everytime if the component is using the per-lookup
instantation strategy.  This snippet of code (minus error checking)
shows where the error manifests itself:

  ComponentHousing housing = componentManager.getComponentHousing();
  component = componentManager.getComponentHousing().getComponent();

Consequently, prior to this fix, there would always be an additional
component instance created when using the per-lookup strategy.  The fix
is simple, just use the reference to the housing that was fetched prior:

  ComponentHousing housing = componentManager.getComponentHousing();
  component = housing.getComponent();



Index: DefaultComponentRepository.java
===================================================================
RCS file: /cvsroot/plexus/plexus-container/src/java/org/apache/plexus/service/repository/DefaultComponentRepository.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- DefaultComponentRepository.java	12 May 2003 18:57:22 -0000	1.4
+++ DefaultComponentRepository.java	12 Jun 2003 16:53:44 -0000	1.5
@@ -303,7 +303,7 @@
                 throw new ServiceException( key, "ComponentHousing is null.");
             }
 
-            component = componentManager.getComponentHousing().getComponent();
+            component = housing.getComponent();
 
             if ( component == null )
             {