You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by joe <fi...@yahoo.de> on 2010/02/09 12:17:23 UTC
testing, @Local/@Remote
Hi,
I am quite new to OpenEJB and EJB3 in general, so many things are
nebulous for me.
What's the right strategy for unit testing EJBs?
My understanding is the following:
For testing i should use the embedded EJB container.
I guessed to make an EJB locally testable it has to implement an
interface annotated with @Local.
But it seems i am wrong. My EJBs methods are also invokeable even if
they implement an interface annotated
with @Remote.
So in general Remote-EJBs are locally invokeable? if yes whats the
@Local for?
Just to make EJB methods not invokeable for remote clients?
in the "Simple Stateless Example"
(http://openejb.apache.org/3.0/simple-stateless-example.html)
two interfaces (with identical signatures) are used one with implicit
@Local and one with @Remote annotation.
Why, maybe some use case?
Re: testing, @Local/@Remote
Posted by Gurkan Erdogdu <cg...@gmail.com>.
Hello;
@Local is used for calling EJB methods inside Application Server (For
example, your web application artifacts(servlets) running inside Web
Container makes calls to @Local EJBs running inside EJB container. Both of
web and ejb container contained in the sample application server). You are
not able to call @Local EJBs from outside of the application server, for
example from Remote Java Swing Client running in different JVM from
Application Server. In @Local mode, EJB method parameters are passed by
reference, means that any change/update to the method parameters in called
EJB method are reflected on the calling side (client).
@Remote is used for calling EJB methods inside/outside of the Application
Server. EJB method parameters are passed by value, means that values are
Marhsalled/UnMarshalled between JVM boundaries. Even if caller lives in same
application server, parameters are marshalled/unmarshalled. Therefore there
is always a performance penalty. (Note : Some application servers may
optimize @Remote calls inside application servers!, even if it does, still
not performancable as @Local).
Hope this helps!
Thanks;
--Gurkan
2010/2/9 joe <fi...@yahoo.de>
> Hi,
>
> I am quite new to OpenEJB and EJB3 in general, so many things are nebulous
> for me.
>
> What's the right strategy for unit testing EJBs?
>
> My understanding is the following:
> For testing i should use the embedded EJB container.
>
> I guessed to make an EJB locally testable it has to implement an interface
> annotated with @Local.
> But it seems i am wrong. My EJBs methods are also invokeable even if they
> implement an interface annotated
> with @Remote.
>
> So in general Remote-EJBs are locally invokeable? if yes whats the @Local
> for?
> Just to make EJB methods not invokeable for remote clients?
>
> in the "Simple Stateless Example" (
> http://openejb.apache.org/3.0/simple-stateless-example.html)
> two interfaces (with identical signatures) are used one with implicit
> @Local and one with @Remote annotation.
> Why, maybe some use case?
>
>
--
Gurkan Erdogdu
http://gurkanerdogdu.blogspot.com
Re: testing, @Local/@Remote
Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
joe-2 wrote:
>
>> Since EJB 3.1, a bean is not required to implement an interface (@local
>> or
>> @remote).
>
> OK, but this makes only sence for local EJBs?
> Cause in EJB 3.0 i use the Remote Interface to reference the EJB.
> So i guess for RemoteEJBs this explicit Remote-Interface is still needed?
>
Definitely.
--
View this message in context: http://n4.nabble.com/testing-Local-Remote-tp1474295p1475464.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: testing, @Local/@Remote
Posted by joe <fi...@yahoo.de>.
Hi,
> Before EJB 3.1, @local was not required. If you have a bean implementing a
> single interface, the container will assume it's the local interface. If you
> implement more than one interface, you have to explicitly add the @Local
> annotation.
OK
> Since EJB 3.1, a bean is not required to implement an interface (@local or
> @remote).
OK, but this makes only sence for local EJBs?
Cause in EJB 3.0 i use the Remote Interface to reference the EJB.
So i guess for RemoteEJBs this explicit Remote-Interface is still needed?
> As you already noticed, some details are available at
> http://openejb.apache.org/3.0/simple-stateless-example.html
> http://openejb.apache.org/3.0/simple-stateless-example.html .
"... Local interfaces in EJB are pass-by-reference interfaces..."
Ah ok, so this will be faster than the serialization / deserialization
of the Parameters as used for RemoteBeans. As i can see in the debugger
the serialization / deserialization really happens if a RemoteEJB method
is invoked.
Re: testing, @Local/@Remote
Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
Gurkan Erdogdu-2 wrote:
>
>>>>Can't remember if the spec clearly defines that point.
> AFAIK, spec. says that define one of them @Local or @Remote but not both
>
Hey Gurkan,
You're right!
It's an OpenEJB feature and not a requirement from the spec.
In OpenEJB, you can have a single interface and use it for @Local, @Remote
and SEI (@WebService).
Jean-Louis
--
View this message in context: http://n4.nabble.com/testing-Local-Remote-tp1474295p1474387.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: testing, @Local/@Remote
Posted by Gurkan Erdogdu <cg...@gmail.com>.
>>>Can't remember if the spec clearly defines that point.
AFAIK, spec. says that define one of them @Local or @Remote but not both
2010/2/9 Jean-Louis MONTEIRO <je...@atosorigin.com>
>
> Hi
>
>
> joe-2 wrote:
> >
> > I am quite new to OpenEJB and EJB3 in general, so many things are
> > nebulous for me.
> >
> Welcome :)
>
>
> joe-2 wrote:
> >
> > I guessed to make an EJB locally testable it has to implement an
> > interface annotated with @Local.
> >
> Before EJB 3.1, @local was not required. If you have a bean implementing a
> single interface, the container will assume it's the local interface. If
> you
> implement more than one interface, you have to explicitly add the @Local
> annotation.
> Since EJB 3.1, a bean is not required to implement an interface (@local or
> @remote).
> As you already noticed, some details are available at
> http://openejb.apache.org/3.0/simple-stateless-example.html
> http://openejb.apache.org/3.0/simple-stateless-example.html .
>
>
> joe-2 wrote:
> >
> > But it seems i am wrong. My EJBs methods are also invokeable even if
> > they implement an interface annotated
> > with @Remote.
> >
> > So in general Remote-EJBs are locally invokeable? if yes whats the
> > @Local for?
> > Just to make EJB methods not invokeable for remote clients?
> >
> > in the "Simple Stateless Example"
> > (http://openejb.apache.org/3.0/simple-stateless-example.html)
> > two interfaces (with identical signatures) are used one with implicit
> > @Local and one with @Remote annotation.
> > Why, maybe some use case?
> >
> Can't remember if the spec clearly defines that point.
>
> Jean-Louis
>
> --
> View this message in context:
> http://n4.nabble.com/testing-Local-Remote-tp1474295p1474348.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
--
Gurkan Erdogdu
http://gurkanerdogdu.blogspot.com
Re: testing, @Local/@Remote
Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
Hi
joe-2 wrote:
>
> I am quite new to OpenEJB and EJB3 in general, so many things are
> nebulous for me.
>
Welcome :)
joe-2 wrote:
>
> I guessed to make an EJB locally testable it has to implement an
> interface annotated with @Local.
>
Before EJB 3.1, @local was not required. If you have a bean implementing a
single interface, the container will assume it's the local interface. If you
implement more than one interface, you have to explicitly add the @Local
annotation.
Since EJB 3.1, a bean is not required to implement an interface (@local or
@remote).
As you already noticed, some details are available at
http://openejb.apache.org/3.0/simple-stateless-example.html
http://openejb.apache.org/3.0/simple-stateless-example.html .
joe-2 wrote:
>
> But it seems i am wrong. My EJBs methods are also invokeable even if
> they implement an interface annotated
> with @Remote.
>
> So in general Remote-EJBs are locally invokeable? if yes whats the
> @Local for?
> Just to make EJB methods not invokeable for remote clients?
>
> in the "Simple Stateless Example"
> (http://openejb.apache.org/3.0/simple-stateless-example.html)
> two interfaces (with identical signatures) are used one with implicit
> @Local and one with @Remote annotation.
> Why, maybe some use case?
>
Can't remember if the spec clearly defines that point.
Jean-Louis
--
View this message in context: http://n4.nabble.com/testing-Local-Remote-tp1474295p1474348.html
Sent from the OpenEJB User mailing list archive at Nabble.com.