[jboss-cvs] JBossAS SVN: r63304 - in projects/microcontainer/trunk: kernel/src/main/org/jboss/beans/metadata/plugins and 18 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jun 1 10:57:24 EDT 2007
Author: alesj
Date: 2007-06-01 10:57:24 -0400 (Fri, 01 Jun 2007)
New Revision: 63304
Added:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractNamedAliasMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/MutableLifecycleHolder.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/NamedAliasMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentAliasInterceptor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleCreateInterceptor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleDestroyInterceptor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleStartInterceptor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleStopInterceptor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/NamedAliasHandler.java
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithCandidate.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithAlias.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithLifecycle.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithMode.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAlias.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAliasWithClass.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAliasWithNoReplace.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAliasWithReplace.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CandidateContextualInjection.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SomeTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CandidateContextualInjectionTestCase.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/ImportHandler.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/ImportInterceptor.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/metadata/AbstractImportMetaData.java
projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/AliasSpringTestCase.xml
projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/DependsSpringTestCase.xml
projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/ImportSpringTestCase.xml
projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/LazySpringTestCase.xml
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/SettingBean.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/WaitingBean.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/AliasSpringTestCase.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/DependsSpringTestCase.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/ImportSpringTestCase.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/LazySpringTestCase.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/LazyTempSpringMicrocontainerTest.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/LazyTempSpringMicrocontainerTestDelegate.java
Removed:
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanCreateInterceptor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanDestroyInterceptor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanStartInterceptor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanStopInterceptor.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeansInterceptor.java
Modified:
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAliasMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InjectionType.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/BeanMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployment.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanHandler.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding20.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentHandler.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/deployment/KernelDeployment.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java
projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/AliasTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BeanTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java
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/SpringBeansHandler.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBinding.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBindingHelper.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/metadata/AbstractSpringDeployment.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateSpringTestCase.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/SpringTestSuite.java
Log:
Phase 2 of Spring-int support.
Porting some of the features to MC.
Additional autowire check.
Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -978,38 +978,43 @@
{
try
{
+ // existing owner callbacks
Set<CallbackItem> installs = getDependencyCallbacks(context, true);
resolveCallbacks(installs, state, isInstallPhase, isInstallPhase, true);
Set<CallbackItem> uninstalls = getDependencyCallbacks(context, false);
resolveCallbacks(uninstalls, state, isInstallPhase == false, isInstallPhase, false);
- // match callbacks by name
- Set<CallbackItem> existingCallbacks = getCallbacks(context.getName(), isInstallPhase);
- // match by classes
- Collection<Class<?>> classes = getClassesImplemented(context.getTarget());
- if (classes != null && classes.isEmpty() == false)
+ // change callbacks, applied only if context is autowire candidate
+ if (isAutowireCandidate(context))
{
- for (Class clazz : classes)
+ // match callbacks by name
+ Set<CallbackItem> existingCallbacks = getCallbacks(context.getName(), isInstallPhase);
+ // match by classes
+ Collection<Class<?>> classes = getClassesImplemented(context.getTarget());
+ if (classes != null && classes.isEmpty() == false)
{
- existingCallbacks.addAll(getCallbacks(clazz, isInstallPhase));
+ for (Class clazz : classes)
+ {
+ existingCallbacks.addAll(getCallbacks(clazz, isInstallPhase));
+ }
}
- }
- // Do the installs if we are at the required state
- if (existingCallbacks != null && existingCallbacks.isEmpty() == false)
- {
- for(CallbackItem callback : existingCallbacks)
+ // Do the installs if we are at the required state
+ if (existingCallbacks != null && existingCallbacks.isEmpty() == false)
{
- if (state.equals(callback.getDependentState()))
+ for(CallbackItem callback : existingCallbacks)
{
- try
+ if (state.equals(callback.getDependentState()))
{
- callback.changeCallback(this, context, isInstallPhase);
+ try
+ {
+ callback.changeCallback(this, context, isInstallPhase);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Broken callback: " + callback, t);
+ }
}
- catch (Throwable t)
- {
- log.warn("Broken callback: " + callback, t);
- }
}
}
}
@@ -1022,6 +1027,17 @@
}
/**
+ * Can we use this context for autowiring.
+ *
+ * @param context the context
+ * @return true if context could be used for autowiring
+ */
+ protected boolean isAutowireCandidate(ControllerContext context)
+ {
+ return true;
+ }
+
+ /**
* Get implemented classes.
*
* @param target target value / bean
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAliasMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAliasMetaData.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAliasMetaData.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -51,7 +51,7 @@
protected String clazz;
/**
- * Create a new annotation meta data
+ * Create a new alias meta data
*/
public AbstractAliasMetaData()
{
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -61,9 +61,9 @@
* @version $Revision$
*/
public class AbstractBeanMetaData extends AbstractFeatureMetaData
- implements BeanMetaData, BeanMetaDataFactory, Serializable
+ implements BeanMetaData, BeanMetaDataFactory, MutableLifecycleHolder, Serializable
{
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 2L;
private static final List<LifecycleCallbackMetaData> EMPTY_LIFECYCLE_CALLBACKS = Collections.unmodifiableList(new ArrayList<LifecycleCallbackMetaData>());
@@ -79,6 +79,9 @@
/** The mode */
protected ControllerMode mode;
+ /** Is contextual injection candidate */
+ protected boolean autowireCandidate = true;
+
/** The properties configuration Set<PropertyMetaData> */
private Set<PropertyMetaData> properties;
@@ -354,6 +357,16 @@
flushJBossObjectCache();
}
+ public boolean isAutowireCandidate()
+ {
+ return autowireCandidate;
+ }
+
+ public void setAutowireCandidate(boolean autowireCandidate)
+ {
+ this.autowireCandidate = autowireCandidate;
+ }
+
public Set<PropertyMetaData> getProperties()
{
return properties;
@@ -604,6 +617,7 @@
if (classLoader != null && classLoader.getClassLoader() != this)
buffer.append(" classLoader=").append(classLoader);
buffer.append(" constructor=").append(constructor);
+ buffer.append(" autowireCandidate=").append(autowireCandidate);
if (create != null)
buffer.append(" create=").append(create);
if (start != null)
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractNamedAliasMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractNamedAliasMetaData.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractNamedAliasMetaData.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,81 @@
+/*
+* 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.beans.metadata.plugins;
+
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.beans.metadata.spi.NamedAliasMetaData;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Metadata for a named alias.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractNamedAliasMetaData extends AbstractAliasMetaData implements NamedAliasMetaData
+{
+ protected Object name;
+
+ /**
+ * Create a new named alias meta data
+ */
+ public AbstractNamedAliasMetaData()
+ {
+ super();
+ }
+
+ public Object getName()
+ {
+ return name;
+ }
+
+ public void setName(Object name)
+ {
+ this.name = name;
+ }
+
+ public void initialVisit(MetaDataVisitor visitor)
+ {
+ // todo
+ super.initialVisit(visitor);
+ }
+
+ public void toString(JBossStringBuilder buffer)
+ {
+ buffer.append("name=").append(name).append(" ");
+ super.toString(buffer);
+ }
+
+ protected int getHashCode()
+ {
+ return name.hashCode() + 7 * super.getHashCode();
+ }
+
+ public boolean equals(Object object)
+ {
+ if (object == null || object instanceof AbstractNamedAliasMetaData == false || super.equals(object) == false)
+ return false;
+
+ AbstractNamedAliasMetaData amd = (AbstractNamedAliasMetaData)object;
+ return name.equals(amd.name);
+ }
+
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InjectionType.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InjectionType.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InjectionType.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -30,20 +30,41 @@
* Injection type:
* * ByClass - matching the class type of value (default)
* * ByName - matching the property name
+ * * Constructor - matching the constructor args
+ * * Auto - matching constructor or by type
+ * * None - do not autowire
*
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
public class InjectionType extends JBossObject
implements Serializable
{
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 2L;
+ /** None */
+ public static final InjectionType NONE = new InjectionType("None");
+
/** Strict */
public static final InjectionType BY_CLASS = new InjectionType("ByClass");
/** Loose */
public static final InjectionType BY_NAME = new InjectionType("ByName");
+ /** Constructor */
+ public static final InjectionType CONSTRUCTOR = new InjectionType("Constructor");
+
+ /** Auto */
+ public static final InjectionType AUTO = new InjectionType("Auto");
+
+ /** Array */
+ public static final InjectionType[] TYPES = new InjectionType[]{
+ NONE,
+ BY_CLASS,
+ BY_NAME,
+ CONSTRUCTOR,
+ AUTO,
+ };
+
/** The type string */
protected final String typeString;
@@ -61,19 +82,19 @@
/**
* Return injection type.
- * Or exception if no matching type.
+ * Or NONE if no matching type.
*
* @param typeString type
* @return InjectionType instance
*/
public static InjectionType getInstance(String typeString)
{
- if ("ByClass".equalsIgnoreCase(typeString))
- return BY_CLASS;
- else if ("ByName".equalsIgnoreCase(typeString))
- return BY_NAME;
- else
- throw new IllegalArgumentException("No such type: " + typeString);
+ for(InjectionType type : TYPES)
+ {
+ if (type.getTypeString().equalsIgnoreCase(typeString))
+ return type;
+ }
+ return NONE;
}
/**
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/MutableLifecycleHolder.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/MutableLifecycleHolder.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/MutableLifecycleHolder.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,38 @@
+/*
+* 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.beans.metadata.plugins;
+
+import org.jboss.beans.metadata.spi.LifecycleMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface MutableLifecycleHolder
+{
+ void setCreate(LifecycleMetaData create);
+
+ void setStart(LifecycleMetaData start);
+
+ void setStop(LifecycleMetaData stop);
+
+ void setDestroy(LifecycleMetaData destroy);
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/BeanMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/BeanMetaData.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/BeanMetaData.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -78,6 +78,15 @@
void setMode(ControllerMode mode);
/**
+ * Is this bean is a candidate for
+ * getting injected via contextual matching
+ * or callback resolution.
+ *
+ * @return true (default) if used for autowiring
+ */
+ boolean isAutowireCandidate();
+
+ /**
* Set the annotations
*
* @param annotations the annotations
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/NamedAliasMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/NamedAliasMetaData.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/NamedAliasMetaData.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -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.beans.metadata.spi;
+
+/**
+ * Metadata about a named alias element.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface NamedAliasMetaData extends AliasMetaData
+{
+ Object getName();
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -409,4 +409,12 @@
return contexts.iterator().next();
}
+ protected boolean isAutowireCandidate(ControllerContext context)
+ {
+ if (context instanceof KernelControllerContext)
+ {
+ return ((KernelControllerContext)context).isAutowireCandidate();
+ }
+ return super.isAutowireCandidate(context);
+ }
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -96,7 +96,7 @@
*/
public AbstractKernelControllerContext(BeanInfo info, BeanMetaData metaData, Object target)
{
- super(metaData.getName(), target == null ? actions : noInstantiate, new AbstractDependencyInfo(), target);
+ super(metaData.getName(), metaData.getAliases(), target == null ? actions : noInstantiate, new AbstractDependencyInfo(), target);
this.info = info;
this.metaData = metaData;
ControllerMode mode = metaData.getMode();
@@ -170,6 +170,11 @@
return installScope;
}
+ public boolean isAutowireCandidate()
+ {
+ return metaData != null && metaData.isAutowireCandidate();
+ }
+
public void setInstallScope(ScopeKey key)
{
this.installScope = key;
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -26,10 +26,10 @@
import org.jboss.joinpoint.spi.Joinpoint;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.config.KernelConfigurator;
+import org.jboss.kernel.spi.dependency.InstantiateKernelControllerContextAware;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
-import org.jboss.kernel.spi.dependency.InstantiateKernelControllerContextAware;
/**
* InstantiateAction.
@@ -62,7 +62,8 @@
context.setBeanInfo(info);
}
- controller.addInstantiatedContext(context);
+ if (context.isAutowireCandidate())
+ controller.addInstantiatedContext(context);
}
catch (Throwable t)
{
@@ -87,7 +88,8 @@
// ((KernelControllerContextAware) object).unsetKernelControllerContext(context);
KernelController controller = (KernelController) context.getController();
- controller.removeInstantiatedContext(context);
+ if (context.isAutowireCandidate())
+ controller.removeInstantiatedContext(context);
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployment.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployment.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployment.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -29,10 +29,16 @@
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.MutableLifecycleHolder;
import org.jboss.beans.metadata.spi.AnnotationMetaData;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
+import org.jboss.beans.metadata.spi.LifecycleMetaData;
+import org.jboss.beans.metadata.spi.NamedAliasMetaData;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.ControllerState;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.kernel.spi.deployment.KernelDeployment;
import org.jboss.util.JBossObject;
@@ -45,7 +51,7 @@
* @version $Revision$
*/
public class AbstractKernelDeployment extends JBossObject
- implements KernelDeployment, Serializable
+ implements KernelDeployment, MutableLifecycleHolder, Serializable
{
private static final long serialVersionUID = 1;
@@ -70,6 +76,24 @@
/** The ClassLoader */
protected ClassLoaderMetaData classLoader;
+ /** default create lifecycle method */
+ protected LifecycleMetaData create;
+
+ /** default start lifecycle method */
+ protected LifecycleMetaData start;
+
+ /** default stop lifecycle method */
+ protected LifecycleMetaData stop;
+
+ /** default destroy lifecycle method */
+ protected LifecycleMetaData destroy;
+
+ /** The ControllerMode */
+ protected ControllerMode mode;
+
+ /** The aliases */
+ protected Set<NamedAliasMetaData> aliases;
+
/**
* Create a new kernel deployment
*/
@@ -142,16 +166,17 @@
public List<BeanMetaData> getBeans()
{
- if (beanFactories == null || beanFactories.size() == 0)
+ List<BeanMetaDataFactory> factories = getBeanFactories();
+ if (factories == null || factories.size() == 0)
return null;
- List<BeanMetaData> result = new ArrayList<BeanMetaData>(beanFactories.size());
- for (BeanMetaDataFactory factory : beanFactories)
+ List<BeanMetaData> result = new ArrayList<BeanMetaData>(factories.size());
+ for (BeanMetaDataFactory factory : factories)
{
List<BeanMetaData> beans = factory.getBeans();
- // add all deployment annotations to bean's annotations
- if (annotations != null && annotations.isEmpty() == false)
+ for (BeanMetaData bmd : beans)
{
- for (BeanMetaData bmd : beans)
+ // check annotations
+ if (annotations != null && annotations.isEmpty() == false)
{
Set<AnnotationMetaData> annotationsBMD = bmd.getAnnotations();
if (annotationsBMD == null)
@@ -161,6 +186,53 @@
}
annotationsBMD.addAll(annotations);
}
+ // impl specific
+ if (bmd instanceof AbstractBeanMetaData)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)bmd;
+ // set deployment defaults, if not already set per bean
+ if (bean.getCreate() == null && getCreate() != null)
+ {
+ bean.setCreate(getCreate());
+ }
+ if (bean.getStart() == null && getStart() != null)
+ {
+ bean.setStart(getStart());
+ }
+ if (bean.getStop() == null && getStop() != null)
+ {
+ bean.setStop(getStop());
+ }
+ if (bean.getDestroy() == null && getDestroy() != null)
+ {
+ bean.setDestroy(getDestroy());
+ }
+
+ // named aliases
+ if (aliases != null && aliases.isEmpty() == false)
+ {
+ Object beanName = bean.getName();
+ for (NamedAliasMetaData alias : aliases)
+ {
+ if (alias.getName().equals(beanName))
+ {
+ Set<Object> beanAliases = bean.getAliases();
+ if (beanAliases == null)
+ {
+ beanAliases = new HashSet<Object>();
+ bean.setAliases(beanAliases);
+ }
+ beanAliases.add(alias.getAliasValue());
+ }
+ }
+ }
+
+ // controller mode
+ if (bean.getMode() == null && getMode() != null)
+ {
+ bean.setMode(getMode());
+ }
+ }
}
result.addAll(beans);
}
@@ -207,6 +279,70 @@
this.classLoader = classLoader;
}
+ public LifecycleMetaData getCreate()
+ {
+ return create;
+ }
+
+ public void setCreate(LifecycleMetaData create)
+ {
+ create.setState(ControllerState.CREATE);
+ this.create = create;
+ }
+
+ public LifecycleMetaData getStart()
+ {
+ return start;
+ }
+
+ public void setStart(LifecycleMetaData start)
+ {
+ start.setState(ControllerState.START);
+ this.start = start;
+ }
+
+ public LifecycleMetaData getStop()
+ {
+ return stop;
+ }
+
+ public void setStop(LifecycleMetaData stop)
+ {
+ stop.setState(ControllerState.START);
+ this.stop = stop;
+ }
+
+ public LifecycleMetaData getDestroy()
+ {
+ return destroy;
+ }
+
+ public void setDestroy(LifecycleMetaData destroy)
+ {
+ destroy.setState(ControllerState.CREATE);
+ this.destroy = destroy;
+ }
+
+ public Set<NamedAliasMetaData> getAliases()
+ {
+ return aliases;
+ }
+
+ public void setAliases(Set<NamedAliasMetaData> aliases)
+ {
+ this.aliases = aliases;
+ }
+
+ public ControllerMode getMode()
+ {
+ return mode;
+ }
+
+ public void setMode(ControllerMode mode)
+ {
+ this.mode = mode;
+ }
+
public void toString(JBossStringBuilder buffer)
{
buffer.append("name=").append(name);
Deleted: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanCreateInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanCreateInterceptor.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanCreateInterceptor.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -1,48 +0,0 @@
-/*
-* 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.kernel.plugins.deployment.xml;
-
-import javax.xml.namespace.QName;
-
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
-
-/**
- * BeanCreateInterceptor.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public class BeanCreateInterceptor extends DefaultElementInterceptor
-{
- /** The interceptor */
- public static final BeanCreateInterceptor INTERCEPTOR = new BeanCreateInterceptor();
-
- public void add(Object parent, Object child, QName name)
- {
- AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
- AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
- lifecycle.setType("create");
- bean.setCreate(lifecycle);
- }
-}
Deleted: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanDestroyInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanDestroyInterceptor.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanDestroyInterceptor.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -1,48 +0,0 @@
-/*
-* 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.kernel.plugins.deployment.xml;
-
-import javax.xml.namespace.QName;
-
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
-
-/**
- * BeanDestroyInterceptor.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public class BeanDestroyInterceptor extends DefaultElementInterceptor
-{
- /** The interceptor */
- public static final BeanDestroyInterceptor INTERCEPTOR = new BeanDestroyInterceptor();
-
- public void add(Object parent, Object child, QName name)
- {
- AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
- AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
- lifecycle.setType("destroy");
- bean.setDestroy(lifecycle);
- }
-}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanHandler.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanHandler.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -59,6 +59,8 @@
bean.setBean(attrs.getValue(i));
else if ("mode".equals(localName))
bean.setMode(new ControllerMode(attrs.getValue(i)));
+ else if ("autowire-candidate".equals(localName))
+ bean.setAutowireCandidate(Boolean.parseBoolean(attrs.getValue(i)));
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding20.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding20.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding20.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -41,6 +41,9 @@
/** The deployment binding */
public static final QName deploymentTypeQName = new QName(BEAN_DEPLOYER_NS, "deploymentType");
+ /** The named alias binding */
+ public static final QName namedAliasTypeQName = new QName(BEAN_DEPLOYER_NS, "namedAliasType");
+
/** The bean binding */
public static final QName beanTypeQName = new QName(BEAN_DEPLOYER_NS, "beanType");
@@ -287,6 +290,10 @@
TypeBinding lifecycleType = schemaBinding.getType(lifecycleTypeQName);
BeanSchemaBindingHelper.initLifecycleHandlers(lifecycleType);
+ // named alias binding
+ TypeBinding namedAliasType = schemaBinding.getType(namedAliasTypeQName);
+ BeanSchemaBindingHelper.initNamedAliasHandlers(namedAliasType);
+
// alias binding
TypeBinding aliasType = schemaBinding.getType(aliasTypeQName);
BeanSchemaBindingHelper.initAliasHandlers(aliasType);
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -50,6 +50,21 @@
// deployment has a classloader
deploymentType.pushInterceptor(BeanSchemaBinding20.classloaderQName, DeploymentClassLoaderInterceptor.INTERCEPTOR);
+ // bean has a create
+ deploymentType.pushInterceptor(BeanSchemaBinding20.createQName, LifecycleCreateInterceptor.INTERCEPTOR);
+
+ // bean has a start
+ deploymentType.pushInterceptor(BeanSchemaBinding20.startQName, LifecycleStartInterceptor.INTERCEPTOR);
+
+ // bean has a stop
+ deploymentType.pushInterceptor(BeanSchemaBinding20.stopQName, LifecycleStopInterceptor.INTERCEPTOR);
+
+ // bean has a destroy
+ deploymentType.pushInterceptor(BeanSchemaBinding20.destroyQName, LifecycleDestroyInterceptor.INTERCEPTOR);
+
+ // deployment has a list aliases
+ deploymentType.pushInterceptor(BeanSchemaBinding20.aliasQName, DeploymentAliasInterceptor.INTERCEPTOR);
+
// deployment has a list beans
deploymentType.pushInterceptor(BeanSchemaBinding20.beanQName, DeploymentBeanInterceptor.INTERCEPTOR);
@@ -79,16 +94,16 @@
beanType.pushInterceptor(BeanSchemaBinding20.propertyQName, BeanPropertyInterceptor.INTERCEPTOR);
// bean has a create
- beanType.pushInterceptor(BeanSchemaBinding20.createQName, BeanCreateInterceptor.INTERCEPTOR);
+ beanType.pushInterceptor(BeanSchemaBinding20.createQName, LifecycleCreateInterceptor.INTERCEPTOR);
// bean has a start
- beanType.pushInterceptor(BeanSchemaBinding20.startQName, BeanStartInterceptor.INTERCEPTOR);
+ beanType.pushInterceptor(BeanSchemaBinding20.startQName, LifecycleStartInterceptor.INTERCEPTOR);
// bean has a stop
- beanType.pushInterceptor(BeanSchemaBinding20.stopQName, BeanStopInterceptor.INTERCEPTOR);
+ beanType.pushInterceptor(BeanSchemaBinding20.stopQName, LifecycleStopInterceptor.INTERCEPTOR);
// bean has a destroy
- beanType.pushInterceptor(BeanSchemaBinding20.destroyQName, BeanDestroyInterceptor.INTERCEPTOR);
+ beanType.pushInterceptor(BeanSchemaBinding20.destroyQName, LifecycleDestroyInterceptor.INTERCEPTOR);
// bean has aliases
beanType.pushInterceptor(BeanSchemaBinding20.aliasQName, BeanAliasInterceptor.INTERCEPTOR);
@@ -282,15 +297,28 @@
}
/**
+ * Initialize the handlers for the named alias type
+ *
+ * @param aliasType the named alias type
+ */
+ public static void initNamedAliasHandlers(TypeBinding aliasType)
+ {
+ aliasType.setHandler(NamedAliasHandler.HANDLER);
+
+ // alias can take characters
+ aliasType.setSimpleType(AliasCharactersHandler.HANDLER);
+ }
+
+ /**
* Initialize the handlers for the alias type
- *
+ *
* @param aliasType the alias type
*/
public static void initAliasHandlers(TypeBinding aliasType)
{
aliasType.setHandler(AliasHandler.HANDLER);
- // annotation can take characters
+ // alias can take characters
aliasType.setSimpleType(AliasCharactersHandler.HANDLER);
}
Deleted: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanStartInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanStartInterceptor.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanStartInterceptor.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -1,48 +0,0 @@
-/*
-* 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.kernel.plugins.deployment.xml;
-
-import javax.xml.namespace.QName;
-
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
-
-/**
- * BeanStartInterceptor.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public class BeanStartInterceptor extends DefaultElementInterceptor
-{
- /** The interceptor */
- public static final BeanStartInterceptor INTERCEPTOR = new BeanStartInterceptor();
-
- public void add(Object parent, Object child, QName name)
- {
- AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
- AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
- lifecycle.setType("start");
- bean.setStart(lifecycle);
- }
-}
Deleted: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanStopInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanStopInterceptor.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanStopInterceptor.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -1,48 +0,0 @@
-/*
-* 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.kernel.plugins.deployment.xml;
-
-import javax.xml.namespace.QName;
-
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
-
-/**
- * BeanStopInterceptor.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public class BeanStopInterceptor extends DefaultElementInterceptor
-{
- /** The interceptor */
- public static final BeanStopInterceptor INTERCEPTOR = new BeanStopInterceptor();
-
- public void add(Object parent, Object child, QName name)
- {
- AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
- AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
- lifecycle.setType("stop");
- bean.setStop(lifecycle);
- }
-}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentAliasInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentAliasInterceptor.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentAliasInterceptor.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,54 @@
+/*
+* 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.kernel.plugins.deployment.xml;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.spi.NamedAliasMetaData;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * DeploymentAliasInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DeploymentAliasInterceptor extends DefaultElementInterceptor
+{
+ /** The interceptor */
+ public static final DeploymentAliasInterceptor INTERCEPTOR = new DeploymentAliasInterceptor();
+
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractKernelDeployment deployment = (AbstractKernelDeployment) parent;
+ NamedAliasMetaData alias = (NamedAliasMetaData) child;
+ Set<NamedAliasMetaData> aliases = deployment.getAliases();
+ if (aliases == null)
+ {
+ aliases = new HashSet<NamedAliasMetaData>();
+ deployment.setAliases(aliases);
+ }
+ aliases.add(alias);
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentHandler.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentHandler.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -24,6 +24,7 @@
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
+import org.jboss.dependency.spi.ControllerMode;
import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
@@ -55,6 +56,8 @@
deployment.setName(attrs.getValue(i));
else if ("scoped".equals(localName))
deployment.setScoped(Boolean.parseBoolean(attrs.getValue(i)));
+ else if ("mode".equals(localName))
+ deployment.setMode(new ControllerMode(attrs.getValue(i)));
}
}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleCreateInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleCreateInterceptor.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleCreateInterceptor.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,47 @@
+/*
+* 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.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.beans.metadata.plugins.MutableLifecycleHolder;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * LifecycleCreateInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LifecycleCreateInterceptor extends DefaultElementInterceptor
+{
+ /** The interceptor */
+ public static final LifecycleCreateInterceptor INTERCEPTOR = new LifecycleCreateInterceptor();
+
+ public void add(Object parent, Object child, QName name)
+ {
+ MutableLifecycleHolder holder = (MutableLifecycleHolder) parent;
+ AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
+ lifecycle.setType("create");
+ holder.setCreate(lifecycle);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleDestroyInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleDestroyInterceptor.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleDestroyInterceptor.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,47 @@
+/*
+* 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.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.beans.metadata.plugins.MutableLifecycleHolder;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * LifecycleDestroyInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LifecycleDestroyInterceptor extends DefaultElementInterceptor
+{
+ /** The interceptor */
+ public static final LifecycleDestroyInterceptor INTERCEPTOR = new LifecycleDestroyInterceptor();
+
+ public void add(Object parent, Object child, QName name)
+ {
+ MutableLifecycleHolder holder = (MutableLifecycleHolder) parent;
+ AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
+ lifecycle.setType("destroy");
+ holder.setDestroy(lifecycle);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleStartInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleStartInterceptor.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleStartInterceptor.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,47 @@
+/*
+* 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.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.beans.metadata.plugins.MutableLifecycleHolder;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * LifecycleStartInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LifecycleStartInterceptor extends DefaultElementInterceptor
+{
+ /** The interceptor */
+ public static final LifecycleStartInterceptor INTERCEPTOR = new LifecycleStartInterceptor();
+
+ public void add(Object parent, Object child, QName name)
+ {
+ MutableLifecycleHolder holder = (MutableLifecycleHolder) parent;
+ AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
+ lifecycle.setType("start");
+ holder.setStart(lifecycle);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleStopInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleStopInterceptor.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/LifecycleStopInterceptor.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,47 @@
+/*
+* 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.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.beans.metadata.plugins.MutableLifecycleHolder;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * LifecycleStopInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LifecycleStopInterceptor extends DefaultElementInterceptor
+{
+ /** The interceptor */
+ public static final LifecycleStopInterceptor INTERCEPTOR = new LifecycleStopInterceptor();
+
+ public void add(Object parent, Object child, QName name)
+ {
+ MutableLifecycleHolder holder = (MutableLifecycleHolder) parent;
+ AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
+ lifecycle.setType("stop");
+ holder.setStop(lifecycle);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/NamedAliasHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/NamedAliasHandler.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/NamedAliasHandler.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,70 @@
+/*
+* 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.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractNamedAliasMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * The named alias handler.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class NamedAliasHandler extends AliasHandler
+{
+ /**
+ * The alias handler
+ */
+ public static final NamedAliasHandler HANDLER = new NamedAliasHandler();
+
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractNamedAliasMetaData();
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractNamedAliasMetaData alias = (AbstractNamedAliasMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("name".equals(localName))
+ alias.setName(attrs.getValue(i));
+ else if ("alias".equals(localName))
+ alias.setAlias(attrs.getValue(i));
+ }
+ super.attributes(o, elementName, element, attrs, nsCtx);
+ }
+
+ public Object endElement(Object object, QName qName, ElementBinding elementBinding)
+ {
+ AbstractNamedAliasMetaData alias = (AbstractNamedAliasMetaData)object;
+ if (alias.getName() == null)
+ throw new IllegalArgumentException("Missing name: " + alias);
+ return super.endElement(object, qName, elementBinding);
+ }
+
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -110,8 +110,15 @@
* @param key the scope key
*/
void setInstallScope(ScopeKey key);
-
+
/**
+ * Can we use this context for autowiring.
+ *
+ * @return true if context can be used for autowiring
+ */
+ boolean isAutowireCandidate();
+
+ /**
* Get the lifecycle callbacks for a particular state.
*
* @param state the state callbacks refer to
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/deployment/KernelDeployment.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/deployment/KernelDeployment.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/deployment/KernelDeployment.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -28,6 +28,9 @@
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
+import org.jboss.beans.metadata.spi.LifecycleMetaData;
+import org.jboss.beans.metadata.spi.NamedAliasMetaData;
+import org.jboss.dependency.spi.ControllerMode;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.util.JBossInterface;
@@ -87,14 +90,56 @@
* @return the classloader
*/
ClassLoaderMetaData getClassLoader();
-
+
/**
+ * Get the default create lifecycle
+ *
+ * @return the create lifecycle
+ */
+ LifecycleMetaData getCreate();
+
+ /**
+ * Get the default start lifecycle
+ *
+ * @return the start lifecycle
+ */
+ LifecycleMetaData getStart();
+
+ /**
+ * Get the default stop lifecycle
+ *
+ * @return the stop lifecycle
+ */
+ LifecycleMetaData getStop();
+
+ /**
+ * Get the default destroy lifecycle
+ *
+ * @return the destroy lifecycle
+ */
+ LifecycleMetaData getDestroy();
+
+ /**
+ * Get named aliases.
+ *
+ * @return the aliases
+ */
+ Set<NamedAliasMetaData> getAliases();
+
+ /**
+ * Get the ControllerMode.
+ *
+ * @return mode
+ */
+ ControllerMode getMode();
+
+ /**
* Get the beans in the deployment
*
* @return List<BeanMetaData>
*/
List<BeanMetaData> getBeans();
-
+
/**
* Get the bean factories in the deployment
*
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -154,11 +154,25 @@
KernelController controller = kernel.getController();
KernelControllerContext context = (KernelControllerContext) controller.getContext(name, state);
if (context == null)
- throw new IllegalStateException("Bean not found " + name + " at state " + state);
+ return handleNotFoundContext(controller, name, state);
return context;
}
/**
+ * Handle not found context.
+ *
+ * @param controller the controller
+ * @param name the name of the bean
+ * @param state the state of the bean
+ * @return the context
+ * @throws IllegalStateException when the context does not exist at that state
+ */
+ protected KernelControllerContext handleNotFoundContext(KernelController controller, Object name, ControllerState state)
+ {
+ throw new IllegalStateException("Bean not found " + name + " at state " + state);
+ }
+
+ /**
* Change the context to the given state
*
* @param context the context
Modified: projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd 2007-06-01 14:57:24 UTC (rev 63304)
@@ -50,6 +50,11 @@
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="classloader" type="classloaderType" minOccurs="0"/>
+ <xsd:element name="alias" type="namedAliasType" minOccurs="0"/>
+ <xsd:element name="create" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="start" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="stop" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="destroy" type="lifecycleType" minOccurs="0"/>
<xsd:element name="bean" type="beanType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="beanfactory" type="beanfactoryType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:any namespace="##other" processContents="strict" minOccurs="0">
@@ -60,6 +65,7 @@
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="optional"/>
<xsd:attribute name="scoped" type="xsd:boolean" use="optional"/>
+ <xsd:attribute name="mode" type="controllerModeType" use="optional"/>
</xsd:complexType>
<xsd:complexType name="beanType">
@@ -100,6 +106,7 @@
<xsd:attribute name="name" type="xsd:string" use="optional"/>
<xsd:attribute name="class" type="xsd:token" use="optional"/>
<xsd:attribute name="mode" type="controllerModeType" use="optional"/>
+ <xsd:attribute name="autowire-candidate" type="xsd:boolean" use="optional"/>
</xsd:complexType>
<xsd:complexType name="classloaderType" mixed="true">
@@ -452,6 +459,21 @@
</xsd:simpleContent>
</xsd:complexType>
+ <xsd:complexType name="namedAliasType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ An alias that has a name attribute.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="aliasType">
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
<xsd:complexType name="parameterType" mixed="true">
<xsd:annotation>
<xsd:documentation>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithCandidate.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithCandidate.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithCandidate.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy" autowire-candidate="false"/>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithAlias.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithAlias.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithAlias.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment name="SimpleDeployment" xmlns="urn:jboss:bean-deployer:2.0">
+
+ <alias name="Bean1">FirstAlias</alias>
+
+ <alias name="Bean2">SecondAlias</alias>
+
+ <bean name="Bean1" class="java.lang.Object"/>
+
+ <bean name="Bean2" class="java.lang.Object"/>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithLifecycle.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithLifecycle.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithLifecycle.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment name="SimpleDeployment" xmlns="urn:jboss:bean-deployer:2.0">
+ <create/>
+ <start/>
+ <stop/>
+ <destroy/>
+ <bean name="Bean1" class="java.lang.Object"/>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithMode.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithMode.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithMode.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment name="SimpleDeployment" xmlns="urn:jboss:bean-deployer:2.0" mode="On Demand">
+ <bean name="Bean1" class="java.lang.Object"/>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAlias.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAlias.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAlias.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <alias name="TestName">SimpleAlias</alias>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAliasWithClass.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAliasWithClass.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAliasWithClass.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <alias name="TestName" class="java.lang.Integer">12345</alias>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAliasWithNoReplace.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAliasWithNoReplace.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAliasWithNoReplace.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <alias name="TestName" replace="false">X${alias.test.name}X</alias>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAliasWithReplace.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAliasWithReplace.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/NamedAliasWithReplace.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <alias name="TestName">X${alias.test.name}X</alias>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CandidateContextualInjection.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CandidateContextualInjection.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CandidateContextualInjection.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="testObject1" class="org.jboss.test.kernel.inject.support.PropertyInjectTestObject">
+ <property name="testerInterface"><inject/></property>
+ </bean>
+
+ <bean name="testObject2" class="org.jboss.test.kernel.inject.support.PropertyInjectTestObject">
+ <property name="duplicateTester"><inject option="Callback"/></property>
+ </bean>
+
+ <bean name="ignored" class="org.jboss.test.kernel.inject.support.DuplicateTester" autowire-candidate="false"/>
+
+ <bean name="used" class="org.jboss.test.kernel.inject.support.SomeTester"/>
+
+</deployment>
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/AliasTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/AliasTestCase.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/AliasTestCase.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -25,6 +25,8 @@
import junit.framework.Test;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.spi.NamedAliasMetaData;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
/**
* AliasTestCase.
@@ -115,4 +117,60 @@
assertFalse(aliases.isEmpty());
}
+ protected NamedAliasMetaData getNamedAlias(String name) throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshalDeployment(name);
+ Set<NamedAliasMetaData> aliases = deployment.getAliases();
+ assertNotNull(aliases);
+ assertEquals(1, aliases.size());
+ NamedAliasMetaData alias = aliases.iterator().next();
+ assertNotNull(alias);
+ return alias;
+ }
+
+ public void testNamedAlias() throws Exception
+ {
+ NamedAliasMetaData alias = getNamedAlias("NamedAlias.xml");
+ assertEquals("TestName", alias.getName());
+ assertEquals("SimpleAlias", alias.getAliasValue());
+ }
+
+ public void testNamedAliasWithClass() throws Exception
+ {
+ NamedAliasMetaData alias = getNamedAlias("NamedAliasWithClass.xml");
+ assertEquals("TestName", alias.getName());
+ assertEquals(12345, alias.getAliasValue());
+ }
+
+ public void testNamedAliasWithReplace() throws Exception
+ {
+ SecurityManager sm = suspendSecurity();
+ try
+ {
+ System.setProperty("alias.test.name", "SimpleAlias");
+ NamedAliasMetaData alias = getNamedAlias("NamedAliasWithReplace.xml");
+ assertEquals("TestName", alias.getName());
+ assertEquals("XSimpleAliasX", alias.getAliasValue());
+ }
+ finally
+ {
+ resumeSecurity(sm);
+ }
+ }
+
+ public void testNamedAliasWithNoReplace() throws Exception
+ {
+ SecurityManager sm = suspendSecurity();
+ try
+ {
+ System.setProperty("alias.test.name", "SimpleAlias");
+ NamedAliasMetaData alias = getNamedAlias("NamedAliasWithNoReplace.xml");
+ assertEquals("TestName", alias.getName());
+ assertEquals("X${alias.test.name}X", alias.getAliasValue());
+ }
+ finally
+ {
+ resumeSecurity(sm);
+ }
+ }
}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BeanTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BeanTestCase.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BeanTestCase.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -722,7 +722,13 @@
checkJBossXBException(IllegalArgumentException.class, expected);
}
}
-
+
+ public void testBeanWithCandidate() throws Exception
+ {
+ AbstractBeanMetaData bean = unmarshalBean("BeanWithCandidate.xml");
+ assertFalse(bean.isAutowireCandidate());
+ }
+
public static Test suite()
{
return suite(BeanTestCase.class);
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentTestCase.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentTestCase.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -22,17 +22,19 @@
package org.jboss.test.kernel.deployment.xml.test;
import java.util.List;
+import java.util.Set;
+import junit.framework.Test;
import org.jboss.beans.metadata.plugins.factory.GenericBeanFactory;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.LifecycleMetaData;
+import org.jboss.dependency.spi.ControllerMode;
import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
import org.jboss.test.kernel.deployment.xml.support.TestBeanMetaDataFactory;
import org.jboss.test.kernel.deployment.xml.support.TestBeanMetaDataFactory1;
import org.jboss.test.kernel.deployment.xml.support.TestBeanMetaDataFactory2;
-import junit.framework.Test;
-
/**
* DeploymentTestCase.
*
@@ -232,7 +234,65 @@
assertNotNull(bean);
assertEquals("Bean4", bean.getBean());
}
-
+
+ public void testDeploymentWithLifecycle() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshalDeployment("DeploymentWithLifecycle.xml");
+
+ LifecycleMetaData create = deployment.getCreate();
+ assertNotNull(create);
+ LifecycleMetaData start = deployment.getStart();
+ assertNotNull(start);
+ LifecycleMetaData stop = deployment.getStop();
+ assertNotNull(stop);
+ LifecycleMetaData destroy = deployment.getDestroy();
+ assertNotNull(destroy);
+
+ List beans = deployment.getBeans();
+ assertNotNull(beans);
+ assertEquals(1, beans.size());
+ BeanMetaData bean = (BeanMetaData)beans.iterator().next();
+
+ assertEquals(create, bean.getCreate());
+ assertEquals(start, bean.getStart());
+ assertEquals(stop, bean.getStop());
+ assertEquals(destroy, bean.getDestroy());
+ }
+
+ public void testDeploymentWithMode() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshalDeployment("DeploymentWithMode.xml");
+
+ ControllerMode mode = deployment.getMode();
+ assertNotNull(mode);
+ assertEquals(ControllerMode.ON_DEMAND, mode);
+
+ List beans = deployment.getBeans();
+ assertNotNull(beans);
+ assertEquals(1, beans.size());
+ BeanMetaData bean = (BeanMetaData)beans.iterator().next();
+
+ assertEquals(mode, bean.getMode());
+ }
+
+ public void testDeploymentWithAlias() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshalDeployment("DeploymentWithAlias.xml");
+ List beans = deployment.getBeans();
+ assertNotNull(beans);
+ assertEquals(2, beans.size());
+ BeanMetaData first = (BeanMetaData)beans.get(0);
+ Set fstAliases = first.getAliases();
+ assertNotNull(fstAliases);
+ assertEquals(1, fstAliases.size());
+ assertEquals("FirstAlias", fstAliases.iterator().next());
+ BeanMetaData second = (BeanMetaData)beans.get(1);
+ Set sndAliases = second.getAliases();
+ assertNotNull(sndAliases);
+ assertEquals(1, sndAliases.size());
+ assertEquals("SecondAlias", sndAliases.iterator().next());
+ }
+
public static Test suite()
{
return suite(DeploymentTestCase.class);
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SomeTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SomeTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SomeTester.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -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.kernel.inject.support;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class SomeTester implements TesterInterface
+{
+
+ public void someMethod()
+ {
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CandidateContextualInjectionTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CandidateContextualInjectionTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CandidateContextualInjectionTestCase.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,64 @@
+/*
+* 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.inject.test;
+
+import junit.framework.Test;
+import org.jboss.test.kernel.inject.support.PropertyInjectTestObject;
+import org.jboss.test.kernel.inject.support.TesterInterface;
+
+/**
+ * Candidate injection.
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class CandidateContextualInjectionTestCase extends SingleContextualInjectionAdapter
+{
+ public CandidateContextualInjectionTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(CandidateContextualInjectionTestCase.class);
+ }
+
+ protected String getResource()
+ {
+ return "CandidateContextualInjection.xml";
+ }
+
+ protected void checkInjection()
+ {
+ PropertyInjectTestObject test1 = (PropertyInjectTestObject) getBean("testObject1");
+ PropertyInjectTestObject test2 = (PropertyInjectTestObject) getBean("testObject2");
+
+ TesterInterface ignored = (TesterInterface)getBean("ignored");
+ assertNotNull(ignored);
+ TesterInterface used = (TesterInterface)getBean("used");
+ assertNotNull(used);
+ assertEquals(used, test1.getTesterInterface());
+
+ assertNull(test2.getDuplicateTester());
+ }
+
+}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -50,6 +50,7 @@
suite.addTest(CollectionCallbackTestCase.suite());
suite.addTest(CardinalityCallbackTestCase.suite());
suite.addTest(BadCardinalityCallbackTestCase.suite());
+ suite.addTest(CandidateContextualInjectionTestCase.suite());
/*
suite.addTest(AdditionAnnotationCallbackTestCase.suite());
suite.addTest(CollectionAnnotationCallbackTestCase.suite());
Added: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/ImportHandler.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/ImportHandler.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/ImportHandler.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,68 @@
+/*
+* 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.deployment.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.spring.metadata.AbstractImportMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * The import handler.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ImportHandler extends DefaultElementHandler
+{
+ /**
+ * The import handler
+ */
+ public static final ImportHandler HANDLER = new ImportHandler();
+
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractImportMetaData();
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractImportMetaData imd = (AbstractImportMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("resource".equals(localName))
+ imd.setResource(attrs.getValue(i));
+ }
+ }
+
+ public Object endElement(Object object, QName qName, ElementBinding elementBinding)
+ {
+ AbstractImportMetaData imd = (AbstractImportMetaData)object;
+ if (imd.getResource() == null)
+ throw new IllegalArgumentException("Missing resource: " + imd);
+ return imd;
+ }
+
+}
Copied: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/ImportInterceptor.java (from rev 63248, projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeansInterceptor.java)
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/ImportInterceptor.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/ImportInterceptor.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,47 @@
+/*
+* 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.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.spring.metadata.AbstractImportMetaData;
+import org.jboss.spring.metadata.AbstractSpringDeployment;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ImportInterceptor extends DefaultElementInterceptor
+{
+ /**
+ * The interceptor
+ */
+ public static final ImportInterceptor INTERCEPTOR = new ImportInterceptor();
+
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractSpringDeployment deployment = (AbstractSpringDeployment)parent;
+ AbstractImportMetaData importMD = (AbstractImportMetaData)child;
+ deployment.addImport(importMD);
+ }
+
+}
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 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeanHandler.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -21,20 +21,26 @@
*/
package org.jboss.spring.deployment.xml;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
-import java.util.Arrays;
-import java.util.List;
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.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.metadata.AbstractConstructorArg;
import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
-import org.jboss.spring.metadata.AbstractConstructorArg;
import org.xml.sax.Attributes;
/**
@@ -47,6 +53,11 @@
*/
public static final SpringBeanHandler HANDLER = new SpringBeanHandler();
+ /**
+ * The delimiter pattern
+ */
+ public static final String DELIMITER_PATTERN = "[,; ]";
+
public Object startElement(Object parent, QName name, ElementBinding element)
{
return new AbstractBeanMetaData();
@@ -60,12 +71,34 @@
String localName = attrs.getLocalName(i);
if ("id".equals(localName))
bean.setName(attrs.getValue(i));
+ else if ("name".equals(localName))
+ {
+ String name = attrs.getValue(i);
+ String[] names = name.split(DELIMITER_PATTERN);
+ bean.setAliases(new TreeSet<Object>(Arrays.asList(names)));
+ }
else if ("class".equals(localName))
bean.setBean(attrs.getValue(i));
else if ("init-method".equals(localName))
bean.setCreate(new AbstractLifecycleMetaData(attrs.getValue(i)));
+ else if ("lazy-init".equals(localName) && Boolean.parseBoolean(attrs.getValue(i)) == true)
+ bean.setMode(ControllerMode.ON_DEMAND);
+ else if ("autowire-candidate".equals(localName))
+ bean.setAutowireCandidate(Boolean.parseBoolean(attrs.getValue(i)));
else if ("destroy-method".equals(localName))
bean.setDestroy(new AbstractLifecycleMetaData(attrs.getValue(i)));
+ else if ("depends-on".equals(localName))
+ {
+ Set<DemandMetaData> demands = bean.getDemands();
+ if (demands == null)
+ {
+ demands = new HashSet<DemandMetaData>();
+ bean.setDemands(demands);
+ }
+ String[] values = attrs.getValue(i).split(DELIMITER_PATTERN);
+ for(String name : values)
+ demands.add(new AbstractDemandMetaData(name));
+ }
else if ("factory-method".equals(localName) || "factory-bean".equals(localName))
{
AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) bean.getConstructor();
Modified: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeansHandler.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeansHandler.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeansHandler.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -25,6 +25,8 @@
import javax.xml.namespace.QName;
import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
import org.jboss.spring.metadata.AbstractSpringDeployment;
import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
@@ -47,7 +49,7 @@
public void attributes(Object object, QName qName, ElementBinding elementBinding, Attributes attrs, NamespaceContext namespaceContext)
{
- AbstractSpringDeployment deployment = (AbstractSpringDeployment) object;
+ AbstractKernelDeployment deployment = (AbstractKernelDeployment) object;
for (int i = 0; i < attrs.getLength(); ++i)
{
String localName = attrs.getLocalName(i);
@@ -55,6 +57,8 @@
deployment.setCreate(new AbstractLifecycleMetaData(attrs.getValue(i)));
else if ("default-destroy-method".equals(localName))
deployment.setDestroy(new AbstractLifecycleMetaData(attrs.getValue(i)));
+ else if ("default-lazy-init".equals(localName) && Boolean.parseBoolean(attrs.getValue(i)) == true)
+ deployment.setMode(ControllerMode.ON_DEMAND);
}
}
Deleted: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeansInterceptor.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeansInterceptor.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeansInterceptor.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -1,72 +0,0 @@
-/*
-* 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.deployment.xml;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.namespace.QName;
-
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
-import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
-import org.jboss.spring.metadata.AbstractSpringDeployment;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
-
-/**
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class SpringBeansInterceptor extends DefaultElementInterceptor
-{
- /**
- * The interceptor
- */
- public static final SpringBeansInterceptor INTERCEPTOR = new SpringBeansInterceptor();
-
- public void add(Object parent, Object child, QName name)
- {
- AbstractKernelDeployment deployment = (AbstractKernelDeployment)parent;
- AbstractBeanMetaData bean = (AbstractBeanMetaData)child;
- List<BeanMetaDataFactory> beans = deployment.getBeanFactories();
- if (beans == null)
- {
- beans = new ArrayList<BeanMetaDataFactory>();
- deployment.setBeanFactories(beans);
- }
- beans.add(bean);
-
- // handle bean lifecycle
- if (deployment instanceof AbstractSpringDeployment)
- {
- AbstractSpringDeployment sd = (AbstractSpringDeployment)deployment;
- // set deployment defaults, if not already set per bean
- if (bean.getCreate() == null && sd.getCreate() != null)
- {
- bean.setCreate(sd.getCreate());
- }
- if (bean.getDestroy() == null && sd.getDestroy() != null)
- {
- bean.setDestroy(sd.getDestroy());
- }
- }
- }
-
-}
Modified: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBinding.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBinding.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBinding.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -48,6 +48,26 @@
public static final QName beansQName = new QName(SPRING_DEPLOYER_NS, "beans");
/**
+ * The alias binding
+ */
+ public static final QName aliasTypeQName = new QName(SPRING_DEPLOYER_NS, "aliasType");
+
+ /**
+ * The alias element name
+ */
+ public static final QName aliasQName = new QName(SPRING_DEPLOYER_NS, "alias");
+
+ /**
+ * The import binding
+ */
+ public static final QName importTypeQName = new QName(SPRING_DEPLOYER_NS, "importType");
+
+ /**
+ * The import element name
+ */
+ public static final QName importQName = new QName(SPRING_DEPLOYER_NS, "import");
+
+ /**
* The bean binding
*/
public static final QName beanTypeQName = new QName(SPRING_DEPLOYER_NS, "beanType");
@@ -179,6 +199,8 @@
// init
initDeployment(schemaBinding);
initBean(schemaBinding);
+ initAlias(schemaBinding);
+ initImport(schemaBinding);
initArtifacts(schemaBinding);
}
@@ -207,6 +229,30 @@
}
/**
+ * Initialize alias part of the schema binding
+ *
+ * @param schemaBinding the schema binding
+ */
+ private static void initAlias(SchemaBinding schemaBinding)
+ {
+ // alias binding
+ TypeBinding aliasType = schemaBinding.getType(aliasTypeQName);
+ SpringSchemaBindingHelper.initAliasHandler(aliasType);
+ }
+
+ /**
+ * Initialize import part of the schema binding
+ *
+ * @param schemaBinding the schema binding
+ */
+ private static void initImport(SchemaBinding schemaBinding)
+ {
+ // import binding
+ TypeBinding importType = schemaBinding.getType(importTypeQName);
+ SpringSchemaBindingHelper.initImportHandler(importType);
+ }
+
+ /**
* Initialize other parts of the schema binding
*
* @param schemaBinding the schema binding
Modified: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBindingHelper.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBindingHelper.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBindingHelper.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -22,11 +22,14 @@
package org.jboss.spring.deployment.xml;
import org.jboss.kernel.plugins.deployment.xml.BeanPropertyInterceptor;
+import org.jboss.kernel.plugins.deployment.xml.DeploymentAliasInterceptor;
+import org.jboss.kernel.plugins.deployment.xml.DeploymentBeanInterceptor;
import org.jboss.kernel.plugins.deployment.xml.DeploymentWildcardHandler;
import org.jboss.kernel.plugins.deployment.xml.EntryHandler;
import org.jboss.kernel.plugins.deployment.xml.EntryKeyInterceptor;
import org.jboss.kernel.plugins.deployment.xml.EntryValueInterceptor;
import org.jboss.kernel.plugins.deployment.xml.MapEntryInterceptor;
+import org.jboss.kernel.plugins.deployment.xml.NamedAliasHandler;
import org.jboss.kernel.plugins.deployment.xml.NullValueElementInterceptor;
import org.jboss.kernel.plugins.deployment.xml.PlainValueCharactersHandler;
import org.jboss.kernel.plugins.deployment.xml.PropHandler;
@@ -47,14 +50,26 @@
public static void initBeansHandler(TypeBinding typeBinding)
{
typeBinding.setHandler(SpringBeansHandler.HANDLER);
+ // handle import
+ typeBinding.pushInterceptor(SpringSchemaBinding.importQName, ImportInterceptor.INTERCEPTOR);
+ // handle aliases
+ typeBinding.pushInterceptor(SpringSchemaBinding.aliasQName, DeploymentAliasInterceptor.INTERCEPTOR);
// handle beans
- typeBinding.pushInterceptor(SpringSchemaBinding.beanQName, SpringBeansInterceptor.INTERCEPTOR);
- // todo alias
- // todo import
+ typeBinding.pushInterceptor(SpringSchemaBinding.beanQName, DeploymentBeanInterceptor.INTERCEPTOR);
// Deployment can take wildcards
typeBinding.getWildcard().setWildcardHandler(DeploymentWildcardHandler.HANDLER);
}
+ public static void initAliasHandler(TypeBinding typeBinding)
+ {
+ typeBinding.setHandler(NamedAliasHandler.HANDLER);
+ }
+
+ public static void initImportHandler(TypeBinding typeBinding)
+ {
+ typeBinding.setHandler(ImportHandler.HANDLER);
+ }
+
public static void initBeanHandler(TypeBinding typeBinding)
{
typeBinding.setHandler(SpringBeanHandler.HANDLER);
Added: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/metadata/AbstractImportMetaData.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/metadata/AbstractImportMetaData.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/metadata/AbstractImportMetaData.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,64 @@
+/*
+* 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.metadata;
+
+import java.io.Serializable;
+
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractImportMetaData extends JBossObject implements Serializable
+{
+ private static final long serialVersionUID = -5372914407585899708L;
+
+ protected String resource;
+
+ public String getResource()
+ {
+ return resource;
+ }
+
+ public void setResource(String resource)
+ {
+ this.resource = resource;
+ }
+
+ protected int getHashCode()
+ {
+ return resource.hashCode();
+ }
+
+ protected void toString(JBossStringBuilder buffer)
+ {
+ buffer.append("resource=").append(resource);
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof AbstractImportMetaData == false)
+ return false;
+ return resource.equals(((AbstractImportMetaData)obj).resource);
+ }
+}
Modified: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/metadata/AbstractSpringDeployment.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/metadata/AbstractSpringDeployment.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/metadata/AbstractSpringDeployment.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -21,8 +21,10 @@
*/
package org.jboss.spring.metadata;
-import org.jboss.beans.metadata.spi.LifecycleMetaData;
-import org.jboss.dependency.spi.ControllerState;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
/**
@@ -31,34 +33,25 @@
public class AbstractSpringDeployment extends AbstractKernelDeployment
{
/** The serialVersionUID */
- private static final long serialVersionUID = 1470671009380840890L;
+ private static final long serialVersionUID = 2L;
- /* default init lifecycle method */
- protected LifecycleMetaData create;
-
- /* default destroy lifecycle method */
- protected LifecycleMetaData destroy;
-
- public LifecycleMetaData getCreate()
+ public void addImport(AbstractImportMetaData imd)
{
- return create;
+ List<BeanMetaDataFactory> importedBeans = getBeans(imd.getResource());
+ if (importedBeans != null && importedBeans.isEmpty() == false)
+ {
+ List<BeanMetaDataFactory> beans = getBeanFactories();
+ if (beans == null)
+ {
+ beans = new ArrayList<BeanMetaDataFactory>();
+ setBeanFactories(beans);
+ }
+ beans.addAll(importedBeans);
+ }
}
- public void setCreate(LifecycleMetaData create)
+ protected List<BeanMetaDataFactory> getBeans(String resource)
{
- create.setState(ControllerState.CREATE);
- this.create = create;
+ return null; //todo
}
-
- public LifecycleMetaData getDestroy()
- {
- return destroy;
- }
-
- public void setDestroy(LifecycleMetaData destroy)
- {
- destroy.setState(ControllerState.CREATE);
- this.destroy = destroy;
- }
-
}
Added: projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/AliasSpringTestCase.xml
===================================================================
--- projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/AliasSpringTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/AliasSpringTestCase.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="urn:jboss:spring-beans:2.0">
+
+ <bean id="testBean" class="org.jboss.test.spring.support.SimpleBean" name="al1,al2;al3 al4" />
+
+ <alias name="testBean" alias="fromAlias"/>
+
+</beans>
\ No newline at end of file
Added: projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/DependsSpringTestCase.xml
===================================================================
--- projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/DependsSpringTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/DependsSpringTestCase.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="urn:jboss:spring-beans:2.0">
+
+ <bean id="wait" class="org.jboss.test.spring.support.WaitingBean" depends-on="set" />
+
+ <bean id="set" class="org.jboss.test.spring.support.SettingBean"/>
+
+</beans>
\ No newline at end of file
Added: projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/ImportSpringTestCase.xml
===================================================================
--- projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/ImportSpringTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/ImportSpringTestCase.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="urn:jboss:spring-beans:2.0">
+
+ <import resource="AliasSpringTestCase.xml"/>
+
+ <bean id="Bean1" class="org.jboss.test.spring.support.SimpleBean" />
+
+</beans>
\ No newline at end of file
Added: projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/LazySpringTestCase.xml
===================================================================
--- projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/LazySpringTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/resources/tests/org/jboss/test/spring/test/LazySpringTestCase.xml 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="urn:jboss:spring-beans:2.0">
+
+ <bean id="set" class="org.jboss.test.spring.support.SettingBean" lazy-init="true"/>
+
+</beans>
\ No newline at end of file
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/SettingBean.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/SettingBean.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/SettingBean.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,33 @@
+/*
+* 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;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SettingBean
+{
+ public SettingBean()
+ {
+ WaitingBean.setFlag(true);
+ }
+}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/WaitingBean.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/WaitingBean.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/WaitingBean.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,47 @@
+/*
+* 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;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class WaitingBean
+{
+ private static boolean flag;
+
+ public WaitingBean()
+ {
+ if (flag == false)
+ throw new IllegalArgumentException("I depend on someone setting this flag.");
+ }
+
+ public static boolean getFlag()
+ {
+ return flag;
+ }
+
+ public static void setFlag(boolean f)
+ {
+ flag = f;
+ }
+
+}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/AliasSpringTestCase.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/AliasSpringTestCase.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/AliasSpringTestCase.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,63 @@
+/*
+* 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.test.spring.support.SimpleBean;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AliasSpringTestCase extends TempSpringMicrocontainerTest
+{
+ public AliasSpringTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Setup the test
+ *
+ * @return the test
+ */
+ public static Test suite()
+ {
+ return suite(AliasSpringTestCase.class);
+ }
+
+ public void testAlias() throws Exception
+ {
+ SimpleBean testBean = (SimpleBean) getBean("testBean");
+ SimpleBean al1 = (SimpleBean) getBean("al1");
+ SimpleBean al2 = (SimpleBean) getBean("al2");
+ SimpleBean al3 = (SimpleBean) getBean("al3");
+ SimpleBean al4 = (SimpleBean) getBean("al4");
+ SimpleBean fromAlias = (SimpleBean) getBean("fromAlias");
+
+ assertEquals(testBean, al1);
+ assertEquals(al1, al2);
+ assertEquals(al2, al3);
+ assertEquals(al3, al4);
+ assertEquals(al4, fromAlias);
+ }
+
+}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/DependsSpringTestCase.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/DependsSpringTestCase.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/DependsSpringTestCase.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.spring.test;
+
+import junit.framework.Test;
+import org.jboss.test.spring.support.SettingBean;
+import org.jboss.test.spring.support.WaitingBean;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DependsSpringTestCase extends TempSpringMicrocontainerTest
+{
+ public DependsSpringTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Setup the test
+ *
+ * @return the test
+ */
+ public static Test suite()
+ {
+ return suite(DependsSpringTestCase.class);
+ }
+
+ public void testDepends() throws Exception
+ {
+ WaitingBean wait = (WaitingBean)getBean("wait");
+ assertNotNull(wait);
+ assertTrue(WaitingBean.getFlag());
+ SettingBean set = (SettingBean)getBean("set");
+ assertNotNull(set);
+ }
+
+}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/ImportSpringTestCase.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/ImportSpringTestCase.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/ImportSpringTestCase.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,54 @@
+/*
+* 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;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ImportSpringTestCase extends TempSpringMicrocontainerTest
+{
+ public ImportSpringTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Setup the test
+ *
+ * @return the test
+ */
+ public static Test suite()
+ {
+ return suite(ImportSpringTestCase.class);
+ }
+
+ public void testImport() throws Exception
+ {
+/*
+ SimpleBean testBean = (SimpleBean) getBean("testBean", ControllerState.INSTANTIATED);
+ SimpleBean bean1 = (SimpleBean) getBean("Bean1", ControllerState.INSTANTIATED);
+*/
+ }
+
+}
Modified: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateSpringTestCase.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateSpringTestCase.java 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateSpringTestCase.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -22,15 +22,14 @@
package org.jboss.test.spring.test;
import junit.framework.Test;
-import org.jboss.test.spring.support.SimpleBean;
import org.jboss.dependency.spi.ControllerState;
+import org.jboss.test.spring.support.SimpleBean;
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
public class InstantiateSpringTestCase extends TempSpringMicrocontainerTest
{
-
public InstantiateSpringTestCase(String name)
{
super(name);
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/LazySpringTestCase.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/LazySpringTestCase.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/LazySpringTestCase.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,62 @@
+/*
+* 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.test.spring.support.SettingBean;
+import org.jboss.test.spring.support.WaitingBean;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LazySpringTestCase extends LazyTempSpringMicrocontainerTest
+{
+ public LazySpringTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Setup the test
+ *
+ * @return the test
+ */
+ public static Test suite()
+ {
+ return suite(LazySpringTestCase.class);
+ }
+
+ protected void setUp() throws Exception
+ {
+ WaitingBean.setFlag(false);
+ super.setUp();
+ }
+
+ public void testLazy() throws Exception
+ {
+ assertFalse(WaitingBean.getFlag());
+ SettingBean set = (SettingBean)getBean("set");
+ assertNotNull(set);
+ assertTrue(WaitingBean.getFlag());
+ }
+
+}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/LazyTempSpringMicrocontainerTest.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/LazyTempSpringMicrocontainerTest.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/LazyTempSpringMicrocontainerTest.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,49 @@
+/*
+* 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 org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LazyTempSpringMicrocontainerTest extends MicrocontainerTest
+{
+ public LazyTempSpringMicrocontainerTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Get the lazy test delegate
+ *
+ * @param clazz the test class
+ * @return the lazy delegate
+ * @throws Exception for any error
+ */
+ public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+ {
+ return new LazyTempSpringMicrocontainerTestDelegate(clazz);
+ }
+
+}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/LazyTempSpringMicrocontainerTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/LazyTempSpringMicrocontainerTestDelegate.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/LazyTempSpringMicrocontainerTestDelegate.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.spring.test;
+
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LazyTempSpringMicrocontainerTestDelegate extends TempSpringMicrocontainerTestDelegate
+{
+ public LazyTempSpringMicrocontainerTestDelegate(Class clazz) throws Exception
+ {
+ super(clazz);
+ }
+
+ protected KernelControllerContext handleNotFoundContext(KernelController controller, Object name, ControllerState state)
+ {
+ KernelControllerContext context = (KernelControllerContext)controller.getContext(name, null);
+ if (context != null && ControllerMode.ON_DEMAND.equals(context.getMode()))
+ {
+ try
+ {
+ controller.change(context, ControllerState.INSTALLED);
+ return context;
+ }
+ catch (Throwable t)
+ {
+ throw new Error("Unable to change on demand context to Installed.", t);
+ }
+ }
+ throw new IllegalStateException("Bean not found " + name + " at state " + state);
+ }
+}
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 2007-06-01 14:53:50 UTC (rev 63303)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/SpringTestSuite.java 2007-06-01 14:57:24 UTC (rev 63304)
@@ -44,6 +44,10 @@
suite.addTest(InstantiateSpringTestCase.suite());
suite.addTest(InstantiateMixedTestCase.suite());
suite.addTest(InstantiateMixed2TestCase.suite());
+ suite.addTest(AliasSpringTestCase.suite());
+ suite.addTest(DependsSpringTestCase.suite());
+ suite.addTest(LazySpringTestCase.suite());
+ suite.addTest(ImportSpringTestCase.suite());
return suite;
}
More information about the jboss-cvs-commits
mailing list