[jboss-cvs] JBossAS SVN: r68321 - in trunk/spring-int: src/main/org/jboss/annotation/spring and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Dec 16 15:06:51 EST 2007
Author: alesj
Date: 2007-12-16 15:06:51 -0500 (Sun, 16 Dec 2007)
New Revision: 68321
Added:
trunk/spring-int/src/main/org/jboss/spring/deployers/
trunk/spring-int/src/main/org/jboss/spring/deployers/AbstractSpringMetaDataDeployer.java
trunk/spring-int/src/main/org/jboss/spring/deployers/ApplicationContextDeployer.java
trunk/spring-int/src/main/org/jboss/spring/deployers/BeanFactoryDeployer.java
trunk/spring-int/src/main/org/jboss/spring/deployers/SpringMetaData.java
trunk/spring-int/src/main/org/jboss/spring/deployers/SpringParserDeployer.java
trunk/spring-int/src/main/org/jboss/spring/loader/
trunk/spring-int/src/main/org/jboss/spring/loader/AbstractBeanFactoryLoader.java
trunk/spring-int/src/main/org/jboss/spring/loader/ApplicationContextLoaderImpl.java
trunk/spring-int/src/main/org/jboss/spring/loader/BeanFactoryLoader.java
trunk/spring-int/src/main/org/jboss/spring/loader/BeanFactoryLoaderImpl.java
trunk/spring-int/src/resources/spring-deployers-beans.xml
Removed:
trunk/spring-int/src/main/org/jboss/spring/factory/AbstractBeanFactoryLoader.java
trunk/spring-int/src/main/org/jboss/spring/factory/ApplicationContextLoaderImpl.java
trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoader.java
trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoaderImpl.java
Modified:
trunk/spring-int/build.xml
trunk/spring-int/src/main/org/jboss/annotation/spring/Spring.java
trunk/spring-int/src/main/org/jboss/spring/callback/SpringLifecycleInterceptor.java
trunk/spring-int/src/main/org/jboss/spring/callback/SpringPassivationInterceptor.java
trunk/spring-int/src/main/org/jboss/spring/deployment/SpringApplicationContextDeployer.java
trunk/spring-int/src/main/org/jboss/spring/deployment/SpringBeanFactoryDeployer.java
trunk/spring-int/src/main/org/jboss/spring/deployment/SpringDeployer.java
trunk/spring-int/src/main/org/jboss/spring/factory/Instantiable.java
trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanDefinitionParser.java
trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanFactory.java
trunk/spring-int/src/main/org/jboss/spring/interceptor/SpringInjectionInterceptor.java
trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerLoaderImpl.java
trunk/spring-int/src/main/org/jboss/spring/kernel/SpringMicrocontainerDeployer.java
trunk/spring-int/src/main/org/jboss/spring/support/SpringInjectionSupport.java
Log:
SpringDeployer re-written to the new Deployers architecture.
Fixed coding standards.
Tests still a TODO.
Modified: trunk/spring-int/build.xml
===================================================================
--- trunk/spring-int/build.xml 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/build.xml 2007-12-16 20:06:51 UTC (rev 68321)
@@ -92,13 +92,14 @@
<path id="dependentmodule.classpath">
<path refid="jboss.aop.classpath"/>
<path refid="jboss.common.classpath"/>
- <path refid="jboss.dependency.classpath"/>
- <path refid="jboss.ejb3x.classpath"/>
+ <path refid="jboss.jboss.ejb3.ext.api.classpath" />
<path refid="jboss.j2se.classpath"/>
- <path refid="jboss.kernel.classpath"/>
<path refid="jboss.server.classpath"/>
<path refid="jboss.system.classpath"/>
<path refid="jboss.systemjmx.classpath"/>
+ <path refid="jboss.microcontainer.classpath"/>
+ <path refid="jboss.jboss.vfs.classpath"/>
+ <path refid="jboss.jboss.javaee.classpath"/>
</path>
<!-- Where source files live -->
@@ -163,8 +164,12 @@
<!-- Generate a jar containing all the compiled sources -->
<jar destfile="${build.lib}/${module.name}.jar">
<fileset dir="${build.classes}">
- <include name="org/jboss/spring/deployment/**"/>
+ <include name="org/jboss/annotation/spring/**"/>
+ <include name="org/jboss/spring/callback/**"/>
+ <include name="org/jboss/spring/deployers/**"/>
<include name="org/jboss/spring/factory/**"/>
+ <include name="org/jboss/spring/interceptor/**"/>
+ <include name="org/jboss/spring/support/**"/>
</fileset>
</jar>
@@ -178,32 +183,10 @@
<exclude name="spring-web.jar"/>
<exclude name="spring-webmvc.jar"/>
</fileset>
- <metainf dir="${build.resources}" includes="*.xml"/>
+ <metainf dir="${build.resources}" includes="*-beans.xml"/>
</jar>
</target>
- <target name="build-spring-jars-jdk5" depends="init, compile-jdk5" unless="NO_JDK_5">
- <mkdir dir="${build.lib}"/>
-
- <!-- Generate a jar containing all the compiled sources -->
- <jar destfile="${build.lib}/${module.name}-jdk5.jar">
- <fileset dir="${build.classes}"/>
- </jar>
-
- <!-- Generate the jar (.deployer) to be used as deployment -->
- <jar destfile="${build.lib}/${module.name}-jdk5.deployer" >
- <fileset file="${build.lib}/${module.name}-jdk5.jar"/>
- <fileset dir="${spring.lib}">
- <include name="*.jar"/>
- <!--<exclude name="spring-aop.jar"/>-->
- <!--<exclude name="spring-context.jar"/>-->
- <exclude name="spring-web.jar"/>
- <exclude name="spring-webmvc.jar"/>
- </fileset>
- <metainf dir="${build.resources}" includes="*.xml"/>
- </jar>
- </target>
-
<target name="rebuild-spring-jars" depends="init, clean-spring-jars, compile, build-spring-jars"/>
<target name="clean-spring-jars" depends="init">
@@ -233,8 +216,8 @@
<mkdir dir="${build.classes}"/>
<javac destdir="${build.classes}"
optimize="${javac.optimize}"
- source="1.4"
- target="1.4"
+ source="1.5"
+ target="1.5"
debug="${javac.debug}"
depend="${javac.depend}"
verbose="${javac.verbose}"
@@ -244,44 +227,18 @@
failonerror="${javac.fail.onerror}">
<src path="${source.java}"/>
<classpath refid="javac.classpath"/>
- <include name="org/jboss/spring/deployment/**"/>
+ <exclude name="org/jboss/spring/deployment/**"/>
+ <exclude name="org/jboss/spring/loader/**"/>
+ <exclude name="org/jboss/spring/kernel/**"/>
+ <include name="org/jboss/annotation/spring/**"/>
+ <include name="org/jboss/spring/callback/**"/>
+ <include name="org/jboss/spring/deployers/**"/>
+ <include name="org/jboss/spring/interceptor/**"/>
<include name="org/jboss/spring/factory/**"/>
- <include name="org/jboss/spring/kernel/**"/>
- <exclude name="org/jboss/annotation/spring/**"/>
- <exclude name="org/jboss/spring/callback/**"/>
- <exclude name="org/jboss/spring/interceptor/**"/>
- <exclude name="org/jboss/spring/support/**"/>
+ <include name="org/jboss/spring/support/**"/>
</javac>
</target>
- <!-- Compile all class files -->
- <target name="compile-jdk5" depends="init" unless="NO_JDK_5">
- <mkdir dir="${build.classes}"/>
- <javac destdir="${build.classes}"
- optimize="${javac.optimize}"
- source="1.5"
- target="1.5"
- debug="${javac.debug}"
- depend="${javac.depend}"
- verbose="${javac.verbose}"
- deprecation="${javac.deprecation}"
- includeAntRuntime="${javac.include.ant.runtime}"
- includeJavaRuntime="${javac.include.java.runtime}"
- includes="${javac.includes}"
- excludes="${javac.excludes}"
- failonerror="${javac.fail.onerror}">
- <src path="${source.java}"/>
- <classpath refid="javac.classpath"/>
- <exclude name="org/jboss/spring/deployment/**"/>
- <exclude name="org/jboss/spring/factory/**"/>
- <exclude name="org/jboss/spring/kernel/**"/>
- <include name="org/jboss/annotation/spring/**"/>
- <include name="org/jboss/spring/callback/**"/>
- <include name="org/jboss/spring/interceptor/**"/>
- <include name="org/jboss/spring/support/**"/>
- </javac>
- </target>
-
<!-- Compile resource files -->
<target name="compile-resources" depends="init">
<mkdir dir="${build.resources}"/>
@@ -302,7 +259,6 @@
</copy>
</target>
-
<!-- ================================================================== -->
<!-- Archives -->
<!-- ================================================================== -->
@@ -316,7 +272,7 @@
unless="build-bypass.on">
<antcall target="build-spring-jars"/>
- <antcall target="build-spring-jars-jdk5"/>
+ <!--<antcall target="build-spring-jars-jdk5"/>-->
<!-- Update the build marker to allow bypassing -->
<touch file="${build-bypass.marker}"/>
@@ -431,6 +387,7 @@
<include name="org/jboss/spring/callback/**"/>
<include name="org/jboss/spring/support/**"/>
<exclude name="org/jboss/spring/deployment/**"/>
+ <exclude name="org/jboss/spring/deployers/**"/>
<exclude name="org/jboss/spring/factory/**"/>
<exclude name="org/jboss/spring/interceptor/**"/>
</javac>
Modified: trunk/spring-int/src/main/org/jboss/annotation/spring/Spring.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/annotation/spring/Spring.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/annotation/spring/Spring.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -28,6 +28,8 @@
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>
*/
@@ -35,9 +37,17 @@
@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 "";
-
}
Modified: trunk/spring-int/src/main/org/jboss/spring/callback/SpringLifecycleInterceptor.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/callback/SpringLifecycleInterceptor.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/callback/SpringLifecycleInterceptor.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -37,7 +37,6 @@
*/
public class SpringLifecycleInterceptor extends SpringPassivationInterceptor
{
-
private static final long serialVersionUID = 365239483909594775L;
@PostConstruct
@@ -46,5 +45,4 @@
inject(ctx.getTarget());
ctx.proceed();
}
-
}
Modified: trunk/spring-int/src/main/org/jboss/spring/callback/SpringPassivationInterceptor.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/callback/SpringPassivationInterceptor.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/callback/SpringPassivationInterceptor.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -42,7 +42,6 @@
*/
public class SpringPassivationInterceptor extends SpringInjectionSupport implements Serializable
{
-
private static final long serialVersionUID = -7259379236645796135L;
@PostActivate
@@ -74,5 +73,4 @@
{
ctx.proceed();
}
-
}
Added: trunk/spring-int/src/main/org/jboss/spring/deployers/AbstractSpringMetaDataDeployer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployers/AbstractSpringMetaDataDeployer.java (rev 0)
+++ trunk/spring-int/src/main/org/jboss/spring/deployers/AbstractSpringMetaDataDeployer.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -0,0 +1,209 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractSpringMetaDataDeployer 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);
+ BeanFactory 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 BeanFactory doCreate(SpringMetaData metaData);
+
+ public void undeploy(DeploymentUnit unit, SpringMetaData springMetaData)
+ {
+ String name = springMetaData.getName();
+ try
+ {
+ BeanFactory 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(BeanFactory 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(BeanFactory 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
+ */
+ protected BeanFactory lookup(String name) throws Exception
+ {
+ BeanFactory beanFactory = (BeanFactory) Util.lookup(name, getExactBeanFactoryClass());
+ 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 getExactBeanFactoryClass();
+}
Added: trunk/spring-int/src/main/org/jboss/spring/deployers/ApplicationContextDeployer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployers/ApplicationContextDeployer.java (rev 0)
+++ trunk/spring-int/src/main/org/jboss/spring/deployers/ApplicationContextDeployer.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.beans.factory.BeanFactory;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Spring application context deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ApplicationContextDeployer extends AbstractSpringMetaDataDeployer
+{
+ protected DeploymentVisitor<SpringMetaData> createDeploymentVisitor()
+ {
+ return new SpringDeploymentVisitor()
+ {
+ protected BeanFactory doCreate(SpringMetaData metaData)
+ {
+ return new NamedXmlApplicationContext(metaData.getDefaultName(), metaData.getResource());
+ }
+
+ protected void doClose(BeanFactory beanFactory)
+ {
+ ((ConfigurableApplicationContext) beanFactory).close();
+ }
+ };
+ }
+
+ protected Class getExactBeanFactoryClass()
+ {
+ return ApplicationContext.class;
+ }
+}
Added: trunk/spring-int/src/main/org/jboss/spring/deployers/BeanFactoryDeployer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployers/BeanFactoryDeployer.java (rev 0)
+++ trunk/spring-int/src/main/org/jboss/spring/deployers/BeanFactoryDeployer.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.BeanFactory;
+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
+{
+ protected DeploymentVisitor<SpringMetaData> createDeploymentVisitor()
+ {
+ return new SpringDeploymentVisitor()
+ {
+ protected BeanFactory doCreate(SpringMetaData metaData)
+ {
+ return new NamedXmlBeanFactory(metaData.getDefaultName(), metaData.getResource());
+ }
+
+ protected void doClose(BeanFactory beanFactory)
+ {
+ ((ConfigurableBeanFactory) beanFactory).destroySingletons();
+ }
+ };
+ }
+
+ protected Class getExactBeanFactoryClass()
+ {
+ return BeanFactory.class;
+ }
+}
Added: trunk/spring-int/src/main/org/jboss/spring/deployers/SpringMetaData.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployers/SpringMetaData.java (rev 0)
+++ trunk/spring-int/src/main/org/jboss/spring/deployers/SpringMetaData.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -0,0 +1,85 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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;
+ }
+}
Added: trunk/spring-int/src/main/org/jboss/spring/deployers/SpringParserDeployer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployers/SpringParserDeployer.java (rev 0)
+++ trunk/spring-int/src/main/org/jboss/spring/deployers/SpringParserDeployer.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.plugins.structure.file.FileMatcher;
+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> implements FileMatcher
+{
+ public SpringParserDeployer()
+ {
+ super(SpringMetaData.class);
+ setSuffix("-spring.xml");
+ }
+
+ /**
+ * Get default name.
+ *
+ * @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);
+ }
+
+ protected SpringMetaData parse(VFSDeploymentUnit unit, VirtualFile file, SpringMetaData metaData) throws Exception
+ {
+ return new SpringMetaData(file.toURL(), getDefaultName(file));
+ }
+
+ public boolean isDeployable(VirtualFile virtualFile)
+ {
+ return virtualFile.getName().endsWith(getSuffix());
+ }
+}
Modified: trunk/spring-int/src/main/org/jboss/spring/deployment/SpringApplicationContextDeployer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployment/SpringApplicationContextDeployer.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/deployment/SpringApplicationContextDeployer.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -11,14 +11,15 @@
import javax.management.ObjectName;
-import org.jboss.spring.factory.ApplicationContextLoaderImpl;
-import org.jboss.spring.factory.BeanFactoryLoader;
+import org.jboss.spring.loader.ApplicationContextLoaderImpl;
+import org.jboss.spring.loader.BeanFactoryLoader;
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
* @jmx:mbean name="jboss.spring:service=SpringApplicationContextDeployer"
* extends="org.jboss.spring.deployment.SpringDeployer"
*/
+ at Deprecated
public class SpringApplicationContextDeployer extends SpringDeployer
{
Modified: trunk/spring-int/src/main/org/jboss/spring/deployment/SpringBeanFactoryDeployer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployment/SpringBeanFactoryDeployer.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/deployment/SpringBeanFactoryDeployer.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -11,14 +11,15 @@
import javax.management.ObjectName;
-import org.jboss.spring.factory.BeanFactoryLoader;
-import org.jboss.spring.factory.BeanFactoryLoaderImpl;
+import org.jboss.spring.loader.BeanFactoryLoader;
+import org.jboss.spring.loader.BeanFactoryLoaderImpl;
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
* @jmx:mbean name="jboss.spring:service=SpringBeanFactoryDeployer"
* extends="org.jboss.spring.deployment.SpringDeployer"
*/
+ at Deprecated
public class SpringBeanFactoryDeployer extends SpringDeployer
{
Modified: trunk/spring-int/src/main/org/jboss/spring/deployment/SpringDeployer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployment/SpringDeployer.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/deployment/SpringDeployer.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -32,12 +32,13 @@
import org.jboss.deployment.DeploymentInfo;
import org.jboss.deployment.SubDeployer;
import org.jboss.deployment.SubDeployerSupport;
-import org.jboss.spring.factory.BeanFactoryLoader;
+import org.jboss.spring.loader.BeanFactoryLoader;
/**
* @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 Deprecated
public abstract class SpringDeployer extends SubDeployerSupport implements
SubDeployer, SpringDeployerMBean
{
Deleted: trunk/spring-int/src/main/org/jboss/spring/factory/AbstractBeanFactoryLoader.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/AbstractBeanFactoryLoader.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/AbstractBeanFactoryLoader.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -1,201 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.net.URL;
-import java.net.URLClassLoader;
-import java.util.Map;
-import java.util.TreeMap;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.deployment.DeploymentException;
-import org.jboss.deployment.DeploymentInfo;
-import org.jboss.logging.Logger;
-import org.jboss.util.naming.NonSerializableFactory;
-import org.jboss.util.naming.Util;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.FatalBeanException;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.UrlResource;
-
-/**
- * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
- */
-public abstract class AbstractBeanFactoryLoader implements BeanFactoryLoader
-{
-
- private final Logger log = Logger.getLogger(getClass());
-
- protected Map beanFactoryNamesMap = new TreeMap();
-
- private URL getDocUrl(DeploymentInfo di) throws DeploymentException
- {
- URL docURL = di.localUrl;
- if (!di.isXML)
- {
- URLClassLoader localCL = di.localCl;
- docURL = localCL.findResource("META-INF/jboss-spring.xml");
- }
- // Validate that the descriptor was found
- if (docURL == null)
- {
- throw new DeploymentException("Failed to find META-INF/jboss-spring.xml");
- }
- return docURL;
- }
-
- private String getDefaultName(DeploymentInfo di)
- {
- String shortName = di.shortName;
- int p = shortName.indexOf(".spring");
- if (p > 0)
- {
- return shortName.substring(0, p);
- }
- p = shortName.indexOf("-spring.xml");
- if (p > 0)
- {
- return shortName.substring(0, p);
- }
- return null;
- }
-
- public void create(DeploymentInfo di) throws DeploymentException
- {
- URL docURL = getDocUrl(di);
- String defaultName = getDefaultName(di);
- BeanFactory beanFactory = null;
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader(di.ucl);
- beanFactory = createBeanFactory(defaultName, new UrlResource(docURL));
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(cl);
- }
- String name = ((Nameable) beanFactory).getName();
- bind(beanFactory, name);
- log.info("Bean factory [" + name + "] binded to local JNDI.");
- beanFactoryNamesMap.put(docURL.toString(), name);
- }
-
- protected abstract BeanFactory createBeanFactory(String defaultName, Resource resource);
-
- public void start(DeploymentInfo di) throws DeploymentException
- {
- }
-
- public void stop(DeploymentInfo di) throws DeploymentException
- {
- try
- {
- URL docURL = getDocUrl(di);
- String name = (String) beanFactoryNamesMap.remove(docURL.toString());
- BeanFactory beanFactory = lookup(name);
- doClose(beanFactory);
- unbind(name);
- log.info("Bean factory [" + name + "] unbinded from local JNDI.");
- }
- catch (Exception e)
- {
- throw new DeploymentException(e);
- }
- }
-
- protected abstract void doClose(BeanFactory beanFactory);
-
- public void destroy(DeploymentInfo di) throws DeploymentException
- {
- }
-
- // JNDI stuff
-
- public static void bind(BeanFactory beanFactory, String name) throws BeansException
- {
- InitialContext ctx = null;
- try
- {
- ctx = new InitialContext();
- NonSerializableFactory.rebind(ctx, name, beanFactory);
- }
- catch (NamingException e)
- {
- throw new FatalBeanException("Unable to bind BeanFactory into JNDI", e);
- }
- finally
- {
- if (ctx != null)
- {
- try
- {
- ctx.close();
- }
- catch (Throwable ignored)
- {
- }
- }
- }
- }
-
- public static void unbind(String name) throws BeansException
- {
- InitialContext ctx = null;
- try
- {
- ctx = new InitialContext();
- ctx.unbind(name);
- NonSerializableFactory.unbind(name);
- }
- catch (NamingException e)
- {
- throw new FatalBeanException("Unable to unbind BeanFactory from JNDI", e);
- }
- finally
- {
- if (ctx != null)
- {
- try
- {
- ctx.close();
- }
- catch (Throwable ignored)
- {
- }
- }
- }
- }
-
- public BeanFactory lookup(String name) throws Exception
- {
- BeanFactory beanFactory = (BeanFactory) Util.lookup(name, getExactBeanFactoryClass());
- log.debug("Found Spring bean factory [" + name + "]: " + beanFactory);
- return beanFactory;
- }
-
- protected abstract Class getExactBeanFactoryClass();
-
-}
Deleted: trunk/spring-int/src/main/org/jboss/spring/factory/ApplicationContextLoaderImpl.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/ApplicationContextLoaderImpl.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/ApplicationContextLoaderImpl.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.factory.BeanFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.core.io.Resource;
-
-/**
- * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
- */
-public class ApplicationContextLoaderImpl extends AbstractBeanFactoryLoader
-{
-
- protected BeanFactory createBeanFactory(String defaultName, Resource resource)
- {
- return new NamedXmlApplicationContext(defaultName, resource);
- }
-
- protected void doClose(BeanFactory beanFactory)
- {
- ((ConfigurableApplicationContext) beanFactory).close();
- }
-
- protected Class getExactBeanFactoryClass()
- {
- return ApplicationContext.class;
- }
-
-}
Deleted: trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoader.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoader.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoader.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.jboss.deployment.DeploymentException;
-import org.jboss.deployment.DeploymentInfo;
-
-/**
- * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
- */
-public interface BeanFactoryLoader
-{
-
- void create(DeploymentInfo di) throws DeploymentException;
-
- void start(DeploymentInfo di) throws DeploymentException;
-
- void stop(DeploymentInfo di) throws DeploymentException;
-
- void destroy(DeploymentInfo di) throws DeploymentException;
-
-}
Deleted: trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoaderImpl.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoaderImpl.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoaderImpl.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.factory.BeanFactory;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.core.io.Resource;
-
-/**
- * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
- */
-public class BeanFactoryLoaderImpl extends AbstractBeanFactoryLoader
-{
-
- protected BeanFactory createBeanFactory(String defaultName, Resource resource)
- {
- return new NamedXmlBeanFactory(defaultName, resource);
- }
-
- protected void doClose(BeanFactory beanFactory)
- {
- ((ConfigurableBeanFactory) beanFactory).destroySingletons();
- }
-
- protected Class getExactBeanFactoryClass()
- {
- return BeanFactory.class;
- }
-
-}
Modified: trunk/spring-int/src/main/org/jboss/spring/factory/Instantiable.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/Instantiable.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/Instantiable.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -27,7 +27,10 @@
*/
public interface Instantiable
{
-
+ /**
+ * Do instantiate.
+ *
+ * @return true if instantiated.
+ */
boolean doInstantiate();
-
}
Modified: trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanDefinitionParser.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanDefinitionParser.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanDefinitionParser.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -26,6 +26,7 @@
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;
@@ -36,11 +37,13 @@
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
+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=\\(([^)]+)\\)";
@@ -67,7 +70,8 @@
if (BeanDefinitionParserDelegate.DESCRIPTION_ELEMENT.equals(node.getNodeName()))
{
String nodeValue = ele.getFirstChild().getNodeValue();
- logger.info("Bean names [description tag]: " + nodeValue);
+ if (log.isTraceEnabled())
+ log.trace("Bean names [description tag]: " + nodeValue);
Matcher bfm = parse(nodeValue, BEAN_FACTORY_ELEMENT);
if (bfm.find())
{
@@ -111,5 +115,4 @@
Pattern pattern = Pattern.compile(regexp);
return pattern.matcher(value);
}
-
}
Modified: trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanFactory.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanFactory.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanFactory.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -29,15 +29,16 @@
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
-public class NamedXmlBeanFactory extends DefaultListableBeanFactory
- implements Nameable, Instantiable
+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
{
@@ -59,5 +60,4 @@
{
return reader.doInstantiate();
}
-
}
Modified: trunk/spring-int/src/main/org/jboss/spring/interceptor/SpringInjectionInterceptor.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/interceptor/SpringInjectionInterceptor.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/interceptor/SpringInjectionInterceptor.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -37,7 +37,6 @@
*/
public class SpringInjectionInterceptor extends SpringInjectionSupport implements Interceptor
{
-
public SpringInjectionInterceptor()
{
log.info("Instantiating " + getName());
@@ -59,5 +58,4 @@
inject(target);
return target;
}
-
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerLoaderImpl.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerLoaderImpl.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerLoaderImpl.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -24,7 +24,7 @@
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.spring.factory.AbstractBeanFactoryLoader;
+import org.jboss.spring.loader.AbstractBeanFactoryLoader;
import org.jboss.spring.factory.NamedXmlApplicationContext;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/SpringMicrocontainerDeployer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/SpringMicrocontainerDeployer.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/SpringMicrocontainerDeployer.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -12,7 +12,7 @@
import javax.management.ObjectName;
import org.jboss.spring.deployment.SpringDeployer;
-import org.jboss.spring.factory.BeanFactoryLoader;
+import org.jboss.spring.loader.BeanFactoryLoader;
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
Copied: trunk/spring-int/src/main/org/jboss/spring/loader/AbstractBeanFactoryLoader.java (from rev 68319, trunk/spring-int/src/main/org/jboss/spring/factory/AbstractBeanFactoryLoader.java)
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/loader/AbstractBeanFactoryLoader.java (rev 0)
+++ trunk/spring-int/src/main/org/jboss/spring/loader/AbstractBeanFactoryLoader.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -0,0 +1,204 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.loader;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Map;
+import java.util.TreeMap;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.deployment.DeploymentInfo;
+import org.jboss.logging.Logger;
+import org.jboss.util.naming.NonSerializableFactory;
+import org.jboss.util.naming.Util;
+import org.jboss.spring.factory.Nameable;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * Abstract bean factory loader.
+ *
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+ at Deprecated
+public abstract class AbstractBeanFactoryLoader implements BeanFactoryLoader
+{
+ private final Logger log = Logger.getLogger(getClass());
+
+ protected Map beanFactoryNamesMap = new TreeMap();
+
+ private URL getDocUrl(DeploymentInfo di) throws DeploymentException
+ {
+ URL docURL = di.localUrl;
+ if (!di.isXML)
+ {
+ URLClassLoader localCL = di.localCl;
+ docURL = localCL.findResource("META-INF/jboss-spring.xml");
+ }
+ // Validate that the descriptor was found
+ if (docURL == null)
+ {
+ throw new DeploymentException("Failed to find META-INF/jboss-spring.xml");
+ }
+ return docURL;
+ }
+
+ private String getDefaultName(DeploymentInfo di)
+ {
+ String shortName = di.shortName;
+ int p = shortName.indexOf(".spring");
+ if (p > 0)
+ {
+ return shortName.substring(0, p);
+ }
+ p = shortName.indexOf("-spring.xml");
+ if (p > 0)
+ {
+ return shortName.substring(0, p);
+ }
+ return null;
+ }
+
+ public void create(DeploymentInfo di) throws DeploymentException
+ {
+ URL docURL = getDocUrl(di);
+ String defaultName = getDefaultName(di);
+ BeanFactory beanFactory = null;
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(di.ucl);
+ beanFactory = createBeanFactory(defaultName, new UrlResource(docURL));
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ String name = ((Nameable) beanFactory).getName();
+ bind(beanFactory, name);
+ log.info("Bean factory [" + name + "] binded to local JNDI.");
+ beanFactoryNamesMap.put(docURL.toString(), name);
+ }
+
+ protected abstract BeanFactory createBeanFactory(String defaultName, Resource resource);
+
+ public void start(DeploymentInfo di) throws DeploymentException
+ {
+ }
+
+ public void stop(DeploymentInfo di) throws DeploymentException
+ {
+ try
+ {
+ URL docURL = getDocUrl(di);
+ String name = (String) beanFactoryNamesMap.remove(docURL.toString());
+ BeanFactory beanFactory = lookup(name);
+ doClose(beanFactory);
+ unbind(name);
+ log.info("Bean factory [" + name + "] unbinded from local JNDI.");
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException(e);
+ }
+ }
+
+ protected abstract void doClose(BeanFactory beanFactory);
+
+ public void destroy(DeploymentInfo di) throws DeploymentException
+ {
+ }
+
+ // JNDI stuff
+
+ public static void bind(BeanFactory beanFactory, String name) throws BeansException
+ {
+ InitialContext ctx = null;
+ try
+ {
+ ctx = new InitialContext();
+ NonSerializableFactory.rebind(ctx, name, beanFactory);
+ }
+ catch (NamingException e)
+ {
+ throw new FatalBeanException("Unable to bind BeanFactory into JNDI", e);
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (Throwable ignored)
+ {
+ }
+ }
+ }
+ }
+
+ public static void unbind(String name) throws BeansException
+ {
+ InitialContext ctx = null;
+ try
+ {
+ ctx = new InitialContext();
+ ctx.unbind(name);
+ NonSerializableFactory.unbind(name);
+ }
+ catch (NamingException e)
+ {
+ throw new FatalBeanException("Unable to unbind BeanFactory from JNDI", e);
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (Throwable ignored)
+ {
+ }
+ }
+ }
+ }
+
+ public BeanFactory lookup(String name) throws Exception
+ {
+ BeanFactory beanFactory = (BeanFactory) Util.lookup(name, getExactBeanFactoryClass());
+ log.debug("Found Spring bean factory [" + name + "]: " + beanFactory);
+ return beanFactory;
+ }
+
+ protected abstract Class getExactBeanFactoryClass();
+
+}
Property changes on: trunk/spring-int/src/main/org/jboss/spring/loader/AbstractBeanFactoryLoader.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/spring-int/src/main/org/jboss/spring/loader/ApplicationContextLoaderImpl.java (from rev 68319, trunk/spring-int/src/main/org/jboss/spring/factory/ApplicationContextLoaderImpl.java)
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/loader/ApplicationContextLoaderImpl.java (rev 0)
+++ trunk/spring-int/src/main/org/jboss/spring/loader/ApplicationContextLoaderImpl.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.loader;
+
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.core.io.Resource;
+import org.jboss.spring.factory.NamedXmlApplicationContext;
+
+/**
+ * Application context loader.
+ *
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+ at Deprecated
+public class ApplicationContextLoaderImpl extends AbstractBeanFactoryLoader
+{
+ protected BeanFactory createBeanFactory(String defaultName, Resource resource)
+ {
+ return new NamedXmlApplicationContext(defaultName, resource);
+ }
+
+ protected void doClose(BeanFactory beanFactory)
+ {
+ ((ConfigurableApplicationContext) beanFactory).close();
+ }
+
+ protected Class getExactBeanFactoryClass()
+ {
+ return ApplicationContext.class;
+ }
+
+}
Property changes on: trunk/spring-int/src/main/org/jboss/spring/loader/ApplicationContextLoaderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/spring-int/src/main/org/jboss/spring/loader/BeanFactoryLoader.java (from rev 68319, trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoader.java)
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/loader/BeanFactoryLoader.java (rev 0)
+++ trunk/spring-int/src/main/org/jboss/spring/loader/BeanFactoryLoader.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.loader;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.deployment.DeploymentInfo;
+
+/**
+ * Loader interface.
+ *
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+ at Deprecated
+public interface BeanFactoryLoader
+{
+ void create(DeploymentInfo di) throws DeploymentException;
+
+ void start(DeploymentInfo di) throws DeploymentException;
+
+ void stop(DeploymentInfo di) throws DeploymentException;
+
+ void destroy(DeploymentInfo di) throws DeploymentException;
+}
Property changes on: trunk/spring-int/src/main/org/jboss/spring/loader/BeanFactoryLoader.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/spring-int/src/main/org/jboss/spring/loader/BeanFactoryLoaderImpl.java (from rev 68319, trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoaderImpl.java)
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/loader/BeanFactoryLoaderImpl.java (rev 0)
+++ trunk/spring-int/src/main/org/jboss/spring/loader/BeanFactoryLoaderImpl.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.loader;
+
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.core.io.Resource;
+import org.jboss.spring.factory.NamedXmlBeanFactory;
+
+/**
+ * Bean factory loader.
+ *
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+ at Deprecated
+public class BeanFactoryLoaderImpl extends AbstractBeanFactoryLoader
+{
+ protected BeanFactory createBeanFactory(String defaultName, Resource resource)
+ {
+ return new NamedXmlBeanFactory(defaultName, resource);
+ }
+
+ protected void doClose(BeanFactory beanFactory)
+ {
+ ((ConfigurableBeanFactory) beanFactory).destroySingletons();
+ }
+
+ protected Class getExactBeanFactoryClass()
+ {
+ return BeanFactory.class;
+ }
+
+}
Property changes on: trunk/spring-int/src/main/org/jboss/spring/loader/BeanFactoryLoaderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/spring-int/src/main/org/jboss/spring/support/SpringInjectionSupport.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/support/SpringInjectionSupport.java 2007-12-16 13:49:13 UTC (rev 68320)
+++ trunk/spring-int/src/main/org/jboss/spring/support/SpringInjectionSupport.java 2007-12-16 20:06:51 UTC (rev 68321)
@@ -44,13 +44,11 @@
*/
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);
@@ -267,6 +265,5 @@
return name1.compareTo(name2);
}
}
-
}
}
Added: trunk/spring-int/src/resources/spring-deployers-beans.xml
===================================================================
--- trunk/spring-int/src/resources/spring-deployers-beans.xml (rev 0)
+++ trunk/spring-int/src/resources/spring-deployers-beans.xml 2007-12-16 20:06:51 UTC (rev 68321)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Spring deployer beans.
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="SpringParserDeployer" class="org.jboss.spring.deployers.SpringParserDeployer"/>
+
+ <bean name="ApplicationContextDeployer" class="org.jboss.spring.deployers.ApplicationContextDeployer"/>
+
+ <!--
+ Uncomment this if you want to use only BeanFactory not the full ApplicationContext.
+ And comment the ApplicationContextDeployer, else both will pick-up the SpringMetaData.
+ -->
+ <!--
+ <bean name="BeanFactoryDeployer" class="org.jboss.spring.deployers.BeanFactoryDeployer"/>
+ -->
+
+</deployment>
More information about the jboss-cvs-commits
mailing list