[jboss-cvs] jboss-seam/src/main/org/jboss/seam/init ...
Gavin King
gavin.king at jboss.com
Fri Nov 24 18:51:23 EST 2006
User: gavin
Date: 06/11/24 18:51:23
Modified: src/main/org/jboss/seam/init Initialization.java
Log:
fix bugs in latest @Install code
Revision Changes Path
1.130 +33 -11 jboss-seam/src/main/org/jboss/seam/init/Initialization.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Initialization.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/init/Initialization.java,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -b -r1.129 -r1.130
--- Initialization.java 24 Nov 2006 23:15:18 -0000 1.129
+++ Initialization.java 24 Nov 2006 23:51:23 -0000 1.130
@@ -57,7 +57,7 @@
/**
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.129 $
+ * @version $Revision: 1.130 $
*/
public class Initialization
{
@@ -263,7 +263,7 @@
String scopeName = component.attributeValue("scope");
String jndiName = component.attributeValue("jndi-name");
String precedenceString = component.attributeValue("precendence");
- Integer precedence = precedenceString==null ? null : Integer.valueOf(precedenceString);
+ int precedence = precedenceString==null ? Install.APPLICATION : Integer.valueOf(precedenceString);
ScopeType scope = scopeName == null ? null : ScopeType.valueOf(scopeName.toUpperCase());
boolean autoCreate = "true".equals(component.attributeValue("auto-create"));
if (className != null)
@@ -336,7 +336,13 @@
{
String name = descriptor.getName();
ComponentDescriptor existing = componentDescriptors.get( name );
- if ( existing==null || existing.getPrecedence()<descriptor.getPrecedence() )
+ boolean newHasPrecedence = existing!=null && existing.getPrecedence()<descriptor.getPrecedence();
+ boolean oldHasPrecedence = existing!=null && existing.getPrecedence()>descriptor.getPrecedence();
+ if ( newHasPrecedence || oldHasPrecedence )
+ {
+ log.info("two components with same name, higher precedence wins: " + name);
+ }
+ if ( existing==null || newHasPrecedence )
{
componentDescriptors.put(name, descriptor);
}
@@ -429,12 +435,10 @@
private void scanForComponents()
{
Set<Package> scannedPackages = new HashSet<Package>();
- for (Class<Object> scannedClass : new ComponentScanner("seam.properties").getClasses())
- {
- installScannedClass(scannedPackages, scannedClass);
- }
- for (Class<Object> scannedClass : new ComponentScanner("META-INF/components.xml")
- .getClasses())
+ Set<Class<Object>> scannedClasses = new HashSet<Class<Object>>();
+ scannedClasses.addAll( new ComponentScanner("seam.properties").getClasses() );
+ scannedClasses.addAll( new ComponentScanner("META-INF/components.xml").getClasses() );
+ for (Class<Object> scannedClass: scannedClasses)
{
installScannedClass(scannedPackages, scannedClass);
}
@@ -512,8 +516,7 @@
private void installRole(Class<Object> scannedClass, Role role)
{
ScopeType scope = Seam.getComponentRoleScope(scannedClass, role);
- addComponentDescriptor(new ComponentDescriptor(role.name(), scannedClass, scope, false,
- null, null, null));
+ addComponentDescriptor( new ComponentDescriptor( role.name(), scannedClass, scope ) );
}
private void addNamespace(Package pkg)
@@ -852,6 +855,9 @@
private boolean autoCreate;
private Integer precedence;
+ /**
+ * For components.xml
+ */
public ComponentDescriptor(String name, Class<?> componentClass, ScopeType scope,
boolean autoCreate, String jndiName, Boolean installed, Integer precedence)
{
@@ -864,11 +870,27 @@
this.precedence = precedence;
}
+ /**
+ * For a scanned role
+ */
+ public ComponentDescriptor(String name, Class<?> componentClass, ScopeType scope)
+ {
+ this.name = name;
+ this.componentClass = componentClass;
+ this.scope = scope;
+ }
+
+ /**
+ * For a scanned default role
+ */
public ComponentDescriptor(Class componentClass)
{
this.componentClass = componentClass;
}
+ /**
+ * For built-ins with special rules
+ */
public ComponentDescriptor(Class componentClass, Boolean installed)
{
this.componentClass = componentClass;
More information about the jboss-cvs-commits
mailing list