tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1022375 - in /openejb/branches/openejb-3.1.x/container/openejb-core/src/main: java/org/apache/openejb/config/ java/org/apache/openejb/core/ resources/org/apache/openejb/config/rules/
Date Thu, 14 Oct 2010 04:32:53 GMT
Author: dblevins
Date: Thu Oct 14 04:32:52 2010
New Revision: 1022375

URL: http://svn.apache.org/viewvc?rev=1022375&view=rev
Log:
OPENEJB-1373: Validation: <ejb-class> omitted with no corresponding annotated bean
OPENEJB-1372: Default openejb.descriptors.output to true when there are validation failures

Modified:
    openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
    openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java
    openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/core/TempClassLoader.java
    openejb/branches/openejb-3.1.x/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties

Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=1022375&r1=1022374&r2=1022375&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
(original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
Thu Oct 14 04:32:52 2010
@@ -1049,12 +1049,21 @@ public class AnnotationDeployer implemen
             EnterpriseBean[] enterpriseBeans = ejbModule.getEjbJar().getEnterpriseBeans();
             for (EnterpriseBean bean : enterpriseBeans) {
                 final String ejbName = bean.getEjbName();
+                final String ejbClassName = bean.getEjbClass();
 
+                if (ejbClassName == null) {
+                    List<String> others = new ArrayList<String>();
+                    for (EnterpriseBean otherBean : enterpriseBeans) {
+                        others.add(otherBean.getEjbName());
+                    }
+                    fail(ejbName, "xml.noEjbClass", ejbName, join(", ", others));
+                }
+                
                 Class<?> clazz;
                 try {
-                    clazz = classLoader.loadClass(bean.getEjbClass());
+                    clazz = classLoader.loadClass(ejbClassName);
                 } catch (ClassNotFoundException e) {
-                    throw new OpenEJBException("Unable to load bean class: " + bean.getEjbClass(),
e);
+                    throw new OpenEJBException("Unable to load bean class: " + ejbClassName,
e);
                 }
                 ClassFinder classFinder = new ClassFinder(clazz);
 

Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java?rev=1022375&r1=1022374&r2=1022375&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java
(original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java
Thu Oct 14 04:32:52 2010
@@ -38,7 +38,7 @@ import java.io.IOException;
 
 public class OutputGeneratedDescriptors implements DynamicDeployer {
     private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_STARTUP_CONFIG,
"org.apache.openejb.util.resources");
-    private static final String OUTPUT_DESCRIPTORS = "openejb.descriptors.output";
+    public static final String OUTPUT_DESCRIPTORS = "openejb.descriptors.output";
 
     public AppModule deploy(AppModule appModule) throws OpenEJBException {
         boolean output = SystemInstance.get().getOptions().get(OUTPUT_DESCRIPTORS, false);
@@ -51,7 +51,12 @@ public class OutputGeneratedDescriptors 
         for (EjbModule ejbModule : appModule.getEjbModules()) {
             Options options = new Options(ejbModule.getOpenejbJar().getProperties(), SystemInstance.get().getOptions());
 
-            output = options.get(OUTPUT_DESCRIPTORS, false);
+            final ValidationContext context = ejbModule.getValidation();
+
+            // output descriptors by default if there are validation errors
+            final boolean invalid = context.hasErrors() || context.hasFailures();
+
+            output = options.get(OUTPUT_DESCRIPTORS, invalid);
 
             if (output){
                 if (ejbModule.getEjbJar() != null) {

Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/core/TempClassLoader.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/core/TempClassLoader.java?rev=1022375&r1=1022374&r2=1022375&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/core/TempClassLoader.java
(original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/core/TempClassLoader.java
Thu Oct 14 04:32:52 2010
@@ -67,6 +67,8 @@ public class TempClassLoader extends URL
     }
 
     protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException
{
+        if (name == null) throw new NullPointerException("name cannot be null");
+        
         // see if we've already loaded it
         Class c = findLoadedClass(name);
         if (c != null) {

Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties?rev=1022375&r1=1022374&r2=1022375&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties
(original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties
Thu Oct 14 04:32:52 2010
@@ -784,3 +784,7 @@ Which can then be implemented by the {0}
 1.userTransactionRef.forbiddenForCmtdBeans = Container-Managed Transaction beans cannot use
UserTransaction
 2.userTransactionRef.forbiddenForCmtdBeans = Container-Managed Transaction beans cannot use
UserTransaction: fix ref {0}
 3.userTransactionRef.forbiddenForCmtdBeans = Only session and message-driven beans with bean-managed
transaction demarcation are allowed to use UserTransaction.  Fix @Resource or resource-env-ref
{0}
+
+1.xml.noEjbClass = Element <ejb-class> unspecified.
+2.xml.noEjbClass = Element <ejb-class> unspecified.  No annotated bean discovered with
<ejb-name>{0}</ejb-name>
+3.xml.noEjbClass = The <ejb-class> element is only optional if there is a matching
annotated bean in the module with the bean name {0}.  No such bean was found.  Other beans
in this module are: {1}  



Mime
View raw message