You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by David Blevins <da...@visi.com> on 2009/03/04 04:41:01 UTC

User Blog: Using OpenEJB for EJB3 testing with Maven2

Pascal Alma has written a good blog post about using OpenEJB and Maven  
to test his GlassFish EJB3 app.

This is one of the more complete tutorials with four different modules  
that combine into one ear along with the complete pom.xml for each.   
It uses maven filtering to supply different sets of deployment  
descriptors for development and testing as well as a Hibernate feature  
for importing the initial sql.

He makes an interesting comment about not being able to use his  
business remote interface also as a web service interface.  This is  
against the EJB spec, but it is certainly something we can support.   
I've already been hacking on this somewhat, so in the next release  
there should be some support for switching between allowing this and  
disallowing it.  When setup to allow this sort of thing, you will be  
able to annotate an interface with @Local, @Remote, and @WebService  
and have it function in all those roles.

http://www.pascalalma.net/2009/02/20/using-openejb-for-ejb3-testing-with-maven2/

Enjoy!

-David



Re: User Blog: Using OpenEJB for EJB3 testing with Maven2

Posted by David Blevins <da...@visi.com>.
On Mar 4, 2009, at 7:10 AM, Jean-Louis MONTEIRO wrote:

>
>
> David Blevins wrote:
>>
>> When setup to allow this sort of thing, you will be
>> able to annotate an interface with @Local, @Remote, and @WebService
>> and have it function in all those roles.
>>
> At a design point of view, I'm not sure it's a good idea, except may  
> be for
> session facade (with dto, ...).

Right, it's definitely one of those things spec members have been  
split on.  There are a few that support the idea, including me, and a  
few that are not sure it's a good idea.

I think it's fine to offer to users who understand the interface will  
have to meet the combined requirements of all the "views" for which  
they sign it up.

Certainly with EJB 3.1 no-interface views it somewhat becomes moot as  
a bean with no interfaces can simultaneously be annotated with  
@WebService and @LocalBean which is equivalent to having an interface  
with @Local and @WebService.

In EJB 3.0 there's always this work around:

     @Stateless
     public static class MyBean implements MainInterface.Local,  
MainInterface.Remote, MainInterface.Service {
         public Object doSomething(Object o) {
             return o;
         }
     }

     public static interface MainInterface {
         public Object doSomething(Object o);

         @javax.ejb.Local
         public static interface Local extends MainInterface{}

         @javax.ejb.Remote
         public static interface Remote extends MainInterface{}

         @javax.jws.WebService
         public static interface Service extends MainInterface{}
     }

The inner classes may not work in some containers, but the basic idea  
is that there's no way someone can be stopped from having one  
interface with all their methods essentially be an @Local, @Remote,  
and @WebService.  In the above the "doSomething" method still has to  
support all the requirements of all the possible views and the bean  
developer in their code could cast any client view possible to  
"MainInterface" universally refer to it that way as if the other "sub"  
interfaces did not exist.  In my mind, if the above is possible, why  
make people work so hard to do it.  Better to just allow it as a  
feature that can be enabled.

-David


Re: User Blog: Using OpenEJB for EJB3 testing with Maven2

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.

David Blevins wrote:
> 
> When setup to allow this sort of thing, you will be  
> able to annotate an interface with @Local, @Remote, and @WebService  
> and have it function in all those roles.
> 
At a design point of view, I'm not sure it's a good idea, except may be for
session facade (with dto, ...). 


David Blevins wrote:
> 
> http://www.pascalalma.net/2009/02/20/using-openejb-for-ejb3-testing-with-maven2/
> 

Thanks for the link.

Jean-Louis

-- 
View this message in context: http://www.nabble.com/User-Blog%3A-Using-OpenEJB-for-EJB3-testing-with-Maven2-tp22323088p22331943.html
Sent from the OpenEJB User mailing list archive at Nabble.com.