Author: nicolas
Date: Thu Feb 21 08:33:22 2008
New Revision: 629854
URL: http://svn.apache.org/viewvc?rev=629854&view=rev
Log:
- plexus compilant ClassPathXmlApplicationContext
- plexus-2-spring xslt now creates simple class name aliases for plexus FQCN
roles
- attempt to use plexus to spring bridge in CachedFailuresPolicyTest
Added:
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusClassPathXmlApplicationContext.java
(with props)
Removed:
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/SpringFactory.java
Modified:
maven/archiva/branches/springy/archiva-base/archiva-common/pom.xml
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusBeanDefinitionDocumentReader.java
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusToSpringUtils.java
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/resources/org/apache/maven/archiva/common/spring/plexus2spring.xsl
Modified: maven/archiva/branches/springy/archiva-base/archiva-common/pom.xml
URL:
http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-base/archiva-common/pom.xml?rev=629854&r1=629853&r2=629854&view=diff
==============================================================================
--- maven/archiva/branches/springy/archiva-base/archiva-common/pom.xml
(original)
+++ maven/archiva/branches/springy/archiva-base/archiva-common/pom.xml Thu Feb
21 08:33:22 2008
@@ -53,7 +53,7 @@
<!-- TODO: temporary spring dependencies for migration -->
<dependency>
<groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
+ <artifactId>spring-context</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
Modified:
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusBeanDefinitionDocumentReader.java
URL:
http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusBeanDefinitionDocumentReader.java?rev=629854&r1=629853&r2=629854&view=diff
==============================================================================
---
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusBeanDefinitionDocumentReader.java
(original)
+++
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusBeanDefinitionDocumentReader.java
Thu Feb 21 08:33:22 2008
@@ -52,6 +52,11 @@
protected Document convertPlexusDescriptorToSpringBeans( Document doc )
{
+ if ( ! "component-set".equals( doc.getDocumentElement().getNodeName()
) )
+ {
+ return doc;
+ }
+
try
{
Source xmlSource = new DOMSource( doc );
Added:
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusClassPathXmlApplicationContext.java
URL:
http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusClassPathXmlApplicationContext.java?rev=629854&view=auto
==============================================================================
---
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusClassPathXmlApplicationContext.java
(added)
+++
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusClassPathXmlApplicationContext.java
Thu Feb 21 08:33:22 2008
@@ -0,0 +1,102 @@
+package org.apache.maven.archiva.common.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;
+
+/**
+ * @author <a href="mailto:[EMAIL PROTECTED]">Nicolas De Loof</a>
+ * @since 1.1
+ */
+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)
+ */
+ @Override
+ 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/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusClassPathXmlApplicationContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusClassPathXmlApplicationContext.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusClassPathXmlApplicationContext.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusToSpringUtils.java
URL:
http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusToSpringUtils.java?rev=629854&r1=629853&r2=629854&view=diff
==============================================================================
---
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusToSpringUtils.java
(original)
+++
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/spring/PlexusToSpringUtils.java
Thu Feb 21 08:33:22 2008
@@ -34,6 +34,16 @@
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();
Modified:
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/resources/org/apache/maven/archiva/common/spring/plexus2spring.xsl
URL:
http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-base/archiva-common/src/main/resources/org/apache/maven/archiva/common/spring/plexus2spring.xsl?rev=629854&r1=629853&r2=629854&view=diff
==============================================================================
---
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/resources/org/apache/maven/archiva/common/spring/plexus2spring.xsl
(original)
+++
maven/archiva/branches/springy/archiva-base/archiva-common/src/main/resources/org/apache/maven/archiva/common/spring/plexus2spring.xsl
Thu Feb 21 08:33:22 2008
@@ -33,6 +33,7 @@
<xsl:template match="/component-set">
<beans>
<xsl:for-each select="components/component">
+
<bean>
<xsl:choose>
<xsl:when test="role-hint">
@@ -66,12 +67,12 @@
<xsl:choose>
<xsl:when test="role-hint">
<xsl:attribute name="ref">
- <xsl:value-of select="concat( role, '#', role-hint )" />
+ <xsl:value-of select="concat( plexus:toSpringId( role ), '#',
role-hint )" />
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="ref">
- <xsl:value-of select="role" />
+ <xsl:value-of select="plexus:toSpringId( role )" />
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
@@ -88,6 +89,35 @@
</property>
</xsl:for-each>
</bean>
+
+ <!--
+ Plexus convention is to use interface FQN as bean ID
+ Spring convention is to use interface simpleName as bean ID
+ To allow smooth migration, we define same bean with both IDs using an
alias
+ -->
+
+ <alias>
+ <xsl:attribute name="alias">
+ <xsl:choose>
+ <xsl:when test="role-hint">
+ <xsl:value-of select="concat( plexus:toSpringId( role ), '#',
role-hint )" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="plexus:toSpringId( role )" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:attribute name="name">
+ <xsl:choose>
+ <xsl:when test="role-hint">
+ <xsl:value-of select="concat( role, '#', role-hint )" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="role" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </alias>
</xsl:for-each>
</beans>
</xsl:template>