Author: rmannibucau
Date: Mon Jun  4 19:50:30 2012
New Revision: 1346120

URL: http://svn.apache.org/viewvc?rev=1346120&view=rev
Log:
@Local on class with no interfaces

Added:
    openejb/trunk/openejb/examples/local-on-localview-bean/
    openejb/trunk/openejb/examples/local-on-localview-bean/pom.xml
    openejb/trunk/openejb/examples/local-on-localview-bean/src/
    openejb/trunk/openejb/examples/local-on-localview-bean/src/main/
    openejb/trunk/openejb/examples/local-on-localview-bean/src/main/java/
    openejb/trunk/openejb/examples/local-on-localview-bean/src/main/java/org/
    
openejb/trunk/openejb/examples/local-on-localview-bean/src/main/java/org/superbiz/
    
openejb/trunk/openejb/examples/local-on-localview-bean/src/main/java/org/superbiz/bean/
    
openejb/trunk/openejb/examples/local-on-localview-bean/src/main/java/org/superbiz/bean/LocalBeanWithLocal.java
    openejb/trunk/openejb/examples/local-on-localview-bean/src/test/
    openejb/trunk/openejb/examples/local-on-localview-bean/src/test/java/
    openejb/trunk/openejb/examples/local-on-localview-bean/src/test/java/org/
    
openejb/trunk/openejb/examples/local-on-localview-bean/src/test/java/org/superbiz/
    
openejb/trunk/openejb/examples/local-on-localview-bean/src/test/java/org/superbiz/bean/
    
openejb/trunk/openejb/examples/local-on-localview-bean/src/test/java/org/superbiz/bean/LocalBeanWithLocalTest.java
Modified:
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
    openejb/trunk/openejb/examples/pom.xml

Modified: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=1346120&r1=1346119&r2=1346120&view=diff
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
 (original)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
 Mon Jun  4 19:50:30 2012
@@ -2795,13 +2795,26 @@ public class AnnotationDeployer implemen
                         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
-                         */
-                        return;
+                        // just warn for @Local since Glassfish supports it 
even if it is weird
+                        // still fail for @Remote!
+                        if (impliedLocal && local.value().length == 0 && 
interfaces.size() == 0) {
+                            validation.warn(ejbName, "ann.local.noAttributes", 
join(", ", interfaceNames));
+                            // we don't go out to let be deployed
+                        } else if (impliedLocal) {
+                            validation.fail(ejbName, "ann.local.noAttributes", 
join(", ", interfaceNames));
+                            /**
+                             * This bean is invalid, so do not bother looking 
at the other interfaces or the superclass
+                             */
+                            return;
+                        }
+                        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
+                             */
+                            return;
+                        }
                     } else if (strict && impliedLocal && impliedRemote) {
                         Class<?> interfce = interfaces.remove(0);
                         /**

Added: openejb/trunk/openejb/examples/local-on-localview-bean/pom.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/local-on-localview-bean/pom.xml?rev=1346120&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/local-on-localview-bean/pom.xml (added)
+++ openejb/trunk/openejb/examples/local-on-localview-bean/pom.xml Mon Jun  4 
19:50:30 2012
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.superbiz</groupId>
+  <artifactId>local-on-localview-bean</artifactId>
+  <packaging>jar</packaging>
+  <version>1.1-SNAPSHOT</version>
+  <name>OpenEJB :: Examples :: @Local without Interface</name>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <build>
+    <defaultGoal>install</defaultGoal>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.4</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <repositories>
+    <repository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>http://repository.apache.org/snapshots</url>
+    </repository>
+  </repositories>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>6.0-3</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.10</version>
+      <scope>test</scope>
+    </dependency>
+    <!-- The <scope>test</scope> guarantees that none of your runtime code
+      is dependent on any OpenEJB classes. -->
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-core</artifactId>
+      <version>4.1.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>arquillian-openejb-embedded-4</artifactId>
+      <version>4.1.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <!-- This section allows you to configure where to publish libraries for
+    sharing. It is not required and may be deleted. For more information see:
+    http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+  <distributionManagement>
+    <repository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/repo/</url>
+    </repository>
+    <snapshotRepository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/snapshot-repo/</url>
+    </snapshotRepository>
+  </distributionManagement>
+
+</project>

Added: 
openejb/trunk/openejb/examples/local-on-localview-bean/src/main/java/org/superbiz/bean/LocalBeanWithLocal.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/local-on-localview-bean/src/main/java/org/superbiz/bean/LocalBeanWithLocal.java?rev=1346120&view=auto
==============================================================================
--- 
openejb/trunk/openejb/examples/local-on-localview-bean/src/main/java/org/superbiz/bean/LocalBeanWithLocal.java
 (added)
+++ 
openejb/trunk/openejb/examples/local-on-localview-bean/src/main/java/org/superbiz/bean/LocalBeanWithLocal.java
 Mon Jun  4 19:50:30 2012
@@ -0,0 +1,12 @@
+package org.superbiz.bean;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+
+@Local
+@Stateless(mappedName = "Foo")
+public class LocalBeanWithLocal {
+    public String msg() {
+        return "@Local shouldn't be put on a bean without interface. It works 
with glassfish so tolerating it.";
+    }
+}

Added: 
openejb/trunk/openejb/examples/local-on-localview-bean/src/test/java/org/superbiz/bean/LocalBeanWithLocalTest.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/local-on-localview-bean/src/test/java/org/superbiz/bean/LocalBeanWithLocalTest.java?rev=1346120&view=auto
==============================================================================
--- 
openejb/trunk/openejb/examples/local-on-localview-bean/src/test/java/org/superbiz/bean/LocalBeanWithLocalTest.java
 (added)
+++ 
openejb/trunk/openejb/examples/local-on-localview-bean/src/test/java/org/superbiz/bean/LocalBeanWithLocalTest.java
 Mon Jun  4 19:50:30 2012
@@ -0,0 +1,32 @@
+package org.superbiz.bean;
+
+import javax.ejb.EJB;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+@RunWith(Arquillian.class)
+public class LocalBeanWithLocalTest {
+    @EJB
+    private LocalBeanWithLocal bean;
+
+    @Deployment
+    public static JavaArchive jar() {
+        return ShrinkWrap.create(JavaArchive.class)
+                .addClass(LocalBeanWithLocal.class);
+    }
+
+    @Test
+    public void checkItIsDeployed() {
+        assertNotNull(bean);
+        System.out.println(bean.msg()); // print it to show it is bad
+        assertThat(bean.msg(), containsString("@Local"));
+    }
+}

Modified: openejb/trunk/openejb/examples/pom.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/pom.xml?rev=1346120&r1=1346119&r2=1346120&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/pom.xml (original)
+++ openejb/trunk/openejb/examples/pom.xml Mon Jun  4 19:50:30 2012
@@ -66,6 +66,7 @@
     <module>jpa-eclipselink</module>
     <module>jpa-hibernate</module>
     <module>jpa-enumerated</module>
+    <module>local-on-localview-bean</module>
     <module>lookup-of-ejbs</module>
     <module>lookup-of-ejbs-with-descriptor</module>
     <module>mbean-auto-registration</module>


Reply via email to