You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by km...@apache.org on 2010/07/18 21:36:32 UTC
svn commit: r965276 - in /openejb/trunk/openejb3/container/openejb-core/src:
main/java/org/apache/openejb/config/
main/resources/org/apache/openejb/config/rules/
test/java/org/apache/openejb/config/rules/
Author: kmalhi
Date: Sun Jul 18 19:36:32 2010
New Revision: 965276
URL: http://svn.apache.org/viewvc?rev=965276&view=rev
Log:
Fixed AnnotationDeployer to properly report the validation data
Fixed Messages.properties to properly escape the curly braces
Tested Annotated interfaces keys
Added:
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInvalidAnnotatedInterfacesTest.java
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.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/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=965276&r1=965275&r2=965276&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java Sun Jul 18 19:36:32 2010
@@ -1754,8 +1754,13 @@ public class AnnotationDeployer implemen
/**
* Cannot imply either @Local or @Remote and list multiple interfaces
*/
- if (impliedLocal) validation.fail(ejbName, "ann.local.noAttributes", join(", ", interfaces));
- if (impliedRemote) validation.fail(ejbName, "ann.remote.noAttributes", join(", ", interfaces));
+ // Need to extract the class names and append .class to them to show proper validation level 3 message
+ List<String> interfaceNames = new ArrayList<String>();
+ for (Class<?> intrfce : interfaces) {
+ interfaceNames.add(intrfce.getName()+".class");
+ }
+ if (impliedLocal) validation.fail(ejbName, "ann.local.noAttributes", join(", ", interfaceNames));
+ if (impliedRemote) validation.fail(ejbName, "ann.remote.noAttributes", join(", ", interfaceNames));
/**
* This bean is invalid, so do not bother looking at the other interfaces or the superclass
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=965276&r1=965275&r2=965276&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 Sun Jul 18 19:36:32 2010
@@ -279,12 +279,13 @@
# fail(ejbName, "ann.remote.noAttributes", join(", ", interfaces));
1.ann.remote.noAttributes = Ambiguous @Remote() usage on bean class
2.ann.remote.noAttributes = Ambiguous @Remote() usage on bean class. Must list interfaces explicitly in annotation.
-3.ann.remote.noAttributes = When annotating a bean class as @Remote with no annotation attributes, the bean must implement exactly one business interface, no more and no less. List the remote interfaces explicitly in the annotation, such as @Remote(\{{0}\}). Alternatively, apply the @Remote annotation to the individual interfaces and remove it from the bean class.
+3.ann.remote.noAttributes = When annotating a bean class as @Remote with no annotation attributes, the bean must implement exactly one business interface, no more and no less. List the remote interfaces explicitly in the annotation, such as @Remote('{'{0}'}'). Alternatively, apply the @Remote annotation to the individual interfaces and remove it from the bean class.
+#This one is the same as ann.localremote.ambiguous -- commenting it out for now
# fail(ejbName, "ann.remoteLocal.ambiguous", join(", ", interfaces));
-1.ann.remoteLocal.ambiguous = Ambiguous @Remote and @Local usage on bean class.
-2.ann.remoteLocal.ambiguous = Ambiguous @Remote and @Local usage on bean class. Must list interfaces explicitly in @Remote annotation.
-3.ann.remoteLocal.ambiguous = When annotating a bean class as @Remote with no annotation attributes you must not also annotate it with @Local with no attributes. List the remote interfaces explicitly in the annotation, such as @Remote(\{{0}\}). Alternatively, apply the @Remote annotation to the individual interfaces and remove it from the bean class.
+#1.ann.remoteLocal.ambiguous = Ambiguous @Remote and @Local usage on bean class.
+#2.ann.remoteLocal.ambiguous = Ambiguous @Remote and @Local usage on bean class. Must list interfaces explicitly in @Remote annotation.
+#3.ann.remoteLocal.ambiguous = When annotating a bean class as @Remote with no annotation attributes you must not also annotate it with @Local with no attributes. List the remote interfaces explicitly in the annotation, such as @Remote(\{{0}\}). Alternatively, apply the @Remote annotation to the individual interfaces and remove it from the bean class.
# fail(ejbName, "ann.remoteLocal.conflict", join(", ", interfaces));
1.ann.remoteLocal.conflict = @Remote annotation in bean class conflicts with @Local in interface.
@@ -294,12 +295,12 @@
# fail(ejbName, "ann.local.noAttributes", join(", ", interfaces));
1.ann.local.noAttributes = Ambiguous @Local() usage on bean class
2.ann.local.noAttributes = Ambiguous @Local() usage on bean class. Must list interfaces explicitly in annotation.
-3.ann.local.noAttributes = When annotating a bean class as @Local with no annotation attributes, the bean must implement exactly one business interface, no more and no less. List the local interfaces explicitly in the annotation, such as @Local(\{{0}\}). Alternatively, apply the @Local annotation to the individual interfaces and remove it from the bean class.
+3.ann.local.noAttributes = When annotating a bean class as @Local with no annotation attributes, the bean must implement exactly one business interface, no more and no less. List the local interfaces explicitly in the annotation, such as @Local('{'{0}'}'). Alternatively, apply the @Local annotation to the individual interfaces and remove it from the bean class.
# fail(ejbName, "ann.localRemote.ambiguous", join(", ", interfaces));
1.ann.localRemote.ambiguous = Ambiguous @Local and @Remote usage on bean class.
2.ann.localRemote.ambiguous = Ambiguous @Local and @Remote usage on bean class. Must list interfaces explicitly in @Local annotation.
-3.ann.localRemote.ambiguous = When annotating a bean class as @Local with no annotation attributes you must not also annotate it with @Remote. List the local interfaces explicitly in the annotation, such as @Local(\{{0}\}). Alternatively, apply the @Local annotation to the individual interfaces and remove it from the bean class.
+3.ann.localRemote.ambiguous = When annotating a bean class as @Local with no annotation attributes you must not also annotate it with @Remote. List the local interfaces explicitly in the annotation, such as @Local('{'{0}'}'). Alternatively, apply the @Local annotation to the individual interfaces and remove it from the bean class.
# fail(ejbName, "ann.localRemote.conflict", join(", ", interfaces));
1.ann.localRemote.conflict = @Local annotation in bean class conflicts with @Remote in interface.
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInvalidAnnotatedInterfacesTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInvalidAnnotatedInterfacesTest.java?rev=965276&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInvalidAnnotatedInterfacesTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInvalidAnnotatedInterfacesTest.java Sun Jul 18 19:36:32 2010
@@ -0,0 +1,83 @@
+/**
+ * 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 javax.ejb.Local;
+import javax.ejb.Remote;
+
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.StatelessBean;
+import org.apache.openejb.loader.SystemInstance;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+
+@RunWith(ValidationRunner.class)
+public class CheckInvalidAnnotatedInterfacesTest {
+ @BeforeClass
+ public static void beforeClass() {
+ System.setProperty("openejb.validation.output.level", "VERBOSE");
+ }
+
+ @Keys( { @Key("ann.local.noAttributes"), @Key("ann.remote.noAttributes") })
+ public EjbJar noAttributes() {
+ EjbJar ejbJar = new EjbJar();
+ ejbJar.addEnterpriseBean(new StatelessBean(FooBeanLocal.class));
+ ejbJar.addEnterpriseBean(new StatelessBean(FooBeanRemote.class));
+ return ejbJar;
+ }
+
+ @Keys( { @Key("ann.localRemote.ambiguous"), @Key("ann.localRemote.conflict") })
+ public EjbJar ambiguous() {
+ SystemInstance.get().setProperty("openejb.strict.interface.declaration", "true");
+ EjbJar ejbJar = new EjbJar();
+ ejbJar.addEnterpriseBean(new StatelessBean(FooBeanLocalRemote.class));
+ ejbJar.addEnterpriseBean(new StatelessBean(FooBeanLocalOne.class));
+ return ejbJar;
+ }
+
+ @After
+ public void after() {
+ SystemInstance.get().setProperty("openejb.strict.interface.declaration", "false");
+ }
+
+ @Local
+ public static class FooBeanLocal implements FooLocalOne, FooLocalTwo {}
+
+ @Remote
+ public static class FooBeanRemote implements FooRemoteOne, FooRemoteTwo {}
+
+ @Local
+ @Remote
+ public static class FooBeanLocalRemote implements FooLocalOne {}
+
+ @Local(FooRemoteOne.class)
+ @Remote(FooRemoteOne.class)
+ public static class FooBeanLocalOne {}
+
+ @Remote
+ public static interface FooRemoteOne {}
+
+ @Remote
+ public static interface FooRemoteTwo {}
+
+ @Local
+ public static interface FooLocalOne {}
+
+ @Local
+ public static interface FooLocalTwo {}
+}