[seam-commits] Seam SVN: r7516 - in trunk/src/main/org/jboss/seam: init and 1 other directory.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Mar 6 23:52:03 EST 2008
Author: christian.bauer at jboss.com
Date: 2008-03-06 23:52:03 -0500 (Thu, 06 Mar 2008)
New Revision: 7516
Modified:
trunk/src/main/org/jboss/seam/Component.java
trunk/src/main/org/jboss/seam/components-2.1.xsd
trunk/src/main/org/jboss/seam/init/ComponentDescriptor.java
trunk/src/main/org/jboss/seam/init/Initialization.java
Log:
JBSEAM-2708, added startupDepends attribute to components.xml
Modified: trunk/src/main/org/jboss/seam/Component.java
===================================================================
--- trunk/src/main/org/jboss/seam/Component.java 2008-03-06 10:11:52 UTC (rev 7515)
+++ trunk/src/main/org/jboss/seam/Component.java 2008-03-07 04:52:03 UTC (rev 7516)
@@ -205,27 +205,28 @@
// only used for tests
public Component(Class<?> clazz, String componentName)
{
- this(clazz, componentName, Seam.getComponentScope(clazz), false, null);
+ this(clazz, componentName, Seam.getComponentScope(clazz), false, new String[0], null);
}
// only used for tests
public Component(Class<?> clazz, Context applicationContext)
{
- this( clazz, getComponentName(clazz), Seam.getComponentScope(clazz), false, null, applicationContext );
+ this( clazz, getComponentName(clazz), Seam.getComponentScope(clazz), false, new String[0], null, applicationContext );
}
- public Component(Class<?> clazz, String componentName, ScopeType componentScope, boolean startup, String jndiName)
+ public Component(Class<?> clazz, String componentName, ScopeType componentScope, boolean startup, String[] dependencies, String jndiName)
{
- this(clazz, componentName, componentScope, startup, jndiName, Contexts.getApplicationContext());
+ this(clazz, componentName, componentScope, startup, dependencies, jndiName, Contexts.getApplicationContext());
}
- private Component(Class<?> beanClass, String componentName, ScopeType componentScope, boolean startup, String componentJndiName, Context applicationContext)
+ private Component(Class<?> beanClass, String componentName, ScopeType componentScope, boolean startup, String[] dependencies, String componentJndiName, Context applicationContext)
{
super(beanClass);
name = componentName;
scope = componentScope;
this.startup = startup;
+ this.dependencies = dependencies;
type = Seam.getComponentType( getBeanClass() );
interceptionEnabled = Seam.isInterceptionEnabled( getBeanClass() );
perNestedConversation = hasAnnotation(getBeanClass(), PerNestedConversation.class);
@@ -302,7 +303,10 @@
throw new IllegalArgumentException("@Startup only supported for SESSION or APPLICATION scoped components: " + name);
}
Startup annotation = getBeanClass().getAnnotation(Startup.class);
- dependencies = annotation==null ? new String[0] : annotation.depends();
+ if (dependencies.length == 0 && annotation != null)
+ {
+ dependencies = annotation.depends();
+ }
}
}
Modified: trunk/src/main/org/jboss/seam/components-2.1.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/components-2.1.xsd 2008-03-06 10:11:52 UTC (rev 7515)
+++ trunk/src/main/org/jboss/seam/components-2.1.xsd 2008-03-07 04:52:03 UTC (rev 7516)
@@ -56,6 +56,7 @@
<xs:attribute name="installed" default="true" type="xs:boolean"/>
<xs:attribute name="auto-create" default="false" type="xs:boolean"/>
<xs:attribute name="startup" default="false" type="xs:boolean"/>
+ <xs:attribute name="startupDepends" type="xs:string"/>
</xs:attributeGroup>
<xs:element name="factory">
<xs:complexType>
Modified: trunk/src/main/org/jboss/seam/init/ComponentDescriptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/ComponentDescriptor.java 2008-03-06 10:11:52 UTC (rev 7515)
+++ trunk/src/main/org/jboss/seam/init/ComponentDescriptor.java 2008-03-07 04:52:03 UTC (rev 7516)
@@ -26,13 +26,14 @@
protected Boolean installed;
protected Boolean autoCreate;
protected Boolean startup;
+ protected String[] startupDepends;
protected Integer precedence;
/**
* For components.xml
*/
public ComponentDescriptor(String name, Class<?> componentClass, ScopeType scope,
- Boolean autoCreate, Boolean startup, String jndiName, Boolean installed, Integer precedence)
+ Boolean autoCreate, Boolean startup, String[] startupDepends, String jndiName, Boolean installed, Integer precedence)
{
this.name = name;
this.componentClass = componentClass;
@@ -42,6 +43,7 @@
this.autoCreate = autoCreate;
this.precedence = precedence;
this.startup = startup;
+ this.startupDepends = startupDepends;
}
/**
@@ -112,8 +114,21 @@
return pkg!=null && pkg.isAnnotationPresent(AutoCreate.class);
}
- public String[] getDependencies()
+ public String[] getStartupDependencies()
{
+ if (startupDepends != null && startupDepends.length > 0) {
+ return startupDepends;
+ }
+ Startup startup = componentClass.getAnnotation(Startup.class);
+ if (startup != null)
+ {
+ return startup.depends();
+ }
+ return new String[0];
+ }
+
+ public String[] getDependencies()
+ {
Install install = componentClass.getAnnotation(Install.class);
if (install == null)
{
Modified: trunk/src/main/org/jboss/seam/init/Initialization.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/Initialization.java 2008-03-06 10:11:52 UTC (rev 7515)
+++ trunk/src/main/org/jboss/seam/init/Initialization.java 2008-03-07 04:52:03 UTC (rev 7516)
@@ -86,6 +86,7 @@
nonPropertyAttributes.add("installed");
nonPropertyAttributes.add("scope");
nonPropertyAttributes.add("startup");
+ nonPropertyAttributes.add("startupDepends");
nonPropertyAttributes.add("class");
nonPropertyAttributes.add("jndi-name");
nonPropertyAttributes.add("precedence");
@@ -370,6 +371,9 @@
Boolean autoCreate = autocreateAttribute==null ? null : "true".equals(autocreateAttribute);
String startupAttribute = component.attributeValue("startup");
Boolean startup = startupAttribute==null ? null : "true".equals(startupAttribute);
+ String startupDependsAttribute = component.attributeValue("startupDepends");
+ String[] startupDepends = startupDependsAttribute==null ? new String[0] : startupDependsAttribute.split(" ");
+
if (className != null)
{
Class<?> clazz = getClassUsingImports(className);
@@ -386,7 +390,7 @@
name = clazz.getAnnotation(Name.class).value();
}
- ComponentDescriptor descriptor = new ComponentDescriptor(name, clazz, scope, autoCreate, startup, jndiName, installed, precedence);
+ ComponentDescriptor descriptor = new ComponentDescriptor(name, clazz, scope, autoCreate, startup, startupDepends, jndiName, installed, precedence);
addComponentDescriptor(descriptor);
installedComponentClasses.add(clazz);
}
@@ -977,6 +981,7 @@
name,
descriptor.getScope(),
descriptor.isStartup(),
+ descriptor.getStartupDependencies(),
descriptor.getJndiName()
);
context.set(componentName, component);
More information about the seam-commits
mailing list