[jboss-cvs] JBossAS SVN: r81518 - in projects/microcontainer/trunk/kernel/src: test/java/org/jboss/test/kernel/deployment/support and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 24 18:51:17 EST 2008
Author: alesj
Date: 2008-11-24 18:51:16 -0500 (Mon, 24 Nov 2008)
New Revision: 81518
Added:
projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/support/GetInstanceBean.java
projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/GetInstanceTestCase.java
projects/microcontainer/trunk/kernel/src/test/resources/org/jboss/test/kernel/deployment/test/GetInstanceTestCase.xml
Modified:
projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java
projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java
Log:
[JBMICROCONT-388]; set bean's class as factoryClass.
Modified: projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java 2008-11-24 22:38:11 UTC (rev 81517)
+++ projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java 2008-11-24 23:51:16 UTC (rev 81518)
@@ -636,19 +636,26 @@
public void initialVisit(MetaDataVisitor visitor)
{
- if (getBean() == null && isAbstract() == false && getParent() == null)
+ ConstructorMetaData constructor = getConstructor();
+ if (getBean() == null)
{
- ConstructorMetaData constructor = getConstructor();
- if (constructor == null)
- throw new IllegalArgumentException("Bean should have a class attribute or a constructor element.");
- if (constructor.getFactoryMethod() == null)
+ if (isAbstract() == false && getParent() == null)
{
- if (constructor.getValue() == null)
- throw new IllegalArgumentException("Bean should have a class attribute or the constructor element should have either a factoryMethod attribute or embedded value.");
+ if (constructor == null)
+ throw new IllegalArgumentException("Bean should have a class attribute or a constructor element.");
+ if (constructor.getFactoryMethod() == null)
+ {
+ if (constructor.getValue() == null)
+ throw new IllegalArgumentException("Bean should have a class attribute or the constructor element should have either a factoryMethod attribute or embedded value.");
+ }
+ else if (constructor.getFactory() == null && constructor.getFactoryClass() == null)
+ throw new IllegalArgumentException("Bean should have a class attribute or the constructor element should have one of a factoryClass attribute or a factory element, or embedded value.");
}
- else if (constructor.getFactory() == null && constructor.getFactoryClass() == null)
- throw new IllegalArgumentException("Bean should have a class attribute or the constructor element should have one of a factoryClass attribute or a factory element, or embedded value.");
}
+ else
+ {
+ checkConstructorFactoryClass(constructor);
+ }
KernelControllerContext ctx = visitor.getControllerContext();
if (ctx.getBeanMetaData() == this)
@@ -673,6 +680,30 @@
super.initialVisit(visitor);
}
+ /**
+ * Check constructor factory class.
+ *
+ * @param constructor the constructor meta data
+ */
+ protected void checkConstructorFactoryClass(ConstructorMetaData constructor)
+ {
+ if (constructor == null)
+ return;
+ if (constructor.getFactoryMethod() == null)
+ return;
+ if (constructor.getFactoryClass() != null)
+ return;
+ if (constructor.getValue() != null)
+ return;
+ if (constructor.getFactory() != null)
+ return;
+ if (constructor instanceof AbstractConstructorMetaData == false)
+ return;
+
+ AbstractConstructorMetaData acmd = AbstractConstructorMetaData.class.cast(constructor);
+ acmd.setFactoryClass(getBean());
+ }
+
protected void addChildren(Set<MetaDataVisitorNode> children)
{
super.addChildren(children);
Copied: projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/support/GetInstanceBean.java (from rev 81226, projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/support/MockServiceBinding.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/support/GetInstanceBean.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/support/GetInstanceBean.java 2008-11-24 23:51:16 UTC (rev 81518)
@@ -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.test.kernel.deployment.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class GetInstanceBean
+{
+ private static final GetInstanceBean instance = new GetInstanceBean("X");
+
+ private GetInstanceBean(String x)
+ {
+ }
+
+ public static GetInstanceBean getInstance()
+ {
+ return instance;
+ }
+}
\ No newline at end of file
Property changes on: projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/support/GetInstanceBean.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java 2008-11-24 22:38:11 UTC (rev 81517)
+++ projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java 2008-11-24 23:51:16 UTC (rev 81518)
@@ -72,6 +72,7 @@
suite.addTest(AnnotationUsageTestCase.suite());
suite.addTest(PropertyUsageTestCase.suite());
suite.addTest(AliasInjectTestCase.suite());
+ suite.addTest(GetInstanceTestCase.suite());
// bean container tests
suite.addTest(BeanContainerUsageTestCase.suite());
suite.addTest(BeanContainerUsageMDTestCase.suite());
Copied: projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/GetInstanceTestCase.java (from rev 81226, projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/AliasInjectTestCase.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/GetInstanceTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/GetInstanceTestCase.java 2008-11-24 23:51:16 UTC (rev 81518)
@@ -0,0 +1,48 @@
+/*
+* 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.kernel.deployment.test;
+
+import junit.framework.Test;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+
+/**
+ * GetInstanceTestCase
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class GetInstanceTestCase extends MicrocontainerTest
+{
+ public GetInstanceTestCase(String name) throws Throwable
+ {
+ super(name, true);
+ }
+
+ public static Test suite()
+ {
+ return suite(GetInstanceTestCase.class);
+ }
+
+ public void testGetInstance() throws Throwable
+ {
+ assertBean("GetInstance", Object.class);
+ }
+}
\ No newline at end of file
Property changes on: projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/GetInstanceTestCase.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: projects/microcontainer/trunk/kernel/src/test/resources/org/jboss/test/kernel/deployment/test/GetInstanceTestCase.xml (from rev 81226, projects/microcontainer/trunk/kernel/src/test/resources/org/jboss/test/kernel/deployment/test/AliasInjectTestCase.xml)
===================================================================
--- projects/microcontainer/trunk/kernel/src/test/resources/org/jboss/test/kernel/deployment/test/GetInstanceTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/test/resources/org/jboss/test/kernel/deployment/test/GetInstanceTestCase.xml 2008-11-24 23:51:16 UTC (rev 81518)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="GetInstance" class="org.jboss.test.kernel.deployment.support.GetInstanceBean">
+ <constructor factoryMethod="getInstance"/>
+ </bean>
+
+</deployment>
Property changes on: projects/microcontainer/trunk/kernel/src/test/resources/org/jboss/test/kernel/deployment/test/GetInstanceTestCase.xml
___________________________________________________________________
Name: svn:mergeinfo
+
More information about the jboss-cvs-commits
mailing list