tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Russo <jru...@genscape.com>
Subject Re: Outbound resource injection in an ejb
Date Fri, 22 Jan 2010 22:11:29 GMT
Ok, so I figured this out myself and it works very nicely.  Some notes
for anyone else who wants to do this:

I created a service-jar.xml file, and in it defined several service
provider tags for the main adapter class
(com.sun.genericra.GenericJMSRA), as well as for queue, topic, and
connection factory proxies in the service-jar.xml.  Within those service
provider tags I listed the setter properties of those classes that are
pertinent to defining a remote connection.  For example:

<ServiceJar>
    <ServiceProvider id="genericra" service="Resource"
types="GenericJMSRA" class-name="com.sun.genericra.GenericJMSRA">
        AdapterProperty1
        AdapterProperty2
        ...
    </ServiceProvider>
</ServiceJar>

Then I repackaged genericra.jar, adding the service-jar.xml as
META-INF/com.sun.genericra/service-jar.xml.

Placed the genericra.jar file in openejb.home/lib (or, tomcat.home/lib
if embedding openejb in tomcat).

Added sections in the openejb.xml file for my resources (adapter,
connection factory, queues and topics) to override the properties in
service-jar.xml with actual values.  Then defined some new containers in
openejb.xml using the adapters, and walla!  Message driven beans work
very nicely.

One caveat: when defining a resource in openejb.xml, make sure to add a
provider attribute and prefix it with com.sun.genericra#<providerid>.
So the openejb resource entry will look like this:

<Resource id="My Generic Adapter" type="GenericJMSRA"
jar="genericra-1.0.jar" provider="com.sun.genericra#genericra">
    AdapterProperty1            PropertyValue1
    AdapterProperty2            PropertyValue2
    ...
</Resource>

If the openejb dev group wants my genericra.jar to embed as a built in
service for external jms provider support, I can contribute my adapter.



Jason Russo

Application Developer

Genscape– See the Energy

445 E. Market St, Suite 200

Louisville, KY 40202

Tel: 502-583-2091

www.genscape.com



On Thu, 2010-01-14 at 10:27 -0500, Jason Russo wrote:

> Let me see if I have this straight.  What goes in the openejb.base/lib
> folder is the rar file, or the jar that normally is wrapped by the
> adapter rar?  And I would need to add a service-jar.xml file into the
> META-INF folder of which package?  In other words, is the resulting
> structure like:
> 
> openejb.home/lib/adapter.jar
>                                     '-->/META-INF
>                                               '-->service-jar.xml
>                                     '-->/classes
>                                               '-->*.class
> 
> or
> 
> openejb.home/lib/adapter.rar
>                                     '-->/META-INF
>                                               '-->service-jar.xml
>                                               '-->ra.xml
>                                     '-->adapter.jar
> ?
> 
> However it works, I like this idea because it allows configuration at
> the container level.  It's something worth looking into if time
> constraints don't limit my ability to research this more. 
> 
> Regarding your first suggestion, however, if I do define configuration
> properties in the ra.xml file for the outbound resource, it sounds like
> I would only be able to define one outbound resource (destination) per
> adapter.  So, my question here is: can I define multiple jms
> destinations in an ear package using just one adapter?  If not, would I
> be able to install multiple adapters in an ear to define more than one
> jms destination?  I hate to say the more I learn the more questions I
> have. :)
> 
> 
> 
> Jason Russo
> 
> Application Developer
> 
> Genscape– See the Energy
> 
> 445 E. Market St, Suite 200
> 
> Louisville, KY 40202
> 
> Tel: 502-583-2091
> 
> www.genscape.com
> 
> 
> 
> On Wed, 2010-01-13 at 19:35 -0500, David Blevins wrote:
> 
> > On Jan 13, 2010, at 11:12 PM, Jason Russo wrote:
> > 
> > > Hi all,
> > >
> > > Previously, I created a message driven bean that can connect to a jms
> > > queue through an external provider (Tibco) using a jca resource  
> > > adapter.
> > > What I am trying to figure out is how I can write an ejb that can  
> > > post a
> > > message to this external queue.  Does openejb support the injection of
> > > such a resource and how can it be configured?  Thanks.
> > 
> > Anything declared as an outbound resource in the ra.xml should just be  
> > injectable via plain old @Resource.  The configuration in the ra.xml  
> > is what will be used, unless... and I wish there was an easier way to  
> > set this up, but...
> > 
> > You *can* just unzip all your resource adapter jars into the  
> > openejb.base/lib/ directory and install it as an OpenEJB service by  
> > giving it a service-jar.xml file.  Essentially, this is what we are  
> > doing under the covers anyway when you put your rar file in the ear.   
> > I wish we had some syntactic sugar for this but we don't.  I looked  
> > into it a bit ago and just didn't have time to finish.
> > 
> > The end result of rewrapping your rar with a service-jar.xml is that  
> > you can declare and configure the MDB container, the resource adapter,  
> > and outbound resources in the openejb.xml via <Container> and  
> > <Resource> tags.
> > 
> > Basically, you pack META-INF/service-jar.xml file into jar and put it  
> > into the openejb.base/lib/ directory.  It's not well documented as it  
> > isn't quite intended for typical use, but it did come up recently and  
> > there are some details available here:
> > 
> >   http://n4.nabble.com/How-do-I-configure-an-alternate-transaction-manager-tp980158p980159.html
> > 
> > Here is the service-jar.xml that contains the declarations for the  
> > ActiveMQ resource adapter and outbound resources:
> > 
> >    http://svn.apache.org/repos/asf/openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb.embedded/service-jar.xml
> > 
> > 
> > -David
> > 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message