On Jun 26, 2012, at 2:28 PM, exabrial wrote:

> Here's a followup question: So, normally, I'd just put @EJB, but the example
> says  @EJB(mappedName = "jndi:ext://shoe/OrangeBeanRemote") I imagine
> "jndi:ext://" is necessary to tell TomEE to go somewhere else other than
> it's own jndi tree.

Exactly.

> Is there away around that so just plain @EJB would work? I want to be able
> to develop with the EJBs in TomEE, but in prod, I want a large cluster of
> OpenEJB servers. It seems like I should be able to set my prod default
> <JndiProvider> to point externally...

Got it.  My brain is spinning on what would be the least PITA.  There are 
options, but not sure they would pass my personal level of laziness :)

Ignoring that for the moment here are some options:

You can set the MappedName for the @EJB ref via an ejb-jar.xml or web.xml 
rather than in code.  For each potentially-external EJB you'd create **named** 
@EJB reference like so:

    @EJB(name="orange")
    private Orange orange;

Then in the web.xml you can override that exact reference like so:

    <ejb-ref>
        <ejb-ref-name>orange</ejb-ref-name>
        <mapped-name>com.foo.shapes.SquareBean/orangeRemote</mapped-name>
    </ejb-ref>

From there you could come up with some clever technique to swap out the web.xml 
with one for production and one for development.

The name is significant as per spec the name defaults to including the class 
name of the object which has the @EJB reference, such as:

    package org.superbiz.foo;

    public class Widget {
        @EJB(name="orange")
        private Orange orange;
    }

This would default to a name of "org.superbiz.foo.Widget/orange"  which means a 
lot of work when overriding as every class which references Orange would have 
its own unique reference and then require its own override.

> I tried to find more information about this on this page:
> http://openejb.apache.org/containers-and-resources.html but JndiProvider
> isn't mentioned :( The source for JndiProvider shows three properties: id,
> type, provider but I can't find any info about those either.

Needs to be better documented.  The "external EJB refs" feature was actually 
only just added.  It was there and decayed, but has recently been re-added with 
all the new people and feature requests due to TomEE.

> I'll keep digging, but any help or ideas appreciated. I'm definitely going
> to add this to the wiki when i'm done.

Happy to shovel information over if it means better docs :)  That's the primary 
goal of the website editing features we added to the CMS this weekend -- to be 
able to work together on docs in situations like this.


-David

Reply via email to