[jboss-cvs] jboss-seam/src/main/org/jboss/seam/init ...
Gavin King
gavin.king at jboss.com
Wed Jun 20 22:29:39 EDT 2007
User: gavin
Date: 07/06/20 22:29:39
Modified: src/main/org/jboss/seam/init ComponentDescriptor.java
DependencyManager.java Initialization.java
Added: src/main/org/jboss/seam/init DeploymentDescriptor.java
EjbDescriptor.java
Removed: src/main/org/jboss/seam/init
DeploymentDescriptorInfo.java
Log:
use the correct classloader for loading descriptors
Revision Changes Path
1.5 +2 -1 jboss-seam/src/main/org/jboss/seam/init/ComponentDescriptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ComponentDescriptor.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/init/ComponentDescriptor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- ComponentDescriptor.java 20 Jun 2007 22:11:31 -0000 1.4
+++ ComponentDescriptor.java 21 Jun 2007 02:29:39 -0000 1.5
@@ -181,7 +181,8 @@
public static class PrecedenceComparator
implements Comparator<ComponentDescriptor>
{
- public int compare(ComponentDescriptor obj1, ComponentDescriptor obj2) {
+ public int compare(ComponentDescriptor obj1, ComponentDescriptor obj2)
+ {
return obj2.getPrecedence() - obj1.getPrecedence();
}
}
1.5 +0 -1 jboss-seam/src/main/org/jboss/seam/init/DependencyManager.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DependencyManager.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/init/DependencyManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- DependencyManager.java 20 Jun 2007 22:11:31 -0000 1.4
+++ DependencyManager.java 21 Jun 2007 02:29:39 -0000 1.5
@@ -18,7 +18,6 @@
this.componentDescriptors = new HashMap<String, Set<ComponentDescriptor>>(componentDescriptors);
}
-
public Set<ComponentDescriptor> installedSet()
{
computeInstallSet();
1.180 +5 -5 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.179
retrieving revision 1.180
diff -u -b -r1.179 -r1.180
--- Initialization.java 20 Jun 2007 22:01:25 -0000 1.179
+++ Initialization.java 21 Jun 2007 02:29:39 -0000 1.180
@@ -666,15 +666,15 @@
private void installScannedComponentAndRoles(Class<Object> scannedClass)
{
- if (scannedClass.isAnnotationPresent(Name.class))
+ if ( scannedClass.isAnnotationPresent(Name.class) )
{
- addComponentDescriptor(new ComponentDescriptor(scannedClass));
+ addComponentDescriptor( new ComponentDescriptor(scannedClass) );
}
- if (scannedClass.isAnnotationPresent(Role.class))
+ if ( scannedClass.isAnnotationPresent(Role.class) )
{
- installRole(scannedClass, scannedClass.getAnnotation(Role.class));
+ installRole( scannedClass, scannedClass.getAnnotation(Role.class) );
}
- if (scannedClass.isAnnotationPresent(Roles.class))
+ if ( scannedClass.isAnnotationPresent(Roles.class) )
{
Role[] roles = scannedClass.getAnnotation(Roles.class).value();
for (Role role : roles)
1.1 date: 2007/06/21 02:29:39; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/init/DeploymentDescriptor.java
Index: DeploymentDescriptor.java
===================================================================
package org.jboss.seam.init;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.jboss.seam.ComponentType;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.util.XML;
public class DeploymentDescriptor
{
private static final LogProvider log = Logging.getLogProvider(Initialization.class);
private Map<Class, EjbDescriptor> ejbDescriptors = new HashMap<Class, EjbDescriptor>();
private Class componentClass;
public DeploymentDescriptor(Class clazz)
{
componentClass = clazz;
try
{
InputStream ejbJarXml = clazz.getClassLoader().getResourceAsStream("/META-INF/ejb-jar.xml");
if (ejbJarXml!=null)
{
parseEjbJarXml( XML.getRootElement(ejbJarXml) );
}
}
catch (DocumentException e)
{
log.warn("Couldn't parse /META-INF/ejb-jar.xml for component types " + e.getMessage());
}
try
{
InputStream ormXml = clazz.getClassLoader().getResourceAsStream("/META-INF/orm.xml");
parseOrmXml( XML.getRootElement(ormXml) );
}
catch (DocumentException e)
{
log.warn("Couldn't parse /META-INF/orm.xml for component types " + e.getMessage());
}
}
public Map<Class, EjbDescriptor> getEjbDescriptors()
{
return ejbDescriptors;
}
@SuppressWarnings("unchecked")
private void parseEjbJarXml(Element root)
{
Element beans = root.element("enterprise-beans");
if (beans != null)
{
for (Element bean: (List<Element>) beans.elements("session"))
{
EjbDescriptor info = new EjbDescriptor();
info.setEjbName(bean.element("ejb-name").getTextTrim());
info.setEjbClassName(bean.element("ejb-class").getTextTrim());
Element sessionType = bean.element("session-type");
if (sessionType != null && sessionType.getTextTrim().equalsIgnoreCase("Stateful"))
{
info.setBeanType(ComponentType.STATEFUL_SESSION_BEAN);
}
else
{
info.setBeanType(ComponentType.STATELESS_SESSION_BEAN);
}
add(info);
}
for (Element bean: (List<Element>) beans.elements("message-driven"))
{
EjbDescriptor info = new EjbDescriptor();
info.setEjbName(bean.element("ejb-name").getTextTrim());
info.setEjbClassName(bean.element("ejb-class").getTextTrim());
info.setBeanType(ComponentType.MESSAGE_DRIVEN_BEAN);
add(info);
}
}
}
@SuppressWarnings("unchecked")
private void parseOrmXml(Element root)
{
String packagePrefix = "";
Element pkg = root.element("package");
if (pkg!=null)
{
packagePrefix = pkg.getTextTrim() + ".";
}
for (Element entity: (List<Element>) root.elements("entity"))
{
String className = packagePrefix + entity.attribute("class").getText();
EjbDescriptor info = new EjbDescriptor();
info.setBeanType(ComponentType.ENTITY_BEAN);
info.setEjbClassName(className);
add(info);
}
}
protected void add(EjbDescriptor descriptor)
{
try
{
Class ejbClass = componentClass.getClassLoader().loadClass( descriptor.getEjbClassName() );
ejbDescriptors.put(ejbClass, descriptor);
}
catch (ClassNotFoundException cnfe)
{
log.warn("Could not load EJB class: " + descriptor.getEjbClassName());
}
}
}
1.1 date: 2007/06/21 02:29:39; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/init/EjbDescriptor.java
Index: EjbDescriptor.java
===================================================================
package org.jboss.seam.init;
import org.jboss.seam.ComponentType;
public class EjbDescriptor
{
private String ejbName;
private String ejbClassName;
private ComponentType beanType;
public ComponentType getBeanType()
{
return beanType;
}
public void setBeanType(ComponentType beanType)
{
this.beanType = beanType;
}
public String getEjbClassName()
{
return ejbClassName;
}
public void setEjbClassName(String ejbClass)
{
this.ejbClassName = ejbClass;
}
public String getEjbName()
{
return ejbName;
}
public void setEjbName(String name)
{
this.ejbName = name;
}
}
More information about the jboss-cvs-commits
mailing list