]> source.dussan.org Git - archiva.git/commitdiff
fix instantiation-strategy
authorNicolas De Loof <nicolas@apache.org>
Mon, 25 Feb 2008 16:36:58 +0000 (16:36 +0000)
committerNicolas De Loof <nicolas@apache.org>
Mon, 25 Feb 2008 16:36:58 +0000 (16:36 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@630922 13f79535-47bb-0310-9956-ffa450edef68

springy/plexus-spring/pom.xml
springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.java
springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusComponentFactoryBean.java
springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/FieldInjectionTest.java

index a5983c141ab9b81557625e9deb7139e37d91ab9e..0a26b34926af2137db4d2c2f09b3b965f411e9a4 100644 (file)
     <dependency>\r
       <groupId>org.codehaus.plexus</groupId>\r
       <artifactId>plexus-component-api</artifactId>\r
-      <version>1.0-alpha-33</version>\r
+      <version>1.0-alpha-22</version>\r
+    </dependency>\r
+    <dependency>\r
+      <groupId>org.codehaus.plexus</groupId>\r
+      <artifactId>plexus-container-default</artifactId>\r
+      <version>1.0-alpha-22</version>\r
     </dependency>\r
     <dependency>\r
       <groupId>dom4j</groupId>\r
index 3866db78d950bb6d638691ee4e5e1872fd7be273..08653851618af530e6625025aaeef5b6f4d56330 100644 (file)
@@ -49,7 +49,7 @@ public class PlexusBeanDefinitionDocumentReader
     public void registerBeanDefinitions( Document doc, XmlReaderContext readerContext )\r
     {\r
         doc = convertPlexusDescriptorToSpringBeans( doc );\r
-        if ( Boolean.getBoolean( "spring-plexus.debug" ) )\r
+        if ( Boolean.getBoolean( "plexus-spring.debug" ) )\r
         {\r
             try\r
             {\r
index a9a5cb4096346ba1f73b8a02eeacc2e6f97fb219..6e6494fc0156d102826ea1f1ac9cdd634f186e94 100644 (file)
@@ -20,15 +20,12 @@ package org.codehaus.plexus.spring;
  */\r
 \r
 import java.lang.reflect.Field;\r
-import java.util.ArrayList;\r
 import java.util.Collection;\r
-import java.util.HashMap;\r
 import java.util.Iterator;\r
 import java.util.LinkedList;\r
 import java.util.List;\r
 import java.util.Map;\r
 \r
-import org.codehaus.plexus.PlexusConstants;\r
 import org.codehaus.plexus.PlexusContainer;\r
 import org.codehaus.plexus.context.Context;\r
 import org.codehaus.plexus.logging.LogEnabled;\r
@@ -65,13 +62,16 @@ import org.springframework.util.ReflectionUtils;
 public class PlexusComponentFactoryBean\r
     implements FactoryBean, BeanFactoryAware, DisposableBean\r
 {\r
-    private static final char HINT = '#';\r
+    /**\r
+     * @todo isn't there a constant for this in plexus ?\r
+     */\r
+    private static final String SINGLETON = "singleton";\r
 \r
     private Class role;\r
 \r
     private Class implementation;\r
 \r
-    private String instanciationStrategy;\r
+    private String instanciationStrategy = SINGLETON;\r
 \r
     private Map requirements;\r
 \r
@@ -105,15 +105,9 @@ public class PlexusComponentFactoryBean
     public Object getObject()\r
         throws Exception\r
     {\r
-        if ( "poolable".equals( instanciationStrategy ) )\r
-        {\r
-            throw new BeanCreationException( "Plexus poolable instanciation-strategy is not supported" );\r
-        }\r
-\r
         // Spring MAY cache the object built by this factory if getSingleton()\r
-        // returns true,\r
-        // but can also requires us to ensure unicity.\r
-        if ( "singleton".equals( instanciationStrategy ) && !instances.isEmpty() )\r
+        // returns true, but can also requires us to ensure unicity.\r
+        if ( SINGLETON.equals( instanciationStrategy ) && !instances.isEmpty() )\r
         {\r
             return instances.get( 0 );\r
         }\r
@@ -147,6 +141,7 @@ public class PlexusComponentFactoryBean
 \r
         if (component instanceof Contextualizable )\r
         {\r
+            // VERRY limiter support for Contextualizable\r
             ((Contextualizable) component).contextualize( getContext() );\r
         }\r
 \r
@@ -167,7 +162,7 @@ public class PlexusComponentFactoryBean
 \r
     public boolean isSingleton()\r
     {\r
-        return "per-lookup".equals( instanciationStrategy );\r
+        return SINGLETON.equals( instanciationStrategy );\r
     }\r
 \r
     /**\r
@@ -246,7 +241,11 @@ public class PlexusComponentFactoryBean
     {\r
         if ( instanciationStrategy.length() == 0 )\r
         {\r
-            instanciationStrategy = "singleton";\r
+            instanciationStrategy = SINGLETON;\r
+        }\r
+        if ( "poolable".equals( instanciationStrategy ) )\r
+        {\r
+            throw new BeanCreationException( "Plexus poolable instanciation-strategy is not supported" );\r
         }\r
         this.instanciationStrategy = instanciationStrategy;\r
     }\r
index 1f288bd4354ecd9a15b87860827fcf17b662dcfb..57980cb0518bb007bc7491889fc9fa8149ed4020 100644 (file)
@@ -26,6 +26,16 @@ import org.springframework.context.ConfigurableApplicationContext;
 public class FieldInjectionTest\r
     extends TestCase\r
 {\r
+    /**\r
+     * {@inheritDoc}\r
+     * @see junit.framework.TestCase#setUp()\r
+     */\r
+    protected void setUp()\r
+        throws Exception\r
+    {\r
+        System.setProperty( "plexus-spring.debug", "true" );\r
+    }\r
+\r
     public void testFieldInjectionInSpringContext()\r
         throws Exception\r
     {\r