[jboss-cvs] JBossAS SVN: r85983 - in projects/spring-int/trunk: build and 40 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 17 09:29:32 EDT 2009


Author: alesj
Date: 2009-03-17 09:29:32 -0400 (Tue, 17 Mar 2009)
New Revision: 85983

Added:
   projects/spring-int/trunk/build/
   projects/spring-int/trunk/build/JBossORG-EULA.txt
   projects/spring-int/trunk/build/pom.xml
   projects/spring-int/trunk/build/src/
   projects/spring-int/trunk/build/src/assembly/
   projects/spring-int/trunk/build/src/assembly/dist-with-deps.xml
   projects/spring-int/trunk/build/src/assembly/dist.xml
   projects/spring-int/trunk/build/src/assembly/src.xml
   projects/spring-int/trunk/cluster/
   projects/spring-int/trunk/cluster/pom.xml
   projects/spring-int/trunk/cluster/src/
   projects/spring-int/trunk/cluster/src/main/
   projects/spring-int/trunk/cluster/src/main/java/
   projects/spring-int/trunk/cluster/src/main/java/org/
   projects/spring-int/trunk/cluster/src/main/java/org/jboss/
   projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/
   projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/
   projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/CacheLookup.java
   projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/CachePostProcessor.java
   projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/CacheScope.java
   projects/spring-int/trunk/deployers/
   projects/spring-int/trunk/deployers/pom.xml
   projects/spring-int/trunk/deployers/src/
   projects/spring-int/trunk/deployers/src/main/
   projects/spring-int/trunk/deployers/src/main/java/
   projects/spring-int/trunk/deployers/src/main/java/org/
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/annotation/
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/annotation/spring/
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/annotation/spring/Spring.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/callback/
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/callback/SpringLifecycleInterceptor.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/callback/SpringPassivationInterceptor.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/AbstractSpringMetaDataDeployer.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/ApplicationContextDeployer.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/BeanFactoryDeployer.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/SpringMetaData.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/SpringParserDeployer.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/Instantiable.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/Nameable.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlApplicationContext.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlBeanDefinitionParser.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlBeanDefinitionReader.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlBeanFactory.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/interceptor/
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/interceptor/SpringInjectionInterceptor.java
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/support/
   projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/support/SpringInjectionSupport.java
   projects/spring-int/trunk/facade/
   projects/spring-int/trunk/facade/pom.xml
   projects/spring-int/trunk/facade/src/
   projects/spring-int/trunk/facade/src/main/
   projects/spring-int/trunk/facade/src/main/java/
   projects/spring-int/trunk/facade/src/main/java/org/
   projects/spring-int/trunk/facade/src/main/java/org/jboss/
   projects/spring-int/trunk/facade/src/main/java/org/jboss/spring/
   projects/spring-int/trunk/facade/src/main/java/org/jboss/spring/facade/
   projects/spring-int/trunk/facade/src/main/java/org/jboss/spring/facade/ControllerBeanFactory.java
   projects/spring-int/trunk/facade/src/main/java/org/jboss/spring/facade/KernelControllerListableBeanFactory.java
   projects/spring-int/trunk/pom.xml
   projects/spring-int/trunk/vfs/
   projects/spring-int/trunk/vfs/pom.xml
   projects/spring-int/trunk/vfs/src/
   projects/spring-int/trunk/vfs/src/main/
   projects/spring-int/trunk/vfs/src/main/java/
   projects/spring-int/trunk/vfs/src/main/java/org/
   projects/spring-int/trunk/vfs/src/main/java/org/jboss/
   projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/
   projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/
   projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResource.java
   projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResourceLoader.java
   projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResourcePatternResolver.java
Log:
Move Spring integration out of jbossas.

Added: projects/spring-int/trunk/build/JBossORG-EULA.txt
===================================================================
--- projects/spring-int/trunk/build/JBossORG-EULA.txt	                        (rev 0)
+++ projects/spring-int/trunk/build/JBossORG-EULA.txt	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,107 @@
+LICENSE AGREEMENT
+JBOSS(r)
+
+This License Agreement governs the use of the Software Packages and any updates to the Software 
+Packages, regardless of the delivery mechanism.  Each Software Package is a collective work 
+under U.S. Copyright Law.  Subject to the following terms, Red Hat, Inc. ("Red Hat") grants to 
+the user ("Client") a license to the applicable collective work(s) pursuant to the 
+GNU Lesser General Public License v. 2.1 except for the following Software Packages: 
+(a) JBoss Portal Forums and JBoss Transactions JTS, each of which is licensed pursuant to the 
+GNU General Public License v.2; 
+
+(b) JBoss Rules, which is licensed pursuant to the Apache  License v.2.0;
+
+(c) an optional download for JBoss Cache for the Berkeley DB for Java database, which is licensed under the 
+(open source) Sleepycat License (if Client does not wish to use the open source version of this database, 
+it may purchase a license from Sleepycat Software); 
+
+and (d) the BPEL extension for JBoss jBPM, which is licensed under the Common Public License v.1, 
+and, pursuant to the OASIS BPEL4WS standard, requires parties wishing to redistribute to enter various 
+royalty-free patent licenses.  
+
+Each of the foregoing licenses is available at http://www.opensource.org/licenses/index.php.
+
+1.  The Software.  "Software Packages" refer to the various software modules that are created and made available 
+for distribution by the JBoss.org open source community at http://www.jboss.org.   Each of the Software Packages 
+may be comprised of hundreds of software components.  The end user license agreement for each component is located in 
+the component's source code.  With the exception of certain image files identified in Section 2 below, 
+the license terms for the components permit Client to copy, modify, and redistribute the component, 
+in both source code and binary code forms.  This agreement does not limit Client's rights under, 
+or grant Client rights that supersede, the license terms of any particular component.
+
+2.  Intellectual Property Rights.  The Software Packages are owned by Red Hat and others and are protected under copyright 
+and other laws.  Title to the Software Packages and any component, or to any copy, modification, or merged portion shall 
+remain with the aforementioned, subject to the applicable license.  The "JBoss" trademark, "Red Hat" trademark, the 
+individual Software Package trademarks, and the "Shadowman" logo are registered trademarks of Red Hat and its affiliates 
+in the U.S. and other countries.  This agreement permits Client to distribute unmodified copies of the Software Packages 
+using the Red Hat trademarks that Red Hat has inserted in the Software Packages on the condition that Client follows Red Hat's 
+trademark guidelines for those trademarks located at http://www.redhat.com/about/corporate/trademark/.  Client must abide by 
+these trademark guidelines when distributing the Software Packages, regardless of whether the Software Packages have been modified. 
+If Client modifies the Software Packages, then Client must replace all Red Hat trademarks and logos identified at 
+http://www.jboss.com/company/logos, unless a separate agreement with Red Hat is executed or other permission granted.  
+Merely deleting the files containing the Red Hat trademarks may corrupt the Software Packages.  
+
+3.  Limited Warranty.  Except as specifically stated in this Paragraph 3 or a license for a particular 
+component, to the maximum extent permitted under applicable law, the Software Packages and the 
+components are provided and licensed "as is" without warranty of any kind, expressed or implied, 
+including the implied warranties of merchantability, non-infringement or fitness for a particular purpose.  
+Red Hat warrants that the media on which Software Packages may be furnished will be free from defects in 
+materials and manufacture under normal use for a period of 30 days from the date of delivery to Client.  
+Red Hat does not warrant that the functions contained in the Software Packages will meet Client's requirements 
+or that the operation of the Software Packages will be entirely error free or appear precisely as described 
+in the accompanying documentation. This warranty extends only to the party that purchases the Services 
+pertaining to the Software Packages from Red Hat or a Red Hat authorized distributor. 
+
+4.  Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, the remedies 
+described below are accepted by Client as its only remedies.  Red Hat's entire liability, and Client's 
+exclusive remedies, shall be: If the Software media is defective, Client may return it within 30 days of 
+delivery along with a copy of Client's payment receipt and Red Hat, at its option, will replace it or 
+refund the money paid by Client for the Software.  To the maximum extent permitted by applicable law, 
+Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential 
+damages, including lost profits or lost savings arising out of the use or inability to use the Software, 
+even if Red Hat or such dealer has been advised of the possibility of such damages.  In no event shall 
+Red Hat's liability under this agreement exceed the amount that Client paid to Red Hat under this 
+Agreement during the twelve months preceding the action.
+
+5.  Export Control.  As required by U.S. law, Client represents and warrants that it: 
+(a) understands that the Software Packages are subject to export controls under the 
+U.S. Commerce Department's Export Administration Regulations ("EAR"); 
+
+(b) is not located in a prohibited destination country under the EAR or U.S. sanctions regulations 
+(currently Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria); 
+
+(c) will not export, re-export, or transfer the Software Packages to any prohibited destination, entity, 
+or individual without the necessary export license(s) or authorizations(s) from the U.S. Government; 
+
+(d) will not use or transfer the Software Packages for use in any sensitive nuclear, chemical or 
+biological weapons, or missile technology end-uses unless authorized by the U.S. Government by 
+regulation or specific license; 
+
+(e) understands and agrees that if it is in the United States and exports or transfers the Software 
+Packages to eligible end users, it will, as required by EAR Section 740.17(e), submit semi-annual 
+reports to the Commerce Department's Bureau of Industry & Security (BIS), which include the name and 
+address (including country) of each transferee; 
+
+and (f) understands that countries other than the United States may restrict the import, use, or 
+export of encryption products and that it shall be solely responsible for compliance with any such 
+import, use, or export restrictions.
+
+6.  Third Party Programs. Red Hat may distribute third party software programs with the Software Packages 
+that are not part of the Software Packages and which Client must install separately.  These third party 
+programs are subject to their own license terms.  The license terms either accompany the programs or 
+can be viewed at http://www.redhat.com/licenses/.  If Client does not agree to abide by the applicable 
+license terms for such programs, then Client may not install them.  If Client wishes to install the programs 
+on more than one system or transfer the programs to another party, then Client must contact the licensor 
+of the programs.
+
+7.  General.  If any provision of this agreement is held to be unenforceable, that shall not affect the 
+enforceability of the remaining provisions.  This License Agreement shall be governed by the laws of the 
+State of North Carolina and of the United States, without regard to any conflict of laws provisions, 
+except that the United Nations Convention on the International Sale of Goods shall not apply.
+
+Copyright 2006 Red Hat, Inc.  All rights reserved.  
+"JBoss" and the JBoss logo are registered trademarks of Red Hat, Inc.  
+All other trademarks are the property of their respective owners. 
+
+	Page 1 of 1	18 October 2006
+

Added: projects/spring-int/trunk/build/pom.xml
===================================================================
--- projects/spring-int/trunk/build/pom.xml	                        (rev 0)
+++ projects/spring-int/trunk/build/pom.xml	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,53 @@
+<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">
+  <parent>
+    <groupId>org.jboss.spring-int</groupId>
+    <artifactId>jboss-spring-int-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.jboss.spring-int</groupId>
+  <artifactId>jboss-spring-int</artifactId>
+  <packaging>pom</packaging>
+  <name>JBoss Spring Integration Distribution</name>
+  <url>http://www.jboss.com/products/jbossmc</url>
+  <description>JBoss Spring Integration Distribution</description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>2.2-beta-2</version>
+        <executions>
+          <execution>
+            <id>make-assembly</id>
+            <phase>package</phase>
+            <goals>
+              <goal>attached</goal>
+            </goals>
+            <configuration>
+              <finalName>jboss-spring-int-${project.version}</finalName>
+              <descriptors>
+                <descriptor>src/assembly/dist.xml</descriptor>
+                <descriptor>src/assembly/dist-with-deps.xml</descriptor>
+                <descriptor>src/assembly/src.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.jboss.spring-int</groupId>
+      <artifactId>jboss-spring-int-vfs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.spring-int</groupId>
+      <artifactId>jboss-spring-int-deployers</artifactId>
+    </dependency>
+  </dependencies>
+  
+</project>
\ No newline at end of file

Added: projects/spring-int/trunk/build/src/assembly/dist-with-deps.xml
===================================================================
--- projects/spring-int/trunk/build/src/assembly/dist-with-deps.xml	                        (rev 0)
+++ projects/spring-int/trunk/build/src/assembly/dist-with-deps.xml	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,11 @@
+<assembly>
+  <id>with-deps</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>/</outputDirectory>
+    </dependencySet>
+  </dependencySets>
+</assembly>

Added: projects/spring-int/trunk/build/src/assembly/dist.xml
===================================================================
--- projects/spring-int/trunk/build/src/assembly/dist.xml	                        (rev 0)
+++ projects/spring-int/trunk/build/src/assembly/dist.xml	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,11 @@
+<assembly>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>/</outputDirectory>
+      <useTransitiveDependencies>false</useTransitiveDependencies>
+    </dependencySet>
+  </dependencySets>
+</assembly>

Added: projects/spring-int/trunk/build/src/assembly/src.xml
===================================================================
--- projects/spring-int/trunk/build/src/assembly/src.xml	                        (rev 0)
+++ projects/spring-int/trunk/build/src/assembly/src.xml	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,15 @@
+<assembly>
+  <id>src</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <fileSets>
+    <fileSet>
+      <directory>..</directory>
+      <outputDirectory></outputDirectory>
+      <excludes>
+        <exclude>*/target/</exclude>
+      </excludes>
+    </fileSet>
+  </fileSets>
+</assembly>

Added: projects/spring-int/trunk/cluster/pom.xml
===================================================================
--- projects/spring-int/trunk/cluster/pom.xml	                        (rev 0)
+++ projects/spring-int/trunk/cluster/pom.xml	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,57 @@
+<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">
+  <parent>
+    <groupId>org.jboss.spring-int</groupId>
+    <artifactId>jboss-spring-int-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.jboss.spring-int</groupId>
+  <artifactId>jboss-spring-int-cluster</artifactId>
+  <packaging>jar</packaging>
+  <name>JBoss Spring Integration - Cluster</name>
+  <url>http://www.jboss.org/jbossmc</url>
+  <description>JBoss Spring Integration - Cluster</description>
+
+  <dependencies>
+    <!-- Compile (global dependencies) -->
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-common-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aop</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-beans</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.cache</groupId>
+      <artifactId>jbosscache-pojo</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>jboss</groupId>
+          <artifactId>jboss-j2ee</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.aop</groupId>
+          <artifactId>jboss-aop</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+  
+</project>
\ No newline at end of file

Added: projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/CacheLookup.java
===================================================================
--- projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/CacheLookup.java	                        (rev 0)
+++ projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/CacheLookup.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.cluster;
+
+import org.jboss.cache.CacheException;
+import org.jboss.cache.pojo.PojoCache;
+
+/**
+ * Cache lookup helper class.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class CacheLookup
+{
+   private String rootName = "/pojos/";
+   protected PojoCache pojoCache;
+
+   protected CacheLookup(PojoCache pojoCache)
+   {
+      this.pojoCache = pojoCache;
+   }
+
+   /**
+    * Get the object out of pojo cache.
+    *
+    * @param name the name to look for
+    * @return cached object or null for some cache exception
+    */
+   protected Object get(String name)
+   {
+      try
+      {
+         return pojoCache.find(rootName + name);
+      }
+      catch (CacheException e)
+      {
+         System.err.println("Exception getting object from PojoCache:" + e);
+      }
+      return null;
+   }
+
+   /**
+    * Put the object into cache.
+    *
+    * @param name the name to put it under
+    * @param object the object to put
+    * @return result of cache put
+    */
+   protected Object put(String name, Object object)
+   {
+      try
+      {
+         return pojoCache.attach(rootName + name, object);
+      }
+      catch (CacheException e)
+      {
+         throw new IllegalArgumentException("Unable to put object to PojoCache: " + e);
+      }
+   }
+
+   /**
+    * Remove object with name param from cache.
+    *
+    * @param name the object's name
+    * @return removed object or null for any cache error
+    */
+   public Object remove(String name)
+   {
+      try
+      {
+         return pojoCache.detach(rootName + name);
+      }
+      catch (CacheException e)
+      {
+         System.err.println("Exception removing object from PojoCache:" + e);
+         return null;
+      }
+   }
+
+   /**
+    * Set the cache root name.
+    *
+    * @param rootName the root name
+    */
+   public void setRootName(String rootName)
+   {
+      this.rootName = rootName;
+   }
+}

Added: projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/CachePostProcessor.java
===================================================================
--- projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/CachePostProcessor.java	                        (rev 0)
+++ projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/CachePostProcessor.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.cluster;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.cache.pojo.annotation.Replicable;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+
+/**
+ * Pojo cache / cluster post processor.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CachePostProcessor extends CacheLookup implements BeanFactoryPostProcessor, BeanPostProcessor
+{
+   private String scopeName = "cache";
+
+   public CachePostProcessor(PojoCache pojoCache)
+   {
+      super(pojoCache);
+   }
+
+   public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
+   {
+      beanFactory.registerScope(scopeName, new CacheScope(pojoCache));
+   }
+
+   public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
+   {
+      Class<?> beanClass = bean.getClass();
+      if (beanClass.isAnnotationPresent(getMarkerAnnotation()))
+      {
+         Object result = get(beanName);
+         if (result != null)
+         {
+            return result;
+         }
+         else
+         {
+            return put(beanName, bean);
+         }
+      }
+      return bean;
+   }
+
+   public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
+   {
+      return bean;
+   }
+
+   /**
+    * Get the bean cache / cluster marker annotation.
+    *
+    * @return the cache / cluster marker annotation
+    */
+   public Class<? extends Annotation> getMarkerAnnotation()
+   {
+      return Replicable.class;
+   }
+
+   /**
+    * Set scope name.
+    *
+    * @param scopeName the scope name
+    */
+   public void setScopeName(String scopeName)
+   {
+      this.scopeName = scopeName;
+   }
+}

Added: projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/CacheScope.java
===================================================================
--- projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/CacheScope.java	                        (rev 0)
+++ projects/spring-int/trunk/cluster/src/main/java/org/jboss/spring/cluster/CacheScope.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.cluster;
+
+import org.jboss.cache.pojo.PojoCache;
+import org.springframework.beans.factory.ObjectFactory;
+import org.springframework.beans.factory.config.Scope;
+
+/**
+ * Pojo cache scope.
+ *
+ * It enables plain spring beans to be clustered
+ * via JBoss Pojo cache.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CacheScope extends CacheLookup implements Scope
+{
+   public CacheScope(PojoCache pojoCache)
+   {
+      super(pojoCache);
+   }
+
+   public String getConversationId()
+   {
+      return null;
+   }
+
+   public Object get(String name, ObjectFactory objectFactory)
+   {
+      Object result = get(name);
+      return (result != null) ?  result : put(name,  objectFactory.getObject());
+   }
+
+   public void registerDestructionCallback(String string, Runnable runnable)
+   {
+   }
+}

Added: projects/spring-int/trunk/deployers/pom.xml
===================================================================
--- projects/spring-int/trunk/deployers/pom.xml	                        (rev 0)
+++ projects/spring-int/trunk/deployers/pom.xml	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,102 @@
+<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">
+  <parent>
+    <groupId>org.jboss.spring-int</groupId>
+    <artifactId>jboss-spring-int-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.jboss.spring-int</groupId>
+  <artifactId>jboss-spring-int-deployers</artifactId>
+  <packaging>jar</packaging>
+  <name>JBoss Spring Integration - Deployers</name>
+  <url>http://www.jboss.org/jbossmc</url>
+  <description>JBoss Spring Integration - Deployers</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.jboss.spring-int</groupId>
+      <artifactId>jboss-spring-int-vfs</artifactId>
+    </dependency>
+    <!-- Compile (global dependencies) -->
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-vfs-spi</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>jboss</groupId>
+          <artifactId>jboss-vfs</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>apache-xerces</groupId>
+      <artifactId>xml-apis</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-vfs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-common-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-log4j</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-dependency</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-structure-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-vfs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-core-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-kernel</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.aop</groupId>
+      <artifactId>jboss-aop</artifactId>
+      <version>${version.jboss.aop}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.javaee</groupId>
+      <artifactId>jboss-ejb-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aop</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-beans</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-core</artifactId>
+    </dependency>
+  </dependencies>
+  
+</project>
\ No newline at end of file

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/annotation/spring/Spring.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/annotation/spring/Spring.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/annotation/spring/Spring.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.annotation.spring;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Spring bean marker annotation.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+ at Target({ElementType.METHOD, ElementType.FIELD})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Spring
+{
+   /**
+    * The BeanFactory JNDI name.
+    *
+    * @return the bean factory jndi name
+    */
+   String jndiName() default "";
+
+   /**
+    * The bean name.
+    *
+    * @return the bean name
+    */
+   String bean() default "";
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/callback/SpringLifecycleInterceptor.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/callback/SpringLifecycleInterceptor.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/callback/SpringLifecycleInterceptor.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.callback;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.spring.support.SpringInjectionSupport;
+
+/**
+ * Injects Spring beans on postConstruction and postActivation.
+ * Sets all non serializable, non transient fields to null before passivation.
+ *
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ * @see SpringPassivationInterceptor
+ * @see SpringInjectionSupport
+ */
+public class SpringLifecycleInterceptor extends SpringPassivationInterceptor
+{
+   private static final long serialVersionUID = 365239483909594775L;
+
+   @PostConstruct
+   public void postConstruct(InvocationContext ctx) throws Exception
+   {
+      inject(ctx.getTarget());
+      ctx.proceed();
+   }
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/callback/SpringPassivationInterceptor.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/callback/SpringPassivationInterceptor.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/callback/SpringPassivationInterceptor.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.callback;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import javax.annotation.PreDestroy;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.spring.support.SpringInjectionSupport;
+
+/**
+ * Injects Spring beans only on postActivation.
+ * If you need injection also on construction, use SpringLifecycleInterceptor.
+ * Sets all non serializable, non transient fields to null before passivation.
+ *
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ * @see org.jboss.spring.support.SpringInjectionSupport
+ */
+public class SpringPassivationInterceptor extends SpringInjectionSupport implements Serializable
+{
+   private static final long serialVersionUID = -7259379236645796135L;
+
+   @PostActivate
+   public void postActivate(InvocationContext ctx) throws Exception
+   {
+      inject(ctx.getTarget());
+      ctx.proceed();
+   }
+
+   @PrePassivate
+   public void prePassivate(InvocationContext ctx) throws Exception
+   {
+      Field[] fields = getAllFields(ctx.getTarget());
+      for (Field f : fields)
+      {
+         boolean isSerializable = Serializable.class.isAssignableFrom(f.getType());
+         boolean isTransient = Modifier.isTransient(f.getModifiers());
+         if (!isSerializable && !isTransient)
+         {
+            f.setAccessible(true);
+            f.set(ctx.getTarget(), null);
+         }
+      }
+      ctx.proceed();
+   }
+
+   @PreDestroy
+   public void preDestroy(InvocationContext ctx) throws Exception
+   {
+      ctx.proceed();
+   }
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/AbstractSpringMetaDataDeployer.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/AbstractSpringMetaDataDeployer.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/AbstractSpringMetaDataDeployer.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,211 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.deployers;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployerWithInput;
+import org.jboss.deployers.spi.deployer.helpers.DeploymentVisitor;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.spring.factory.Nameable;
+import org.jboss.util.naming.NonSerializableFactory;
+import org.jboss.util.naming.Util;
+import org.springframework.beans.factory.BeanFactory;
+
+/**
+ * Deploys SpringMetaData.
+ * @see ApplicationContextDeployer
+ * @see BeanFactoryDeployer
+ *
+ * @param <T> exact bean factory type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractSpringMetaDataDeployer<T extends BeanFactory> extends AbstractRealDeployerWithInput<SpringMetaData>
+{
+   protected AbstractSpringMetaDataDeployer()
+   {
+      setDeploymentVisitor(createDeploymentVisitor());
+   }
+
+   /**
+    * Create deployment visitor.
+    *
+    * @return the deployment visitor
+    */
+   protected abstract DeploymentVisitor<SpringMetaData> createDeploymentVisitor();
+
+   protected abstract class SpringDeploymentVisitor implements DeploymentVisitor<SpringMetaData>
+   {
+      public Class<SpringMetaData> getVisitorType()
+      {
+         return SpringMetaData.class;
+      }
+
+      public void deploy(DeploymentUnit unit, SpringMetaData springMetaData) throws DeploymentException
+      {
+         ClassLoader classLoader = unit.getClassLoader();
+         ClassLoader old = Thread.currentThread().getContextClassLoader();
+         try
+         {
+            Thread.currentThread().setContextClassLoader(classLoader);
+            T beanFactory = doCreate(springMetaData);
+            String name = ((Nameable) beanFactory).getName();
+            springMetaData.setName(name);
+            bind(beanFactory, name);
+            if (log.isTraceEnabled())
+               log.trace("Bean factory [" + name + "] binded to local JNDI.");
+         }
+         finally
+         {
+            Thread.currentThread().setContextClassLoader(old);
+         }
+      }
+
+      /**
+       * Do create BeanFactory instance.
+       *
+       * @param metaData the spring meta data
+       * @return new bean factory instance
+       */
+      protected abstract T doCreate(SpringMetaData metaData);
+
+      public void undeploy(DeploymentUnit unit, SpringMetaData springMetaData)
+      {
+         String name = springMetaData.getName();
+         try
+         {
+            T beanFactory = lookup(name);
+            if (beanFactory != null)
+            {
+               doClose(beanFactory);
+               unbind(name);
+               if (log.isTraceEnabled())
+                  log.trace("Bean factory [" + name + "] unbinded from local JNDI.");
+            }
+         }
+         catch (Exception e)
+         {
+            if (log.isTraceEnabled())
+               log.trace("Exception finding BeanFactory instance named " + name, e);
+         }
+      }
+
+      /**
+       * Do close bean factory.
+       *
+       * @param beanFactory the bean factory to close
+       */
+      protected abstract void doClose(T beanFactory);
+   }
+
+   /**
+    * Bind factory to non-serializable JNDI context.
+    *
+    * @param beanFactory the bean factory
+    * @param name the jndi name
+    * @throws DeploymentException for any error
+    */
+   protected void bind(T beanFactory, String name) throws DeploymentException
+   {
+      InitialContext ctx = null;
+      try
+      {
+         ctx = new InitialContext();
+         NonSerializableFactory.rebind(ctx, name, beanFactory);
+      }
+      catch (NamingException e)
+      {
+         throw new DeploymentException("Unable to bind BeanFactory into JNDI", e);
+      }
+      finally
+      {
+         if (ctx != null)
+         {
+            try
+            {
+               ctx.close();
+            }
+            catch (Throwable ignored)
+            {
+            }
+         }
+      }
+   }
+
+   /**
+    * Unind factory from non-serializable JNDI context.
+    *
+    * @param name the jndi name
+    */
+   protected void unbind(String name)
+   {
+      InitialContext ctx = null;
+      try
+      {
+         ctx = new InitialContext();
+         ctx.unbind(name);
+         NonSerializableFactory.unbind(name);
+      }
+      catch (NamingException e)
+      {
+         log.warn("Unable to unbind BeanFactory from JNDI", e);
+      }
+      finally
+      {
+         if (ctx != null)
+         {
+            try
+            {
+               ctx.close();
+            }
+            catch (Throwable ignored)
+            {
+            }
+         }
+      }
+   }
+
+   /**
+    * Do a jndi lookup for bean factory.
+    *
+    * @param name the jndi name
+    * @return bean factory instance
+    * @throws Exception for any exception
+    */
+   protected T lookup(String name) throws Exception
+   {
+      Class<T> beanFactoryClass = getExactBeanFactoryClass();
+      T beanFactory = beanFactoryClass.cast(Util.lookup(name, beanFactoryClass));
+      if (log.isTraceEnabled())
+         log.trace("Found Spring bean factory [" + name + "]: " + beanFactory);
+      return beanFactory;
+   }
+
+   /**
+    * Exact bean factory class.
+    *
+    * @return the bean factory class
+    */
+   protected abstract Class<T> getExactBeanFactoryClass();
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/ApplicationContextDeployer.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/ApplicationContextDeployer.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/ApplicationContextDeployer.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.deployers;
+
+import org.jboss.deployers.spi.deployer.helpers.DeploymentVisitor;
+import org.jboss.spring.factory.NamedXmlApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+
+/**
+ * Spring application context deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ApplicationContextDeployer extends AbstractSpringMetaDataDeployer<ConfigurableApplicationContext>
+{
+   protected DeploymentVisitor<SpringMetaData> createDeploymentVisitor()
+   {
+      return new SpringDeploymentVisitor()
+      {
+         protected ConfigurableApplicationContext doCreate(SpringMetaData metaData)
+         {
+            return new NamedXmlApplicationContext(metaData.getDefaultName(), metaData.getResource());
+         }
+
+         protected void doClose(ConfigurableApplicationContext beanFactory)
+         {
+            beanFactory.close();
+         }
+      };
+   }
+
+   protected Class<ConfigurableApplicationContext> getExactBeanFactoryClass()
+   {
+      return ConfigurableApplicationContext.class;
+   }
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/BeanFactoryDeployer.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/BeanFactoryDeployer.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/BeanFactoryDeployer.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.deployers;
+
+import org.jboss.deployers.spi.deployer.helpers.DeploymentVisitor;
+import org.jboss.spring.factory.NamedXmlBeanFactory;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+
+/**
+ * Spring bean factory deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanFactoryDeployer extends AbstractSpringMetaDataDeployer<ConfigurableBeanFactory>
+{
+   protected DeploymentVisitor<SpringMetaData> createDeploymentVisitor()
+   {
+      return new SpringDeploymentVisitor()
+      {
+         protected ConfigurableBeanFactory doCreate(SpringMetaData metaData)
+         {
+            return new NamedXmlBeanFactory(metaData.getDefaultName(), metaData.getResource());
+         }
+
+         protected void doClose(ConfigurableBeanFactory beanFactory)
+         {
+            beanFactory.destroySingletons();
+         }
+      };
+   }
+
+   protected Class<ConfigurableBeanFactory> getExactBeanFactoryClass()
+   {
+      return ConfigurableBeanFactory.class;
+   }
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/SpringMetaData.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/SpringMetaData.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/SpringMetaData.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.deployers;
+
+import java.io.Serializable;
+import java.net.URL;
+
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * Spring meta data.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SpringMetaData implements Serializable
+{
+   private static final long serialVersionUID = 8989753488155849440L;
+
+   private URL fileURL;
+   private String defaultName;
+   private String name;
+   private transient Resource resource;
+
+   public SpringMetaData()
+   {
+   }
+
+   public SpringMetaData(URL fileURL, String defaultName)
+   {
+      this.fileURL = fileURL;
+      this.defaultName = defaultName;
+   }
+
+   public URL getFileURL()
+   {
+      return fileURL;
+   }
+
+   public void setFileURL(URL fileURL)
+   {
+      this.fileURL = fileURL;
+   }
+
+   public String getDefaultName()
+   {
+      return defaultName;
+   }
+
+   public String getName()
+   {
+      return name != null ? name : defaultName;
+   }
+
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   public Resource getResource()
+   {
+      if (resource == null)
+         resource = new UrlResource(fileURL);
+      return resource;
+   }
+
+   public String toString()
+   {
+      StringBuilder builder = new StringBuilder();
+      builder.append("fileURL=").append(fileURL);
+      builder.append(", defaultName=").append(defaultName);
+      return builder.toString();
+   }
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/SpringParserDeployer.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/SpringParserDeployer.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/deployers/SpringParserDeployer.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.deployers;
+
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Spring deployer.
+ * Picks up -spring.xml file.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SpringParserDeployer extends AbstractVFSParsingDeployer<SpringMetaData>
+{
+   private boolean useLegacyDefaultName;
+
+   public SpringParserDeployer()
+   {
+      super(SpringMetaData.class);
+      setSuffix("-spring.xml");
+      setJarExtension(".spring");
+      setUseLegacyDefaultName(false);
+   }
+
+   /**
+    * Get the use name flag.
+    *
+    * @return true if the default name should be determined from deployment unit
+    */
+   protected boolean isUseLegacyDefaultName()
+   {
+      return useLegacyDefaultName;
+   }
+
+   /**
+    * Should we use deployment unit's name as default.
+    * e.g. using string before .jar|spring|... as the name
+    *
+    * Previous versions used string before .spring as the name,
+    * setting this to true results in this legacy behaviour.
+    *
+    * Current default is string before -spring.xml.
+    *
+    * @param useLegacyDefaultName the flag
+    */
+   public void setUseLegacyDefaultName(boolean useLegacyDefaultName)
+   {
+      this.useLegacyDefaultName = useLegacyDefaultName;
+   }
+
+   /**
+    * Get default name from meta file.
+    *
+    * @param file the virtual file
+    * @return default name
+    */
+   protected String getDefaultName(VirtualFile file)
+   {
+      String shortName = file.getName();
+      int p = shortName.indexOf("-spring.xml");
+      return shortName.substring(0, p);
+   }
+
+   /**
+    * Get default name from unit.
+    *
+    * @param unit the deployment unit
+    * @return default name
+    */
+   protected String getDefaultName(VFSDeploymentUnit unit)
+   {
+      String shortName = unit.getSimpleName();
+      int p = shortName.lastIndexOf(".");
+      return shortName.substring(0, p);
+   }
+
+   protected SpringMetaData parse(VFSDeploymentUnit unit, VirtualFile file, SpringMetaData metaData) throws Exception
+   {
+      String defaultName;
+      if (isUseLegacyDefaultName())
+         defaultName = getDefaultName(unit);
+      else
+         defaultName = getDefaultName(file);
+
+      return new SpringMetaData(file.toURL(), defaultName);
+   }
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/Instantiable.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/Instantiable.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/Instantiable.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.factory;
+
+/**
+ * Instatiable.
+ * 
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+public interface Instantiable
+{
+   /**
+    * Do instantiate.
+    *
+    * @return true if instantiated.
+    */
+   boolean doInstantiate();
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/Nameable.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/Nameable.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/Nameable.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.factory;
+
+/**
+ * Nameable.
+ * 
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+public interface Nameable
+{
+   /**
+    * Get the name.
+    *
+    * @return the name
+    */
+   String getName();
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlApplicationContext.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlApplicationContext.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlApplicationContext.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.factory;
+
+import java.io.IOException;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.xml.ResourceEntityResolver;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.ResourcePatternResolver;
+import org.jboss.spring.vfs.VFSResourcePatternResolver;
+
+/**
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+public class NamedXmlApplicationContext extends ClassPathXmlApplicationContext implements Nameable
+{
+   private String defaultName;
+   private Resource resource;
+   private NamedXmlBeanDefinitionReader beanDefinitionReader;
+
+   public NamedXmlApplicationContext(String defaultName, Resource resource) throws BeansException
+   {
+      this(defaultName, resource, true);
+   }
+
+   public NamedXmlApplicationContext(String defaultName, Resource resource, boolean refresh) throws BeansException
+   {
+      //loading config from Resource
+      super(new String[]{}, false);
+      this.defaultName = defaultName;
+      this.resource = resource;
+      if (refresh)
+      {
+         refresh();
+      }
+   }
+
+   protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException
+   {
+      // Create a new XmlBeanDefinitionReader for the given BeanFactory.
+      beanDefinitionReader = new NamedXmlBeanDefinitionReader(beanFactory);
+
+      // Configure the bean definition reader with this context's
+      // resource loading environment.
+      beanDefinitionReader.setResourceLoader(this);
+      if (getClassLoader() != null)
+         beanDefinitionReader.setBeanClassLoader(getClassLoader());
+      beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
+
+      // Allow a subclass to provide custom initialization of the reader,
+      // then proceed with actually loading the bean definitions.
+      initBeanDefinitionReader(beanDefinitionReader);
+      loadBeanDefinitions(beanDefinitionReader);
+   }
+
+   protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws BeansException, IOException
+   {
+      reader.loadBeanDefinitions(resource);
+   }
+
+   public String getName()
+   {
+      String name = beanDefinitionReader.getName() != null ? beanDefinitionReader.getName() : defaultName;
+      if (name == null)
+         throw new IllegalArgumentException("Bean factory JNDI name must be set!");
+
+      return name;
+   }
+
+   protected ResourcePatternResolver getResourcePatternResolver()
+   {
+      return new VFSResourcePatternResolver(getClassLoader());
+   }
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlBeanDefinitionParser.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlBeanDefinitionParser.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlBeanDefinitionParser.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.factory;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.util.naming.Util;
+import org.jboss.logging.Logger;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
+import org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Named bean definition parser.
+ * 
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+public class NamedXmlBeanDefinitionParser extends DefaultBeanDefinitionDocumentReader implements Nameable, Instantiable
+{
+   protected static Logger log = Logger.getLogger(NamedXmlBeanDefinitionParser.class);
+
+   public static final String BEAN_FACTORY_ELEMENT = "BeanFactory=\\(([^)]+)\\)";
+   public static final String PARENT_BEAN_FACTORY_ELEMENT = "ParentBeanFactory=\\(([^)]+)\\)";
+   public static final String INSTANTIATION_ELEMENT = "Instantiate=\\(([^)]+)\\)";
+
+   private ConfigurableBeanFactory beanFactory;
+   private String beanFactoryName;
+   private boolean instantiate;
+
+   public NamedXmlBeanDefinitionParser(ConfigurableBeanFactory beanFactory)
+   {
+      this.beanFactory = beanFactory;
+   }
+
+   protected void preProcessXml(Element root) throws BeanDefinitionStoreException
+   {
+      NodeList nl = root.getChildNodes();
+      for (int i = 0; i < nl.getLength(); i++)
+      {
+         Node node = nl.item(i);
+         if (node instanceof Element)
+         {
+            Element ele = (Element) node;
+            if (BeanDefinitionParserDelegate.DESCRIPTION_ELEMENT.equals(node.getNodeName()))
+            {
+               String nodeValue = ele.getFirstChild().getNodeValue();
+               if (log.isTraceEnabled())
+                  log.trace("Bean names [description tag]: " + nodeValue);
+               Matcher bfm = parse(nodeValue, BEAN_FACTORY_ELEMENT);
+               if (bfm.find())
+               {
+                  beanFactoryName = bfm.group(1);
+               }
+               Matcher pbfm = parse(nodeValue, PARENT_BEAN_FACTORY_ELEMENT);
+               if (pbfm.find())
+               {
+                  String parentBeanFactoryName = pbfm.group(1);
+                  try
+                  {
+                     beanFactory.setParentBeanFactory((BeanFactory) Util.lookup(parentBeanFactoryName, BeanFactory.class));
+                  }
+                  catch (Exception e)
+                  {
+                     throw new BeanDefinitionStoreException("Failure during parent bean factory JNDI lookup: " + parentBeanFactoryName, e);
+                  }
+               }
+               Matcher inst = parse(nodeValue, INSTANTIATION_ELEMENT);
+               if (inst.find())
+               {
+                  instantiate = Boolean.parseBoolean(inst.group(1));
+               }
+            }
+         }
+      }
+   }
+
+   public String getName()
+   {
+      return beanFactoryName;
+   }
+
+   public boolean doInstantiate()
+   {
+      return instantiate;
+   }
+
+   private static Matcher parse(String value, String regexp)
+   {
+      Pattern pattern = Pattern.compile(regexp);
+      return pattern.matcher(value);
+   }
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlBeanDefinitionReader.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlBeanDefinitionReader.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlBeanDefinitionReader.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.factory;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.core.io.Resource;
+import org.w3c.dom.Document;
+
+/**
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+public class NamedXmlBeanDefinitionReader extends XmlBeanDefinitionReader implements Nameable, Instantiable
+{
+   private NamedXmlBeanDefinitionParser parser;
+
+   public NamedXmlBeanDefinitionReader(BeanDefinitionRegistry beanFactory)
+   {
+      super(beanFactory);
+      if (!(beanFactory instanceof ConfigurableBeanFactory))
+      {
+         throw new IllegalArgumentException("BeanFactory must implement ConfigurableBeanFactory!");
+      }
+      parser = new NamedXmlBeanDefinitionParser((ConfigurableBeanFactory) beanFactory);
+   }
+
+   public int registerBeanDefinitions(Document doc, Resource resource) throws BeansException
+   {
+      int countBefore = this.getBeanFactory().getBeanDefinitionCount();
+      parser.registerBeanDefinitions(doc, createReaderContext(resource));
+      return this.getBeanFactory().getBeanDefinitionCount() - countBefore;
+   }
+
+   public String getName()
+   {
+      return parser.getName();
+   }
+
+   public boolean doInstantiate()
+   {
+      return parser.doInstantiate();
+   }
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlBeanFactory.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlBeanFactory.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/factory/NamedXmlBeanFactory.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.factory;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.core.io.Resource;
+
+/**
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+public class NamedXmlBeanFactory extends DefaultListableBeanFactory implements Nameable, Instantiable
+{
+   private String defaultName;
+   private final NamedXmlBeanDefinitionReader reader = new NamedXmlBeanDefinitionReader(this);
+
+   /**
+    * @param defaultName the default name
+    * @param resource the resource
+    * @see org.springframework.beans.factory.xml.XmlBeanFactory
+    * @throws BeansException for any exception
+    */
+   public NamedXmlBeanFactory(String defaultName, Resource resource) throws BeansException
+   {
+      this.reader.loadBeanDefinitions(resource);
+      this.defaultName = defaultName;
+   }
+
+   public String getName()
+   {
+      String name = reader.getName() != null ? reader.getName() : defaultName;
+      if (name == null)
+      {
+         throw new IllegalArgumentException("Bean factory JNDI name must be set!");
+      }
+      return name;
+   }
+
+   public boolean doInstantiate()
+   {
+      return reader.doInstantiate();
+   }
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/interceptor/SpringInjectionInterceptor.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/interceptor/SpringInjectionInterceptor.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/interceptor/SpringInjectionInterceptor.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.interceptor;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.ConstructorInvocation;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.spring.support.SpringInjectionSupport;
+
+/**
+ * Injects Spring beans on ConstructorInterceptor invocation.
+ * Should be the last interceptor in chain since it actually constructs EJB object
+ * (in order to inject beans).
+ *
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ * @see SpringInjectionSupport
+ */
+public class SpringInjectionInterceptor extends SpringInjectionSupport implements Interceptor
+{
+   public SpringInjectionInterceptor()
+   {
+      log.info("Instantiating " + getName());
+   }
+
+   public String getName()
+   {
+      return "SpringInjectionInterceptor";
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      if (!(invocation instanceof ConstructorInvocation))
+      {
+         throw new IllegalArgumentException("This interceptor is meant to be applied" +
+               " only on new instantiation of @Spring annotated objects");
+      }
+      Object target = invocation.invokeNext();
+      inject(target);
+      return target;
+   }
+}

Added: projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/support/SpringInjectionSupport.java
===================================================================
--- projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/support/SpringInjectionSupport.java	                        (rev 0)
+++ projects/spring-int/trunk/deployers/src/main/java/org/jboss/spring/support/SpringInjectionSupport.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,268 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.support;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.*;
+
+import org.jboss.annotation.spring.Spring;
+import org.jboss.logging.Logger;
+import org.jboss.util.naming.Util;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.ListableBeanFactory;
+
+/**
+ * Injects objects from bean factory located in JNDI at jndiName gained
+ * from @Spring annotation's field jndiName.
+ * It is applied to setter methods and fields annotated with @Spring annotation.
+ *
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ * @see MethodComparator Excludes overridden @Spring annotated methods
+ *      Class type check is performed before actual setting.
+ */
+public abstract class SpringInjectionSupport
+{
+   protected Logger log = Logger.getLogger(getClass());
+   private final Comparator<Method> METHOD_COMPARATOR = new MethodComparator();
+
+   protected Object inject(Object target) throws Exception
+   {
+      log.debug("Invoking Spring injection: " + target.getClass().getName());
+
+      Method[] methods = getAllMethods(target);
+      for (Method m : methods)
+      {
+         Spring spring = m.getAnnotation(Spring.class);
+         if (spring != null)
+         {
+            if (isSetterMethod(m))
+            {
+               injectToMethod(target, m, spring);
+            }
+            else
+            {
+               log.warn("Spring annotation only allowed on setter methods.");
+            }
+         }
+      }
+
+      Field[] fields = getAllFields(target);
+      for (Field f : fields)
+      {
+         Spring spring = f.getAnnotation(Spring.class);
+         if (spring != null)
+         {
+            injectToField(target, f, spring);
+         }
+      }
+
+      return target;
+   }
+
+   protected Method[] getAllMethods(Object bean)
+   {
+      Class beanClass = bean.getClass();
+      Set<Method> methods = new TreeSet<Method>(METHOD_COMPARATOR);
+      while (beanClass != Object.class)
+      {
+         methods.addAll(Arrays.asList(beanClass.getDeclaredMethods()));
+         beanClass = beanClass.getSuperclass();
+      }
+      return methods.toArray(new Method[methods.size()]);
+   }
+
+   protected Field[] getAllFields(Object bean)
+   {
+      Class beanClass = bean.getClass();
+      List<Field> fields = new ArrayList<Field>();
+      while (beanClass != Object.class)
+      {
+         fields.addAll(Arrays.asList(beanClass.getDeclaredFields()));
+         beanClass = beanClass.getSuperclass();
+      }
+      return fields.toArray(new Field[fields.size()]);
+   }
+
+   private boolean isSetterMethod(Method m)
+   {
+      return m.getName().startsWith("set") && m.getParameterTypes().length == 1;
+   }
+
+   /**
+    * Get jndi name for bean factory.
+    * Simple check for null or empty string is applied.
+    * You can override this in subclasses for any extra
+    * jndi name handling.
+    *
+    * @param jndiName the current jndi name
+    * @return jndiName parameter
+    */
+   protected String getJndiName(String jndiName)
+   {
+      if (jndiName == null || jndiName.length() == 0)
+         throw new IllegalArgumentException("Empty BeanFactory jndi name.");
+      return jndiName;
+   }
+
+   private Object getObjectFromBeanFactory(Spring spring, String defaultBeanName, Class beanType) throws Exception
+   {
+      BeanFactory beanFactory = (BeanFactory) Util.lookup(getJndiName(spring.jndiName()), BeanFactory.class);
+      String beanName = spring.bean();
+      if (beanName != null && beanName.length() > 0)
+      {
+         return beanFactory.getBean(beanName, beanType);
+      }
+      else
+      {
+         // by type injection
+         if (beanFactory instanceof ListableBeanFactory)
+         {
+            ListableBeanFactory lbf = (ListableBeanFactory) beanFactory;
+            Map beans = lbf.getBeansOfType(beanType);
+            if (beans.size() > 1)
+            {
+               Object bean = beans.get(defaultBeanName);
+               if (bean == null)
+               {
+                  throw new IllegalArgumentException("More than one bean of type: " + beanType);
+               }
+               return bean;
+            }
+            else if (beans.size() == 1)
+            {
+               return beans.values().iterator().next();
+            }
+            else
+            {
+               throw new IllegalArgumentException("No such bean by type: " + beanType);
+            }
+         }
+         else
+         {
+            // bean factory is not listable - use default bean name
+            return beanFactory.getBean(defaultBeanName, beanType);
+         }
+      }
+   }
+
+   private void injectToMethod(Object target, Method method, Spring spring) throws Exception
+   {
+      String defaultBeanName = getDefaultBeanName(method);
+      Object bean = getObjectFromBeanFactory(spring, defaultBeanName, method.getParameterTypes()[0]);
+      logInjection(spring, bean, target, method);
+      method.setAccessible(true);
+      method.invoke(target, bean);
+   }
+
+   protected String getDefaultBeanName(Method method)
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append(method.getName().substring(3, 3).toLowerCase());
+      buffer.append(method.getName().substring(4));
+      return buffer.toString();
+   }
+
+   private void injectToField(Object target, Field field, Spring spring) throws Exception
+   {
+      String defaultBeanName = getDefaultBeanName(field);
+      Object bean = getObjectFromBeanFactory(spring, defaultBeanName, field.getType());
+      logInjection(spring, bean, target, field);
+      field.setAccessible(true);
+      field.set(target, bean);
+   }
+
+   protected String getDefaultBeanName(Field field)
+   {
+      return field.getName();
+   }
+
+   private void logInjection(Spring spring, Object bean, Object target, Member m)
+   {
+      log.debug("Injecting bean '" + spring.bean() + "' of class type " +
+            bean.getClass().getName() + " into " + target + " via " + m);
+   }
+
+   /**
+    * Equals on overridden methods.
+    * Any other solution?
+    */
+   private class MethodComparator implements Comparator<Method>
+   {
+
+      public int compare(Method m1, Method m2)
+      {
+         String name1 = m1.getName();
+         String name2 = m2.getName();
+
+         if (name1.equals(name2))
+         {
+            Class returnType1 = m1.getReturnType();
+            Class returnType2 = m2.getReturnType();
+            Class[] params1 = m1.getParameterTypes();
+            Class[] params2 = m1.getParameterTypes();
+            if (params1.length == params2.length)
+            {
+               if (returnType1.equals(returnType2))
+               {
+                  int i;
+                  int length = params1.length;
+                  for (i = 0; i < length; i++)
+                  {
+                     if (!params1[i].equals(params2[i]))
+                     {
+                        break;
+                     }
+                  }
+                  //not equal
+                  if (i < length)
+                  {
+                     return params1[i].getName().compareTo(params2[i].getName());
+                  }
+                  else
+                  {
+                     //overridden method
+                     if (m1.getAnnotation(Spring.class) != null)
+                     {
+                        log.warn("Found overridden @Spring annotated method: " + m1);
+                     }
+                     return 0;
+                  }
+               }
+               else
+               {
+                  return returnType1.getName().compareTo(returnType2.getName());
+               }
+            }
+            else
+            {
+               return params1.length - params2.length;
+            }
+         }
+         else
+         {
+            return name1.compareTo(name2);
+         }
+      }
+   }
+}

Added: projects/spring-int/trunk/facade/pom.xml
===================================================================
--- projects/spring-int/trunk/facade/pom.xml	                        (rev 0)
+++ projects/spring-int/trunk/facade/pom.xml	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,51 @@
+<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">
+  <parent>
+    <groupId>org.jboss.spring-int</groupId>
+    <artifactId>jboss-spring-int-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.jboss.spring-int</groupId>
+  <artifactId>jboss-spring-int-facade</artifactId>
+  <packaging>jar</packaging>
+  <name>JBoss Spring Integration - Facade</name>
+  <url>http://www.jboss.org/jbossmc</url>
+  <description>JBoss Spring Integration - Facade</description>
+
+  <dependencies>
+    <!-- Compile (global dependencies) -->
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-dependency</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-kernel</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-common-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aop</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-beans</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-core</artifactId>
+    </dependency>
+  </dependencies>
+  
+</project>
\ No newline at end of file

Added: projects/spring-int/trunk/facade/src/main/java/org/jboss/spring/facade/ControllerBeanFactory.java
===================================================================
--- projects/spring-int/trunk/facade/src/main/java/org/jboss/spring/facade/ControllerBeanFactory.java	                        (rev 0)
+++ projects/spring-int/trunk/facade/src/main/java/org/jboss/spring/facade/ControllerBeanFactory.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,289 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.facade;
+
+import java.util.Set;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.ConstructorMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.beans.metadata.spi.factory.AbstractBeanFactory;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.TypeInfoFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+
+/**
+ * BeanFactory facade over MC's Controller.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ControllerBeanFactory implements BeanFactory
+{
+   private Controller controller;
+
+   public ControllerBeanFactory(Controller controller)
+   {
+      if (controller == null)
+         throw new IllegalArgumentException("Null controller");
+
+      this.controller = controller;
+   }
+
+   /**
+    * Get the controller context.
+    *
+    * @param name the context name
+    * @return context or null if not found
+    */
+   protected ControllerContext getInstalledContext(String name)
+   {
+      return controller.getInstalledContext(name);
+   }
+
+   /**
+    * Get the controller context.
+    *
+    * @param name  the context name
+    * @param state the state
+    * @return context or null if not found
+    */
+   protected ControllerContext getContext(String name, ControllerState state)
+   {
+      return controller.getContext(name, state);
+   }
+
+   public Object getBean(String name) throws BeansException
+   {
+      ControllerContext context = getInstalledContext(name);
+      if (context == null)
+         throw new NoSuchBeanDefinitionException(name);
+
+      return context.getTarget();
+   }
+
+   @SuppressWarnings("unchecked")
+   public Object getBean(String name, Class clazz) throws BeansException
+   {
+      return getExactBean(name, clazz);
+   }
+
+   /**
+    * Get exact bean.
+    *
+    * @param name the bean name
+    * @param clazz the expected class
+    * @param <T> the exact type
+    * @return exact bean
+    * @throws BeansException for any error
+    */
+   protected <T> T getExactBean(String name, Class<T> clazz) throws BeansException
+   {
+      Object result = getBean(name);
+      if (clazz.isInstance(result) == false)
+         throw new BeanNotOfRequiredTypeException(name, clazz, result.getClass());
+
+      return clazz.cast(result);
+   }
+
+   @SuppressWarnings({"SynchronizationOnLocalVariableOrMethodParameter"})
+   public Object getBean(String name, Object[] parameters) throws BeansException
+   {
+      AbstractBeanFactory result = getExactBean(name, AbstractBeanFactory.class);
+      ConstructorMetaData cmd = result.getConstructor();
+
+      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("Temp");
+      for (Object parameter : parameters )
+         builder.addConstructorParameter(null, parameter);
+      ConstructorMetaData tempCMD = builder.getBeanMetaData().getConstructor();
+
+      synchronized (result)
+      {
+         result.setConstructor(tempCMD);
+         try
+         {
+            return createBean(result);
+         }
+         finally
+         {
+            result.setConstructor(cmd);
+         }
+      }
+   }
+
+   public boolean containsBean(String name)
+   {
+      return getInstalledContext(name) != null;
+   }
+
+   public boolean isSingleton(String name) throws NoSuchBeanDefinitionException
+   {
+      return isPrototype(name) == false;
+   }
+
+   public boolean isPrototype(String name) throws NoSuchBeanDefinitionException
+   {
+      Object result = getBean(name);
+      return isPrototype(result);
+   }
+
+   /**
+    * Is the result prototype.
+    *
+    * @param result the result
+    * @return true if prototyle, false otherwise
+    */
+   protected boolean isPrototype(Object result)
+   {
+      return org.jboss.beans.metadata.spi.factory.BeanFactory.class.isInstance(result);
+   }
+
+   /**
+    * Create the bean.
+    *
+    * @param factory the bean factory
+    * @return new bean instance
+    * @throws BeansException for any error
+    */
+   protected Object createBean(Object factory) throws BeansException
+   {
+      try
+      {
+         return org.jboss.beans.metadata.spi.factory.BeanFactory.class.cast(factory).createBean();
+      }
+      catch (Throwable t)
+      {
+         throw new FatalBeanException("Cannot create bean: " + factory, t);
+      }
+   }
+
+   public boolean isTypeMatch(String name, Class clazz) throws NoSuchBeanDefinitionException
+   {
+      return clazz.isInstance(getBean(name));
+   }
+
+   @SuppressWarnings("deprecation")
+   public Class getType(String name) throws NoSuchBeanDefinitionException
+   {
+      ControllerContext context = getContext(name, ControllerState.DESCRIBED);
+      if (context == null)
+         throw new NoSuchBeanDefinitionException(name);
+
+      if (context instanceof KernelControllerContext)
+      {
+         KernelControllerContext kcc = (KernelControllerContext)context;
+         BeanInfo beanInfo = kcc.getBeanInfo();
+         ClassInfo classInfo = beanInfo.getClassInfo();
+         TypeInfoFactory tif = classInfo.getTypeInfoFactory();
+         // it's a bean factory
+         if (tif.getTypeInfo(AbstractBeanFactory.class).isAssignableFrom(classInfo))
+         {
+            return getPrototypeClass(kcc);
+         }
+         else
+         {
+            return classInfo.getType();
+         }
+      }
+      return null;
+   }
+
+   /**
+    * Get prototype class.
+    *
+    * @param kcc the kernel controller context
+    * @return prototype's class
+    */
+   protected Class<?> getPrototypeClass(KernelControllerContext kcc)
+   {
+      BeanMetaData bmd = kcc.getBeanMetaData();
+      Set<PropertyMetaData> properties = bmd.getProperties();
+      for (PropertyMetaData pmd : properties)
+      {
+         if ("bean".equals(pmd.getName()))
+         {
+            ValueMetaData value = pmd.getValue();
+            if (value != null && value.getUnderlyingValue() != null)
+            {
+               String className = value.getUnderlyingValue().toString();
+               return getBeanClass(className, kcc);
+            }
+            else
+            {
+               return null;
+            }
+         }
+      }
+      return null;
+   }
+
+   /**
+    * Get the bean class.
+    *
+    * @param className the class name
+    * @param context the context
+    * @return bean's class
+    * @throws BeansException for any error
+    */
+   protected Class<?> getBeanClass(String className, KernelControllerContext context) throws BeansException
+   {
+      try
+      {
+         ClassLoader cl = context.getClassLoader();
+         return cl.loadClass(className);
+      }
+      catch (Throwable t)
+      {
+         throw new FatalBeanException("Cannot load class: " + className + ", context: " + context, t);
+      }
+   }
+
+   public String[] getAliases(String name)
+   {
+      ControllerContext context = getContext(name, null);
+      if (context == null || context.getAliases() == null)
+      {
+         return new String[]{};
+      }
+      else
+      {
+         Set<Object> aliases = context.getAliases();
+         String[] result = new String[aliases.size()];
+         int i = 0;
+         for (Object alias : aliases)
+         {
+            result[i++] = alias.toString();
+         }
+         return result;
+      }
+   }
+}

Added: projects/spring-int/trunk/facade/src/main/java/org/jboss/spring/facade/KernelControllerListableBeanFactory.java
===================================================================
--- projects/spring-int/trunk/facade/src/main/java/org/jboss/spring/facade/KernelControllerListableBeanFactory.java	                        (rev 0)
+++ projects/spring-int/trunk/facade/src/main/java/org/jboss/spring/facade/KernelControllerListableBeanFactory.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.facade;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.beans.metadata.spi.factory.AbstractBeanFactory;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.ControllerStateModel;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.ListableBeanFactory;
+
+/**
+ * ListableBeanFactory facade over MC's KernelController.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class KernelControllerListableBeanFactory extends ControllerBeanFactory implements ListableBeanFactory
+{
+   private KernelController kernelController;
+
+   public KernelControllerListableBeanFactory(KernelController kernelController)
+   {
+      super(kernelController);
+      this.kernelController = kernelController;
+   }
+
+   public KernelControllerListableBeanFactory(Kernel kernel)
+   {
+      super(kernel != null ? kernel.getController() : null);
+      this.kernelController = kernel.getController();
+   }
+
+   public boolean containsBeanDefinition(String name)
+   {
+      return getContext(name, null) != null;
+   }
+
+   public int getBeanDefinitionCount()
+   {
+      int count = 0;
+      ControllerStateModel stateModel = kernelController.getStates();
+      for (ControllerState state : stateModel)
+      {
+         Set<ControllerContext> byState = kernelController.getContextsByState(state);
+         count += byState.size();
+      }
+      return count;
+   }
+
+   public String[] getBeanDefinitionNames()
+   {
+      List<String> result = new ArrayList<String>();
+      ControllerStateModel stateModel = kernelController.getStates();
+      for (ControllerState state : stateModel)
+      {
+         Set<ControllerContext> byState = kernelController.getContextsByState(state);
+         for (ControllerContext context : byState)
+            result.add(context.getName().toString());
+      }
+      return result.toArray(new String[result.size()]);
+   }
+
+   public String[] getBeanNamesForType(Class clazz)
+   {
+      return getBeanNamesForType(clazz, true, true);
+   }
+
+   public String[] getBeanNamesForType(Class clazz, boolean includePrototypes, boolean allowEagerInit)
+   {
+      List<String> result = new ArrayList<String>();
+      Set<KernelControllerContext> contexts = kernelController.getInstantiatedContexts(clazz);
+      if (contexts != null && contexts.isEmpty() == false)
+      {
+         for (KernelControllerContext context : contexts)
+         {
+            result.add(context.getName().toString());
+         }
+      }
+      if (includePrototypes)
+      {
+         Set<KernelControllerContext> factories = kernelController.getInstantiatedContexts(AbstractBeanFactory.class);
+         if (factories != null && factories.isEmpty() == false)
+         {
+            for (KernelControllerContext kcc : factories)
+            {
+               Class<?> prototypeClass = getPrototypeClass(kcc);
+               if (prototypeClass != null)
+               {
+                  if (clazz.isAssignableFrom(prototypeClass))
+                     result.add(kcc.getName().toString());
+               }
+               else if (allowEagerInit)
+               {
+                  Object bean = createBean(kcc.getTarget());
+                  if (clazz.isInstance(bean))
+                     result.add(kcc.getName().toString());
+               }
+            }
+         }
+      }
+      return result.toArray(new String[result.size()]);
+   }
+
+   public Map getBeansOfType(Class clazz) throws BeansException
+   {
+      return getBeansOfType(clazz, true, true);
+   }
+
+   public Map getBeansOfType(Class clazz, boolean includePrototypes, boolean allowEagerInit) throws BeansException
+   {
+      Map<String, Object> result = new HashMap<String, Object>();
+      Set<KernelControllerContext> contexts = kernelController.getContexts(clazz, ControllerState.INSTALLED);
+      for (KernelControllerContext context : contexts)
+      {
+         Object target = context.getTarget();
+         result.put(context.getName().toString(), target);
+      }
+      if (includePrototypes)
+      {
+         Set<KernelControllerContext> factories = kernelController.getInstantiatedContexts(AbstractBeanFactory.class);
+         if (factories != null && factories.isEmpty() == false)
+         {
+            for (KernelControllerContext kcc : factories)
+            {
+               Class<?> prototypeClass = getPrototypeClass(kcc);
+               if (prototypeClass != null)
+               {
+                  if (clazz.isAssignableFrom(prototypeClass))
+                     result.put(kcc.getName().toString(), createBean(kcc.getTarget()));
+               }
+               else if (allowEagerInit)
+               {
+                  Object bean = createBean(kcc.getTarget());
+                  if (clazz.isInstance(bean))
+                     result.put(kcc.getName().toString(), bean);
+               }
+            }
+         }
+      }
+      return result;
+   }
+}
\ No newline at end of file

Added: projects/spring-int/trunk/pom.xml
===================================================================
--- projects/spring-int/trunk/pom.xml	                        (rev 0)
+++ projects/spring-int/trunk/pom.xml	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,402 @@
+<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>
+  <parent>
+    <groupId>org.jboss</groupId>
+    <artifactId>jboss-parent</artifactId>
+    <version>4</version>
+  </parent>
+  <groupId>org.jboss.spring-int</groupId>
+  <artifactId>jboss-spring-int-parent</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+  <name>JBoss Spring Integration Parent POM</name>
+  <url>http://www.jboss.com/products/jbossmc</url>
+  <description>JBoss Spring integration</description>
+  <scm>
+    <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/spring-int/trunk</connection>
+    <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/spring-int/trunk</developerConnection>
+    <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/spring-int/trunk</url>
+  </scm>
+
+  <modules>
+    <module>cluster</module>
+    <module>deployers</module>
+    <module>facade</module>
+    <module>vfs</module>
+    <module>build</module>
+  </modules>
+  
+  <properties>
+    <version.jboss.vfs>2.1.0.GA</version.jboss.vfs>
+    <version.jboss.man>2.0.0.GA</version.jboss.man>
+    <version.jboss.mdr>2.0.1.GA</version.jboss.mdr>
+    <version.jboss.microcontainer>2.0.4.GA</version.jboss.microcontainer>
+    <version.jboss.deployers>2.0.5.GA</version.jboss.deployers>
+    <version.jboss.classloader>2.0.4.GA</version.jboss.classloader>
+    <version.jboss.common.core>2.2.11.GA</version.jboss.common.core>
+    <version.jboss.common.logging.spi>2.0.5.GA</version.jboss.common.logging.spi>
+    <version.jboss.common.logging.log4j>2.0.5.GA</version.jboss.common.logging.log4j>
+    <version.jbossxb>2.0.0.GA</version.jbossxb>
+    <version.jboss.aop>2.0.1.GA</version.jboss.aop>
+    <version.jboss.pojocache>3.0.0.GA</version.jboss.pojocache>
+    <version.org.jboss.test>1.0.5.GA</version.org.jboss.test>
+    <version.junit>4.4</version.junit>
+    <version.javassist>3.9.0.GA</version.javassist>
+    <version.javaee>3.0.0.GA</version.javaee>
+    <version.xerces>2.9.1</version.xerces>
+    <version.aopalliance>1.0</version.aopalliance>
+    <version.spring>2.5.6</version.spring>
+  </properties>
+
+  <build>
+    <outputDirectory>${microcontainer.outputDirectory}</outputDirectory>
+    <testOutputDirectory>${microcontainer.testOutputDirectory}</testOutputDirectory>
+    <finalName>${artifactId}</finalName>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+          <showDeprecation>true</showDeprecation>
+          <showWarnings>true</showWarnings>
+          <optimize>true</optimize>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-release-plugin</artifactId>
+        <version>2.0-beta-7</version>
+        <configuration>
+          <generateReleasePoms>false</generateReleasePoms>
+          <tagBase>https://svn.jboss.org/repos/jbossas/projects/spring-int/tags</tagBase>
+          <autoVersionSubmodules>true</autoVersionSubmodules>
+        </configuration>
+      </plugin>
+    </plugins>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-assembly-plugin</artifactId>
+          <executions>
+            <execution>
+              <id>make-assembly</id>
+              <phase>package</phase>
+              <goals>
+                <goal>attached</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
+        <plugin>
+          <artifactId>maven-idea-plugin</artifactId>
+          <configuration>
+            <downloadSources>true</downloadSources>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-jar-plugin</artifactId>
+          <version>2.2</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>2.4.1</version>
+          <configuration>
+            <redirectTestOutputToFile>true</redirectTestOutputToFile>
+            <includes>
+              <include>org/jboss/test/**/*TestCase.java</include>
+            </includes>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+  
+  <repositories>
+    <repository>
+      <id>repository.jboss.org</id>
+      <name>JBoss Repository</name>
+      <layout>default</layout>
+      <url>http://repository.jboss.org/maven2/</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+    <repository>
+      <id>snapshots.jboss.org</id>
+      <name>JBoss Snapshots Repository</name>
+      <layout>default</layout>
+      <url>http://snapshots.jboss.org/maven2/</url>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+      <releases>
+        <enabled>false</enabled>
+      </releases>
+    </repository>
+  </repositories>
+  
+  <dependencyManagement>
+    <!-- The parent pom manages the inter-dependencies of the modules. -->
+    <dependencies>
+
+      <dependency>
+        <groupId>org.jboss.spring-int</groupId>
+        <artifactId>jboss-spring-int-cluster</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.spring-int</groupId>
+        <artifactId>jboss-spring-int-deployers</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.spring-int</groupId>
+        <artifactId>jboss-spring-int-facade</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.spring-int</groupId>
+        <artifactId>jboss-spring-int-vfs</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.microcontainer</groupId>
+        <artifactId>jboss-dependency</artifactId>
+        <version>${version.jboss.microcontainer}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.microcontainer</groupId>
+        <artifactId>jboss-kernel</artifactId>
+        <version>${version.jboss.microcontainer}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.microcontainer</groupId>
+        <artifactId>jboss-aop-mc-int</artifactId>
+        <version>${version.jboss.microcontainer}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.microcontainer</groupId>
+        <artifactId>jboss-spring-int</artifactId>
+        <version>${version.jboss.microcontainer}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.microcontainer</groupId>
+        <artifactId>jboss-guice-int</artifactId>
+        <version>${version.jboss.microcontainer}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-client</artifactId>
+        <version>${version.jboss.deployers}</version>
+      </dependency>      
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-client-spi</artifactId>
+        <version>${version.jboss.deployers}</version>
+      </dependency>      
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-core-spi</artifactId>
+        <version>${version.jboss.deployers}</version>
+      </dependency>      
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-impl</artifactId>
+        <version>${version.jboss.deployers}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.jboss</groupId>
+            <artifactId>javassist</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>      
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-spi</artifactId>
+        <version>${version.jboss.deployers}</version>
+      </dependency>      
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-structure-spi</artifactId>
+        <version>${version.jboss.deployers}</version>
+      </dependency>      
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-vfs</artifactId>
+        <version>${version.jboss.deployers}</version>
+      </dependency>      
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-vfs-spi</artifactId>
+        <version>${version.jboss.deployers}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.cl</groupId>
+        <artifactId>jboss-classloader</artifactId>
+        <version>${version.jboss.classloader}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.cl</groupId>
+        <artifactId>jboss-classloading</artifactId>
+        <version>${version.jboss.classloader}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.cl</groupId>
+        <artifactId>jboss-classloading-vfs</artifactId>
+        <version>${version.jboss.classloader}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.man</groupId>
+        <artifactId>jboss-managed</artifactId>
+        <version>${version.jboss.man}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.man</groupId>
+        <artifactId>jboss-metatype</artifactId>
+        <version>${version.jboss.man}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss</groupId>
+        <artifactId>jboss-mdr</artifactId>
+        <version>${version.jboss.mdr}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss</groupId>
+        <artifactId>jboss-common-core</artifactId>
+        <version>${version.jboss.common.core}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.logging</groupId>
+        <artifactId>jboss-logging-spi</artifactId>
+        <version>${version.jboss.common.logging.spi}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.logging</groupId>
+        <artifactId>jboss-logging-log4j</artifactId>
+        <version>${version.jboss.common.logging.log4j}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss</groupId>
+        <artifactId>jbossxb</artifactId>
+        <version>${version.jbossxb}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss</groupId>
+        <artifactId>jboss-vfs</artifactId>
+        <version>${version.jboss.vfs}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.aop</groupId>
+        <artifactId>jboss-aop</artifactId>
+        <version>${version.jboss.aop}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss</groupId>
+        <artifactId>javassist</artifactId>
+        <version>${version.javassist}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.javaee</groupId>
+        <artifactId>jboss-ejb-api</artifactId>
+        <version>${version.javaee}</version>
+      </dependency>
+      <dependency>
+        <groupId>apache-xerces</groupId>
+        <artifactId>xml-apis</artifactId>
+        <version>${version.xerces}</version>
+      </dependency>
+      <dependency>
+        <groupId>aopalliance</groupId>
+        <artifactId>aopalliance</artifactId>
+        <version>${version.aopalliance}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-beans</artifactId>
+        <version>${version.spring}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-core</artifactId>
+        <version>${version.spring}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-context</artifactId>
+        <version>${version.spring}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-aop</artifactId>
+        <version>${version.spring}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.cache</groupId>
+        <artifactId>jbosscache-pojo</artifactId>
+        <version>${version.jboss.pojocache}</version>
+      </dependency>
+      <!-- test dependencies -->
+      <dependency>
+        <groupId>org.jboss</groupId>
+        <artifactId>jboss-test</artifactId>
+        <version>${version.org.jboss.test}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>${version.junit}</version>
+        <scope>test</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <profiles>
+    <profile>
+      <id>default</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <properties>
+        <microcontainer.outputDirectory>target/classes</microcontainer.outputDirectory>
+        <microcontainer.testOutputDirectory>target/test-classes</microcontainer.testOutputDirectory>
+      </properties>
+    </profile>
+    <profile>
+      <id>eclipse</id>
+      <build>
+        <defaultGoal>process-test-resources</defaultGoal>
+        <plugins>
+          <plugin>
+            <artifactId>maven-eclipse-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>eclipse</id>
+                <phase>process-test-resources</phase>
+                <goals>
+                  <goal>eclipse</goal>
+                </goals>
+              </execution>
+            </executions>
+            <configuration>
+              <downloadSources>true</downloadSources>
+              <buildOutputDirectory>${microcontainer.outputDirectory}</buildOutputDirectory>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+      <properties>
+        <microcontainer.outputDirectory>eclipse-target/classes</microcontainer.outputDirectory>
+        <microcontainer.testOutputDirectory>eclipse-target/test-classes</microcontainer.testOutputDirectory>
+      </properties>
+    </profile>
+  </profiles>
+
+</project>
\ No newline at end of file

Added: projects/spring-int/trunk/vfs/pom.xml
===================================================================
--- projects/spring-int/trunk/vfs/pom.xml	                        (rev 0)
+++ projects/spring-int/trunk/vfs/pom.xml	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,35 @@
+<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">
+  <parent>
+    <groupId>org.jboss.spring-int</groupId>
+    <artifactId>jboss-spring-int-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.jboss.spring-int</groupId>
+  <artifactId>jboss-spring-int-vfs</artifactId>
+  <packaging>jar</packaging>
+  <name>JBoss Spring Integration - VFS</name>
+  <url>http://www.jboss.org/jbossmc</url>
+  <description>JBoss Spring Integration - VFS</description>
+
+  <dependencies>
+    <!-- Compile (global dependencies) -->
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-vfs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-common-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-core</artifactId>
+    </dependency>
+  </dependencies>
+  
+</project>
\ No newline at end of file

Added: projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResource.java
===================================================================
--- projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResource.java	                        (rev 0)
+++ projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResource.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,163 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.vfs;
+
+import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.io.IOException;
+import java.io.File;
+import java.io.InputStream;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VFSUtils;
+import org.springframework.core.io.Resource;
+
+/**
+ * VFS based Resource.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class VFSResource implements Resource
+{
+   private VirtualFile file;
+
+   public VFSResource(VirtualFile file)
+   {
+      if (file == null)
+         throw new IllegalArgumentException("Null file");
+      this.file = file;
+   }
+
+   public boolean exists()
+   {
+      try
+      {
+         return file.exists();
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public boolean isOpen()
+   {
+      return false;
+   }
+
+   public boolean isReadable()
+   {
+      try
+      {
+         return file.getSize() > 0;
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public long lastModified()
+   {
+      try
+      {
+         return file.getLastModified();
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public URL getURL() throws IOException
+   {
+      try
+      {
+         return file.toURL();
+      }
+      catch (URISyntaxException e)
+      {
+         IOException ioe = new IOException(e.getMessage());
+         ioe.initCause(e);
+         throw ioe;
+      }
+   }
+
+   public URI getURI() throws IOException
+   {
+      try
+      {
+         return file.toURI();
+      }
+      catch (URISyntaxException e)
+      {
+         IOException ioe = new IOException(e.getMessage());
+         ioe.initCause(e);
+         throw ioe;
+      }
+   }
+
+   public File getFile() throws IOException
+   {
+      try
+      {
+         return new File(VFSUtils.getCompatibleURI(file));
+      }
+      catch (IOException e)
+      {
+         throw e;
+      }
+      catch (Exception e)
+      {
+         IOException ioe = new IOException(e.getMessage());
+         ioe.initCause(e);
+         throw ioe;
+      }
+   }
+
+   @SuppressWarnings("deprecation")
+   public Resource createRelative(String relativePath) throws IOException
+   {
+      return new VFSResource(file.findChild(relativePath));
+   }
+
+   public String getFilename()
+   {
+      return file.getName();
+   }
+
+   public String getDescription()
+   {
+      return file.toString();
+   }
+
+   public InputStream getInputStream() throws IOException
+   {
+      return file.openStream();
+   }
+
+   public String toString()
+   {
+      return getDescription();
+   }
+}

Added: projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResourceLoader.java
===================================================================
--- projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResourceLoader.java	                        (rev 0)
+++ projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResourceLoader.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.vfs;
+
+import java.net.URL;
+
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.DefaultResourceLoader;
+import org.springframework.core.io.Resource;
+import org.springframework.util.Assert;
+
+/**
+ * VFS based ResourceLoader.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class VFSResourceLoader extends DefaultResourceLoader
+{
+   public VFSResourceLoader()
+   {
+   }
+
+   public VFSResourceLoader(ClassLoader classLoader)
+   {
+      super(classLoader);
+   }
+
+   public Resource getResource(String location)
+   {
+      Assert.notNull(location, "Location must not be null");
+      if (location.startsWith(CLASSPATH_URL_PREFIX))
+      {
+         return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX.length()), getClassLoader());
+      }
+      else
+      {
+         try
+         {
+            // Try to parse the location as a URL...
+            URL url = new URL(location);
+            VirtualFile file = VFS.getRoot(url);
+            return new VFSResource(file);
+         }
+         catch (Exception ex)
+         {
+            // No URL -> resolve as resource path.
+            return getResourceByPath(location);
+         }
+      }
+   }
+}
\ No newline at end of file

Added: projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResourcePatternResolver.java
===================================================================
--- projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResourcePatternResolver.java	                        (rev 0)
+++ projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResourcePatternResolver.java	2009-03-17 13:29:32 UTC (rev 85983)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.spring.vfs;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Enumeration;
+
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileVisitor;
+import org.jboss.virtual.VisitorAttributes;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+
+/**
+ * VFS based ResourcePatternResolver.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class VFSResourcePatternResolver extends PathMatchingResourcePatternResolver
+{
+   private Logger log = Logger.getLogger(VFSResourcePatternResolver.class);
+
+   public VFSResourcePatternResolver()
+   {
+      super(new VFSResourceLoader());
+   }
+
+   public VFSResourcePatternResolver(ClassLoader classLoader)
+   {
+      super(new VFSResourceLoader(classLoader));
+   }
+
+   protected Resource[] findPathMatchingResources(String locationPattern) throws IOException
+   {
+      if (locationPattern.startsWith(CLASSPATH_ALL_URL_PREFIX))
+         locationPattern = locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length());
+
+      String rootDirPath = determineRootDir(locationPattern);
+      String subPattern = locationPattern.substring(rootDirPath.length());
+      if (rootDirPath.startsWith("/"))
+         rootDirPath = rootDirPath.substring(1);
+
+      List<Resource> resources = new ArrayList<Resource>();
+      Enumeration<URL> urls = getClassLoader().getResources(rootDirPath);
+      while(urls.hasMoreElements())
+         resources.addAll(getVFSResources(urls.nextElement(), subPattern));
+
+      return resources.toArray(new Resource[resources.size()]);
+   }
+
+   /**
+    * Get VFS resources.
+    *
+    * @param rootURL the root URL
+    * @param subPattern the sub pattern
+    * @return vfs resources list
+    * @throws IOException for any error
+    */
+   protected List<Resource> getVFSResources(URL rootURL, String subPattern) throws IOException
+   {
+      log.debug("Scanning url: " + rootURL + ", sub-pattern: " + subPattern);
+      VirtualFile root = VFS.getRoot(rootURL);
+      PatternVirtualFileVisitor visitor = new PatternVirtualFileVisitor(subPattern);
+      root.visit(visitor);
+      if (log.isTraceEnabled())
+         log.trace("Found resources: " + visitor);
+      return visitor.getResources();
+   }
+
+   protected Resource convertClassLoaderURL(URL url)
+   {
+      try
+      {
+         VirtualFile file = VFS.getRoot(url);
+         return new VFSResource(file);
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   /**
+    * Get visitor attributes.
+    * Allows for override, if necessary.
+    *
+    * @return  visitor attributes
+    */
+   protected VisitorAttributes getVisitorAttributes()
+   {
+      return VisitorAttributes.RECURSE_LEAVES_ONLY;
+   }
+
+   private class PatternVirtualFileVisitor implements VirtualFileVisitor
+   {
+      private String subPattern;
+      private List<Resource> resources = new ArrayList<Resource>();
+
+      private PatternVirtualFileVisitor(String subPattern)
+      {
+         this.subPattern = subPattern;
+      }
+
+      public VisitorAttributes getAttributes()
+      {
+         return getVisitorAttributes();
+      }
+
+      public void visit(VirtualFile vf)
+      {
+         if (getPathMatcher().match(subPattern, vf.getPathName()))
+            resources.add(new VFSResource(vf));
+      }
+
+      public List<Resource> getResources()
+      {
+         return resources;
+      }
+
+      public int size()
+      {
+         return resources.size();
+      }
+
+      public String toString()
+      {
+         StringBuffer buffer = new StringBuffer();
+         buffer.append("sub-pattern: ").append(subPattern);
+         buffer.append(", resources: ").append(resources);
+         return buffer.toString();
+      }
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list