Whoops!  Fixing.

-David

On Jul 17, 2008, at 6:02 AM, Rick McGuire wrote:

David,

I'm now getting tons of test case errors trying to build...is there additional test case cleanup required, or is the validation acting too aggresively?

Rick

[EMAIL PROTECTED] wrote:
Author: dblevins
Date: Wed Jul 16 22:32:23 2008
New Revision: 677503

URL: http://svn.apache.org/viewvc?rev=677503&view=rev
Log:
OPENEJB-859: Improved validation for <home>, <remote>, <local- home>, <local>, <business-local> and <business-remote> elements Rewrote this validation completely to be more aggressive in figuring out what the user might have intended to do.

Added:
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/ apache/openejb/config/rules/InvalidInterfacesTest.java
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/ apache/openejb/assembler/classic/JndiBuilder.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/ apache/openejb/config/ValidationException.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/ apache/openejb/config/rules/CheckClasses.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/ apache/openejb/util/Strings.java openejb/trunk/openejb3/container/openejb-core/src/main/resources/ org/apache/openejb/config/rules/Messages.properties

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/ java/org/apache/openejb/assembler/classic/JndiBuilder.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java?rev=677503&r1=677502&r2=677503&view=diff
= = = = = = = = = ===================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/ apache/openejb/assembler/classic/JndiBuilder.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/ apache/openejb/assembler/classic/JndiBuilder.java Wed Jul 16 22:32:23 2008
@@ -29,6 +29,7 @@
import org.apache.openejb.spi.ContainerSystem;
import org.apache.openejb.util.LogCategory;
import org.apache.openejb.util.Logger;
+import org.apache.openejb.util.Strings;
import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.core.CoreDeploymentInfo;
import org.apache.openejb.core.ivm.naming.BusinessLocalReference;
@@ -126,21 +127,10 @@
                this.type = type;
                this.annotatedName = annotatedName;
                this.xmlName = xmlName;
-                this.xmlNameCc = camelCase(xmlName);
+                this.xmlNameCc = Strings.camelCase(xmlName);
                this.openejbLegacy = openejbLegacy;
            }
-            private String camelCase(String string){
-                StringBuilder sb = new StringBuilder();
-                String[] strings = string.split("-");
-                for (String s : strings) {
-                    int l = sb.length();
-                    sb.append(s);
- sb.setCharAt(l, Character.toUpperCase(sb.charAt(l)));
-                }
-                return sb.toString();
-            }
-
             public InterfaceType getType() {
                return type;

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/ java/org/apache/openejb/config/ValidationException.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidationException.java?rev=677503&r1=677502&r2=677503&view=diff
= = = = = = = = = ===================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/ apache/openejb/config/ValidationException.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/ apache/openejb/config/ValidationException.java Wed Jul 16 22:32:23 2008
@@ -36,6 +36,10 @@
        }
    }
+    public String getMessageKey(){
+        return message;
+    }
+         public Object[] getDetails() {
        return details;
    }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/ java/org/apache/openejb/config/rules/CheckClasses.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckClasses.java?rev=677503&r1=677502&r2=677503&view=diff
= = = = = = = = = ===================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/ apache/openejb/config/rules/CheckClasses.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/ apache/openejb/config/rules/CheckClasses.java Wed Jul 16 22:32:23 2008
@@ -24,12 +24,15 @@
import org.apache.openejb.jee.Interceptor;
import org.apache.openejb.config.EjbModule;
import org.apache.openejb.util.SafeToolkit;
+import org.apache.openejb.util.Strings;
import org.apache.xbean.finder.ClassFinder;
 import javax.ejb.EJBLocalHome;
import javax.ejb.EJBLocalObject;
import javax.ejb.EJBHome;
import javax.ejb.EJBObject;
+import javax.ejb.Local;
+import javax.ejb.Remote;
import javax.jws.WebService;
import static java.lang.reflect.Modifier.isAbstract;
import java.lang.reflect.Method;
@@ -69,38 +72,40 @@
    public void validate(EjbModule ejbModule) {
for (EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) {
            try {
-                check_hasEjbClass(bean);
+                Class<?> beanClass = check_hasEjbClass(bean);
                 if (!(bean instanceof RemoteBean)) continue;
                RemoteBean b = (RemoteBean) bean;
                 check_isEjbClass(b);
- check_hasDependentClasses(b, b.getEjbClass(), "<ejb-class>"); + check_hasDependentClasses(b, b.getEjbClass(), "ejb- class");
                check_hasInterface(b);
+
+                if (b.getRemote() != null){
+ checkInterface(b, beanClass, "remote", b.getRemote());
+                }
+
                if (b.getHome() != null) {
-                    check_hasHomeClass(b);
-                    check_hasRemoteClass(b);
-                    check_isHomeInterface(b);
-                    check_isRemoteInterface(b);
- check_hasDependentClasses(b, b.getHome(), "<home>"); - check_hasDependentClasses(b, b.getRemote(), "<remote>"); + checkInterface(b, beanClass, "home", b.getHome());
+                }
+
+                if (b.getLocal() != null) {
+ checkInterface(b, beanClass, "local", b.getLocal());
                }
+
                if (b.getLocalHome() != null) {
-                    check_hasLocalHomeClass(b);
-                    check_hasLocalClass(b);
-                    check_isLocalHomeInterface(b);
-                    check_isLocalInterface(b);
- check_hasDependentClasses(b, b.getLocalHome(), "<local-home>"); - check_hasDependentClasses(b, b.getLocal(), "<local>"); + checkInterface(b, beanClass, "local-home", b.getLocalHome());
                }
                 if (b instanceof SessionBean) {
                    SessionBean sessionBean = (SessionBean) b;
+
for (String interfce : sessionBean.getBusinessLocal()) { - check_businessInterface(sessionBean, interfce, "<business-local>"); + checkInterface(b, beanClass, "business- local", interfce);
                    }
+
for (String interfce : sessionBean.getBusinessRemote()) { - check_businessInterface(sessionBean, interfce, "<business-remote>"); + checkInterface(b, beanClass, "business- local", interfce);
                    }
                }
            } catch (RuntimeException e) {
@@ -113,35 +118,30 @@
        }
    }
- private void check_businessInterface(SessionBean b, String interfaceName, String tagName) {
-        String ejbName = b.getEjbName();
- Class<?> interfce = lookForClass(interfaceName, tagName, b.getEjbName()); + private void checkInterface(RemoteBean b, Class<?> beanClass, String tag, String className) { + Class<?> interfce = lookForClass(className, tag, b.getEjbName());
-        if (!interfce.isInterface()){
-            fail(b, "notAnInterface", interfce.getName(), tagName);
-        }
+        if (interfce == null) return;
+
+        check_hasDependentClasses(b, className, tag);
+
+        tag = Strings.lcfirst(Strings.camelCase(tag));
+
+        if (isValidInterface(b, interfce, beanClass, tag));
         ClassFinder finder = new ClassFinder(interfce);
for (Class<? extends Annotation> annotation : beanOnlyAnnotations) {
+
            if (interfce.isAnnotationPresent(annotation)){
warn(b, "interface.beanOnlyAnnotation", annotation.getSimpleName(), interfce.getName(), b.getEjbClass());
            }
+
for (Method method : finder.findAnnotatedMethods(annotation)) { warn(b, "interfaceMethod.beanOnlyAnnotation", annotation.getSimpleName(), interfce.getName(), method.getName(), b.getEjbClass());
            }
        }
-        if (EJBHome.class.isAssignableFrom(interfce)){
- fail(ejbName, "xml.businessRemoteOrLocal.ejbHome", tagName, interfce.getName());
-        } else if (EJBObject.class.isAssignableFrom(interfce)){
- fail(ejbName, "xml.businessRemoteOrLocal.ejbObject", tagName, interfce.getName());
-        } else if (EJBLocalHome.class.isAssignableFrom(interfce)) {
- fail(ejbName, "xml.businessRemoteOrLocal.ejbLocalHome", tagName, interfce.getName());
-        } else if (EJBLocalObject.class.isAssignableFrom(interfce)){
- fail(ejbName, "xml.businessRemoteOrLocal.ejbLocalObject", tagName, interfce.getName());
-        }
-
    }
     private void check_hasInterface(RemoteBean b) {
@@ -187,7 +187,8 @@
            # 2 - Element (home, ejb-class, remote)
            # 3 - Bean name
            */
- fail(b, "missing.dependent.class", className, e.getMessage(), type, b.getEjbName());
+            String missingClass = e.getMessage();
+ fail(b, "missing.dependent.class", className, missingClass, type, b.getEjbName());
        } catch (NoClassDefFoundError e) {
            /*
            # 0 - Referring Class name
@@ -195,19 +196,12 @@
            # 2 - Element (home, ejb-class, remote)
            # 3 - Bean name
            */
- fail(b, "missing.dependent.class", className, e.getMessage(), type, b.getEjbName());
+            String missingClass = e.getMessage();
+ fail(b, "missing.dependent.class", className, missingClass, type, b.getEjbName());
        }
    }
-    private void check_hasLocalClass(RemoteBean b) {
-        lookForClass(b.getLocal(), "<local>", b.getEjbName());
-    }
-
-    private void check_hasLocalHomeClass(RemoteBean b) {
- lookForClass(b.getLocalHome(), "<local-home>", b.getEjbName());
-    }
-
-    public void check_hasEjbClass(EnterpriseBean b) {
+    public Class<?> check_hasEjbClass(EnterpriseBean b) {
         String ejbName = b.getEjbName();
@@ -217,32 +211,22 @@
fail(ejbName, "interfaceDeclaredAsBean", beanClass.getName());
        }
-        if (isCmp(b)) return;
+        if (isCmp(b)) return beanClass;
         if (isAbstract(beanClass.getModifiers())){
fail(ejbName, "abstractDeclaredAsBean", beanClass.getName());
        }
-    }
-
-    public void check_hasInterceptorClass(Interceptor i) {
-
- lookForClass(i.getInterceptorClass(), "<interceptor- class>", "Interceptor");
+        return beanClass;
    }
-    public void check_hasHomeClass(RemoteBean b) {
+    private void check_hasInterceptorClass(Interceptor i) {
-        lookForClass(b.getHome(), "<home>", b.getEjbName());
+ lookForClass(i.getInterceptorClass(), "interceptor-class", "Interceptor");
     }
-    public void check_hasRemoteClass(RemoteBean b) {
-
-        lookForClass(b.getRemote(), "<remote>", b.getEjbName());
-
-    }
-
-    public void check_isEjbClass(RemoteBean b) {
+    private void check_isEjbClass(RemoteBean b) {
         if (b instanceof SessionBean) {
@@ -258,26 +242,6 @@
     }
-    private void check_isLocalInterface(RemoteBean b) {
-        compareTypes(b, b.getLocal(), EJBLocalObject.class);
-    }
-
-    private void check_isLocalHomeInterface(RemoteBean b) {
-        compareTypes(b, b.getLocalHome(), EJBLocalHome.class);
-    }
-
-    public void check_isHomeInterface(RemoteBean b) {
-
-        compareTypes(b, b.getHome(), javax.ejb.EJBHome.class);
-
-    }
-
-    public void check_isRemoteInterface(RemoteBean b) {
-
-        compareTypes(b, b.getRemote(), javax.ejb.EJBObject.class);
-
-    }
-
private Class<?> lookForClass(String clazz, String type, String ejbName) {
        try {
            return loadClass(clazz);
@@ -305,6 +269,63 @@
        return null;
    }
+ private boolean isValidInterface(RemoteBean b, Class clazz, Class beanClass, String tag) {
+
+        if (clazz.equals(beanClass)) {
+
+            fail(b, "xml." + tag + ".beanClass", clazz.getName());
+
+        } else if (!clazz.isInterface()) {
+
+ fail(b, "xml." + tag + ".notInterface", clazz.getName());
+
+        } else if (EJBHome.class.isAssignableFrom(clazz)) {
+
+            if (tag.equals("home")) return true;
+
+            fail(b, "xml." + tag + ".ejbHome", clazz.getName());
+
+        } else if (EJBLocalHome.class.isAssignableFrom(clazz)) {
+
+            if (tag.equals("local-home")) return true;
+
+ fail(b, "xml." + tag + ".ejbLocalHome", clazz.getName());
+
+        } else if (EJBObject.class.isAssignableFrom(clazz)) {
+
+            if (tag.equals("remote")) return true;
+
+            fail(b, "xml." + tag + ".ejbObject", clazz.getName());
+
+        } else if (EJBLocalObject.class.isAssignableFrom(clazz)) {
+
+            if (tag.equals("local")) return true;
+
+ fail(b, "xml." + tag + ".ejbLocalObject", clazz.getName());
+
+ } else if (tag.equals("businessLocal") && tag.equals("businessRemote")) {
+
+            return true;
+        }
+
+ // must be tagged as <home>, <local-home>, <remote>, or <local>
+        if (clazz.isAnnotationPresent(Local.class)) {
+
+ fail(b, "xml." + tag + ".businessLocal", clazz.getName());
+
+        } else if (clazz.isAnnotationPresent(Remote.class)) {
+
+ fail(b, "xml." + tag + ".businessRemote", clazz.getName());
+
+        } else {
+
+            fail(b, "xml." + tag + ".unknown", clazz.getName());
+
+        }
+
+        return false;
+    }
+
private void compareTypes(RemoteBean b, String clazz1, Class<?> class2) {
        Class<?> class1 = null;
        try {

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/ java/org/apache/openejb/util/Strings.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Strings.java?rev=677503&r1=677502&r2=677503&view=diff
= = = = = = = = = ===================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/ apache/openejb/util/Strings.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/ apache/openejb/util/Strings.java Wed Jul 16 22:32:23 2008
@@ -70,4 +70,15 @@
        return sb.toString();
    }
+    public static String camelCase(String string){
+        StringBuilder sb = new StringBuilder();
+        String[] strings = string.split("-");
+        for (String s : strings) {
+            int l = sb.length();
+            sb.append(s);
+            sb.setCharAt(l, Character.toUpperCase(sb.charAt(l)));
+        }
+        return sb.toString();
+    }
+
}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/ resources/org/apache/openejb/config/rules/Messages.properties
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties?rev=677503&r1=677502&r2=677503&view=diff
= = = = = = = = = ===================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/ resources/org/apache/openejb/config/rules/Messages.properties (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/ resources/org/apache/openejb/config/rules/Messages.properties Wed Jul 16 22:32:23 2008
@@ -47,7 +47,7 @@
# 2 - Bean name
1.missing.class           Missing class
2.missing.class           Missing class {0}
-3.missing.class The class {0} not found. Check that the class specified in the {1} element for bean {2} is spelled correctly and the class is present in the jar +3.missing.class The class {0} not found. Check that the class specified in the <{1}> element for bean {2} is spelled correctly and the class is present in the jar
 # 0 - Class name
# 1 - EJB Class name
@@ -125,9 +125,10 @@
# 1 - Dependent Class name
# 2 - Element (home, ejb-class, remote)
# 3 - Bean name
+# fail(b, "missing.dependent.class", className, missingClass, type, b.getEjbName()); 1.missing.dependent.class Missing dependent class or library -2.missing.dependent.class Missing dependent class or library: {1} needed by {2} -3.missing.dependent.class The class {1} not found and is referenced by the {2} class {0}. The Check that the class or related library is available in the classpath +2.missing.dependent.class Missing dependent class or library: {1} needed by {0} +3.missing.dependent.class The class {1} not found and is referenced by the <{2}> class {0}. The Check that the class or related library is available in the classpath
  # CheckAssemblyBindings.java
@@ -304,26 +305,6 @@
2.ann.remoteOrLocal.ejbLocalObject = @{0} used in bean class lists a javax.ejb.EJBLocalObject interface. Use @LocalHome with home interface of "{1}". 3.ann.remoteOrLocal.ejbLocalObject = When applied to a bean class, the @{0} annotation must only list business interfaces and cannot list legacy EJBLocalObject interfaces. The EJBLocalHome of interface for "{1}" can be annotated on the bean class with @LocalHome -# fail(ejbName, "xml.businessRemoteOrLocal.ejbHome", tagName, interfce.getName()); -1.xml.businessRemoteOrLocal.ejbHome = javax.ejb.EJBHome interface declared as {0}. -2.xml.businessRemoteOrLocal.ejbHome = javax.ejb.EJBHome interface declared as {0}. Use <home>{1}</home> -3.xml.businessRemoteOrLocal.ejbHome = Interfaces extending javax.ejb.EJBHome pre-date the concept of EJB 3.0 simplified business interfaces and must not use the {0} tag when declared in the ejb-jar.xml. Declare this interface as <home>{1}</home>.
-
-# fail(ejbName, "xml.businessRemoteOrLocal.ejbLocalHome", tagName, interfce.getName()); -1.xml.businessRemoteOrLocal.ejbLocalHome = javax.ejb.EJBLocalHome interface declared as {0}. -2.xml.businessRemoteOrLocal.ejbLocalHome = javax.ejb.EJBLocalHome interface declared as {0}. Use <local-home>{1}</local-home> -3.xml.businessRemoteOrLocal.ejbLocalHome = Interfaces extending javax.ejb.EJBLocalHome pre-date the concept of EJB 3.0 simplified business interfaces and must not use the {0} tag when declared in the ejb-jar.xml. Declare this interface as <local-home>{1}</local- home>.
-
-# fail(ejbName, "xml.businessRemoteOrLocal.ejbObject", tagName, interfce.getName()); -1.xml.businessRemoteOrLocal.ejbObject = javax.ejb.EJBObject interface declared as {0}. -2.xml.businessRemoteOrLocal.ejbObject = javax.ejb.EJBObject interface declared as {0}. Use <remote>{1}</remote> -3.xml.businessRemoteOrLocal.ejbObject = Interfaces extending javax.ejb.EJBObject pre-date the concept of EJB 3.0 simplified business interfaces and must not use the {0} tag when declared in the ejb-jar.xml. Declare this interface as <remote>{1}</remote>.
-
-# fail(ejbName, "xml.businessRemoteOrLocal.ejbLocalObject", tagName, interfce.getName()); -1.xml.businessRemoteOrLocal.ejbLocalObject = javax.ejb.EJBLocalObject interface declared as {0}. -2.xml.businessRemoteOrLocal.ejbLocalObject = javax.ejb.EJBLocalObject interface declared as {0}. Use <local>{1}</ local> -3.xml.businessRemoteOrLocal.ejbLocalObject = Interfaces extending javax.ejb.EJBLocalObject pre-date the concept of EJB 3.0 simplified business interfaces and must not use the {0} tag when declared in the ejb-jar.xml. Declare this interface as <local>{1}</local>.
-
# warn(bean, "ignoredStatefulAnnotation", annotationType, beanType, methodName);
1.ignoredStatefulAnnotation = @{0} is ignored for beans of type {1}
2.ignoredStatefulAnnotation = @{0} is ignored for beans of type {1}. Method: {2}
@@ -524,11 +505,6 @@
Which can then be implemented by the {0} class.\
 -# fail(b, "notAnInterface", interfce.getName(), tagName);
-1.notAnInterface = Business remotes and locals must be interfaces.
-2.notAnInterface = Class tagged as {1} is not an interface: {0}
-3.notAnInterface = All business remote and business local views must be java interfaces. Classes, abstract classes or enums are not allowed. Either convert {0} to an interface or remove the related {1} xml tag from your ejb-jar.xml.
-
# fail(ejbName, "ann.notAnInterface", annotationName, interfce.getName());
1.ann.notAnInterface = @{0} lists a non-interface.
2.ann.notAnInterface = @{0} lists a non-interface: {1}
@@ -574,3 +550,195 @@
2.ann.invalidConcurrencyAttribute = Ignoring {0} invalid @Lock annotations. Bean not using Container-Managed Concurrencys. 3.ann.invalidConcurrencyAttribute = The @Lock annotation applies only to beans using Container-Managed Concurrencys. Beans marked as @ConcurrencyManagement(BEAN) are responsible for thier own concurrency and may not use the @Lock annotation. There are {0} such invalid annotations in the bean class that will be ignored and should be removed.
+
+1.xml.home.ejbLocalHome = javax.ejb.EJBLocalHome interface declared as <home>. Use <local-home>{0}</local-home> +2.xml.home.ejbLocalHome = javax.ejb.EJBLocalHome interface declared as <home>. Use <local-home>{0}</local-home> +3.xml.home.ejbLocalHome = The <home> element is for interfaces extending javax.ejb.EJBHome. The interface supplied is a javax.ejb.EJBLocalHome and should be declared with the <local-home> element as in: <local-home>{0}</local-home>
+
+1.xml.home.ejbObject = javax.ejb.EJBObject interface declared as <home>. Use <remote>{0}</remote> +2.xml.home.ejbObject = javax.ejb.EJBObject interface declared as <home>. Use <remote>{0}</remote> +3.xml.home.ejbObject = The <home> element is for interfaces extending javax.ejb.EJBHome. The interface supplied is a javax.ejb.EJBObject and should be declared with the <remote> element as in: <remote>{0}</remote>
+
+1.xml.home.ejbLocalObject = javax.ejb.EJBLocalObject interface declared as <home>. Use <local>{0}</local> +2.xml.home.ejbLocalObject = javax.ejb.EJBLocalObject interface declared as <home>. Use <local>{0}</local> +3.xml.home.ejbLocalObject = The <home> element is for interfaces extending javax.ejb.EJBHome. The interface supplied is a javax.ejb.EJBLocalObject and should be declared with the <local> element as in: <local>{0}</local>
+
+1.xml.home.businessLocal = EJB 3.0 business interface declared as <home>. Use <business-local>{0}</business-local> +2.xml.home.businessLocal = EJB 3.0 business interface declared as <home>. Use <business-local>{0}</business-local> +3.xml.home.businessLocal = The <home> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBHome. EJB 3.0 simplified business interfaces can be decalred via <business-local>{0}</ business-local> or via the @Remote annotation on the bean class or interface class.
+
+1.xml.home.businessRemote = EJB 3.0 business interface declared as <home>. Use <business-remote>{0}</business-remote> +2.xml.home.businessRemote = EJB 3.0 business interface declared as <home>. Use <business-remote>{0}</business-remote> +3.xml.home.businessRemote = The <home> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBHome. EJB 3.0 simplified business interfaces can be decalred via <business-remote>{0}</ business-remote> or via the @Remote annotation on the bean class or interface class.
+
+1.xml.home.beanClass = Bean class mistakenly declared as <home>
+2.xml.home.beanClass = Bean class mistakenly declared as <home>
+3.xml.home.beanClass = The <home> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBHome. The bean class cannot be used as a home interface.
+
+1.xml.home.notInterface = The value of <home> is not an interface
+2.xml.home.notInterface = The value of <home> is not an interface: {0} +3.xml.home.notInterface = The <home> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBHome. Classes, abstract classes or enums are not allowed. Either convert {0} to an interface or remove the related <home> xml tag from your ejb-jar.xml
+
+1.xml.home.unknown = The value of <home> must be an interface extending javax.ejb.EJBHome +2.xml.home.unknown = The value of <home> must be an interface extending javax.ejb.EJBHome +3.xml.home.unknown = The <home> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBHome. If this interface is intended to be an EJB 3.0 business remote view, declare this interface as <business-remote>{0}</business-remote> or via the @Remote annotation on the bean class or interface class.
+
+
+
+1.xml.remote.ejbHome = javax.ejb.EJBHome interface declared as <remote>. Use <home>{0}</home> +2.xml.remote.ejbHome = javax.ejb.EJBHome interface declared as <remote>. Use <home>{0}</home> +3.xml.remote.ejbHome = The <remote> element is for interfaces extending javax.ejb.EJBObject. The interface supplied is a javax.ejb.EJBHome and should be declared with the <home> element as in: <home>{0}</home>
+
+1.xml.remote.ejbLocalHome = javax.ejb.EJBLocalHome interface declared as <remote>. Use <local-home>{0}</local-home> +2.xml.remote.ejbLocalHome = javax.ejb.EJBLocalHome interface declared as <remote>. Use <local-home>{0}</local-home> +3.xml.remote.ejbLocalHome = The <remote> element is for interfaces extending javax.ejb.EJBHome. The interface supplied is a javax.ejb.EJBLocalHome and should be declared with the <local-home> element as in: <local-home>{0}</local-home>
+
+1.xml.remote.ejbLocalObject = javax.ejb.EJBLocalObject interface declared as <remote>. Use <local>{0}</local> +2.xml.remote.ejbLocalObject = javax.ejb.EJBLocalObject interface declared as <remote>. Use <local>{0}</local> +3.xml.remote.ejbLocalObject = The <remote> element is for interfaces extending javax.ejb.EJBObject. The interface supplied is a javax.ejb.EJBLocalObject and should be declared with the <local> element as in: <local>{0}</local>
+
+# must be attempting an override
+1.xml.remote.businessLocal = EJB 3.0 business interface declared as <remote>. Use <business-remote>{0}</business-remote> +2.xml.remote.businessLocal = EJB 3.0 business interface declared as <remote>. Use <business-remote>{0}</business-remote> +3.xml.remote.businessLocal = The <remote> element of the ejb- jar.xml is for interfaces extending javax.ejb.EJBObject. EJB 3.0 simplified business interfaces can be decalred via <business- local>{0}</business-local> or via the @Remote annotation on the bean class or interface class.
+
+1.xml.remote.businessRemote = EJB 3.0 business interface declared as <remote>. Use <business-remote>{0}</business-remote> +2.xml.remote.businessRemote = EJB 3.0 business interface declared as <remote>. Use <business-remote>{0}</business-remote> +3.xml.remote.businessRemote = The <remote> element of the ejb- jar.xml is for interfaces extending javax.ejb.EJBObject. EJB 3.0 simplified business interfaces can be decalred via <business- remote>{0}</business-remote> or via the @Remote annotation on the bean class or interface class.
+
+1.xml.remote.beanClass = Bean class mistakenly declared as <remote>
+2.xml.remote.beanClass = Bean class mistakenly declared as <remote>
+3.xml.remote.beanClass = The <remote> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBObject. The bean class cannot be used as a home interface.
+
+1.xml.remote.notInterface = The value of <remote> is not an interface +2.xml.remote.notInterface = The value of <remote> is not an interface: {0} +3.xml.remote.notInterface = The <remote> element of the ejb- jar.xml is for interfaces extending javax.ejb.EJBObject. Classes, abstract classes or enums are not allowed. Either convert {0} to an interface or remove the related <remote> xml tag from your ejb- jar.xml
+
+1.xml.remote.unknown = The value of <remote> must be an interface extending javax.ejb.EJBObject +2.xml.remote.unknown = The value of <remote> must be an interface extending javax.ejb.EJBObject +3.xml.remote.unknown = The <remote> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBObject. If this interface is intended to be an EJB 3.0 business remote view, declare this interface as <business-remote>{0}</business-remote> or via the @Remote annotation on the bean class or interface class.
+
+
+
+
+1.xml.localHome.ejbHome = javax.ejb.EJBHome interface declared as <local-home>. Use <home>{0}</home> +2.xml.localHome.ejbHome = javax.ejb.EJBHome interface declared as <local-home>. Use <home>{0}</home> +3.xml.localHome.ejbHome = The <local-home> element is for interfaces extending javax.ejb.EJBLocalHome. The interface supplied is a javax.ejb.EJBHome and should be declared with the <home> element as in: <home>{0}</home>
+
+1.xml.localHome.ejbObject = javax.ejb.EJBObject interface declared as <local-home>. Use <remote>{0}</remote> +2.xml.localHome.ejbObject = javax.ejb.EJBObject interface declared as <local-home>. Use <remote>{0}</remote> +3.xml.localHome.ejbObject = The <local-home> element is for interfaces extending javax.ejb.EJBLocalHome. The interface supplied is a javax.ejb.EJBObject and should be declared with the <remote> element as in: <remote>{0}</remote>
+
+1.xml.localHome.ejbLocalObject = javax.ejb.EJBLocalObject interface declared as <local-home>. Use <local>{0}</local> +2.xml.localHome.ejbLocalObject = javax.ejb.EJBLocalObject interface declared as <local-home>. Use <local>{0}</local> +3.xml.localHome.ejbLocalObject = The <local-home> element is for interfaces extending javax.ejb.EJBLocalHome. The interface supplied is a javax.ejb.EJBLocalObject and should be declared with the <local> element as in: <local>{0}</local>
+
+1.xml.localHome.businessLocal = EJB 3.0 business interface declared as <local-home>. Use <business-local>{0}</business-local> +2.xml.localHome.businessLocal = EJB 3.0 business interface declared as <local-home>. Use <business-local>{0}</business-local> +3.xml.localHome.businessLocal = The <local-home> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBLocalHome. EJB 3.0 simplified business interfaces can be decalred via <business-local>{0}</business-local> or via the @Remote annotation on the bean class or interface class.
+
+1.xml.localHome.businessRemote = EJB 3.0 business interface declared as <local-home>. Use <business-remote>{0}</business-remote> +2.xml.localHome.businessRemote = EJB 3.0 business interface declared as <local-home>. Use <business-remote>{0}</business-remote> +3.xml.localHome.businessRemote = The <local-home> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBLocalHome. EJB 3.0 simplified business interfaces can be decalred via <business-remote>{0}</business-remote> or via the @Remote annotation on the bean class or interface class.
+
+1.xml.localHome.beanClass = Bean class mistakenly declared as <local-home> +2.xml.localHome.beanClass = Bean class mistakenly declared as <local-home> +3.xml.localHome.beanClass = The <local-home> element of the ejb- jar.xml is for interfaces extending javax.ejb.EJBLocalHome. The bean class cannot be used as a home interface.
+
+1.xml.localHome.notInterface = The value of <local-home> is not an interface +2.xml.localHome.notInterface = The value of <local-home> is not an interface: {0} +3.xml.localHome.notInterface = The <local-home> element of the ejb- jar.xml is for interfaces extending javax.ejb.EJBLocalHome. Classes, abstract classes or enums are not allowed. Either convert {0} to an interface or remove the related <local-home> xml tag from your ejb-jar.xml
+
+1.xml.localHome.unknown = The value of <local-home> must be an interface extending javax.ejb.EJBLocalHome +2.xml.localHome.unknown = The value of <local-home> must be an interface extending javax.ejb.EJBLocalHome +3.xml.localHome.unknown = The <local-home> element of the ejb- jar.xml is for interfaces extending javax.ejb.EJBLocalHome. If this interface is intended to be an EJB 3.0 business local view, declare this interface as <business-local>{0}</business-local> or via the @Local annotation on the bean class or interface class.
+
+
+
+
+1.xml.local.ejbHome = javax.ejb.EJBHome interface declared as <local>. Use <home>{0}</home> +2.xml.local.ejbHome = javax.ejb.EJBHome interface declared as <local>. Use <home>{0}</home> +3.xml.local.ejbHome = The <local> element is for interfaces extending javax.ejb.EJBLocalObject. The interface supplied is a javax.ejb.EJBHome and should be declared with the <home> element as in: <home>{0}</home>
+
+1.xml.local.ejbLocalHome = javax.ejb.EJBLocalHome interface declared as <local>. Use <local-home>{0}</local-home> +2.xml.local.ejbLocalHome = javax.ejb.EJBLocalHome interface declared as <local>. Use <local-home>{0}</local-home> +3.xml.local.ejbLocalHome = The <local> element is for interfaces extending javax.ejb.EJBLocalObject. The interface supplied is a javax.ejb.EJBLocalHome and should be declared with the <local-home> element as in: <local-home>{0}</local-home>
+
+1.xml.local.ejbObject = javax.ejb.EJBObject interface declared as <local>. Use <remote>{0}</remote> +2.xml.local.ejbObject = javax.ejb.EJBObject interface declared as <local>. Use <remote>{0}</remote> +3.xml.local.ejbObject = The <local> element is for interfaces extending javax.ejb.EJBLocalObject. The interface supplied is a javax.ejb.EJBObject and should be declared with the <remote> element as in: <remote>{0}</remote>
+
+1.xml.local.businessLocal = EJB 3.0 business interface declared as <local>. Use <business-local>{0}</business-local> +2.xml.local.businessLocal = EJB 3.0 business interface declared as <local>. Use <business-local>{0}</business-local> +3.xml.local.businessLocal = The <local> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBLocalObject. EJB 3.0 simplified business interfaces can be decalred via <business- local>{0}</business-local> or via the @Remote annotation on the bean class or interface class.
+
+# must be attempting an override
+1.xml.local.businessRemote = EJB 3.0 business interface declared as <local>. Use <business-local>{0}</business-local> +2.xml.local.businessRemote = EJB 3.0 business interface declared as <local>. Use <business-local>{0}</business-local> +3.xml.local.businessRemote = The <local> element of the ejb- jar.xml is for interfaces extending javax.ejb.EJBLocalObject. EJB 3.0 simplified business interfaces can be decalred via <business- remote>{0}</business-remote> or via the @Remote annotation on the bean class or interface class.
+
+1.xml.local.beanClass = Bean class mistakenly declared as <local>
+2.xml.local.beanClass = Bean class mistakenly declared as <local>
+3.xml.local.beanClass = The <local> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBLocalObject. The bean class cannot be used as a home interface.
+
+1.xml.local.notInterface = The value of <local> is not an interface
+2.xml.local.notInterface = The value of <local> is not an interface: {0} +3.xml.local.notInterface = The <local> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBLocalObject. Classes, abstract classes or enums are not allowed. Either convert {0} to an interface or remove the related <local> xml tag from your ejb- jar.xml
+
+1.xml.local.unknown = The value of <local> must be an interface extending javax.ejb.EJBLocalObject +2.xml.local.unknown = The value of <local> must be an interface extending javax.ejb.EJBLocalObject. Perhaps you meant to use <business-local>{0}</business-local> +3.xml.local.unknown = The <local> element of the ejb-jar.xml is for interfaces extending javax.ejb.EJBLocalObject. If this interface is intended to be an EJB 3.0 business local view, declare this interface as <business-local>{0}</business-local> or via the @Local annotation on the bean class or interface class.
+
+
+
+
+1.xml.businessRemote.ejbHome = javax.ejb.EJBHome interface declared as <business-remote>. Use <home>{0}</home> +2.xml.businessRemote.ejbHome = javax.ejb.EJBHome interface declared as <business-remote>. Use <home>{0}</home> +3.xml.businessRemote.ejbHome = Interfaces extending javax.ejb.EJBHome must use the <home> tag, not the <business- remote> tag, when declared in the ejb-jar.xml. Declare this interface as <home>{0}</home> or alternatively add @RemoteHome({0}.class) to the top of your bean class.
+
+1.xml.businessRemote.ejbLocalHome = javax.ejb.EJBLocalHome interface declared as <business-remote>. Use <local-home>{0}</local- home> +2.xml.businessRemote.ejbLocalHome = javax.ejb.EJBLocalHome interface declared as <business-remote>. Use <local-home>{0}</local- home> +3.xml.businessRemote.ejbLocalHome = Interfaces extending javax.ejb.EJBLocalHome must use the <local-home> tag, not the <business-remote> tag, when declared in the ejb-jar.xml. Declare this interface as <local-home>{0}</local-home> or alternatively add @LocalHome({0}.class) to the top of your bean class.
+
+1.xml.businessRemote.ejbObject = javax.ejb.EJBObject interface declared as <business-remote>. Use <remote>{0}</remote> +2.xml.businessRemote.ejbObject = javax.ejb.EJBObject interface declared as <business-remote>. Use <remote>{0}</remote> +3.xml.businessRemote.ejbObject = Interfaces extending javax.ejb.EJBObject must use the <remote> tag, not the <business- remote> tag, when declared in the ejb-jar.xml. Declare this interface as <remote>{0}</remote>.
+
+1.xml.businessRemote.ejbLocalObject = javax.ejb.EJBLocalObject interface declared as <business-remote>. Use <local>{0}</local> +2.xml.businessRemote.ejbLocalObject = javax.ejb.EJBLocalObject interface declared as <business-remote>. Use <local>{0}</local> +3.xml.businessRemote.ejbLocalObject = Interfaces extending javax.ejb.EJBLocalObject must use the <local> tag, not the <business-remote> tag, when declared in the ejb-jar.xml. Declare this interface as <local>{0}</local>.
+
+1.xml.businessRemote.beanClass = Bean class mistakenly declared as <business-remote> +2.xml.businessRemote.beanClass = Bean class mistakenly declared as <business-remote> +3.xml.businessRemote.beanClass = The bean class cannot itself cannot be used as the value of the <business-remote> element of the ejb-jar.xml. Either list a valid java interface or delete this element and annotate the intended interface with the @Remote annotation.
+
+1.xml.businessRemote.notInterface = The value of <business-remote> is not an interface +2.xml.businessRemote.notInterface = The value of <business-remote> is not an interface: {0} +3.xml.businessRemote.notInterface = The <business-remote> element of the ejb-jar.xml must be an interface. Classes, abstract classes or enums are not allowed. Either convert {0} to an interface or remove the related <business-remote> xml tag from your ejb-jar.xml
+
+
+
+
+1.xml.businessLocal.ejbHome = javax.ejb.EJBHome interface declared as <business-local>. Use <home>{0}</home> +2.xml.businessLocal.ejbHome = javax.ejb.EJBHome interface declared as <business-local>. Use <home>{0}</home> +3.xml.businessLocal.ejbHome = Interfaces extending javax.ejb.EJBHome must use the <home> tag, not the <business-local> tag, when declared in the ejb-jar.xml. Declare this interface as <home>{0}</home> or alternatively add @RemoteHome({0}.class) to the top of your bean class.
+
+1.xml.businessLocal.ejbLocalHome = javax.ejb.EJBLocalHome interface declared as <business-local>. Use <local-home>{0}</local- home> +2.xml.businessLocal.ejbLocalHome = javax.ejb.EJBLocalHome interface declared as <business-local>. Use <local-home>{0}</local- home> +3.xml.businessLocal.ejbLocalHome = Interfaces extending javax.ejb.EJBLocalHome must use the <local-home> tag, not the <business-local> tag, when declared in the ejb-jar.xml. Declare this interface as <local-home>{0}</local-home> or alternatively add @LocalHome({0}.class) to the top of your bean class.
+
+1.xml.businessLocal.ejbObject = javax.ejb.EJBObject interface declared as <business-local>. Use <remote>{0}</remote> +2.xml.businessLocal.ejbObject = javax.ejb.EJBObject interface declared as <business-local>. Use <remote>{0}</remote> +3.xml.businessLocal.ejbObject = Interfaces extending javax.ejb.EJBObject must use the <remote> tag, not the <business- local> tag, when declared in the ejb-jar.xml. Declare this interface as <remote>{0}</remote>.
+
+1.xml.businessLocal.ejbLocalObject = javax.ejb.EJBLocalObject interface declared as <business-local>. Use <local>{0}</local> +2.xml.businessLocal.ejbLocalObject = javax.ejb.EJBLocalObject interface declared as <business-local>. Use <local>{0}</local> +3.xml.businessLocal.ejbLocalObject = Interfaces extending javax.ejb.EJBLocalObject must use the <local> tag, not the <business-local> tag, when declared in the ejb-jar.xml. Declare this interface as <local>{0}</local>.
+
+1.xml.businessLocal.beanClass = Bean class mistakenly declared as <business-local> +2.xml.businessLocal.beanClass = Bean class mistakenly declared as <business-local> +3.xml.businessLocal.beanClass = The bean class cannot itself cannot be used as the value of the <business-local> element of the ejb-jar.xml. Either 1) list a valid java interface or 2) delete this element and annotate the intended interface with the @Local annotation.
+
+1.xml.businessLocal.notInterface = The value of <business-local> is not an interface +2.xml.businessLocal.notInterface = The value of <business-local> is not an interface: {0} +3.xml.businessLocal.notInterface = The <business-local> element of the ejb-jar.xml must be an interface. Classes, abstract classes or enums are not allowed. Either convert {0} to an interface or remove the related <business-local> xml tag from your ejb-jar.xml

Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/ org/apache/openejb/config/rules/InvalidInterfacesTest.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidInterfacesTest.java?rev=677503&view=auto
= = = = = = = = = ===================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/ apache/openejb/config/rules/InvalidInterfacesTest.java (added) +++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/ apache/openejb/config/rules/InvalidInterfacesTest.java Wed Jul 16 22:32:23 2008
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.config.rules;
+
+import junit.framework.TestCase;
+import org.apache.openejb.assembler.classic.ContainerSystemInfo;
+import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
+import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.config.ValidationFailedException;
+import org.apache.openejb.config.ValidationFailure;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.StatelessBean;
+
+import javax.ejb.EJBHome;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvalidInterfacesTest extends TestCase {
+    private ConfigurationFactory config;
+
+    public void testBadHomeAndLocal() throws Exception {
+
+        EjbJar ejbJar = new EjbJar();
+ StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(FooBean.class));
+        bean.setHomeAndLocal(FooLocal.class, FooLocal.class);
+        bean.setHomeAndRemote(FooLocal.class, FooLocal.class);
+
+        try {
+            config.configureApplication(ejbJar);
+        } catch (ValidationFailedException e) {
+            for (ValidationFailure failure : e.getFailures()) {
+ System.out.println("failure = " + failure.getMessageKey());
+            }
+        }
+
+    }
+
+    public void setUp() throws Exception {
+        config = new ConfigurationFactory(true);
+ ContainerSystemInfo containerSystem = config.getOpenEjbConfiguration().containerSystem; + containerSystem .containers .add(config.configureService(StatelessSessionContainerInfo.class));
+    }
+
+    public static class FooBean {
+
+    }
+
+    public static interface FooEJBHome extends EJBHome {
+    }
+
+    public static interface FooEJBObject extends EJBObject {
+    }
+
+    public static interface FooEJBLocalHome extends EJBLocalHome {
+    }
+
+ public static interface FooEJBLocalObject extends EJBLocalObject {
+    }
+
+    @Remote
+    public static interface FooRemote {
+    }
+
+    @Local
+    public static interface FooLocal {
+    }
+
+}







Reply via email to