Author: nicolas
Date: Sun Feb 24 05:25:08 2008
New Revision: 630621

URL: http://svn.apache.org/viewvc?rev=630621&view=rev
Log:
spring support for plexus components

Added:
    maven/archiva/branches/springy/plexus-spring/pom.xml   (with props)
    maven/archiva/branches/springy/plexus-spring/src/
    maven/archiva/branches/springy/plexus-spring/src/main/
    maven/archiva/branches/springy/plexus-spring/src/main/java/
    maven/archiva/branches/springy/plexus-spring/src/main/java/org/
    maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/
    
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/
    
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/
    
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.java
   (with props)
    
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusClassPathXmlApplicationContext.java
   (with props)
    
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusComponentFactoryBean.java
   (with props)
    
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusNamespaceHandler.java
   (with props)
    
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusToSpringUtils.java
   (with props)
    maven/archiva/branches/springy/plexus-spring/src/main/resources/
    maven/archiva/branches/springy/plexus-spring/src/main/resources/META-INF/
    
maven/archiva/branches/springy/plexus-spring/src/main/resources/META-INF/spring.handlers
    
maven/archiva/branches/springy/plexus-spring/src/main/resources/META-INF/spring.schemas
    maven/archiva/branches/springy/plexus-spring/src/main/resources/org/
    
maven/archiva/branches/springy/plexus-spring/src/main/resources/org/codehaus/
    
maven/archiva/branches/springy/plexus-spring/src/main/resources/org/codehaus/plexus/
    
maven/archiva/branches/springy/plexus-spring/src/main/resources/org/codehaus/plexus/spring/
    
maven/archiva/branches/springy/plexus-spring/src/main/resources/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.xsl
   (with props)
    maven/archiva/branches/springy/plexus-spring/src/main/resources/plexus.xsd  
 (with props)
    maven/archiva/branches/springy/plexus-spring/src/test/
    maven/archiva/branches/springy/plexus-spring/src/test/java/
    maven/archiva/branches/springy/plexus-spring/src/test/java/org/
    maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/
    
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/
    
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/
    
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/FieldInjectionTest.java
   (with props)
    
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/PlexusBean.java
   (with props)
    
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/PlexusBeanImpl.java
   (with props)
    
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/SpringBean.java
   (with props)
    maven/archiva/branches/springy/plexus-spring/src/test/resources/
    
maven/archiva/branches/springy/plexus-spring/src/test/resources/applicationContext.xml
   (with props)
    
maven/archiva/branches/springy/plexus-spring/src/test/resources/components.xml  
 (with props)
    maven/archiva/branches/springy/plexus-spring/src/test/resources/log4j.xml   
(with props)

Added: maven/archiva/branches/springy/plexus-spring/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/pom.xml?rev=630621&view=auto
==============================================================================
--- maven/archiva/branches/springy/plexus-spring/pom.xml (added)
+++ maven/archiva/branches/springy/plexus-spring/pom.xml Sun Feb 24 05:25:08 
2008
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+       ~ Copyright 2006-2007 Nicolas De Loof.
+       ~
+       ~ Licensed under the Apache License, Version 2.0 (the "License");
+       ~ you may not use this file except in compliance with the License.
+       ~ You may obtain a copy of the License at
+       ~
+       ~      http://www.apache.org/licenses/LICENSE-2.0
+       ~
+       ~ Unless required by applicable law or agreed to in writing, software
+       ~ distributed under the License is distributed on an "AS IS" BASIS,
+       ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
+       ~ See the License for the specific language governing permissions and
+       ~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+                        http://maven.apache.org/maven-v4_0_0.xsd";>
+
+       <modelVersion>4.0.0</modelVersion>
+       <groupId>org.apache.maven.archiva</groupId>
+       <artifactId>filed-injection</artifactId>
+       <version>1</version>
+
+       <dependencies>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>3.8.2</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>commons-lang</groupId>
+                       <artifactId>commons-lang</artifactId>
+                       <version>2.2</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.codehaus.plexus</groupId>
+                       <artifactId>plexus-component-api</artifactId>
+                       <version>1.0-alpha-33</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.codehaus.plexus</groupId>
+                       <artifactId>plexus-component-api</artifactId>
+                       <version>1.0-alpha-33</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.codehaus.plexus</groupId>
+                       <artifactId>plexus-log4j-logging</artifactId>
+                       <version>1.1-alpha-3</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-context</artifactId>
+                       <version>2.5.1</version>
+               </dependency>
+       </dependencies>
+
+</project>

Propchange: maven/archiva/branches/springy/plexus-spring/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.java?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.java
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.java
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,79 @@
+package org.codehaus.plexus.spring;
+
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.InputStream;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.xml.BeanDefinitionDocumentReader;
+import 
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader;
+import org.springframework.beans.factory.xml.XmlReaderContext;
+import org.w3c.dom.Document;
+
+/**
+ * A Spring [EMAIL PROTECTED] BeanDefinitionDocumentReader} that converts on 
the fly the
+ * Plexus components descriptor to a spring XML context.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Nicolas De Loof</a>
+ */
+public class PlexusBeanDefinitionDocumentReader
+    extends DefaultBeanDefinitionDocumentReader
+{
+    public void registerBeanDefinitions( Document doc, XmlReaderContext 
readerContext )
+    {
+        doc = convertPlexusDescriptorToSpringBeans( doc );
+        super.registerBeanDefinitions( doc, readerContext );
+    }
+
+    protected Document convertPlexusDescriptorToSpringBeans( Document doc )
+    {
+        if ( ! "component-set".equals( doc.getDocumentElement().getNodeName() 
) )
+        {
+            return doc;
+        }
+
+        try
+        {
+            Source xmlSource = new DOMSource( doc );
+            InputStream is = getClass().getResourceAsStream( 
"PlexusBeanDefinitionDocumentReader.xsl" );
+            Source xsltSource = new StreamSource( is );
+
+            DOMResult transResult = new DOMResult();
+
+            TransformerFactory tf = TransformerFactory.newInstance();
+            Transformer t = tf.newTransformer( xsltSource );
+            t.transform( xmlSource, transResult );
+
+            return (Document) transResult.getNode();
+        }
+        catch ( Exception e )
+        {
+            throw new BeanDefinitionStoreException( "Failed to translate 
plexus component descriptor to Spring XML context", e );
+        }
+    }
+}

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusClassPathXmlApplicationContext.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusClassPathXmlApplicationContext.java?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusClassPathXmlApplicationContext.java
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusClassPathXmlApplicationContext.java
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,104 @@
+package org.codehaus.plexus.spring;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * A custom ClassPathXmlApplicationContext to support plexus
+ * <tr>components.xml</tt> descriptors in Spring, with no changes required
+ * to neither plexus nor spring beans.
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Nicolas De Loof</a>
+ */
+public class PlexusClassPathXmlApplicationContext
+    extends ClassPathXmlApplicationContext
+{
+
+    // TODO enable Field injection...
+    // @see http://forum.springframework.org/showthread.php?t=50181
+
+    public PlexusClassPathXmlApplicationContext( String path, Class clazz )
+        throws BeansException
+    {
+        super( path, clazz );
+    }
+
+    public PlexusClassPathXmlApplicationContext( String configLocation )
+        throws BeansException
+    {
+        super( configLocation );
+    }
+
+    public PlexusClassPathXmlApplicationContext( String[] configLocations, 
ApplicationContext parent )
+        throws BeansException
+    {
+        super( configLocations, parent );
+    }
+
+    public PlexusClassPathXmlApplicationContext( String[] configLocations, 
boolean refresh, ApplicationContext parent )
+        throws BeansException
+    {
+        super( configLocations, refresh, parent );
+    }
+
+    public PlexusClassPathXmlApplicationContext( String[] configLocations, 
boolean refresh )
+        throws BeansException
+    {
+        super( configLocations, refresh );
+    }
+
+    public PlexusClassPathXmlApplicationContext( String[] paths, Class clazz, 
ApplicationContext parent )
+        throws BeansException
+    {
+        super( paths, clazz, parent );
+    }
+
+    public PlexusClassPathXmlApplicationContext( String[] paths, Class clazz )
+        throws BeansException
+    {
+        super( paths, clazz );
+    }
+
+    public PlexusClassPathXmlApplicationContext( String[] configLocations )
+        throws BeansException
+    {
+        super( configLocations );
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     * 
+     * @see 
org.springframework.context.support.AbstractXmlApplicationContext#loadBeanDefinitions(org.springframework.beans.factory.xml.XmlBeanDefinitionReader)
+     */
+    protected void loadBeanDefinitions( XmlBeanDefinitionReader reader )
+        throws BeansException, IOException
+    {
+        reader.setDocumentReaderClass( 
PlexusBeanDefinitionDocumentReader.class );
+        reader.setValidationMode( XmlBeanDefinitionReader.VALIDATION_NONE );
+        super.loadBeanDefinitions( reader );
+    }
+
+}

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusClassPathXmlApplicationContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusComponentFactoryBean.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusComponentFactoryBean.java?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusComponentFactoryBean.java
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusComponentFactoryBean.java
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,213 @@
+package org.codehaus.plexus.spring;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.lang.reflect.Field;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.codehaus.plexus.logging.LogEnabled;
+import org.codehaus.plexus.logging.LoggerManager;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
+import 
org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.BeanInitializationException;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.ListableBeanFactory;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.context.Lifecycle;
+import org.springframework.util.ReflectionUtils;
+
+/**
+ * A FactoryBean dedicated to building plexus components. This includes :
+ * <ul>
+ *   <li>Support for direct field injection or "requirements"</li>
+ *   <li>Support for LogEnabled, Initializable and Disposable plexus 
interfaces</li>
+ * </ul>
+ * If not set, the beanFActory will auto-detect the loggerManager to use by 
searching for the
+ * adequate bean in the spring context.
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Nicolas De Loof</a>
+ */
+public class PlexusComponentFactoryBean
+    implements FactoryBean, BeanFactoryAware, InitializingBean, DisposableBean
+{
+    private Class role;
+
+    private Class implementation;
+
+    private String instanciationStrategy;
+
+    private Map requirements;
+
+    private ListableBeanFactory beanFactory;
+
+    private LoggerManager loggerManager;
+
+    private List instances = new LinkedList();
+    
+    public void afterPropertiesSet()
+        throws Exception
+    {
+        if ( loggerManager == null )
+        {
+            if ( beanFactory.containsBean( "loggerManager" ) )
+            {
+                loggerManager = (LoggerManager) beanFactory.getBean( 
"loggerManager" );
+            }
+            Map loggers = beanFactory.getBeansOfType( LoggerManager.class );
+            if ( loggers.size() == 1 )
+            {
+                loggerManager = (LoggerManager) 
loggers.values().iterator().next();
+            }
+            else
+            {
+                throw new BeanInitializationException(
+                                                       "You must explicitly 
set a LoggerManager or define a unique one in bean context" );
+            }
+        }
+    }
+    
+    public void destroy()
+        throws Exception
+    {
+        synchronized ( instances )
+        {
+            for ( Iterator iterator = instances.iterator(); 
iterator.hasNext(); )
+            {
+                Object component = (Object) iterator.next();
+                if ( component instanceof Disposable )
+                {
+                    ((Disposable) component).dispose();
+                    
+                }
+            }
+        }        
+    }
+    
+    public Object getObject()
+        throws Exception
+    {
+        final Object component = implementation.newInstance();
+        synchronized ( instances )
+        {
+            instances.add( component );
+        }
+        if ( requirements != null )
+        {
+            ReflectionUtils.doWithFields( implementation, new 
ReflectionUtils.FieldCallback()
+            {
+                public void doWith( Field field )
+                    throws IllegalArgumentException, IllegalAccessException
+                {
+                    Object dependency = requirements.get( field.getName() );
+                    if ( dependency instanceof RuntimeBeanReference )
+                    {
+                        dependency = beanFactory.getBean( 
((RuntimeBeanReference) dependency).getBeanName() );                        
+                    }
+                    if ( dependency != null )
+                    {
+                        ReflectionUtils.makeAccessible( field );
+                        ReflectionUtils.setField( field, component, dependency 
);
+                    }
+                }
+            }, ReflectionUtils.COPYABLE_FIELDS );
+        }
+
+        if ( component instanceof Initializable )
+        {
+            ( (Initializable) component ).initialize();
+        }
+
+        // TODO handle Initializable, Startable, Stopable, Disposable
+
+        if ( component instanceof LogEnabled )
+        {
+            ( (LogEnabled) component ).enableLogging( 
loggerManager.getLoggerForComponent( role.getName() ) );
+        }
+
+        return component;
+    }
+
+    public Class getObjectType()
+    {
+        return role;
+    }
+
+    public boolean isSingleton()
+    {
+        return "per-lookup".equals( instanciationStrategy );
+    }
+
+    public void setBeanFactory( BeanFactory beanFactory )
+        throws BeansException
+    {
+        this.beanFactory = (ListableBeanFactory) beanFactory;
+    }
+
+    /**
+     * @param loggerManager the loggerManager to set
+     */
+    public void setLoggerManager( LoggerManager loggerManager )
+    {
+        this.loggerManager = loggerManager;
+    }
+
+    /**
+     * @param role the role to set
+     */
+    public void setRole( Class role )
+    {
+        this.role = role;
+    }
+
+    /**
+     * @param implementation the implementation to set
+     */
+    public void setImplementation( Class implementation )
+    {
+        this.implementation = implementation;
+    }
+
+    /**
+     * @param instanciationStrategy the instanciationStrategy to set
+     */
+    public void setInstanciationStrategy( String instanciationStrategy )
+    {
+        this.instanciationStrategy = instanciationStrategy;
+    }
+
+    /**
+     * @param requirements the requirements to set
+     */
+    public void setRequirements( Map requirements )
+    {
+        this.requirements = requirements;
+    }
+
+}

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusComponentFactoryBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusNamespaceHandler.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusNamespaceHandler.java?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusNamespaceHandler.java
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusNamespaceHandler.java
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,136 @@
+package org.codehaus.plexus.spring;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
+import 
org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.ClassUtils;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+
+/**
+ * A spring namespace handler to support plexus components creation and direct 
field-injection in a spring
+ * XmlApplicationContext.
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Nicolas De Loof</a>
+ * @since 1.1
+ */
+public class PlexusNamespaceHandler
+    extends NamespaceHandlerSupport
+{
+    public void init()
+    {
+        registerBeanDefinitionParser( "component", new 
PlexusComponentBeanDefinitionParser() );
+        registerBeanDefinitionParser( "requirement", new 
PlexusPropertyBeanDefinitionParser() );
+    }
+
+    private class PlexusPropertyBeanDefinitionParser
+        extends AbstractBeanDefinitionParser
+    {
+        protected AbstractBeanDefinition parseInternal( Element element, 
ParserContext parserContext )
+        {
+            return null;
+        }
+
+    }
+
+    /**
+     * BeanDefinitionParser for &lt;plexus:component&gt;. Register a bean 
definition for a PlexusComponentFactoryBean
+     * with all nested requirement / configuration injected using direct field 
injection.
+     * <p>
+     * Also register an alias for the Plexus component using spring 
conventions (interface class simple name + "#"
+     * role-hint)
+     */
+    private class PlexusComponentBeanDefinitionParser
+        extends AbstractSingleBeanDefinitionParser
+    {
+
+        protected void doParse( Element element, BeanDefinitionBuilder builder 
)
+        {
+            builder.addPropertyValue( "role", element.getAttribute( "role" ) );
+            String implementation = element.getAttribute( "implementation" );
+            builder.addPropertyValue( "implementation", implementation );
+
+            Map dependencies = new HashMap();
+
+            List requirements = DomUtils.getChildElementsByTagName( element, 
"requirement" );
+            for ( Iterator iterator = requirements.iterator(); 
iterator.hasNext(); )
+            {
+                Element child = (Element) iterator.next();
+                String name = child.getAttribute( "name" );
+                String role = child.getAttribute( "role" );
+                String roleHint = child.getAttribute( "role-hint" );
+                String ref = PlexusToSpringUtils.buildSpringId( role, roleHint 
);
+                if ( roleHint == null )
+                {
+//                    Field f = ClassUtils.forName( implementation ).getField( 
name );
+//                    if ( Map.class.isAssignableFrom( f.getType() ) )
+//                    {
+//                        // TODO add add support for plexus role --> 
Map<role-hint, component>
+//                    }
+                }
+                dependencies.put( name, new RuntimeBeanReference( ref ) );
+
+            }
+
+            List configurations = DomUtils.getChildElementsByTagName( element, 
"configuration" );
+            for ( Iterator iterator = configurations.iterator(); 
iterator.hasNext(); )
+            {
+                Element child = (Element) iterator.next();
+                String name = child.getAttribute( "name" );
+                String value = child.getAttribute( "value" );
+                dependencies.put( name, value );
+            }
+
+            builder.addPropertyValue( "requirements", dependencies );
+        }
+        
+        protected String resolveId( Element element, AbstractBeanDefinition 
definition, ParserContext parserContext )
+            throws BeanDefinitionStoreException
+        {
+            String role = element.getAttribute( "role" );
+            String roleHint = element.getAttribute( "role-hint" );
+            return PlexusToSpringUtils.buildSpringId( role, roleHint );
+        }
+
+        protected Class getBeanClass( Element element )
+        {
+            return PlexusComponentFactoryBean.class;
+        }
+
+    }
+
+    public static String buildSpringId( String role, String roleHint )
+    {
+        return PlexusToSpringUtils.buildSpringId( role, roleHint );
+    }
+}

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusNamespaceHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusToSpringUtils.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusToSpringUtils.java?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusToSpringUtils.java
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusToSpringUtils.java
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,108 @@
+package org.codehaus.plexus.spring;
+
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.StringTokenizer;
+
+import org.apache.commons.lang.ClassUtils;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+
+/**
+ * Utility method to convert plexus descriptors to spring bean context.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Nicolas De Loof</a>
+ * @since 1.1
+ */
+public class PlexusToSpringUtils
+{
+
+    public static String toSpringId( String string )
+    {
+        int i = string.lastIndexOf( '.' );
+        if (i >= 0 )
+        {
+            return Character.toLowerCase( string.charAt( i + 1 ) ) + 
string.substring( i + 2 );
+        }
+        return string;
+    }
+
+    public static String toCamelCase( String string )
+    {
+        StringBuilder camelCase = new StringBuilder();
+        boolean first = true;
+
+        StringTokenizer tokenizer = new StringTokenizer( string.toLowerCase(), 
"-" );
+        while ( tokenizer.hasMoreTokens() )
+        {
+            String token = tokenizer.nextToken();
+            if ( first )
+            {
+                camelCase.append( token.charAt( 0 ) );
+                first = false;
+            }
+            else
+            {
+                camelCase.append( Character.toUpperCase( token.charAt( 0 ) ) );
+            }
+            camelCase.append( token.substring( 1, token.length() ) );
+        }
+        return camelCase.toString();
+    }
+
+    public static boolean isInitializable( String className )
+    {
+        boolean initializable = false;
+        try
+        {
+            initializable = Initializable.class.isAssignableFrom( 
ClassUtils.getClass( className ) );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            // ignored
+        }
+        return initializable;
+    }
+
+    public static boolean isDisposable( String className )
+    {
+        boolean disposable = false;
+        try
+        {
+            disposable = Disposable.class.isAssignableFrom( 
ClassUtils.getClass( className ) );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            // ignored
+        }
+        return disposable;
+    }
+
+    public static String buildSpringId( String role, String roleHint )
+    {
+        int i = role.lastIndexOf( '.' ) + 1;
+        if ( i <= 0 )
+        {
+            i = 0;
+        }
+        String id = Character.toLowerCase( role.charAt( i ) ) + 
role.substring( i + 1 );
+        return roleHint.length() == 0 ? id : id + '#' + roleHint;
+    }}

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusToSpringUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/main/resources/META-INF/spring.handlers
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/main/resources/META-INF/spring.handlers?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/main/resources/META-INF/spring.handlers
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/main/resources/META-INF/spring.handlers
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,3 @@
+# register a NamespaceHandler for the custom <plexus: namespace
+http\://plexus.codehaus.org/spring = 
org.codehaus.plexus.spring.PlexusNamespaceHandler
+ 
\ No newline at end of file

Added: 
maven/archiva/branches/springy/plexus-spring/src/main/resources/META-INF/spring.schemas
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/main/resources/META-INF/spring.schemas?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/main/resources/META-INF/spring.schemas
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/main/resources/META-INF/spring.schemas
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,3 @@
+# register a local copy of the plexus namespace XML schema
+http\://plexus.codehaus.org/schemas/spring-1.0.xsd = plexus.xsd
+ 
\ No newline at end of file

Added: 
maven/archiva/branches/springy/plexus-spring/src/main/resources/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.xsl
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/main/resources/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.xsl?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/main/resources/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.xsl
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/main/resources/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.xsl
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<xsl:stylesheet
+    version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+    xmlns:plexus="http://plexus.codehaus.org/spring";>
+
+<xsl:output method="xml"/>
+
+<!-- 
+  Convert a plexus descriptor to a spring XML context with help of the custom 
<plexus: namespace
+  to handle IoC containers incompatibilities. 
+ -->
+
+<xsl:template match="/component-set">
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xmlns:plexus="http://plexus.codehaus.org/spring";
+       xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+                           http://plexus.codehaus.org/spring 
http://plexus.codehaus.org/schemas/spring-1.0.xsd";>
+  <xsl:for-each select="components/component">
+
+    <plexus:component>
+      <xsl:attribute name="role">
+        <xsl:value-of select="role" />
+      </xsl:attribute>
+      <xsl:if test="role-hint">
+        <xsl:attribute name="role-hint">
+          <xsl:value-of select="role-hint" />
+        </xsl:attribute>
+      </xsl:if>
+      <xsl:attribute name="implementation">
+        <xsl:value-of select="implementation" />
+      </xsl:attribute>
+      <xsl:if test="instanciation-strategy">
+        <xsl:attribute name="instanciation-strategy">
+          <xsl:value-of select="instanciation-strategy" />
+        </xsl:attribute>
+      </xsl:if>
+      <xsl:for-each select="requirements/requirement">
+        <plexus:requirement>
+          <xsl:attribute name="name">
+            <xsl:value-of select="field-name" />
+          </xsl:attribute>
+          <xsl:attribute name="role">
+            <xsl:value-of select="role" />
+          </xsl:attribute>
+          <xsl:if test="role-hint">
+            <xsl:attribute name="role-hint">
+              <xsl:value-of select="role-hint" />
+            </xsl:attribute>
+          </xsl:if>
+        </plexus:requirement>
+      </xsl:for-each>
+      <xsl:for-each select="configuration/*">
+        <plexus:configuration>
+          <xsl:attribute name="name">
+            <xsl:value-of select="name(.)" />
+          </xsl:attribute>
+          <xsl:attribute name="value">
+            <xsl:value-of select="." />
+          </xsl:attribute>
+        </plexus:configuration>
+      </xsl:for-each>
+    </plexus:component>
+
+  </xsl:for-each>
+</beans>
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/main/resources/org/codehaus/plexus/spring/PlexusBeanDefinitionDocumentReader.xsl
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/main/resources/plexus.xsd
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/main/resources/plexus.xsd?rev=630621&view=auto
==============================================================================
--- maven/archiva/branches/springy/plexus-spring/src/main/resources/plexus.xsd 
(added)
+++ maven/archiva/branches/springy/plexus-spring/src/main/resources/plexus.xsd 
Sun Feb 24 05:25:08 2008
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns="http://plexus.codehaus.org/spring"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
+targetNamespace="http://plexus.codehaus.org/spring"; 
+elementFormDefault="qualified" attributeFormDefault="unqualified">
+ 
+  <xsd:element name="component">
+        <xsd:complexType>
+          <xsd:sequence>
+            <xsd:element name="requirement" minOccurs="0">
+              <xsd:complexType>
+                          <xsd:attribute name="name" type="xsd:string" 
use="required"/>
+                          <xsd:attribute name="role" type="xsd:string" 
use="required"/>
+                          <xsd:attribute name="role-hint" type="xsd:string" 
use="optional"/>
+              </xsd:complexType>
+            </xsd:element>
+            <xsd:element name="configuration" minOccurs="0">
+              <xsd:complexType>
+                          <xsd:attribute name="name" type="xsd:string" 
use="required"/>
+                          <xsd:attribute name="value" type="xsd:string" 
use="required"/>
+              </xsd:complexType>
+            </xsd:element>
+          </xsd:sequence>
+          <xsd:attribute name="role" type="xsd:string" use="required"/>
+          <xsd:attribute name="role-hint" type="xsd:string" use="optional"/>
+          <xsd:attribute name="implementation" type="xsd:string" 
use="required"/>
+        </xsd:complexType>
+  </xsd:element>
+</xsd:schema>
\ No newline at end of file

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/main/resources/plexus.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/FieldInjectionTest.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/FieldInjectionTest.java?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/FieldInjectionTest.java
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/FieldInjectionTest.java
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,41 @@
+package org.codehaus.plexus.spring;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+import org.springframework.context.ConfigurableApplicationContext;
+
+public class FieldInjectionTest
+    extends TestCase
+{
+    public void testFieldInjectionInSpringContext()
+        throws Exception
+    {
+        ConfigurableApplicationContext applicationContext = new 
PlexusClassPathXmlApplicationContext( new String[] { "components.xml", 
"applicationContext.xml" } );       
+        PlexusBean plexusBean = (PlexusBean) applicationContext.getBean( 
"plexusBean" );
+        assertEquals( PlexusBean.INITIALIZED, plexusBean.getState() );
+        assertEquals( "field injection failed", "expected SpringBean", 
plexusBean.toString() );
+        applicationContext.close();
+        assertEquals( PlexusBean.DISPOSED, plexusBean.getState() );
+        
+    }
+
+}

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/FieldInjectionTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/PlexusBean.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/PlexusBean.java?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/PlexusBean.java
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/PlexusBean.java
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,37 @@
+package org.codehaus.plexus.spring;
+
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * A plexus component interface
+ * @author <a href="mailto:[EMAIL PROTECTED]">Nicolas De Loof</a>
+ */
+public interface PlexusBean
+{
+    public static final String DISPOSED = "disposed";
+    public static final String INITIALIZED = "initialized";
+    String ROLE = PlexusBean.class.getName();
+    
+    String toString();
+
+    String getState();
+
+}
\ No newline at end of file

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/PlexusBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/PlexusBeanImpl.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/PlexusBeanImpl.java?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/PlexusBeanImpl.java
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/PlexusBeanImpl.java
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,75 @@
+package org.codehaus.plexus.spring;
+
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.logging.LogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import 
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.LogEnablePhase;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * A typical plexus component implementation
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Nicolas De Loof</a>
+ */
+public class PlexusBeanImpl
+    extends AbstractLogEnabled
+    implements PlexusBean, Initializable, Disposable
+{
+    private String message;
+    
+    private String state = "undefined";
+
+    /**
+     * @plexus.requirement
+     */
+    private SpringBean bean;
+
+    public void initialize()
+        throws InitializationException
+    {
+        state = INITIALIZED;
+    }
+
+    public void dispose()
+    {
+        state = DISPOSED;        
+    }
+    
+    /**
+     * @see org.codehaus.plexus.spring.PlexusBean#toString()
+     */
+    public String toString()
+    {
+        getLogger().info( "Logger has been set" );
+        return message + " " + bean.toString();
+    }
+
+    /**
+     * @return the state
+     */
+    public String getState()
+    {
+        return state;
+    }
+
+}

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/PlexusBeanImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/SpringBean.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/SpringBean.java?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/SpringBean.java
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/SpringBean.java
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,32 @@
+package org.codehaus.plexus.spring;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * A bean expected to live in the spring context
+ * @author <a href="mailto:[EMAIL PROTECTED]">Nicolas De Loof</a>
+ */
+public class SpringBean
+{
+    public String toString()
+    {
+        return "SpringBean";
+    }
+}

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/test/java/org/codehaus/plexus/spring/SpringBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/test/resources/applicationContext.xml
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/test/resources/applicationContext.xml?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/test/resources/applicationContext.xml
 (added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/test/resources/applicationContext.xml
 Sun Feb 24 05:25:08 2008
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd";>
+
+     <bean id="loggerManager" 
class="org.codehaus.plexus.logging.console.ConsoleLoggerManager"
+       init-method="initialize"/>
+
+     <bean id="springBean" class="org.codehaus.plexus.spring.SpringBean"/>
+
+</beans>
\ No newline at end of file

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/test/resources/applicationContext.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
maven/archiva/branches/springy/plexus-spring/src/test/resources/components.xml
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/test/resources/components.xml?rev=630621&view=auto
==============================================================================
--- 
maven/archiva/branches/springy/plexus-spring/src/test/resources/components.xml 
(added)
+++ 
maven/archiva/branches/springy/plexus-spring/src/test/resources/components.xml 
Sun Feb 24 05:25:08 2008
@@ -0,0 +1,17 @@
+<component-set>
+  <components>
+    <component>
+      <role>org.codehaus.plexus.spring.PlexusBean</role>
+      
<implementation>org.codehaus.plexus.spring.PlexusBeanImpl</implementation>
+      <requirements>
+       <requirement>
+               <field-name>bean</field-name>
+               <role>springBean</role>
+       </requirement>
+      </requirements>
+      <configuration>
+        <message>expected</message>
+      </configuration>
+    </component>
+  </components>
+</component-set>

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/test/resources/components.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/archiva/branches/springy/plexus-spring/src/test/resources/log4j.xml
URL: 
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/test/resources/log4j.xml?rev=630621&view=auto
==============================================================================
--- maven/archiva/branches/springy/plexus-spring/src/test/resources/log4j.xml 
(added)
+++ maven/archiva/branches/springy/plexus-spring/src/test/resources/log4j.xml 
Sun Feb 24 05:25:08 2008
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<!-- ===================================================================== -->
+<!-- Log4j Configuration -->
+<!-- ===================================================================== -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/";
+  debug="false">
+
+    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+        <param name="Target" value="System.out"/>
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p 
[%c{1}.%M](%L) %m%n"/>
+        </layout>
+    </appender>
+
+    <category name="org.springframework">
+        <priority value="DEBUG"/>
+    </category>
+
+    <category name="org.codehaus">
+        <priority value="DEBUG"/>
+    </category>
+
+    <root>
+        <priority value="WARN"/>
+        <appender-ref ref="CONSOLE"/>
+    </root>
+
+</log4j:configuration>
\ No newline at end of file

Propchange: 
maven/archiva/branches/springy/plexus-spring/src/test/resources/log4j.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to