[jboss-cvs] JBossAS SVN: r57727 - in trunk/spring-int/src: main/org/jboss/annotation/spring main/org/jboss/spring/callback main/org/jboss/spring/deployment main/org/jboss/spring/factory main/org/jboss/spring/interceptor main/org/jboss/spring/kernel main/org/jboss/spring/support resources resources/test/dd resources/test/dd/spring resources/test/dd/web resources/test/docs resources/test/ear resources/test/ear/business/META-INF resources/test/ear/spring/META-INF resources/test/web resources/test/web/WEB-INF test/org/jboss/spring/test/ear/business test/org/jboss/spring/test/ear/pojo test/org/jboss/spring/test/ear/unit test/org/jboss/tutorial/ee/service test/org/jboss/tutorial/ee/service/impl test/org/jboss/tutorial/spring test/org/jboss/tutorial/web
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 19 07:44:46 EDT 2006
Author: alesj
Date: 2006-10-19 07:43:35 -0400 (Thu, 19 Oct 2006)
New Revision: 57727
Modified:
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/SpringApplicationContextDeployerMBean.java
trunk/spring-int/src/main/org/jboss/spring/deployment/SpringBeanFactoryDeployer.java
trunk/spring-int/src/main/org/jboss/spring/deployment/SpringBeanFactoryDeployerMBean.java
trunk/spring-int/src/main/org/jboss/spring/deployment/SpringDeployer.java
trunk/spring-int/src/main/org/jboss/spring/deployment/SpringDeployerMBean.java
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
trunk/spring-int/src/main/org/jboss/spring/factory/Instantiable.java
trunk/spring-int/src/main/org/jboss/spring/factory/Nameable.java
trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlApplicationContext.java
trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanDefinitionParser.java
trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanDefinitionReader.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/ContextMicrocontainerConfigurer.java
trunk/spring-int/src/main/org/jboss/spring/kernel/ControllerLocator.java
trunk/spring-int/src/main/org/jboss/spring/kernel/KernelBinderLocator.java
trunk/spring-int/src/main/org/jboss/spring/kernel/KernelLocator.java
trunk/spring-int/src/main/org/jboss/spring/kernel/LazyLocator.java
trunk/spring-int/src/main/org/jboss/spring/kernel/Locator.java
trunk/spring-int/src/main/org/jboss/spring/kernel/MapLocator.java
trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerConfigurer.java
trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerLoaderImpl.java
trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerLocatorSupport.java
trunk/spring-int/src/main/org/jboss/spring/kernel/NullLocator.java
trunk/spring-int/src/main/org/jboss/spring/kernel/SpringMicrocontainerDeployer.java
trunk/spring-int/src/main/org/jboss/spring/kernel/SpringMicrocontainerDeployerMBean.java
trunk/spring-int/src/main/org/jboss/spring/support/SpringInjectionSupport.java
trunk/spring-int/src/resources/jboss-service.xml
trunk/spring-int/src/resources/test/dd/application.xml
trunk/spring-int/src/resources/test/dd/spring/jboss-spring.xml
trunk/spring-int/src/resources/test/dd/web/web.xml
trunk/spring-int/src/resources/test/docs/JBoss-Spring-Example.html
trunk/spring-int/src/resources/test/ear/application.xml
trunk/spring-int/src/resources/test/ear/business/META-INF/ejb-jar.xml
trunk/spring-int/src/resources/test/ear/spring/META-INF/jboss-spring.xml
trunk/spring-int/src/resources/test/web/WEB-INF/applicationContext.xml
trunk/spring-int/src/resources/test/web/WEB-INF/jboss-spring-servlet.xml
trunk/spring-int/src/resources/test/web/index.jsp
trunk/spring-int/src/test/org/jboss/spring/test/ear/business/SessionTestBean.java
trunk/spring-int/src/test/org/jboss/spring/test/ear/business/SessionTestBeanImpl.java
trunk/spring-int/src/test/org/jboss/spring/test/ear/pojo/Tester.java
trunk/spring-int/src/test/org/jboss/spring/test/ear/unit/SpringEARUnitTestCase.java
trunk/spring-int/src/test/org/jboss/tutorial/ee/service/Horoscope.java
trunk/spring-int/src/test/org/jboss/tutorial/ee/service/Randomizer.java
trunk/spring-int/src/test/org/jboss/tutorial/ee/service/impl/HoroscopeBean.java
trunk/spring-int/src/test/org/jboss/tutorial/ee/service/impl/RandomizerBean.java
trunk/spring-int/src/test/org/jboss/tutorial/spring/DummyStateIntCreator.java
trunk/spring-int/src/test/org/jboss/tutorial/spring/FileLineReader.java
trunk/spring-int/src/test/org/jboss/tutorial/spring/IntCreator.java
trunk/spring-int/src/test/org/jboss/tutorial/spring/JavaRandomIntCreator.java
trunk/spring-int/src/test/org/jboss/tutorial/spring/RandomFileWordsCreator.java
trunk/spring-int/src/test/org/jboss/tutorial/spring/StaticWordsCreator.java
trunk/spring-int/src/test/org/jboss/tutorial/spring/WordsCreator.java
trunk/spring-int/src/test/org/jboss/tutorial/web/AppController.java
Log:
Springframework 2.0 final usage.
Modified: trunk/spring-int/src/main/org/jboss/annotation/spring/Spring.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/annotation/spring/Spring.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/annotation/spring/Spring.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -36,8 +36,8 @@
public @interface Spring
{
- String jndiName();
+ String jndiName();
- String bean();
+ 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 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/callback/SpringLifecycleInterceptor.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,11 +22,11 @@
package org.jboss.spring.callback;
-import org.jboss.spring.support.SpringInjectionSupport;
-
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.
@@ -38,13 +38,13 @@
public class SpringLifecycleInterceptor extends SpringPassivationInterceptor
{
- private static final long serialVersionUID = 365239483909594775L;
+ private static final long serialVersionUID = 365239483909594775L;
- @PostConstruct
- public void postConstruct(InvocationContext ctx) throws Exception
- {
- inject(ctx.getTarget());
- ctx.proceed();
- }
+ @PostConstruct
+ public void postConstruct(InvocationContext ctx) throws Exception
+ {
+ 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 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/callback/SpringPassivationInterceptor.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,16 +22,16 @@
package org.jboss.spring.callback;
-import org.jboss.spring.support.SpringInjectionSupport;
-
+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 java.io.Serializable;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
+import org.jboss.spring.support.SpringInjectionSupport;
+
/**
* Injects Spring beans only on postActivation.
* If you need injection also on construction, use SpringLifecycleInterceptor.
@@ -43,36 +43,36 @@
public class SpringPassivationInterceptor extends SpringInjectionSupport implements Serializable
{
- private static final long serialVersionUID = -7259379236645796135L;
+ private static final long serialVersionUID = -7259379236645796135L;
- @PostActivate
- public void postActivate(InvocationContext ctx) throws Exception
- {
- inject(ctx.getTarget());
- ctx.proceed();
- }
+ @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();
- }
+ @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();
- }
+ @PreDestroy
+ public void preDestroy(InvocationContext ctx) throws Exception
+ {
+ ctx.proceed();
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/deployment/SpringApplicationContextDeployer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployment/SpringApplicationContextDeployer.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/deployment/SpringApplicationContextDeployer.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -9,36 +9,36 @@
package org.jboss.spring.deployment;
+import javax.management.ObjectName;
+
import org.jboss.spring.factory.ApplicationContextLoaderImpl;
import org.jboss.spring.factory.BeanFactoryLoader;
-import javax.management.ObjectName;
-
/**
* @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"
+ * extends="org.jboss.spring.deployment.SpringDeployer"
*/
public class SpringApplicationContextDeployer extends SpringDeployer
{
- //default object name
- public static final javax.management.ObjectName OBJECT_NAME =
- org.jboss.mx.util.ObjectNameFactory.create("jboss.spring:service=SpringApplicationContextDeployer");
+ //default object name
+ public static final javax.management.ObjectName OBJECT_NAME =
+ org.jboss.mx.util.ObjectNameFactory.create("jboss.spring:service=SpringApplicationContextDeployer");
- public SpringApplicationContextDeployer()
- {
- super();
- }
+ public SpringApplicationContextDeployer()
+ {
+ super();
+ }
- protected BeanFactoryLoader createBeanFactoryLoader()
- {
- return new ApplicationContextLoaderImpl();
- }
+ protected BeanFactoryLoader createBeanFactoryLoader()
+ {
+ return new ApplicationContextLoaderImpl();
+ }
- protected ObjectName getDefaultObjectName()
- {
- return OBJECT_NAME;
- }
+ protected ObjectName getDefaultObjectName()
+ {
+ return OBJECT_NAME;
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/deployment/SpringApplicationContextDeployerMBean.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployment/SpringApplicationContextDeployerMBean.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/deployment/SpringApplicationContextDeployerMBean.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -20,8 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.spring.deployment;
+
/**
* MBean interface.
+ *
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
public interface SpringApplicationContextDeployerMBean extends SpringDeployerMBean
Modified: trunk/spring-int/src/main/org/jboss/spring/deployment/SpringBeanFactoryDeployer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployment/SpringBeanFactoryDeployer.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/deployment/SpringBeanFactoryDeployer.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -9,36 +9,36 @@
package org.jboss.spring.deployment;
+import javax.management.ObjectName;
+
import org.jboss.spring.factory.BeanFactoryLoader;
import org.jboss.spring.factory.BeanFactoryLoaderImpl;
-import javax.management.ObjectName;
-
/**
* @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"
+ * extends="org.jboss.spring.deployment.SpringDeployer"
*/
public class SpringBeanFactoryDeployer extends SpringDeployer
{
- //default object name
- public static final javax.management.ObjectName OBJECT_NAME =
- org.jboss.mx.util.ObjectNameFactory.create("jboss.spring:service=SpringBeanFactoryDeployer");
+ //default object name
+ public static final javax.management.ObjectName OBJECT_NAME =
+ org.jboss.mx.util.ObjectNameFactory.create("jboss.spring:service=SpringBeanFactoryDeployer");
- public SpringBeanFactoryDeployer()
- {
- super();
- }
+ public SpringBeanFactoryDeployer()
+ {
+ super();
+ }
- protected BeanFactoryLoader createBeanFactoryLoader()
- {
- return new BeanFactoryLoaderImpl();
- }
+ protected BeanFactoryLoader createBeanFactoryLoader()
+ {
+ return new BeanFactoryLoaderImpl();
+ }
- protected ObjectName getDefaultObjectName()
- {
- return OBJECT_NAME;
- }
+ protected ObjectName getDefaultObjectName()
+ {
+ return OBJECT_NAME;
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/deployment/SpringBeanFactoryDeployerMBean.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployment/SpringBeanFactoryDeployerMBean.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/deployment/SpringBeanFactoryDeployerMBean.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -20,10 +20,12 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.spring.deployment;
+
/**
* MBean interface.
+ *
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
-public interface SpringBeanFactoryDeployerMBean extends SpringDeployerMBean
+public interface SpringBeanFactoryDeployerMBean extends SpringDeployerMBean
{
}
Modified: trunk/spring-int/src/main/org/jboss/spring/deployment/SpringDeployer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployment/SpringDeployer.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/deployment/SpringDeployer.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,180 +22,185 @@
package org.jboss.spring.deployment;
+import java.io.File;
+import java.net.URL;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
import org.jboss.deployment.DeploymentException;
import org.jboss.deployment.DeploymentInfo;
import org.jboss.deployment.SubDeployer;
import org.jboss.deployment.SubDeployerSupport;
import org.jboss.spring.factory.BeanFactoryLoader;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import java.io.File;
-import java.net.URL;
-
/**
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
public abstract class SpringDeployer extends SubDeployerSupport implements
- SubDeployer, SpringDeployerMBean
+ SubDeployer, SpringDeployerMBean
{
- protected abstract BeanFactoryLoader createBeanFactoryLoader();
+ protected abstract BeanFactoryLoader createBeanFactoryLoader();
- private BeanFactoryLoader beanFactoryLoader = createBeanFactoryLoader();
+ private BeanFactoryLoader beanFactoryLoader = createBeanFactoryLoader();
- /**
- * Default CTOR used to set default values to the Suffixes and RelativeOrder
- * attributes. Those are read at subdeployer registration time by the MainDeployer
- * to alter its SuffixOrder.
- */
- public SpringDeployer()
- {
- initializeMainDeployer();
- }
+ /**
+ * Default CTOR used to set default values to the Suffixes and RelativeOrder
+ * attributes. Those are read at subdeployer registration time by the MainDeployer
+ * to alter its SuffixOrder.
+ */
+ public SpringDeployer()
+ {
+ initializeMainDeployer();
+ }
- protected void initializeMainDeployer()
- {
- setSuffixes(new String[]{".spring", "-spring.xml"});
- setRelativeOrder(350); //after -ds, before ejb3
- }
+ protected void initializeMainDeployer()
+ {
+ setSuffixes(new String[]{".spring", "-spring.xml"});
+ setRelativeOrder(350); //after -ds, before ejb3
+ }
- /**
- * Returns true if this deployer can deploy the given DeploymentInfo.
- *
- * @return True if this deployer can deploy the given DeploymentInfo.
- * @jmx:managed-operation
- */
- public boolean accepts(DeploymentInfo di)
- {
- String urlStr = di.url.toString();
- return urlStr.endsWith(".spring") || urlStr.endsWith(".spring/") ||
- urlStr.endsWith("-spring.xml");
- }
+ /**
+ * Returns true if this deployer can deploy the given DeploymentInfo.
+ *
+ * @return True if this deployer can deploy the given DeploymentInfo.
+ * @jmx:managed-operation
+ */
+ public boolean accepts(DeploymentInfo di)
+ {
+ String urlStr = di.url.toString();
+ return urlStr.endsWith(".spring") || urlStr.endsWith(".spring/") ||
+ urlStr.endsWith("-spring.xml");
+ }
- /**
- * Describe <code>init</code> method here.
- *
- * @param di a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- * @jmx:managed-operation
- */
- public void init(DeploymentInfo di) throws DeploymentException
- {
- try
- {
- if (di.watch == null)
+ /**
+ * Describe <code>init</code> method here.
+ *
+ * @param di a <code>DeploymentInfo</code> value
+ * @throws DeploymentException if an error occurs
+ * @jmx:managed-operation
+ */
+ public void init(DeploymentInfo di) throws DeploymentException
+ {
+ try
+ {
+ if (di.watch == null)
+ {
+ // resolve the watch
+ if (di.url.getProtocol().equals("file"))
{
- // resolve the watch
- if (di.url.getProtocol().equals("file"))
- {
- File file = new File(di.url.getFile());
- // If not directory we watch the package
- if (!file.isDirectory())
- {
- di.watch = di.url;
- }
- // If directory we watch the xml files
- else
- {
- di.watch = new URL(di.url, "META-INF/jboss-spring.xml");
- }
- } else
- {
- // We watch the top only, no directory support
- di.watch = di.url;
- }
+ File file = new File(di.url.getFile());
+ // If not directory we watch the package
+ if (!file.isDirectory())
+ {
+ di.watch = di.url;
+ }
+ // If directory we watch the xml files
+ else
+ {
+ di.watch = new URL(di.url, "META-INF/jboss-spring.xml");
+ }
}
- } catch (Exception e)
- {
- log.error("failed to parse Spring context document: ", e);
- throw new DeploymentException(e);
- }
- super.init(di);
- }
+ else
+ {
+ // We watch the top only, no directory support
+ di.watch = di.url;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("failed to parse Spring context document: ", e);
+ throw new DeploymentException(e);
+ }
+ super.init(di);
+ }
- /**
- * Describe <code>create</code> method here.
- *
- * @param di a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- * @jmx:managed-operation
- */
- public void create(DeploymentInfo di) throws DeploymentException
- {
- try
- {
- beanFactoryLoader.create(di);
- emitNotification("Spring Deploy", di);
- log.info("Deployed Spring: " + di.url);
- } catch (Exception e)
- {
- throw new DeploymentException(e);
- }
- }
+ /**
+ * Describe <code>create</code> method here.
+ *
+ * @param di a <code>DeploymentInfo</code> value
+ * @throws DeploymentException if an error occurs
+ * @jmx:managed-operation
+ */
+ public void create(DeploymentInfo di) throws DeploymentException
+ {
+ try
+ {
+ beanFactoryLoader.create(di);
+ emitNotification("Spring Deploy", di);
+ log.info("Deployed Spring: " + di.url);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException(e);
+ }
+ }
- /**
- * The <code>start</code> method starts all the mbeans in this DeploymentInfo..
- *
- * @param di a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- * @jmx:managed-operation
- */
- public void start(DeploymentInfo di) throws DeploymentException
- {
- beanFactoryLoader.start(di);
- }
+ /**
+ * The <code>start</code> method starts all the mbeans in this DeploymentInfo..
+ *
+ * @param di a <code>DeploymentInfo</code> value
+ * @throws DeploymentException if an error occurs
+ * @jmx:managed-operation
+ */
+ public void start(DeploymentInfo di) throws DeploymentException
+ {
+ beanFactoryLoader.start(di);
+ }
- /**
- * Undeploys the package at the url string specified. This will: Undeploy
- * packages depending on this one. Stop, destroy, and unregister all the
- * specified mbeans Unload this package and packages this package deployed
- * via the classpath tag. Keep track of packages depending on this one that
- * we undeployed so that they can be redeployed should this one be
- * redeployed.
- *
- * @param di the <code>DeploymentInfo</code> value to stop.
- * @jmx:managed-operation
- */
- public void stop(DeploymentInfo di)
- {
- log.info("Undeploying Spring: " + di.url);
- try
- {
- beanFactoryLoader.stop(di);
- emitNotification("Spring Undeploy", di);
- } catch (Exception e)
- {
- log.error("Failed to stop bean factory: " + di.url);
- }
- }
+ /**
+ * Undeploys the package at the url string specified. This will: Undeploy
+ * packages depending on this one. Stop, destroy, and unregister all the
+ * specified mbeans Unload this package and packages this package deployed
+ * via the classpath tag. Keep track of packages depending on this one that
+ * we undeployed so that they can be redeployed should this one be
+ * redeployed.
+ *
+ * @param di the <code>DeploymentInfo</code> value to stop.
+ * @jmx:managed-operation
+ */
+ public void stop(DeploymentInfo di)
+ {
+ log.info("Undeploying Spring: " + di.url);
+ try
+ {
+ beanFactoryLoader.stop(di);
+ emitNotification("Spring Undeploy", di);
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to stop bean factory: " + di.url);
+ }
+ }
- /**
- * Describe <code>destroy</code> method here.
- *
- * @param di a <code>DeploymentInfo</code> value
- * @jmx:managed-operation
- */
- public void destroy(DeploymentInfo di)
- {
- try
- {
- beanFactoryLoader.destroy(di);
- emitNotification("Spring Destroy", di);
- } catch (DeploymentException e)
- {
- log.error("Failed to destroy deployer: " + di);
- }
- }
+ /**
+ * Describe <code>destroy</code> method here.
+ *
+ * @param di a <code>DeploymentInfo</code> value
+ * @jmx:managed-operation
+ */
+ public void destroy(DeploymentInfo di)
+ {
+ try
+ {
+ beanFactoryLoader.destroy(di);
+ emitNotification("Spring Destroy", di);
+ }
+ catch (DeploymentException e)
+ {
+ log.error("Failed to destroy deployer: " + di);
+ }
+ }
- protected ObjectName getObjectName(MBeanServer server, ObjectName name)
- throws MalformedObjectNameException
- {
- return name == null ? getDefaultObjectName() : name;
- }
+ protected ObjectName getObjectName(MBeanServer server, ObjectName name)
+ throws MalformedObjectNameException
+ {
+ return name == null ? getDefaultObjectName() : name;
+ }
- protected abstract ObjectName getDefaultObjectName();
+ protected abstract ObjectName getDefaultObjectName();
}
Modified: trunk/spring-int/src/main/org/jboss/spring/deployment/SpringDeployerMBean.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/deployment/SpringDeployerMBean.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/deployment/SpringDeployerMBean.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -28,51 +28,54 @@
*/
public interface SpringDeployerMBean extends org.jboss.deployment.SubDeployerMBean
{
- /**
- * Returns true if this deployer can deploy the given DeploymentInfo.
- *
- * @return True if this deployer can deploy the given DeploymentInfo.
- */
- boolean accepts(org.jboss.deployment.DeploymentInfo di);
+ /**
+ * Returns true if this deployer can deploy the given DeploymentInfo.
+ *
+ * @return True if this deployer can deploy the given DeploymentInfo.
+ */
+ boolean accepts(org.jboss.deployment.DeploymentInfo di);
- /**
- * Describe <code>init</code> method here.
- *
- * @param di a <code>DeploymentInfo</code> value
- * @throws org.jboss.deployment.DeploymentException if an error occurs
- */
- void init(org.jboss.deployment.DeploymentInfo di) throws org.jboss.deployment.DeploymentException;
+ /**
+ * Describe <code>init</code> method here.
+ *
+ * @param di a <code>DeploymentInfo</code> value
+ * @throws org.jboss.deployment.DeploymentException
+ * if an error occurs
+ */
+ void init(org.jboss.deployment.DeploymentInfo di) throws org.jboss.deployment.DeploymentException;
- /**
- * Describe <code>create</code> method here.
- *
- * @param di a <code>DeploymentInfo</code> value
- * @throws org.jboss.deployment.DeploymentException if an error occurs
- */
- void create(org.jboss.deployment.DeploymentInfo di) throws org.jboss.deployment.DeploymentException;
+ /**
+ * Describe <code>create</code> method here.
+ *
+ * @param di a <code>DeploymentInfo</code> value
+ * @throws org.jboss.deployment.DeploymentException
+ * if an error occurs
+ */
+ void create(org.jboss.deployment.DeploymentInfo di) throws org.jboss.deployment.DeploymentException;
- /**
- * The <code>start</code> method starts all the mbeans in this DeploymentInfo..
- *
- * @param di a <code>DeploymentInfo</code> value
- * @throws org.jboss.deployment.DeploymentException if an error occurs
- */
- void start(org.jboss.deployment.DeploymentInfo di) throws org.jboss.deployment.DeploymentException;
+ /**
+ * The <code>start</code> method starts all the mbeans in this DeploymentInfo..
+ *
+ * @param di a <code>DeploymentInfo</code> value
+ * @throws org.jboss.deployment.DeploymentException
+ * if an error occurs
+ */
+ void start(org.jboss.deployment.DeploymentInfo di) throws org.jboss.deployment.DeploymentException;
- /**
- * Undeploys the package at the url string specified. This will: Undeploy packages depending on this one.
- * Stop, destroy, and unregister all the specified mbeans Unload this package and packages this package
- * deployed via the classpath tag. Keep track of packages depending on this one that we undeployed so
- * that they can be redeployed should this one be redeployed.
- *
- * @param di the <code>DeploymentInfo</code> value to stop.
- */
- void stop(org.jboss.deployment.DeploymentInfo di);
+ /**
+ * Undeploys the package at the url string specified. This will: Undeploy packages depending on this one.
+ * Stop, destroy, and unregister all the specified mbeans Unload this package and packages this package
+ * deployed via the classpath tag. Keep track of packages depending on this one that we undeployed so
+ * that they can be redeployed should this one be redeployed.
+ *
+ * @param di the <code>DeploymentInfo</code> value to stop.
+ */
+ void stop(org.jboss.deployment.DeploymentInfo di);
- /**
- * Describe <code>destroy</code> method here.
- *
- * @param di a <code>DeploymentInfo</code> value
- */
- void destroy(org.jboss.deployment.DeploymentInfo di);
+ /**
+ * Describe <code>destroy</code> method here.
+ *
+ * @param di a <code>DeploymentInfo</code> value
+ */
+ void destroy(org.jboss.deployment.DeploymentInfo di);
}
Modified: trunk/spring-int/src/main/org/jboss/spring/factory/AbstractBeanFactoryLoader.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/AbstractBeanFactoryLoader.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/AbstractBeanFactoryLoader.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,172 +22,180 @@
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.naming.NonSerializableFactory;
-import org.jboss.naming.Util;
+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;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Map;
-import java.util.TreeMap;
-
/**
* @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());
+ private final Logger log = Logger.getLogger(getClass());
- protected Map beanFactoryNamesMap = new TreeMap();
+ 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 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;
- }
+ 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);
- }
+ 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);
+ protected abstract BeanFactory createBeanFactory(String defaultName, Resource resource);
- public void start(DeploymentInfo di) throws DeploymentException
- {
- }
+ 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);
- }
- }
+ 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);
+ protected abstract void doClose(BeanFactory beanFactory);
- public void destroy(DeploymentInfo di) throws DeploymentException
- {
- }
+ public void destroy(DeploymentInfo di) throws DeploymentException
+ {
+ }
- // JNDI stuff
+ // 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)
+ 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
{
- try
- {
- ctx.close();
- } catch (Throwable ignored)
- {
- }
+ 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)
+ 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
{
- try
- {
- ctx.close();
- } catch (Throwable ignored)
- {
- }
+ 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;
- }
+ 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();
+ protected abstract Class getExactBeanFactoryClass();
}
Modified: trunk/spring-int/src/main/org/jboss/spring/factory/ApplicationContextLoaderImpl.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/ApplicationContextLoaderImpl.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/ApplicationContextLoaderImpl.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -33,19 +33,19 @@
public class ApplicationContextLoaderImpl extends AbstractBeanFactoryLoader
{
- protected BeanFactory createBeanFactory(String defaultName, Resource resource)
- {
- return new NamedXmlApplicationContext(defaultName, resource);
- }
+ protected BeanFactory createBeanFactory(String defaultName, Resource resource)
+ {
+ return new NamedXmlApplicationContext(defaultName, resource);
+ }
- protected void doClose(BeanFactory beanFactory)
- {
- ((ConfigurableApplicationContext) beanFactory).close();
- }
+ protected void doClose(BeanFactory beanFactory)
+ {
+ ((ConfigurableApplicationContext) beanFactory).close();
+ }
- protected Class getExactBeanFactoryClass()
- {
- return ApplicationContext.class;
- }
+ protected Class getExactBeanFactoryClass()
+ {
+ return ApplicationContext.class;
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoader.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoader.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoader.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -31,12 +31,12 @@
public interface BeanFactoryLoader
{
- void create(DeploymentInfo di) throws DeploymentException;
+ void create(DeploymentInfo di) throws DeploymentException;
- void start(DeploymentInfo di) throws DeploymentException;
+ void start(DeploymentInfo di) throws DeploymentException;
- void stop(DeploymentInfo di) throws DeploymentException;
+ void stop(DeploymentInfo di) throws DeploymentException;
- void destroy(DeploymentInfo di) throws DeploymentException;
+ void destroy(DeploymentInfo di) throws DeploymentException;
}
Modified: trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoaderImpl.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoaderImpl.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/BeanFactoryLoaderImpl.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -32,19 +32,19 @@
public class BeanFactoryLoaderImpl extends AbstractBeanFactoryLoader
{
- protected BeanFactory createBeanFactory(String defaultName, Resource resource)
- {
- return new NamedXmlBeanFactory(defaultName, resource);
- }
+ protected BeanFactory createBeanFactory(String defaultName, Resource resource)
+ {
+ return new NamedXmlBeanFactory(defaultName, resource);
+ }
- protected void doClose(BeanFactory beanFactory)
- {
- ((ConfigurableBeanFactory) beanFactory).destroySingletons();
- }
+ protected void doClose(BeanFactory beanFactory)
+ {
+ ((ConfigurableBeanFactory) beanFactory).destroySingletons();
+ }
- protected Class getExactBeanFactoryClass()
- {
- return BeanFactory.class;
- }
+ 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 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/Instantiable.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -28,6 +28,6 @@
public interface Instantiable
{
- boolean doInstantiate();
+ boolean doInstantiate();
}
Modified: trunk/spring-int/src/main/org/jboss/spring/factory/Nameable.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/Nameable.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/Nameable.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -28,6 +28,6 @@
public interface Nameable
{
- String getName();
+ String getName();
}
Modified: trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlApplicationContext.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlApplicationContext.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlApplicationContext.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,6 +22,8 @@
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;
@@ -29,72 +31,70 @@
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.Resource;
-import java.io.IOException;
-
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
public class NamedXmlApplicationContext extends ClassPathXmlApplicationContext
- implements Nameable
+ implements Nameable
{
- private String defaultName;
- private Resource resource;
- private NamedXmlBeanDefinitionReader beanDefinitionReader;
+ private String defaultName;
+ private Resource resource;
+ private NamedXmlBeanDefinitionReader beanDefinitionReader;
- /**
- * @see org.springframework.beans.factory.xml.XmlBeanFactory
- */
- public NamedXmlApplicationContext(String defaultName, Resource resource) throws BeansException
- {
- this(defaultName, resource, true);
- }
+ /**
+ * @see org.springframework.beans.factory.xml.XmlBeanFactory
+ */
+ 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();
- }
- }
+ 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);
+ 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));
+ // 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);
- }
+ // 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);
- }
+ 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;
- }
+ 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;
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanDefinitionParser.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanDefinitionParser.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanDefinitionParser.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,95 +22,94 @@
package org.jboss.spring.factory;
-import org.jboss.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import org.jboss.util.naming.Util;
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.DefaultXmlBeanDefinitionParser;
+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;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
-public class NamedXmlBeanDefinitionParser extends DefaultXmlBeanDefinitionParser
- implements Nameable, Instantiable
+public class NamedXmlBeanDefinitionParser extends DefaultBeanDefinitionDocumentReader
+ implements Nameable, Instantiable
{
- private static final Logger log = Logger.getLogger(NamedXmlBeanDefinitionParser.class);
- private static final String DESCRIPTION_ELEMENT = "description";
- public static final String BEAN_FACTORY_ELEMENT = "BeanFactory=\\(([^)]+)\\)";
- public static final String PARENT_BEAN_FACTORY_ELEMENT = "ParentBeanFactory=\\(([^)]+)\\)";
- public static final String INSTANTIATION_ELEMENT = "Instantiate=\\(([^)]+)\\)";
+ 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;
+ private ConfigurableBeanFactory beanFactory;
+ private String beanFactoryName;
+ private boolean instantiate;
- public NamedXmlBeanDefinitionParser(ConfigurableBeanFactory beanFactory)
- {
- this.beanFactory = beanFactory;
- }
+ 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)
+ 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()))
{
- Element ele = (Element) node;
- if (DESCRIPTION_ELEMENT.equals(node.getNodeName()))
- {
- String nodeValue = ele.getFirstChild().getNodeValue();
- log.info("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));
- }
- }
+ String nodeValue = ele.getFirstChild().getNodeValue();
+ logger.info("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 String getName()
+ {
+ return beanFactoryName;
+ }
- public boolean doInstantiate()
- {
- return instantiate;
- }
+ public boolean doInstantiate()
+ {
+ return instantiate;
+ }
- private static Matcher parse(String value, String regexp)
- {
- Pattern pattern = Pattern.compile(regexp);
- return pattern.matcher(value);
- }
+ private static Matcher parse(String value, String regexp)
+ {
+ Pattern pattern = Pattern.compile(regexp);
+ return pattern.matcher(value);
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanDefinitionReader.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanDefinitionReader.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanDefinitionReader.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -33,36 +33,36 @@
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
public class NamedXmlBeanDefinitionReader extends XmlBeanDefinitionReader
- implements Nameable, Instantiable
+ implements Nameable, Instantiable
{
- private NamedXmlBeanDefinitionParser parser;
+ 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 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 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 String getName()
+ {
+ return parser.getName();
+ }
- public boolean doInstantiate()
- {
- return parser.doInstantiate();
- }
+ public boolean doInstantiate()
+ {
+ return parser.doInstantiate();
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanFactory.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanFactory.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/factory/NamedXmlBeanFactory.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -30,34 +30,34 @@
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
public class NamedXmlBeanFactory extends DefaultListableBeanFactory
- implements Nameable, Instantiable
+ implements Nameable, Instantiable
{
- private String defaultName;
- private final NamedXmlBeanDefinitionReader reader = new NamedXmlBeanDefinitionReader(this);
+ private String defaultName;
+ private final NamedXmlBeanDefinitionReader reader = new NamedXmlBeanDefinitionReader(this);
- /**
- * @see org.springframework.beans.factory.xml.XmlBeanFactory
- */
- public NamedXmlBeanFactory(String defaultName, Resource resource) throws BeansException
- {
- this.reader.loadBeanDefinitions(resource);
- this.defaultName = defaultName;
- }
+ /**
+ * @see org.springframework.beans.factory.xml.XmlBeanFactory
+ */
+ 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 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();
- }
+ public boolean doInstantiate()
+ {
+ 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 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/interceptor/SpringInjectionInterceptor.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -38,26 +38,26 @@
public class SpringInjectionInterceptor extends SpringInjectionSupport implements Interceptor
{
- public SpringInjectionInterceptor()
- {
- log.info("Instantiating " + getName());
- }
+ public SpringInjectionInterceptor()
+ {
+ log.info("Instantiating " + getName());
+ }
- public String getName()
- {
- return "SpringInjectionInterceptor";
- }
+ 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;
- }
+ 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;
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/ContextMicrocontainerConfigurer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/ContextMicrocontainerConfigurer.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/ContextMicrocontainerConfigurer.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -30,56 +30,57 @@
/**
* Used as a post processor singleton declared directly in .xml descriptor file.
*
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
* @see MicrocontainerConfigurer
* @see org.springframework.beans.factory.config.AutowireCapableBeanFactory
- *
- * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
public class ContextMicrocontainerConfigurer extends MicrocontainerConfigurer
- implements BeanNameAware, BeanFactoryAware
+ implements BeanNameAware, BeanFactoryAware
{
- private String beanName;
- private BeanFactory beanFactory;
+ private String beanName;
+ private BeanFactory beanFactory;
- public ContextMicrocontainerConfigurer()
- {
- setLocator(new KernelBinderLocator());
- }
+ public ContextMicrocontainerConfigurer()
+ {
+ setLocator(new KernelBinderLocator());
+ }
- /**
- * Check that we're not parsing our own bean definition,
- * to avoid failing on unresolvable placeholders in properties file locations.
- */
- protected boolean checkBean(ConfigurableBeanFactory beanFactoryToProcess, String beanName)
- {
- return !(beanName.equals(this.beanName) && beanFactoryToProcess.equals(this.beanFactory));
- }
+ /**
+ * Check that we're not parsing our own bean definition,
+ * to avoid failing on unresolvable placeholders in properties file locations.
+ */
+ protected boolean checkBean(ConfigurableBeanFactory beanFactoryToProcess, String beanName)
+ {
+ return !(beanName.equals(this.beanName) && beanFactoryToProcess.equals(this.beanFactory));
+ }
- /**
- * Only necessary to check that we're not parsing our own bean definition,
- * to avoid failing on unresolvable placeholders in properties file locations.
- * The latter case can happen with placeholders for system properties in
- * resource locations.
- * @see #setLocations
- * @see org.springframework.core.io.ResourceEditor
- */
- public void setBeanName(String beanName)
- {
- this.beanName = beanName;
- }
+ /**
+ * Only necessary to check that we're not parsing our own bean definition,
+ * to avoid failing on unresolvable placeholders in properties file locations.
+ * The latter case can happen with placeholders for system properties in
+ * resource locations.
+ *
+ * @see #setLocations
+ * @see org.springframework.core.io.ResourceEditor
+ */
+ public void setBeanName(String beanName)
+ {
+ this.beanName = beanName;
+ }
- /**
- * Only necessary to check that we're not parsing our own bean definition,
- * to avoid failing on unresolvable placeholders in properties file locations.
- * The latter case can happen with placeholders for system properties in
- * resource locations.
- * @see #setLocations
- * @see org.springframework.core.io.ResourceEditor
- */
- public void setBeanFactory(BeanFactory beanFactory)
- {
- this.beanFactory = beanFactory;
- }
+ /**
+ * Only necessary to check that we're not parsing our own bean definition,
+ * to avoid failing on unresolvable placeholders in properties file locations.
+ * The latter case can happen with placeholders for system properties in
+ * resource locations.
+ *
+ * @see #setLocations
+ * @see org.springframework.core.io.ResourceEditor
+ */
+ public void setBeanFactory(BeanFactory beanFactory)
+ {
+ this.beanFactory = beanFactory;
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/ControllerLocator.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/ControllerLocator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/ControllerLocator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -17,30 +17,30 @@
public class ControllerLocator implements Locator
{
- private KernelController controller;
+ private KernelController controller;
- protected ControllerLocator()
- {
- }
+ protected ControllerLocator()
+ {
+ }
- public ControllerLocator(KernelController controller)
- {
- this.controller = controller;
- }
+ public ControllerLocator(KernelController controller)
+ {
+ this.controller = controller;
+ }
- public KernelController getController()
- {
- return controller;
- }
+ public KernelController getController()
+ {
+ return controller;
+ }
- public Object locateBean(String beanName)
- {
- ControllerContext context = getController().getInstalledContext(beanName);
- if (context == null)
- {
- return null;
- }
- return context.getTarget();
- }
+ public Object locateBean(String beanName)
+ {
+ ControllerContext context = getController().getInstalledContext(beanName);
+ if (context == null)
+ {
+ return null;
+ }
+ return context.getTarget();
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/KernelBinderLocator.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/KernelBinderLocator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/KernelBinderLocator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -34,21 +34,21 @@
public class KernelBinderLocator extends KernelLocator
{
- public synchronized Kernel getKernel()
- {
- Kernel kernel = super.getKernel();
- if (kernel == null)
- {
- kernel = lookupKernel();
- setKernel(kernel);
- }
- return kernel;
- }
+ public synchronized Kernel getKernel()
+ {
+ Kernel kernel = super.getKernel();
+ if (kernel == null)
+ {
+ kernel = lookupKernel();
+ setKernel(kernel);
+ }
+ return kernel;
+ }
- // todo - bind jbossas5 kernel
- private Kernel lookupKernel()
- {
- throw new UnsupportedOperationException("MC kernel lookup not yet implemented!");
- }
+ // todo - bind jbossas5 kernel
+ private Kernel lookupKernel()
+ {
+ throw new UnsupportedOperationException("MC kernel lookup not yet implemented!");
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/KernelLocator.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/KernelLocator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/KernelLocator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -17,30 +17,30 @@
public class KernelLocator extends ControllerLocator
{
- private Kernel kernel;
+ private Kernel kernel;
- protected KernelLocator()
- {
- }
+ protected KernelLocator()
+ {
+ }
- public KernelLocator(Kernel kernel)
- {
- this.kernel = kernel;
- }
+ public KernelLocator(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
- public Kernel getKernel()
- {
- return kernel;
- }
+ public Kernel getKernel()
+ {
+ return kernel;
+ }
- protected void setKernel(Kernel kernel)
- {
- this.kernel = kernel;
- }
+ protected void setKernel(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
- public KernelController getController()
- {
- return getKernel().getController();
- }
+ public KernelController getController()
+ {
+ return getKernel().getController();
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/LazyLocator.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/LazyLocator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/LazyLocator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -30,62 +30,61 @@
* Must have delegating locator set.
* By default NullLocator is delegating locator.
*
- * @see NullLocator
- *
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ * @see NullLocator
*/
public class LazyLocator extends MicrocontainerLocatorSupport implements Locator
{
- public Object locateBean(String beanName, Class targetType)
- {
- TargetSource targetSource = new LocatorTargetSource(beanName, targetType);
- ProxyFactory proxyFactory = new ProxyFactory();
- proxyFactory.addInterface(targetType);
- proxyFactory.setTargetSource(targetSource);
- return proxyFactory.getProxy();
- }
+ public Object locateBean(String beanName, Class targetType)
+ {
+ TargetSource targetSource = new LocatorTargetSource(beanName, targetType);
+ ProxyFactory proxyFactory = new ProxyFactory();
+ proxyFactory.addInterface(targetType);
+ proxyFactory.setTargetSource(targetSource);
+ return proxyFactory.getProxy();
+ }
- private class LocatorTargetSource implements TargetSource
- {
+ private class LocatorTargetSource implements TargetSource
+ {
- private String beanName;
- private Class targetClass;
+ private String beanName;
+ private Class targetClass;
- private Object cachedObject;
+ private Object cachedObject;
- public LocatorTargetSource(String beanName, Class targetClass)
- {
- this.beanName = beanName;
- this.targetClass = targetClass;
- }
+ public LocatorTargetSource(String beanName, Class targetClass)
+ {
+ this.beanName = beanName;
+ this.targetClass = targetClass;
+ }
- public Class getTargetClass()
- {
- return (this.cachedObject != null ? this.cachedObject.getClass() : this.targetClass);
- }
+ public Class getTargetClass()
+ {
+ return (this.cachedObject != null ? this.cachedObject.getClass() : this.targetClass);
+ }
- public boolean isStatic()
- {
- return (this.cachedObject != null);
- }
+ public boolean isStatic()
+ {
+ return (this.cachedObject != null);
+ }
- public Object getTarget() throws Exception
- {
- synchronized (this)
+ public Object getTarget() throws Exception
+ {
+ synchronized (this)
+ {
+ if (this.cachedObject == null)
{
- if (this.cachedObject == null)
- {
- this.cachedObject = locateBean(beanName, targetClass);
- }
- return this.cachedObject;
+ this.cachedObject = locateBean(beanName, targetClass);
}
- }
+ return this.cachedObject;
+ }
+ }
- public void releaseTarget(Object target)
- {
- }
+ public void releaseTarget(Object target)
+ {
+ }
- }
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/Locator.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/Locator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/Locator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -14,6 +14,6 @@
public interface Locator
{
- Object locateBean(String beanName);
+ Object locateBean(String beanName);
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/MapLocator.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/MapLocator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/MapLocator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -16,21 +16,21 @@
public class MapLocator implements Locator
{
- private Map map;
+ private Map map;
- public MapLocator(Map map)
- {
- this.map = map;
- }
+ public MapLocator(Map map)
+ {
+ this.map = map;
+ }
- public Map getMap()
- {
- return map;
- }
+ public Map getMap()
+ {
+ return map;
+ }
- public Object locateBean(String beanName)
- {
- return getMap().get(beanName);
- }
+ public Object locateBean(String beanName)
+ {
+ return getMap().get(beanName);
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerConfigurer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerConfigurer.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerConfigurer.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -20,125 +20,125 @@
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
public class MicrocontainerConfigurer extends MicrocontainerLocatorSupport
- implements BeanFactoryPostProcessor, BeanNameAware, BeanFactoryAware, Ordered
+ implements BeanFactoryPostProcessor, BeanNameAware, BeanFactoryAware, Ordered
{
- private String beanName;
- private BeanFactory beanFactory;
- private int order = Integer.MAX_VALUE;
+ private String beanName;
+ private BeanFactory beanFactory;
+ private int order = Integer.MAX_VALUE;
- private String prefix = "mc${";
+ private String prefix = "mc${";
- public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactoryToProcess) throws BeansException
- {
- BeanDefinitionVisitor visitor = new MicrocontainerBeanDefinitionVisitor();
- String[] beanNames = beanFactoryToProcess.getBeanDefinitionNames();
- //noinspection ForLoopReplaceableByForEach
- for (int i = 0; i < beanNames.length; i++)
- {
- // Check that we're not parsing our own bean definition,
- // to avoid failing on unresolvable placeholders in properties file locations.
- if (!(beanNames[i].equals(this.beanName) && beanFactoryToProcess.equals(this.beanFactory)))
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactoryToProcess) throws BeansException
+ {
+ BeanDefinitionVisitor visitor = new MicrocontainerBeanDefinitionVisitor();
+ String[] beanNames = beanFactoryToProcess.getBeanDefinitionNames();
+ //noinspection ForLoopReplaceableByForEach
+ for (int i = 0; i < beanNames.length; i++)
+ {
+ // Check that we're not parsing our own bean definition,
+ // to avoid failing on unresolvable placeholders in properties file locations.
+ if (!(beanNames[i].equals(this.beanName) && beanFactoryToProcess.equals(this.beanFactory)))
+ {
+ BeanDefinition bd = beanFactoryToProcess.getBeanDefinition(beanNames[i]);
+ try
{
- BeanDefinition bd = beanFactoryToProcess.getBeanDefinition(beanNames[i]);
- try
- {
- visitor.visitBeanDefinition(bd);
- }
- catch (BeanDefinitionStoreException ex)
- {
- throw new BeanDefinitionStoreException(bd.getResourceDescription(), beanNames[i], ex.getMessage());
- }
+ visitor.visitBeanDefinition(bd);
}
- }
- }
+ catch (BeanDefinitionStoreException ex)
+ {
+ throw new BeanDefinitionStoreException(bd.getResourceDescription(), beanNames[i], ex.getMessage());
+ }
+ }
+ }
+ }
- protected boolean isMicrocontainerRef(String value)
- {
- return value != null && value.startsWith(prefix);
- }
+ protected boolean isMicrocontainerRef(String value)
+ {
+ return value != null && value.startsWith(prefix);
+ }
- protected String parseBeansReference(String value)
- {
- int endIndex = value.lastIndexOf("$");
- endIndex = endIndex >= 0 ? endIndex : value.length();
- return value.substring(prefix.length(), endIndex);
- }
+ protected String parseBeansReference(String value)
+ {
+ int endIndex = value.lastIndexOf("$");
+ endIndex = endIndex >= 0 ? endIndex : value.length();
+ return value.substring(prefix.length(), endIndex);
+ }
- private class MicrocontainerBeanDefinitionVisitor extends BeanDefinitionVisitor
- {
+ private class MicrocontainerBeanDefinitionVisitor extends BeanDefinitionVisitor
+ {
- protected String resolveStringValue(String strVal)
- {
- return strVal;
- }
+ protected String resolveStringValue(String strVal)
+ {
+ return strVal;
+ }
- protected Object resolveValue(Object value)
- {
- value = super.resolveValue(value);
- if (value instanceof TypedStringValue)
+ protected Object resolveValue(Object value)
+ {
+ value = super.resolveValue(value);
+ if (value instanceof TypedStringValue)
+ {
+ TypedStringValue typedStringValue = (TypedStringValue) value;
+ String beansRef = typedStringValue.getValue();
+ if (isMicrocontainerRef(beansRef))
{
- TypedStringValue typedStringValue = (TypedStringValue) value;
- String beansRef = typedStringValue.getValue();
- if (isMicrocontainerRef(beansRef))
- {
- return locateBean(parseBeansReference(beansRef));
- }
+ return locateBean(parseBeansReference(beansRef));
}
- if (value instanceof String)
+ }
+ if (value instanceof String)
+ {
+ String beansRef = (String) value;
+ if (isMicrocontainerRef(beansRef))
{
- String beansRef = (String) value;
- if (isMicrocontainerRef(beansRef))
- {
- return locateBean(parseBeansReference(beansRef));
- }
+ return locateBean(parseBeansReference(beansRef));
}
- return value;
- }
+ }
+ return value;
+ }
- }
+ }
- /**
- * Only necessary to check that we're not parsing our own bean definition,
- * to avoid failing on unresolvable placeholders in properties file locations.
- * The latter case can happen with placeholders for system properties in
- * resource locations.
- *
- * @see #setLocations
- * @see org.springframework.core.io.ResourceEditor
- */
- public void setBeanName(String beanName)
- {
- this.beanName = beanName;
- }
+ /**
+ * Only necessary to check that we're not parsing our own bean definition,
+ * to avoid failing on unresolvable placeholders in properties file locations.
+ * The latter case can happen with placeholders for system properties in
+ * resource locations.
+ *
+ * @see #setLocations
+ * @see org.springframework.core.io.ResourceEditor
+ */
+ public void setBeanName(String beanName)
+ {
+ this.beanName = beanName;
+ }
- /**
- * Only necessary to check that we're not parsing our own bean definition,
- * to avoid failing on unresolvable placeholders in properties file locations.
- * The latter case can happen with placeholders for system properties in
- * resource locations.
- *
- * @see #setLocations
- * @see org.springframework.core.io.ResourceEditor
- */
- public void setBeanFactory(BeanFactory beanFactory)
- {
- this.beanFactory = beanFactory;
- }
+ /**
+ * Only necessary to check that we're not parsing our own bean definition,
+ * to avoid failing on unresolvable placeholders in properties file locations.
+ * The latter case can happen with placeholders for system properties in
+ * resource locations.
+ *
+ * @see #setLocations
+ * @see org.springframework.core.io.ResourceEditor
+ */
+ public void setBeanFactory(BeanFactory beanFactory)
+ {
+ this.beanFactory = beanFactory;
+ }
- public int getOrder()
- {
- return order;
- }
+ public int getOrder()
+ {
+ return order;
+ }
- public void setOrder(int order)
- {
- this.order = order;
- }
+ public void setOrder(int order)
+ {
+ this.order = order;
+ }
- public void setPrefix(String prefix)
- {
- this.prefix = prefix;
- }
+ public void setPrefix(String prefix)
+ {
+ this.prefix = prefix;
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerLoaderImpl.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerLoaderImpl.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerLoaderImpl.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -37,44 +37,45 @@
public class MicrocontainerLoaderImpl extends AbstractBeanFactoryLoader
{
- protected BeanFactory createBeanFactory(String defaultName, Resource resource)
- {
- ConfigurableApplicationContext applicationContext = new NamedXmlApplicationContext(defaultName, resource, false);
- MicrocontainerConfigurer microcontainerPostProcessor = new MicrocontainerConfigurer();
- Locator locator = new NullLocator();
- KernelController controller = getKernelController();
- Kernel kernel = getKernel();
- if (controller != null)
- {
- locator = new ControllerLocator(controller);
- } else if (kernel != null)
- {
- locator = new KernelLocator(kernel);
- }
- microcontainerPostProcessor.setLocator(locator);
- applicationContext.addBeanFactoryPostProcessor(microcontainerPostProcessor);
- applicationContext.refresh();
- return applicationContext;
- }
+ protected BeanFactory createBeanFactory(String defaultName, Resource resource)
+ {
+ ConfigurableApplicationContext applicationContext = new NamedXmlApplicationContext(defaultName, resource, false);
+ MicrocontainerConfigurer microcontainerPostProcessor = new MicrocontainerConfigurer();
+ Locator locator = new NullLocator();
+ KernelController controller = getKernelController();
+ Kernel kernel = getKernel();
+ if (controller != null)
+ {
+ locator = new ControllerLocator(controller);
+ }
+ else if (kernel != null)
+ {
+ locator = new KernelLocator(kernel);
+ }
+ microcontainerPostProcessor.setLocator(locator);
+ applicationContext.addBeanFactoryPostProcessor(microcontainerPostProcessor);
+ applicationContext.refresh();
+ return applicationContext;
+ }
- protected void doClose(BeanFactory beanFactory)
- {
- ((ConfigurableApplicationContext) beanFactory).close();
- }
+ protected void doClose(BeanFactory beanFactory)
+ {
+ ((ConfigurableApplicationContext) beanFactory).close();
+ }
- protected Class getExactBeanFactoryClass()
- {
- return ApplicationContext.class;
- }
+ protected Class getExactBeanFactoryClass()
+ {
+ return ApplicationContext.class;
+ }
- protected Kernel getKernel()
- {
- return null;
- }
+ protected Kernel getKernel()
+ {
+ return null;
+ }
- protected KernelController getKernelController()
- {
- return null;
- }
+ protected KernelController getKernelController()
+ {
+ return null;
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerLocatorSupport.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerLocatorSupport.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/MicrocontainerLocatorSupport.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -14,30 +14,30 @@
public class MicrocontainerLocatorSupport
{
- private Locator locator = new NullLocator();
+ private Locator locator = new NullLocator();
- public MicrocontainerLocatorSupport()
- {
- }
+ public MicrocontainerLocatorSupport()
+ {
+ }
- public MicrocontainerLocatorSupport(Locator locator)
- {
- this.locator = locator;
- }
+ public MicrocontainerLocatorSupport(Locator locator)
+ {
+ this.locator = locator;
+ }
- public Locator getLocator()
- {
- return locator;
- }
+ public Locator getLocator()
+ {
+ return locator;
+ }
- public void setLocator(Locator locator)
- {
- this.locator = locator;
- }
+ public void setLocator(Locator locator)
+ {
+ this.locator = locator;
+ }
- public Object locateBean(String beanName)
- {
- return getLocator().locateBean(beanName);
- }
+ public Object locateBean(String beanName)
+ {
+ return getLocator().locateBean(beanName);
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/NullLocator.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/NullLocator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/NullLocator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -14,9 +14,9 @@
public class NullLocator implements Locator
{
- public Object locateBean(String beanName)
- {
- return null;
- }
+ public Object locateBean(String beanName)
+ {
+ return null;
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/SpringMicrocontainerDeployer.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/SpringMicrocontainerDeployer.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/SpringMicrocontainerDeployer.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -9,11 +9,11 @@
package org.jboss.spring.kernel;
+import javax.management.ObjectName;
+
import org.jboss.spring.deployment.SpringDeployer;
import org.jboss.spring.factory.BeanFactoryLoader;
-import javax.management.ObjectName;
-
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
* @jmx:mbean name="jboss.spring:service=SpringApplicationContextDeployer"
@@ -22,23 +22,23 @@
public class SpringMicrocontainerDeployer extends SpringDeployer
{
- //default object name
- public static final ObjectName OBJECT_NAME =
- org.jboss.mx.util.ObjectNameFactory.create("jboss.spring:service=SpringMicrocontainerDeployer");
+ //default object name
+ public static final ObjectName OBJECT_NAME =
+ org.jboss.mx.util.ObjectNameFactory.create("jboss.spring:service=SpringMicrocontainerDeployer");
- public SpringMicrocontainerDeployer()
- {
- super();
- }
+ public SpringMicrocontainerDeployer()
+ {
+ super();
+ }
- protected BeanFactoryLoader createBeanFactoryLoader()
- {
- return new MicrocontainerLoaderImpl();
- }
+ protected BeanFactoryLoader createBeanFactoryLoader()
+ {
+ return new MicrocontainerLoaderImpl();
+ }
- protected ObjectName getDefaultObjectName()
- {
- return OBJECT_NAME;
- }
+ protected ObjectName getDefaultObjectName()
+ {
+ return OBJECT_NAME;
+ }
}
Modified: trunk/spring-int/src/main/org/jboss/spring/kernel/SpringMicrocontainerDeployerMBean.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/kernel/SpringMicrocontainerDeployerMBean.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/kernel/SpringMicrocontainerDeployerMBean.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -25,6 +25,7 @@
/**
* MBean interface.
+ *
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
public interface SpringMicrocontainerDeployerMBean extends SpringDeployerMBean
Modified: trunk/spring-int/src/main/org/jboss/spring/support/SpringInjectionSupport.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/support/SpringInjectionSupport.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/main/org/jboss/spring/support/SpringInjectionSupport.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,17 +22,17 @@
package org.jboss.spring.support;
-import org.jboss.annotation.spring.Spring;
-import org.jboss.logging.Logger;
-import org.jboss.naming.Util;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.util.Assert;
-
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.
@@ -45,166 +45,212 @@
public abstract class SpringInjectionSupport
{
- protected Logger log = Logger.getLogger(getClass());
- private final Comparator<Method> METHOD_COMPARATOR = new MethodComparator();
+ protected Logger log = Logger.getLogger(getClass());
+ private final Comparator<Method> METHOD_COMPARATOR = new MethodComparator();
- protected Object inject(Object target) throws Exception
- {
+ protected Object inject(Object target) throws Exception
+ {
- log.debug("Invoking Spring injection: " + target.getClass().getName());
+ 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)
+ Method[] methods = getAllMethods(target);
+ for (Method m : methods)
+ {
+ Spring spring = m.getAnnotation(Spring.class);
+ if (spring != null)
+ {
+ if (isSetterMethod(m))
{
- if (isSetterMethod(m))
- {
- injectToMethod(target, m, spring);
- } else
- {
- log.warn("Spring annotation only allowed on setter methods.");
- }
+ injectToMethod(target, m, spring);
}
- }
-
- Field[] fields = getAllFields(target);
- for (Field f : fields)
- {
- Spring spring = f.getAnnotation(Spring.class);
- if (spring != null)
+ else
{
- injectToField(target, f, spring);
+ log.warn("Spring annotation only allowed on setter methods.");
}
- }
+ }
+ }
- return target;
- }
+ Field[] fields = getAllFields(target);
+ for (Field f : fields)
+ {
+ Spring spring = f.getAnnotation(Spring.class);
+ if (spring != null)
+ {
+ injectToField(target, f, spring);
+ }
+ }
- 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()]);
- }
+ return target;
+ }
- 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()]);
- }
+ 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()]);
+ }
- private boolean isSetterMethod(Method m)
- {
- return m.getName().startsWith("set") && m.getParameterTypes().length == 1;
- }
+ 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 Object getObjectFromBeanFactory(Spring spring) throws Exception
- {
- BeanFactory beanFactory = (BeanFactory) Util.lookup(spring.jndiName(), BeanFactory.class);
- return beanFactory.getBean(spring.bean());
- }
+ private boolean isSetterMethod(Method m)
+ {
+ return m.getName().startsWith("set") && m.getParameterTypes().length == 1;
+ }
- private void injectToMethod(Object target, Method method, Spring spring) throws Exception
- {
- Object bean = getObjectFromBeanFactory(spring);
- doAssert(bean, method.getParameterTypes()[0]);
- logInjection(spring, bean, target, method);
- method.setAccessible(true);
- method.invoke(target, bean);
- }
+ private Object getObjectFromBeanFactory(Spring spring, String defaultBeanName, Class beanType) throws Exception
+ {
+ BeanFactory beanFactory = (BeanFactory) Util.lookup(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 injectToField(Object target, Field field, Spring spring) throws Exception
- {
- Object bean = getObjectFromBeanFactory(spring);
- doAssert(bean, field.getType());
- logInjection(spring, bean, target, field);
- field.setAccessible(true);
- field.set(target, bean);
- }
+ 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);
+ }
- private void doAssert(Object bean, Class expectedBeanClass)
- {
- Assert.isTrue(expectedBeanClass.isAssignableFrom(bean.getClass()),
- "Illegal bean class type - " + bean.getClass().getName() +
- " - cannot be assigned to: " + expectedBeanClass.getName());
- }
+ 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 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);
- }
+ 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);
+ }
- /**
- * Equals on overridden methods.
- * Any other solution?
- */
- private class MethodComparator implements Comparator<Method>
- {
+ protected String getDefaultBeanName(Field field)
+ {
+ return field.getName();
+ }
- public int compare(Method m1, Method m2)
- {
- String name1 = m1.getName();
- String name2 = m2.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);
+ }
- if (name1.equals(name2))
+ /**
+ * 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)
{
- 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
+ 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 name1.compareTo(name2);
+ return params1.length - params2.length;
}
- }
+ }
+ else
+ {
+ return name1.compareTo(name2);
+ }
+ }
- }
+ }
}
Modified: trunk/spring-int/src/resources/jboss-service.xml
===================================================================
--- trunk/spring-int/src/resources/jboss-service.xml 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/resources/jboss-service.xml 2006-10-19 11:43:35 UTC (rev 57727)
@@ -2,18 +2,17 @@
<!DOCTYPE server>
-
<server>
- <!--
- Defines the Spring deployer service. See the javadocs for
- org.jboss.spring.deployment.SpringDeployer for more info.
- -->
+ <!--
+ Defines the Spring deployer service. See the javadocs for
+ org.jboss.spring.deployment.SpringDeployer for more info.
+ -->
- <!--<mbean code="org.jboss.spring.deployment.SpringBeanFactoryDeployer" name="jboss.spring:service=SpringBeanFactoryDeployer" />-->
+ <!--<mbean code="org.jboss.spring.deployment.SpringBeanFactoryDeployer" name="jboss.spring:service=SpringBeanFactoryDeployer" />-->
- <mbean code="org.jboss.spring.deployment.SpringApplicationContextDeployer"
- name="jboss.spring:service=SpringApplicationContextDeployer"/>
+ <mbean code="org.jboss.spring.deployment.SpringApplicationContextDeployer"
+ name="jboss.spring:service=SpringApplicationContextDeployer"/>
</server>
Modified: trunk/spring-int/src/resources/test/dd/application.xml
===================================================================
--- trunk/spring-int/src/resources/test/dd/application.xml 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/resources/test/dd/application.xml 2006-10-19 11:43:35 UTC (rev 57727)
@@ -2,22 +2,22 @@
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
- <display-name>JBoss Spring</display-name>
- <description>J2EE Made Easy - JBoss + Spring</description>
+ <display-name>JBoss Spring</display-name>
+ <description>J2EE Made Easy - JBoss + Spring</description>
- <module>
- <ejb>spring-pojo.spring</ejb>
- </module>
+ <module>
+ <ejb>spring-pojo.spring</ejb>
+ </module>
- <module>
- <ejb>business.ejb3</ejb>
- </module>
+ <module>
+ <ejb>business.ejb3</ejb>
+ </module>
- <module>
- <web>
- <web-uri>web.war</web-uri>
- <context-root>jboss-spring</context-root>
- </web>
- </module>
+ <module>
+ <web>
+ <web-uri>web.war</web-uri>
+ <context-root>jboss-spring</context-root>
+ </web>
+ </module>
</application>
Modified: trunk/spring-int/src/resources/test/dd/spring/jboss-spring.xml
===================================================================
--- trunk/spring-int/src/resources/test/dd/spring/jboss-spring.xml 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/resources/test/dd/spring/jboss-spring.xml 2006-10-19 11:43:35 UTC (rev 57727)
@@ -3,45 +3,45 @@
<beans>
- <!-- File line readers -->
+ <!-- File line readers -->
- <bean id="fileLineReader" class="org.jboss.tutorial.spring.FileLineReader" abstract="true"/>
+ <bean id="fileLineReader" class="org.jboss.tutorial.spring.FileLineReader" abstract="true"/>
- <bean id="randomFileLineReader"
- class="org.jboss.tutorial.spring.RandomFileWordsCreator"
- parent="fileLineReader"
- abstract="true">
- <property name="intCreator">
- <ref local="javaRandomIntCreator"/>
- </property>
- </bean>
+ <bean id="randomFileLineReader"
+ class="org.jboss.tutorial.spring.RandomFileWordsCreator"
+ parent="fileLineReader"
+ abstract="true">
+ <property name="intCreator">
+ <ref local="javaRandomIntCreator"/>
+ </property>
+ </bean>
- <!-- Randomizer beans -->
+ <!-- Randomizer beans -->
- <bean id="staticWordsCreator" class="org.jboss.tutorial.spring.StaticWordsCreator"/>
+ <bean id="staticWordsCreator" class="org.jboss.tutorial.spring.StaticWordsCreator"/>
- <bean id="fileWordsCreator" parent="fileLineReader">
- <property name="resource">
- <value>classpath:words.properties</value>
- </property>
- </bean>
+ <bean id="fileWordsCreator" parent="fileLineReader">
+ <property name="resource">
+ <value>classpath:words.properties</value>
+ </property>
+ </bean>
- <bean id="randomWordsCreator" parent="randomFileLineReader">
- <property name="resource">
- <value>classpath:words.properties</value>
- </property>
- </bean>
+ <bean id="randomWordsCreator" parent="randomFileLineReader">
+ <property name="resource">
+ <value>classpath:words.properties</value>
+ </property>
+ </bean>
- <bean id="stateIntCreator" class="org.jboss.tutorial.spring.DummyStateIntCreator"/>
+ <bean id="stateIntCreator" class="org.jboss.tutorial.spring.DummyStateIntCreator"/>
- <bean id="javaRandomIntCreator" class="org.jboss.tutorial.spring.JavaRandomIntCreator"/>
+ <bean id="javaRandomIntCreator" class="org.jboss.tutorial.spring.JavaRandomIntCreator"/>
- <!-- Horoscope -->
+ <!-- Horoscope -->
- <bean id="horoscopeSentenceCreator" parent="fileLineReader">
- <property name="resource">
- <value>classpath:horoscope.properties</value>
- </property>
- </bean>
+ <bean id="horoscopeSentenceCreator" parent="fileLineReader">
+ <property name="resource">
+ <value>classpath:horoscope.properties</value>
+ </property>
+ </bean>
</beans>
Modified: trunk/spring-int/src/resources/test/dd/web/web.xml
===================================================================
--- trunk/spring-int/src/resources/test/dd/web/web.xml 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/resources/test/dd/web/web.xml 2006-10-19 11:43:35 UTC (rev 57727)
@@ -3,25 +3,25 @@
<web-app>
- <display-name>JBoss-Spring-Example</display-name>
+ <display-name>JBoss-Spring-Example</display-name>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
- <servlet>
- <servlet-name>jboss-spring</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
+ <servlet>
+ <servlet-name>jboss-spring</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
- <servlet-mapping>
- <servlet-name>jboss-spring</servlet-name>
- <url-pattern>*.htm</url-pattern>
- </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>jboss-spring</servlet-name>
+ <url-pattern>*.htm</url-pattern>
+ </servlet-mapping>
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
</web-app>
Modified: trunk/spring-int/src/resources/test/docs/JBoss-Spring-Example.html
===================================================================
--- trunk/spring-int/src/resources/test/docs/JBoss-Spring-Example.html 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/resources/test/docs/JBoss-Spring-Example.html 2006-10-19 11:43:35 UTC (rev 57727)
@@ -42,72 +42,72 @@
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal {
- mso-style-parent: "";
- margin: 0cm;
- margin-bottom: .0001pt;
- mso-pagination: widow-orphan;
- font-size: 12.0pt;
- font-family: "Times New Roman";
- mso-fareast-font-family: "Times New Roman";
+ mso-style-parent: "";
+ margin: 0cm;
+ margin-bottom: .0001pt;
+ mso-pagination: widow-orphan;
+ font-size: 12.0pt;
+ font-family: "Times New Roman";
+ mso-fareast-font-family: "Times New Roman";
}
h2 {
- mso-style-next: Normal;
- margin-top: 12.0pt;
- margin-right: 0cm;
- margin-bottom: 3.0pt;
- margin-left: 0cm;
- mso-pagination: widow-orphan;
- page-break-after: avoid;
- mso-outline-level: 2;
- font-size: 14.0pt;
- font-family: Arial;
- font-style: italic;
+ mso-style-next: Normal;
+ margin-top: 12.0pt;
+ margin-right: 0cm;
+ margin-bottom: 3.0pt;
+ margin-left: 0cm;
+ mso-pagination: widow-orphan;
+ page-break-after: avoid;
+ mso-outline-level: 2;
+ font-size: 14.0pt;
+ font-family: Arial;
+ font-style: italic;
}
a:link, span.MsoHyperlink {
- color: blue;
- text-decoration: underline;
- text-underline: single;
+ color: blue;
+ text-decoration: underline;
+ text-underline: single;
}
a:visited, span.MsoHyperlinkFollowed {
- color: purple;
- text-decoration: underline;
- text-underline: single;
+ color: purple;
+ text-decoration: underline;
+ text-underline: single;
}
pre {
- margin: 0cm;
- margin-bottom: .0001pt;
- mso-pagination: widow-orphan;
- tab-stops: 36.0pt;
- font-size: 10.0pt;
- font-family: "Courier New";
- mso-fareast-font-family: "Times New Roman";
+ margin: 0cm;
+ margin-bottom: .0001pt;
+ mso-pagination: widow-orphan;
+ tab-stops: 36.0pt;
+ font-size: 10.0pt;
+ font-family: "Courier New";
+ mso-fareast-font-family: "Times New Roman";
}
span.GramE {
- mso-style-name: "";
- mso-gram-e: yes;
+ mso-style-name: "";
+ mso-gram-e: yes;
}
@page
Section1
{
- size: 612.0pt 792.0pt
+ size: 612.0pt 792.0pt
;
- margin: 72.0pt 90.0pt 72.0pt 90.0pt
+ margin: 72.0pt 90.0pt 72.0pt 90.0pt
;
- mso-header-margin: 35.4pt
+ mso-header-margin: 35.4pt
;
- mso-footer-margin: 35.4pt
+ mso-footer-margin: 35.4pt
;
- mso-paper-source: 0
+ mso-paper-source: 0
;
}
div.Section1 {
- page: Section1;
+ page: Section1;
}
/* List Definitions */
@@ -313,6 +313,7 @@
mso-level-text
:
\F0B7
+
;
mso-level-tab-stop
:
@@ -369,6 +370,7 @@
mso-level-text
:
\F0B7
+
;
mso-level-tab-stop
:
@@ -424,6 +426,7 @@
mso-level-text
:
\F0B7
+
;
mso-level-tab-stop
:
@@ -480,6 +483,7 @@
mso-level-text
:
\F0B7
+
;
mso-level-tab-stop
:
@@ -580,6 +584,7 @@
mso-level-text
:
\F0B7
+
;
mso-level-tab-stop
:
@@ -607,11 +612,11 @@
;
}
ol {
- margin-bottom: 0cm;
+ margin-bottom: 0cm;
}
ul {
- margin-bottom: 0cm;
+ margin-bottom: 0cm;
}
-->
@@ -644,44 +649,44 @@
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The source shows how simple it is to inject <span
- class=GramE>Spring</span> managed fine grained POJO beans into EJB components.</p>
+ class=GramE>Spring</span> managed fine grained POJO beans into EJB components.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>First make sure that you have <span class=GramE>Spring</span>
- deployer in your JBOSS_HOME/server/default/deploy directory. That should be
- jboss-spring-jdk5.deployer directory with three jars and META-INF directory
- inside (jboss-spring-jdk5.jar, spring-beans.jar, spring-core.jar and
- META-INF/jboss-service.xml).</p>
+ deployer in your JBOSS_HOME/server/default/deploy directory. That should be
+ jboss-spring-jdk5.deployer directory with three jars and META-INF directory
+ inside (jboss-spring-jdk5.jar, spring-beans.jar, spring-core.jar and
+ META-INF/jboss-service.xml).</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Since our code is dependant on <span class=GramE>Spring</span>
- library, we must make sure that all of the needed classes are in our classpath.
- Copy spring-aop.jar, spring-context.jar, spring-web.jar and spring-webmvc.jar
- into JBOSS_HOME/server/default/lib directory.</p>
+ library, we must make sure that all of the needed classes are in our classpath.
+ Copy spring-aop.jar, spring-context.jar, spring-web.jar and spring-webmvc.jar
+ into JBOSS_HOME/server/default/lib directory.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Fix ejb3-interceptors-aop.xml in your JBOSS_HOME/server/default/deploy
- directory:</p>
+ directory:</p>
<p class=MsoNormal><o:p> </o:p></p>
<pre><span style='mso-spacerun:yes'>�� </span><interceptor class="org.jboss.ejb3.AllowedOperationsInterceptor"
- scope="PER_VM"/></pre><pre><o:p> </o:p></pre><pre><b
- style='mso-bidi-font-weight:normal'><span style='mso-spacerun:yes'>�� </span><interceptor class="org.jboss.spring.interceptor.SpringInjectionInterceptor"
- scope="PER_VM"/><o:p></o:p></b></pre><pre><o:p> </o:p></pre><pre><span
- style='mso-spacerun:yes'>�� </span><typedef name="ejb3intercepted" expr="<span
- class=GramE>class(</span>@javax.ejb.Interceptors) OR class(@javax.ejb.Interceptor) OR has(* *->@javax.ejb.AroundInvoke(..))"/>
+ scope="PER_VM"/></pre><pre><o:p> </o:p></pre><pre><b
+ style='mso-bidi-font-weight:normal'><span style='mso-spacerun:yes'>�� </span><interceptor class="org.jboss.spring.interceptor.SpringInjectionInterceptor"
+ scope="PER_VM"/><o:p></o:p></b></pre><pre><o:p> </o:p></pre><pre><span
+ style='mso-spacerun:yes'>�� </span><typedef name="ejb3intercepted" expr="<span
+ class=GramE>class(</span>@javax.ejb.Interceptors) OR class(@javax.ejb.Interceptor) OR has(* *->@javax.ejb.AroundInvoke(..))"/>
</pre><pre><o:p> </o:p></pre><pre><span style='mso-spacerun:yes'>�� </span><domain name="Stateless Bean">
</pre><pre><b
- style='mso-bidi-font-weight:normal'><span style='mso-spacerun:yes'>����� </span><bind pointcut="<span
- class=GramE>execution(</span>*->new(..))"><o:p></o:p></b></pre><pre><b
- style='mso-bidi-font-weight:normal'><span style='mso-spacerun:yes'>�������� </span><<span
- class=GramE>interceptor-ref</span> name="org.jboss.spring.interceptor.SpringInjectionInterceptor"/>
- <o:p></o:p></b></pre><pre><b
- style='mso-bidi-font-weight:normal'><span style='mso-spacerun:yes'>����� </span></bind><o:p></o:p></b>
+ style='mso-bidi-font-weight:normal'><span style='mso-spacerun:yes'>����� </span><bind pointcut="<span
+ class=GramE>execution(</span>*->new(..))"><o:p></o:p></b></pre><pre><b
+ style='mso-bidi-font-weight:normal'><span style='mso-spacerun:yes'>�������� </span><<span
+ class=GramE>interceptor-ref</span> name="org.jboss.spring.interceptor.SpringInjectionInterceptor"/>
+ <o:p></o:p></b></pre><pre><b
+ style='mso-bidi-font-weight:normal'><span style='mso-spacerun:yes'>����� </span></bind><o:p></o:p></b>
</pre>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p> </o:p></b></p>
@@ -691,81 +696,81 @@
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Looking at the source code you will see that our
- RandomizerBean class is declared as @Stateless session bean. The pointcut above
- will pick up our stateless session bean at instantiation time and perform <span
- class=GramE>Spring</span> injection interception.</p>
+ RandomizerBean class is declared as @Stateless session bean. The pointcut above
+ will pick up our stateless session bean at instantiation time and perform <span
+ class=GramE>Spring</span> injection interception.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The second example from source code shows how we can do <span
- class=GramE>Spring</span> bean injection in a <b style='mso-bidi-font-weight:
+ class=GramE>Spring</span> bean injection in a <b style='mso-bidi-font-weight:
normal'>non</b> AOP way. Look at the HoroscopeBean class which has a @CallbackListener
- annotation with the value SpringCallbackListener.class. Read the EJB3Trail
- application�s documentation (<a
- href="http://trailblazer.demo.jboss.com/EJB3Trail/serviceobjects/lifecycle/index.html">http://trailblazer.demo.jboss.com/EJB3Trail/serviceobjects/lifecycle/index.html</a>)
- on how callback listeners are used.</p>
+ annotation with the value SpringCallbackListener.class. Read the EJB3Trail
+ application�s documentation (<a
+ href="http://trailblazer.demo.jboss.com/EJB3Trail/serviceobjects/lifecycle/index.html">http://trailblazer.demo.jboss.com/EJB3Trail/serviceobjects/lifecycle/index.html</a>)
+ on how callback listeners are used.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Now you are all set to go. Unzip example�s archive into
- APP_HOME. Run Ant�s build script (APP_HOME/build.bat in Windows or
- APP_HOME/build.sh in Linux/Unix). Run default JBoss server (JBOSS_HOME/bin run).
- Drop JBoss-Spring.ear from APP_HOME/build/jar into JBOSS_HOME/server/default/deploy.
- The <span class=GramE>Spring</span> injection should take place the moment you
- will click on the application�s web page (<a
- href="http://localhost:8080/jboss-spring">http://localhost:8080/jboss-spring</a>).</p>
+ APP_HOME. Run Ant�s build script (APP_HOME/build.bat in Windows or
+ APP_HOME/build.sh in Linux/Unix). Run default JBoss server (JBOSS_HOME/bin run).
+ Drop JBoss-Spring.ear from APP_HOME/build/jar into JBOSS_HOME/server/default/deploy.
+ The <span class=GramE>Spring</span> injection should take place the moment you
+ will click on the application�s web page (<a
+ href="http://localhost:8080/jboss-spring">http://localhost:8080/jboss-spring</a>).</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Our <span class=GramE>Spring</span> deployer watches for the
- Spring components which should have the following suffixes: .spring for archive
- or �spring.xml for the beans descriptor. Spring beans descriptor inside archive
- is expected to be in META-INF directory by the name jboss-spring.xml.</p>
+ Spring components which should have the following suffixes: .spring for archive
+ or �spring.xml for the beans descriptor. Spring beans descriptor inside archive
+ is expected to be in META-INF directory by the name jboss-spring.xml.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>By default our bean factory�s JNDI name equals <span
- class=GramE>Spring</span> components name: <name>.spring or
- <name>-spring.xml. It can be overridden inside beans descriptor
- description tag. You can also set parent bean factory JNDI name:</p>
+ class=GramE>Spring</span> components name: <name>.spring or
+ <name>-spring.xml. It can be overridden inside beans descriptor
+ description tag. You can also set parent bean factory JNDI name:</p>
<p class=MsoNormal><o:p> </o:p></p>
<pre><<span class=GramE>beans</span>></pre><pre><o:p> </o:p></pre><pre><span
- style='mso-spacerun:yes'>��� </span><<span
- class=GramE>description></span>BeanFactory=(<name>) ParentBeanFactory=(<parent name>)</description>
+ style='mso-spacerun:yes'>��� </span><<span
+ class=GramE>description></span>BeanFactory=(<name>) ParentBeanFactory=(<parent name>)</description>
</pre><pre><o:p> </o:p></pre>
<p class=MsoNormal>There are different ways to deploy your <span class=GramE>Spring</span>
- beans. One with .ear file we just saw. But you can also deploy only your <span
- class=GramE>Spring</span> beans and let them be used by different applications.
- Instead of droping the whole .ear, you can just deploy .spring archive file or
- only beans descriptor. In descriptor�s case, its name must end with �spring.xml
- and, as expected, all the classes must already be made available on the
- classpath to the descriptor.</p>
+ beans. One with .ear file we just saw. But you can also deploy only your <span
+ class=GramE>Spring</span> beans and let them be used by different applications.
+ Instead of droping the whole .ear, you can just deploy .spring archive file or
+ only beans descriptor. In descriptor�s case, its name must end with �spring.xml
+ and, as expected, all the classes must already be made available on the
+ classpath to the descriptor.</p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Let�s look this on the example. Just drop spring-pojo.spring
- file from APP_HOME/build/jar into JBOSS_HOME/server/default/<span class=GramE>deploy
+ file from APP_HOME/build/jar into JBOSS_HOME/server/default/<span class=GramE>deploy
.</span> As before, bean factory with JNDI name �spring-pojo� gets deployed.
- You can now include this bean factory by setting its name as the parent bean
- factory name in your new beans factory xml descriptor:</p>
+ You can now include this bean factory by setting its name as the parent bean
+ factory name in your new beans factory xml descriptor:</p>
<p class=MsoNormal><o:p> </o:p></p>
<pre><<span class=GramE>beans</span>></pre><pre><o:p> </o:p></pre><pre><span
- style='mso-spacerun:yes'>���</span><<span
- class=GramE>description></span>ParentBeanFactory=(spring-pojo)</description></pre>
+ style='mso-spacerun:yes'>���</span><<span
+ class=GramE>description></span>ParentBeanFactory=(spring-pojo)</description></pre>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>When undeploying single files, be careful of the order of
- undeploying � take notice of bean factory hierarchy.</p>
+ undeploying � take notice of bean factory hierarchy.</p>
<p class=MsoNormal>When shutting down application server, the <span
- class=GramE>Spring</span> deployer will take care of correct undeployment
- order.</p>
+ class=GramE>Spring</span> deployer will take care of correct undeployment
+ order.</p>
</div>
Modified: trunk/spring-int/src/resources/test/ear/application.xml
===================================================================
--- trunk/spring-int/src/resources/test/ear/application.xml 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/resources/test/ear/application.xml 2006-10-19 11:43:35 UTC (rev 57727)
@@ -2,15 +2,15 @@
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
- <display-name>JBoss Spring Test</display-name>
- <description>J2EE Made Easy - JBoss + Spring</description>
+ <display-name>JBoss Spring Test</display-name>
+ <description>J2EE Made Easy - JBoss + Spring</description>
- <module>
- <ejb>spring-pojo-test.spring</ejb>
- </module>
+ <module>
+ <ejb>spring-pojo-test.spring</ejb>
+ </module>
- <module>
- <ejb>spring-business-test.jar</ejb>
- </module>
+ <module>
+ <ejb>spring-business-test.jar</ejb>
+ </module>
</application>
Modified: trunk/spring-int/src/resources/test/ear/business/META-INF/ejb-jar.xml
===================================================================
--- trunk/spring-int/src/resources/test/ear/business/META-INF/ejb-jar.xml 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/resources/test/ear/business/META-INF/ejb-jar.xml 2006-10-19 11:43:35 UTC (rev 57727)
@@ -1,8 +1,8 @@
<ejb-jar>
- <assembly-descriptor>
- <interceptor-binding>
- <ejb-name>*</ejb-name>
- <interceptor-class>org.jboss.spring.callback.SpringLifecycleInterceptor</interceptor-class>
- </interceptor-binding>
- </assembly-descriptor>
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+ <interceptor-class>org.jboss.spring.callback.SpringLifecycleInterceptor</interceptor-class>
+ </interceptor-binding>
+ </assembly-descriptor>
</ejb-jar>
Modified: trunk/spring-int/src/resources/test/ear/spring/META-INF/jboss-spring.xml
===================================================================
--- trunk/spring-int/src/resources/test/ear/spring/META-INF/jboss-spring.xml 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/resources/test/ear/spring/META-INF/jboss-spring.xml 2006-10-19 11:43:35 UTC (rev 57727)
@@ -3,11 +3,15 @@
<beans>
- <description>BeanFactory=(test)</description>
+ <description>BeanFactory=(test)</description>
- <bean id="tester" class="org.jboss.spring.test.ear.pojo.Tester">
- <property name="integerValue"><value>1</value></property>
- <property name="stringValue"><value>Ales</value></property>
- </bean>
+ <bean id="tester" class="org.jboss.spring.test.ear.pojo.Tester">
+ <property name="integerValue">
+ <value>1</value>
+ </property>
+ <property name="stringValue">
+ <value>Ales</value>
+ </property>
+ </bean>
</beans>
Modified: trunk/spring-int/src/resources/test/web/WEB-INF/applicationContext.xml
===================================================================
--- trunk/spring-int/src/resources/test/web/WEB-INF/applicationContext.xml 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/resources/test/web/WEB-INF/applicationContext.xml 2006-10-19 11:43:35 UTC (rev 57727)
@@ -3,22 +3,22 @@
<beans>
- <bean id="randomizer" class="org.springframework.jndi.JndiObjectFactoryBean">
- <property name="jndiName">
- <value>JBoss-Spring/RandomizerBean/local</value>
- </property>
- </bean>
+ <bean id="randomizer" class="org.springframework.jndi.JndiObjectFactoryBean">
+ <property name="jndiName">
+ <value>JBoss-Spring/RandomizerBean/local</value>
+ </property>
+ </bean>
- <bean id="horoscope" class="org.springframework.jndi.JndiObjectFactoryBean">
- <property name="cache">
- <value>false</value>
- </property>
- <property name="proxyInterface">
- <value>org.jboss.tutorial.ee.service.Horoscope</value>
- </property>
- <property name="jndiName">
- <value>JBoss-Spring/HoroscopeBean/local</value>
- </property>
- </bean>
+ <bean id="horoscope" class="org.springframework.jndi.JndiObjectFactoryBean">
+ <property name="cache">
+ <value>false</value>
+ </property>
+ <property name="proxyInterface">
+ <value>org.jboss.tutorial.ee.service.Horoscope</value>
+ </property>
+ <property name="jndiName">
+ <value>JBoss-Spring/HoroscopeBean/local</value>
+ </property>
+ </bean>
</beans>
\ No newline at end of file
Modified: trunk/spring-int/src/resources/test/web/WEB-INF/jboss-spring-servlet.xml
===================================================================
--- trunk/spring-int/src/resources/test/web/WEB-INF/jboss-spring-servlet.xml 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/resources/test/web/WEB-INF/jboss-spring-servlet.xml 2006-10-19 11:43:35 UTC (rev 57727)
@@ -6,45 +6,45 @@
-->
<beans>
- <bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
- <property name="basename">
- <value>views</value>
- </property>
- </bean>
+ <bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
+ <property name="basename">
+ <value>views</value>
+ </property>
+ </bean>
- <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
- <property name="mappings">
- <props>
- <prop key="/number.htm">appController</prop>
- <prop key="/word.htm">appController</prop>
- <prop key="/horoscope.htm">appController</prop>
- </props>
- </property>
- </bean>
+ <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
+ <property name="mappings">
+ <props>
+ <prop key="/number.htm">appController</prop>
+ <prop key="/word.htm">appController</prop>
+ <prop key="/horoscope.htm">appController</prop>
+ </props>
+ </property>
+ </bean>
- <!-- ========================= CONTROLLER DEFINITIONS ========================= -->
+ <!-- ========================= CONTROLLER DEFINITIONS ========================= -->
- <bean id="appControllerResolver"
- class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
- <property name="mappings">
- <props>
- <prop key="/number.htm">numberHandler</prop>
- <prop key="/word.htm">wordHandler</prop>
- <prop key="/horoscope.htm">horoscopeHandler</prop>
- </props>
- </property>
- </bean>
+ <bean id="appControllerResolver"
+ class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
+ <property name="mappings">
+ <props>
+ <prop key="/number.htm">numberHandler</prop>
+ <prop key="/word.htm">wordHandler</prop>
+ <prop key="/horoscope.htm">horoscopeHandler</prop>
+ </props>
+ </property>
+ </bean>
- <bean id="appController" class="org.jboss.tutorial.web.AppController">
- <property name="methodNameResolver">
- <ref local="appControllerResolver"/>
- </property>
- <property name="randomizer">
- <ref bean="randomizer"/>
- </property>
- <property name="horoscope">
- <ref bean="horoscope"/>
- </property>
- </bean>
+ <bean id="appController" class="org.jboss.tutorial.web.AppController">
+ <property name="methodNameResolver">
+ <ref local="appControllerResolver"/>
+ </property>
+ <property name="randomizer">
+ <ref bean="randomizer"/>
+ </property>
+ <property name="horoscope">
+ <ref bean="horoscope"/>
+ </property>
+ </bean>
</beans>
Modified: trunk/spring-int/src/resources/test/web/index.jsp
===================================================================
--- trunk/spring-int/src/resources/test/web/index.jsp 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/resources/test/web/index.jsp 2006-10-19 11:43:35 UTC (rev 57727)
@@ -5,43 +5,43 @@
<p/>
Number:
<form action="number.htm" method="POST">
- Radius: <input type="text" name="radius" value=""/>
- <%
- if (request.getAttribute("number") != null)
- {
- %>
- Random number: <%=request.getAttribute("number")%><p/>
- <%
- }
- %>
- <input type="submit" value="Submit"/>
+ Radius: <input type="text" name="radius" value=""/>
+ <%
+ if (request.getAttribute("number") != null)
+ {
+ %>
+ Random number: <%=request.getAttribute("number")%><p/>
+ <%
+ }
+ %>
+ <input type="submit" value="Submit"/>
</form>
<p/>
Word:
<form action="word.htm" method="POST">
- <%
- if (request.getAttribute("word") != null)
- {
- %>
- Random word: <%=request.getAttribute("word")%><p/>
- <%
- }
- %>
- <input type="submit" value="Submit"/>
+ <%
+ if (request.getAttribute("word") != null)
+ {
+ %>
+ Random word: <%=request.getAttribute("word")%><p/>
+ <%
+ }
+ %>
+ <input type="submit" value="Submit"/>
</form>
<p/>
Horoscope:
<form action="horoscope.htm" method="POST">
- Month: <input type="text" name="month" value=""/>
- <%
- if (request.getAttribute("horoscope") != null)
- {
- %>
- Random horoscope: <%=request.getAttribute("horoscope")%><p/>
- <%
- }
- %>
- <input type="submit" value="Submit"/>
+ Month: <input type="text" name="month" value=""/>
+ <%
+ if (request.getAttribute("horoscope") != null)
+ {
+ %>
+ Random horoscope: <%=request.getAttribute("horoscope")%><p/>
+ <%
+ }
+ %>
+ <input type="submit" value="Submit"/>
</form>
<p/>
<a href="horoscope.htm?clear=true">Clear horoscope</a>
Modified: trunk/spring-int/src/test/org/jboss/spring/test/ear/business/SessionTestBean.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/spring/test/ear/business/SessionTestBean.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/spring/test/ear/business/SessionTestBean.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -29,5 +29,5 @@
*/
public interface SessionTestBean
{
- Tester getTester();
+ Tester getTester();
}
Modified: trunk/spring-int/src/test/org/jboss/spring/test/ear/business/SessionTestBeanImpl.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/spring/test/ear/business/SessionTestBeanImpl.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/spring/test/ear/business/SessionTestBeanImpl.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,23 +22,23 @@
package org.jboss.spring.test.ear.business;
+import javax.ejb.Stateless;
+
import org.jboss.annotation.spring.Spring;
import org.jboss.spring.test.ear.pojo.Tester;
-import javax.ejb.Stateless;
-
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
@Stateless
public class SessionTestBeanImpl implements SessionTestBeanLocal, SessionTestBeanRemote
{
- @Spring(jndiName = "test", bean = "tester")
- private Tester tester;
+ @Spring(jndiName = "test", bean = "tester")
+ private Tester tester;
- public Tester getTester()
- {
- return tester;
- }
+ public Tester getTester()
+ {
+ return tester;
+ }
}
Modified: trunk/spring-int/src/test/org/jboss/spring/test/ear/pojo/Tester.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/spring/test/ear/pojo/Tester.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/spring/test/ear/pojo/Tester.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -27,27 +27,27 @@
*/
public class Tester
{
- private int integerValue;
- private String stringValue;
+ private int integerValue;
+ private String stringValue;
- public int getIntegerValue()
- {
- return integerValue;
- }
+ public int getIntegerValue()
+ {
+ return integerValue;
+ }
- public void setIntegerValue(int integerValue)
- {
- this.integerValue = integerValue;
- }
+ public void setIntegerValue(int integerValue)
+ {
+ this.integerValue = integerValue;
+ }
- public String getStringValue()
- {
- return stringValue;
- }
+ public String getStringValue()
+ {
+ return stringValue;
+ }
- public void setStringValue(String stringValue)
- {
- this.stringValue = stringValue;
- }
+ public void setStringValue(String stringValue)
+ {
+ this.stringValue = stringValue;
+ }
}
Modified: trunk/spring-int/src/test/org/jboss/spring/test/ear/unit/SpringEARUnitTestCase.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/spring/test/ear/unit/SpringEARUnitTestCase.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/spring/test/ear/unit/SpringEARUnitTestCase.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,47 +22,48 @@
package org.jboss.spring.test.ear.unit;
-import junit.framework.Test;
import org.jboss.spring.test.ear.business.SessionTestBean;
import org.jboss.spring.test.ear.pojo.Tester;
import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
public class SpringEARUnitTestCase extends JBossTestCase
{
- public SpringEARUnitTestCase(String name)
- {
- super(name);
- }
+ public SpringEARUnitTestCase(String name)
+ {
+ super(name);
+ }
- private void testInjection(String type) throws Exception
- {
- SessionTestBean testBean = (SessionTestBean) getInitialContext().
- lookup("spring-test/SessionTestBeanImpl/" + type);
- Tester tester = testBean.getTester();
- if (tester == null)
- {
- throw new RuntimeException("Tester should be injected!!");
- }
- assertEquals(tester.getIntegerValue(), 1);
- assertEquals(tester.getStringValue(), "Ales");
- }
+ private void testInjection(String type) throws Exception
+ {
+ SessionTestBean testBean = (SessionTestBean) getInitialContext().
+ lookup("spring-test/SessionTestBeanImpl/" + type);
+ Tester tester = testBean.getTester();
+ if (tester == null)
+ {
+ throw new RuntimeException("Tester should be injected!!");
+ }
+ assertEquals(tester.getIntegerValue(), 1);
+ assertEquals(tester.getStringValue(), "Ales");
+ }
- public void testLocalInjection() throws Exception
- {
- testInjection("local");
- }
+ public void testLocalInjection() throws Exception
+ {
+ testInjection("local");
+ }
- public void testRemoteInjection() throws Exception
- {
- testInjection("remote");
- }
+ public void testRemoteInjection() throws Exception
+ {
+ testInjection("remote");
+ }
- public static Test suite() throws Exception
- {
- return getDeploySetup(SpringEARUnitTestCase.class, "spring-test.ear");
- }
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(SpringEARUnitTestCase.class, "spring-test.ear");
+ }
}
Modified: trunk/spring-int/src/test/org/jboss/tutorial/ee/service/Horoscope.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/tutorial/ee/service/Horoscope.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/tutorial/ee/service/Horoscope.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -27,7 +27,7 @@
*/
public interface Horoscope
{
- String getHoroscope(int month);
+ String getHoroscope(int month);
- void clear();
+ void clear();
}
Modified: trunk/spring-int/src/test/org/jboss/tutorial/ee/service/Randomizer.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/tutorial/ee/service/Randomizer.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/tutorial/ee/service/Randomizer.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -27,7 +27,7 @@
*/
public interface Randomizer
{
- int getNumber(int radius);
+ int getNumber(int radius);
- String getWord();
+ String getWord();
}
Modified: trunk/spring-int/src/test/org/jboss/tutorial/ee/service/impl/HoroscopeBean.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/tutorial/ee/service/impl/HoroscopeBean.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/tutorial/ee/service/impl/HoroscopeBean.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,18 +22,18 @@
package org.jboss.tutorial.ee.service.impl;
+import java.io.Serializable;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.interceptor.Interceptors;
+
import org.jboss.annotation.spring.Spring;
import org.jboss.spring.callback.SpringLifecycleInterceptor;
import org.jboss.tutorial.ee.service.Horoscope;
import org.jboss.tutorial.spring.WordsCreator;
-import javax.ejb.Remove;
-import javax.ejb.Stateful;
-import javax.interceptor.Interceptors;
-import java.io.Serializable;
-import java.util.Set;
-import java.util.TreeSet;
-
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
@@ -42,27 +42,27 @@
public class HoroscopeBean implements Horoscope, Serializable
{
- private static final long serialVersionUID = 2300669204640707036L;
+ private static final long serialVersionUID = 2300669204640707036L;
- private Set<String> sentences = new TreeSet<String>();
+ private Set<String> sentences = new TreeSet<String>();
- @Spring(jndiName = "spring-pojo", bean = "horoscopeSentenceCreator")
- private WordsCreator horoscopeCreator;
+ @Spring(jndiName = "spring-pojo", bean = "horoscopeSentenceCreator")
+ private WordsCreator horoscopeCreator;
- public String getHoroscope(int month)
- {
- String sentence = horoscopeCreator.createWord();
- if (!sentences.add(sentence))
- {
- System.out.println("Repeating horoscope sentence.");
- }
- return sentence;
- }
+ public String getHoroscope(int month)
+ {
+ String sentence = horoscopeCreator.createWord();
+ if (!sentences.add(sentence))
+ {
+ System.out.println("Repeating horoscope sentence.");
+ }
+ return sentence;
+ }
- @Remove
- public void clear()
- {
- sentences.clear();
- }
+ @Remove
+ public void clear()
+ {
+ sentences.clear();
+ }
}
Modified: trunk/spring-int/src/test/org/jboss/tutorial/ee/service/impl/RandomizerBean.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/tutorial/ee/service/impl/RandomizerBean.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/tutorial/ee/service/impl/RandomizerBean.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,13 +22,13 @@
package org.jboss.tutorial.ee.service.impl;
+import javax.ejb.Stateless;
+
import org.jboss.annotation.spring.Spring;
import org.jboss.tutorial.ee.service.Randomizer;
import org.jboss.tutorial.spring.IntCreator;
import org.jboss.tutorial.spring.WordsCreator;
-import javax.ejb.Stateless;
-
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
@@ -36,30 +36,30 @@
public class RandomizerBean implements Randomizer
{
- private WordsCreator wordsCreator;
+ private WordsCreator wordsCreator;
- @Spring(jndiName = "spring-pojo", bean = "stateIntCreator")
- private IntCreator intCreator;
+ @Spring(jndiName = "spring-pojo", bean = "stateIntCreator")
+ private IntCreator intCreator;
- public WordsCreator getWordsCreator()
- {
- return wordsCreator;
- }
+ public WordsCreator getWordsCreator()
+ {
+ return wordsCreator;
+ }
- @Spring(jndiName = "spring-pojo", bean = "staticWordsCreator")
- public void setWordsCreator(WordsCreator wordsCreator)
- {
- this.wordsCreator = wordsCreator;
- }
+ @Spring(jndiName = "spring-pojo", bean = "staticWordsCreator")
+ public void setWordsCreator(WordsCreator wordsCreator)
+ {
+ this.wordsCreator = wordsCreator;
+ }
- public int getNumber(int radius)
- {
- return intCreator.createInt(radius);
- }
+ public int getNumber(int radius)
+ {
+ return intCreator.createInt(radius);
+ }
- public String getWord()
- {
- return getWordsCreator().createWord();
- }
+ public String getWord()
+ {
+ return getWordsCreator().createWord();
+ }
}
Modified: trunk/spring-int/src/test/org/jboss/tutorial/spring/DummyStateIntCreator.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/tutorial/spring/DummyStateIntCreator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/tutorial/spring/DummyStateIntCreator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -28,12 +28,12 @@
public class DummyStateIntCreator implements IntCreator
{
- private int state = 1;
+ private int state = 1;
- public int createInt(int radius)
- {
- state = (state * 3 * 7 * 19 * 37) % radius;
- return state;
- }
+ public int createInt(int radius)
+ {
+ state = (state * 3 * 7 * 19 * 37) % radius;
+ return state;
+ }
}
Modified: trunk/spring-int/src/test/org/jboss/tutorial/spring/FileLineReader.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/tutorial/spring/FileLineReader.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/tutorial/spring/FileLineReader.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,57 +22,58 @@
package org.jboss.tutorial.spring;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.Resource;
-
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.Resource;
+
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
public class FileLineReader extends StaticWordsCreator implements InitializingBean
{
- private Resource resource;
- protected List<String> words;
+ private Resource resource;
+ protected List<String> words;
- public Resource getResource()
- {
- return resource;
- }
+ public Resource getResource()
+ {
+ return resource;
+ }
- public void setResource(Resource resource)
- {
- this.resource = resource;
- }
+ public void setResource(Resource resource)
+ {
+ this.resource = resource;
+ }
- public void afterPropertiesSet() throws Exception
- {
- if (getResource() == null)
- {
- throw new IllegalArgumentException("Resource must be set!");
- }
- BufferedReader reader = new BufferedReader(new InputStreamReader(getResource().getInputStream()));
- try
- {
- words = new ArrayList<String>();
- String line;
- while ((line = reader.readLine()) != null)
- {
- words.add(line);
- }
- } finally
- {
- reader.close();
- }
- }
+ public void afterPropertiesSet() throws Exception
+ {
+ if (getResource() == null)
+ {
+ throw new IllegalArgumentException("Resource must be set!");
+ }
+ BufferedReader reader = new BufferedReader(new InputStreamReader(getResource().getInputStream()));
+ try
+ {
+ words = new ArrayList<String>();
+ String line;
+ while ((line = reader.readLine()) != null)
+ {
+ words.add(line);
+ }
+ }
+ finally
+ {
+ reader.close();
+ }
+ }
- protected String[] getArray()
- {
- return words.toArray(new String[words.size()]);
- }
+ protected String[] getArray()
+ {
+ return words.toArray(new String[words.size()]);
+ }
}
Modified: trunk/spring-int/src/test/org/jboss/tutorial/spring/IntCreator.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/tutorial/spring/IntCreator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/tutorial/spring/IntCreator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -27,5 +27,5 @@
*/
public interface IntCreator
{
- int createInt(int radius);
+ int createInt(int radius);
}
Modified: trunk/spring-int/src/test/org/jboss/tutorial/spring/JavaRandomIntCreator.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/tutorial/spring/JavaRandomIntCreator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/tutorial/spring/JavaRandomIntCreator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -30,11 +30,11 @@
public class JavaRandomIntCreator implements IntCreator
{
- private Random random = new Random();
+ private Random random = new Random();
- public int createInt(int radius)
- {
- return random.nextInt(radius);
- }
+ public int createInt(int radius)
+ {
+ return random.nextInt(radius);
+ }
}
Modified: trunk/spring-int/src/test/org/jboss/tutorial/spring/RandomFileWordsCreator.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/tutorial/spring/RandomFileWordsCreator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/tutorial/spring/RandomFileWordsCreator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -28,30 +28,30 @@
public class RandomFileWordsCreator extends FileLineReader
{
- private IntCreator intCreator;
+ private IntCreator intCreator;
- public IntCreator getIntCreator()
- {
- return intCreator;
- }
+ public IntCreator getIntCreator()
+ {
+ return intCreator;
+ }
- public void setIntCreator(IntCreator intCreator)
- {
- this.intCreator = intCreator;
- }
+ public void setIntCreator(IntCreator intCreator)
+ {
+ this.intCreator = intCreator;
+ }
- public void afterPropertiesSet() throws Exception
- {
- super.afterPropertiesSet();
- if (getIntCreator() == null)
- {
- throw new IllegalArgumentException("IntCreatot must be set!");
- }
- }
+ public void afterPropertiesSet() throws Exception
+ {
+ super.afterPropertiesSet();
+ if (getIntCreator() == null)
+ {
+ throw new IllegalArgumentException("IntCreatot must be set!");
+ }
+ }
- protected String getNext()
- {
- return words.get(getIntCreator().createInt(words.size()));
- }
+ protected String getNext()
+ {
+ return words.get(getIntCreator().createInt(words.size()));
+ }
}
Modified: trunk/spring-int/src/test/org/jboss/tutorial/spring/StaticWordsCreator.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/tutorial/spring/StaticWordsCreator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/tutorial/spring/StaticWordsCreator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -28,32 +28,32 @@
public class StaticWordsCreator implements WordsCreator
{
- private static final String[] words = {
- "Java",
- "Enterprise",
- "Beans",
- "Word",
- "Create",
- "Spring",
- "JBoss",
- };
+ private static final String[] words = {
+ "Java",
+ "Enterprise",
+ "Beans",
+ "Word",
+ "Create",
+ "Spring",
+ "JBoss",
+ };
- private int counter;
+ private int counter;
- protected String[] getArray()
- {
- return words;
- }
+ protected String[] getArray()
+ {
+ return words;
+ }
- protected String getNext()
- {
- String[] array = getArray();
- return array[(counter++) % array.length];
- }
+ protected String getNext()
+ {
+ String[] array = getArray();
+ return array[(counter++) % array.length];
+ }
- public String createWord()
- {
- return getNext();
- }
+ public String createWord()
+ {
+ return getNext();
+ }
}
Modified: trunk/spring-int/src/test/org/jboss/tutorial/spring/WordsCreator.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/tutorial/spring/WordsCreator.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/tutorial/spring/WordsCreator.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -28,6 +28,6 @@
public interface WordsCreator
{
- String createWord();
+ String createWord();
}
Modified: trunk/spring-int/src/test/org/jboss/tutorial/web/AppController.java
===================================================================
--- trunk/spring-int/src/test/org/jboss/tutorial/web/AppController.java 2006-10-19 11:36:23 UTC (rev 57726)
+++ trunk/spring-int/src/test/org/jboss/tutorial/web/AppController.java 2006-10-19 11:43:35 UTC (rev 57727)
@@ -22,69 +22,70 @@
package org.jboss.tutorial.web;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.jboss.tutorial.ee.service.Horoscope;
import org.jboss.tutorial.ee.service.Randomizer;
-import org.springframework.web.bind.RequestUtils;
+import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
/**
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
public class AppController extends MultiActionController
{
- private Randomizer randomizer;
- private Horoscope horoscope;
+ private Randomizer randomizer;
+ private Horoscope horoscope;
- public Randomizer getRandomizer()
- {
- return randomizer;
- }
+ public Randomizer getRandomizer()
+ {
+ return randomizer;
+ }
- public void setRandomizer(Randomizer randomizer)
- {
- this.randomizer = randomizer;
- }
+ public void setRandomizer(Randomizer randomizer)
+ {
+ this.randomizer = randomizer;
+ }
- public Horoscope getHoroscope()
- {
- return horoscope;
- }
+ public Horoscope getHoroscope()
+ {
+ return horoscope;
+ }
- public void setHoroscope(Horoscope horoscope)
- {
- this.horoscope = horoscope;
- }
+ public void setHoroscope(Horoscope horoscope)
+ {
+ this.horoscope = horoscope;
+ }
- public ModelAndView numberHandler(HttpServletRequest request, HttpServletResponse response)
- throws Exception
- {
- int radius = RequestUtils.getRequiredIntParameter(request, "radius");
- return new ModelAndView("main", "number", randomizer.getNumber(radius));
- }
+ public ModelAndView numberHandler(HttpServletRequest request, HttpServletResponse response)
+ throws Exception
+ {
+ int radius = ServletRequestUtils.getRequiredIntParameter(request, "radius");
+ return new ModelAndView("main", "number", randomizer.getNumber(radius));
+ }
- public ModelAndView wordHandler(HttpServletRequest request, HttpServletResponse response)
- throws Exception
- {
- return new ModelAndView("main", "word", randomizer.getWord());
- }
+ public ModelAndView wordHandler(HttpServletRequest request, HttpServletResponse response)
+ throws Exception
+ {
+ return new ModelAndView("main", "word", randomizer.getWord());
+ }
- public ModelAndView horoscopeHandler(HttpServletRequest request, HttpServletResponse response)
- throws Exception
- {
- if (RequestUtils.getStringParameter(request, "clear") != null)
- {
- horoscope.clear();
- return new ModelAndView("main");
- } else
- {
- int month = RequestUtils.getRequiredIntParameter(request, "month");
- return new ModelAndView("main", "horoscope", horoscope.getHoroscope(month));
- }
- }
+ public ModelAndView horoscopeHandler(HttpServletRequest request, HttpServletResponse response)
+ throws Exception
+ {
+ if (ServletRequestUtils.getStringParameter(request, "clear") != null)
+ {
+ horoscope.clear();
+ return new ModelAndView("main");
+ }
+ else
+ {
+ int month = ServletRequestUtils.getRequiredIntParameter(request, "month");
+ return new ModelAndView("main", "horoscope", horoscope.getHoroscope(month));
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list