[jboss-cvs] JBossAS SVN: r69845 - in projects/microcontainer/trunk/spring-int/src: main/org/jboss/spring/annotations and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 14 17:12:29 EST 2008
Author: alesj
Date: 2008-02-14 17:12:29 -0500 (Thu, 14 Feb 2008)
New Revision: 69845
Added:
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/annotations/
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/annotations/SpringBean.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/annotations/SpringBeanAnnotationPlugin.java
projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/BeanNameAwareSpringTestCase.xml
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/BeanNameAwareBean.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/IntBeanNameAwareBean.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/MyInterface.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/SubBeanNameAwareBean.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/BeanNameAwareSpringTestCase.java
projects/microcontainer/trunk/spring-int/src/tests/org/springframework/
projects/microcontainer/trunk/spring-int/src/tests/org/springframework/beans/
projects/microcontainer/trunk/spring-int/src/tests/org/springframework/beans/factory/
projects/microcontainer/trunk/spring-int/src/tests/org/springframework/beans/factory/BeanNameAware.java
Modified:
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeanHandler.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/SpringTestSuite.java
Log:
JBMICROCONT-240; bean name aware
Added: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/annotations/SpringBean.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/annotations/SpringBean.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/annotations/SpringBean.java 2008-02-14 22:12:29 UTC (rev 69845)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.spring.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation.
+ *
+ * @author John Bailey
+ * @author Davide Panelli
+ */
+ at Target(ElementType.TYPE)
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface SpringBean
+{
+}
Added: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/annotations/SpringBeanAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/annotations/SpringBeanAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/annotations/SpringBeanAnnotationPlugin.java 2008-02-14 22:12:29 UTC (rev 69845)
@@ -0,0 +1,122 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.spring.annotations;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.plugins.FromContext;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.kernel.plugins.annotations.ClassAnnotationPlugin;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.InterfaceInfo;
+
+/**
+ * Marker annotation plugin handler.
+ *
+ * @author John Bailey
+ * @author Davide Panelli
+ */
+public class SpringBeanAnnotationPlugin extends ClassAnnotationPlugin<SpringBean>
+{
+ private static final String BNAI = "org.springframework.beans.factory.BeanNameAware";
+ private static final String BNP = "beanName";
+
+ public SpringBeanAnnotationPlugin()
+ {
+ super(SpringBean.class);
+ }
+
+ @Override
+ protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, SpringBean annotation, BeanMetaData metaData) throws Throwable
+ {
+ PropertyMetaData property = findBeanNameAwareInterface(info, metaData);
+ return property != null ? Collections.singletonList(property) : null;
+ }
+
+ /**
+ * Find the BeanNameAware interface.
+ *
+ * @param info the type info
+ * @param metaData the metadata
+ * @return bean property metadata or null if not found
+ */
+ protected PropertyMetaData findBeanNameAwareInterface(ClassInfo info, BeanMetaData metaData)
+ {
+ InterfaceInfo[] interfaces = info.getInterfaces();
+ if (interfaces != null && interfaces.length > 0)
+ {
+ for (InterfaceInfo anInterface : interfaces)
+ {
+ String name = anInterface.getName();
+ if (BNAI.equals(name))
+ {
+ AbstractInjectionValueMetaData injectionMetaData = new AbstractInjectionValueMetaData();
+ injectionMetaData.setFromContext(FromContext.NAME);
+ AbstractPropertyMetaData beanNameProperty = new AbstractPropertyMetaData(BNP, injectionMetaData);
+ Set<PropertyMetaData> properties = metaData.getProperties();
+ if (properties == null)
+ {
+ properties = new HashSet<PropertyMetaData>();
+ ((AbstractBeanMetaData)metaData).setProperties(properties);
+ }
+ properties.add(beanNameProperty);
+ return beanNameProperty;
+ }
+ // Search on super interfaces
+ PropertyMetaData property = findBeanNameAwareInterface(anInterface, metaData);
+ if (property != null)
+ return property;
+ }
+ }
+ // Search on super class
+ ClassInfo superInfo = info.getSuperclass();
+ if (superInfo != null)
+ return findBeanNameAwareInterface(superInfo, metaData);
+
+ return null;
+ }
+
+ @Override
+ protected boolean isMetaDataAlreadyPresent(ClassInfo info, SpringBean annotation, BeanMetaData beanMetaData)
+ {
+ Set<PropertyMetaData> properties = beanMetaData.getProperties();
+ if (properties != null && properties.isEmpty() == false)
+ {
+ for (PropertyMetaData property : properties)
+ {
+ if (BNP.equals(property.getName()))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
Modified: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeanHandler.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeanHandler.java 2008-02-14 20:33:54 UTC (rev 69844)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeanHandler.java 2008-02-14 22:12:29 UTC (rev 69845)
@@ -29,22 +29,26 @@
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
+import org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
import org.jboss.beans.metadata.spi.AutowireType;
import org.jboss.beans.metadata.spi.ConstructorMetaData;
import org.jboss.beans.metadata.spi.DemandMetaData;
import org.jboss.beans.metadata.spi.ParameterMetaData;
import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.spring.annotations.SpringBean;
import org.jboss.spring.metadata.AbstractConstructorArg;
import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
import org.xml.sax.Attributes;
/**
+ *
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
public class SpringBeanHandler extends DefaultElementHandler
@@ -61,7 +65,18 @@
public Object startElement(Object parent, QName name, ElementBinding element)
{
- return new AbstractBeanMetaData();
+ AbstractBeanMetaData bean = new AbstractBeanMetaData();
+ Set<AnnotationMetaData> annotations = bean.getAnnotations();
+ if(annotations == null)
+ {
+ annotations = new HashSet<AnnotationMetaData>();
+ bean.setAnnotations(annotations);
+ }
+ // It's a bit of a hack, but it's a transparent one
+ AbstractAnnotationMetaData springAnnotation = new AbstractAnnotationMetaData();
+ springAnnotation.setAnnotation("@" + SpringBean.class.getName());
+ annotations.add(springAnnotation);
+ return bean;
}
public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
Added: projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/BeanNameAwareSpringTestCase.xml
===================================================================
--- projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/BeanNameAwareSpringTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/BeanNameAwareSpringTestCase.xml 2008-02-14 22:12:29 UTC (rev 69845)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="urn:jboss:spring-beans:2.0">
+
+ <!-- Adding @Spring annotation handler -->
+ <bean xmlns="urn:jboss:bean-deployer:2.0" name="AnnotationHandlerFactory">
+ <constructor factoryClass="org.jboss.kernel.plugins.annotations.BeanAnnotationAdapterFactory" factoryMethod="getInstance" />
+ </bean>
+ <bean xmlns="urn:jboss:bean-deployer:2.0" name="AnnotationHandler">
+ <constructor factoryMethod="getBeanAnnotationAdapter">
+ <factory bean="AnnotationHandlerFactory"/>
+ </constructor>
+ <incallback method="addAnnotationPlugin" />
+ <uncallback method="removeAnnotationPlugin" />
+ </bean>
+ <bean id="SpringAnnotationPlugin" class="org.jboss.spring.annotations.SpringBeanAnnotationPlugin" />
+
+ <bean id="testBean" class="org.jboss.test.spring.support.BeanNameAwareBean" />
+ <bean id="subTestBean" class="org.jboss.test.spring.support.SubBeanNameAwareBean" />
+ <bean id="intTestBean" class="org.jboss.test.spring.support.IntBeanNameAwareBean" />
+
+ <bean id="testBeanWithExisingName" class="org.jboss.test.spring.support.BeanNameAwareBean">
+ <property name="beanName">OtherBean</property>
+ </bean>
+ <bean id="subTestBeanWithExisingName" class="org.jboss.test.spring.support.SubBeanNameAwareBean">
+ <property name="beanName">subOtherBean</property>
+ </bean>
+ <bean id="intTestBeanWithExisingName" class="org.jboss.test.spring.support.IntBeanNameAwareBean">
+ <property name="beanName">intOtherBean</property>
+ </bean>
+
+</beans>
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/BeanNameAwareBean.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/BeanNameAwareBean.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/BeanNameAwareBean.java 2008-02-14 22:12:29 UTC (rev 69845)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.spring.support;
+
+import org.springframework.beans.factory.BeanNameAware;
+
+/**
+ * Tester bean.
+ *
+ * @author John Bailey
+ * @author Davide Panelli
+ */
+public class BeanNameAwareBean implements BeanNameAware
+{
+ private String name;
+
+ public String getBeanName()
+ {
+ return name;
+ }
+
+ public void setBeanName(String name)
+ {
+ this.name = name;
+ }
+}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/IntBeanNameAwareBean.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/IntBeanNameAwareBean.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/IntBeanNameAwareBean.java 2008-02-14 22:12:29 UTC (rev 69845)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.spring.support;
+
+/**
+ * Tester bean.
+ *
+ * @author John Bailey
+ * @author Davide Panelli
+ */
+public class IntBeanNameAwareBean implements MyInterface
+{
+ private String name;
+
+ public void setBeanName(String beanName)
+ {
+ name = beanName;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/MyInterface.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/MyInterface.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/MyInterface.java 2008-02-14 22:12:29 UTC (rev 69845)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.spring.support;
+
+import org.springframework.beans.factory.BeanNameAware;
+
+/**
+ * Tester interface.
+ *
+ * @author John Bailey
+ * @author Davide Panelli
+ */
+public interface MyInterface extends BeanNameAware
+{
+}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/SubBeanNameAwareBean.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/SubBeanNameAwareBean.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/SubBeanNameAwareBean.java 2008-02-14 22:12:29 UTC (rev 69845)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.spring.support;
+
+/**
+ * Tester bean.
+ *
+ * @author John Bailey
+ * @author Davide Panelli
+ */
+public class SubBeanNameAwareBean extends BeanNameAwareBean
+{
+}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/BeanNameAwareSpringTestCase.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/BeanNameAwareSpringTestCase.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/BeanNameAwareSpringTestCase.java 2008-02-14 22:12:29 UTC (rev 69845)
@@ -0,0 +1,74 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.spring.test;
+
+import junit.framework.Test;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.test.spring.support.BeanNameAwareBean;
+import org.jboss.test.spring.support.IntBeanNameAwareBean;
+
+/**
+ * Name aware test.
+ *
+ * @author John Bailey
+ * @author Davide Panelli
+ */
+public class BeanNameAwareSpringTestCase extends TempSpringMicrocontainerTest
+{
+ public BeanNameAwareSpringTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Setup the test
+ *
+ * @return the test
+ */
+ public static Test suite()
+ {
+ return suite(BeanNameAwareSpringTestCase.class);
+ }
+
+ public void testConfigure() throws Exception
+ {
+ BeanNameAwareBean testBean = (BeanNameAwareBean) getBean("testBean", ControllerState.INSTANTIATED);
+ assertNotNull(testBean);
+ assertEquals("testBean" , testBean.getBeanName());
+ BeanNameAwareBean subTestBean = (BeanNameAwareBean) getBean("subTestBean", ControllerState.INSTANTIATED);
+ assertNotNull(subTestBean);
+ assertEquals("subTestBean" , subTestBean.getBeanName());
+ IntBeanNameAwareBean intTestBean = (IntBeanNameAwareBean) getBean("intTestBean", ControllerState.INSTANTIATED);
+ assertNotNull(intTestBean);
+ assertEquals("intTestBean" , intTestBean.getName());
+
+ BeanNameAwareBean otherBean = (BeanNameAwareBean) getBean("testBeanWithExisingName", ControllerState.INSTANTIATED);
+ assertNotNull(otherBean);
+ assertEquals("OtherBean" , otherBean.getBeanName());
+ BeanNameAwareBean subOtherBean = (BeanNameAwareBean) getBean("subTestBeanWithExisingName", ControllerState.INSTANTIATED);
+ assertNotNull(subOtherBean);
+ assertEquals("subOtherBean" , subOtherBean.getBeanName());
+ IntBeanNameAwareBean intOtherBean = (IntBeanNameAwareBean) getBean("intTestBeanWithExisingName", ControllerState.INSTANTIATED);
+ assertNotNull(intOtherBean);
+ assertEquals("intOtherBean" , intOtherBean.getName());
+ }
+}
Modified: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/SpringTestSuite.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/SpringTestSuite.java 2008-02-14 20:33:54 UTC (rev 69844)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/SpringTestSuite.java 2008-02-14 22:12:29 UTC (rev 69845)
@@ -48,6 +48,7 @@
suite.addTest(DependsSpringTestCase.suite());
suite.addTest(LazySpringTestCase.suite());
suite.addTest(ImportSpringTestCase.suite());
+ suite.addTest(BeanNameAwareSpringTestCase.suite());
return suite;
}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/springframework/beans/factory/BeanNameAware.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/springframework/beans/factory/BeanNameAware.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/springframework/beans/factory/BeanNameAware.java 2008-02-14 22:12:29 UTC (rev 69845)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.springframework.beans.factory;
+
+/**
+ * Mock interface.
+ *
+ * @author John Bailey
+ * @author Davide Panelli
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface BeanNameAware
+{
+ /**
+ * Set the bean name.
+ *
+ * @param beanName the bean name
+ */
+ void setBeanName(String beanName);
+}
More information about the jboss-cvs-commits
mailing list