Ok, maybe I'm doing more than I need to do there. I do have the EL adapter 
bundle, but I guess for some reason I thought that I needed to do the 
target-server bit also. I will see if my results are any different if I remove 
the target-server declaration.

Thanks,
-matt

-----Original Message-----
From: Christian Schneider [mailto:[email protected]] On Behalf Of 
Christian Schneider
Sent: Friday, October 09, 2015 8:59 AM
To: Pitts, Matthew W.
Subject: Re: Bundle set recommendations for JPA+JTA+Eclipselink Partitioning?

Oh .. I guess you are kind of doing the right thing but there is an
existing module for it.

See
https://github.com/apache/aries/tree/trunk/jpa/jpa-container-eclipselink-adapter.

The problem is that eclipselink unlike openjpa and hibernate is not OSGi
ready per se. Kind of strange as they are OSGi in eclipse all over the
place.
So aries jpa has an adapter for eclipselink that does the necessary steps.

So the solution is to simply install the adapter. Then you own bundles
do not have to do anything special.

In karaf you just need to install the eclipselink feature.

Christian



On 09.10.2015 14:22, [email protected] wrote:
> I don't know the exact reference, but I did this based on some examples I
> had seen. The aries.jpa.eclipselink.adapter bundle comes with classes
> (OSGiTSWrapper and OSGiTSServer) and I had seen some examples of linking a
> persistence unit to use them via the 'eclipselink.target-server' property.
>
> So, are you saying this doesn't need to be done at all? If not, then how
> does EL become aware of the transaction manager?
>
> Is it possible that because I am doing this *and* using eclipselink's own
> Partitioning/Replication support that I am indeed getting XA-enlisted
> datasources without the aries wrappers?
>
> Thanks again for all your help.
>
> v/r
> -matt
>
> -----Original Message-----
> From: Christian Schneider [mailto:[email protected]] On Behalf Of
> Christian Schneider
> Sent: Friday, October 09, 2015 4:00 AM
> To: Pitts, Matthew W.
> Subject: Re: Bundle set recommendations for JPA+JTA+Eclipselink
> Partitioning?
>
> I totally did not get why you need the code below.
> When you use Aries JPA then Eclipselink should be working with the
> TransactionManager without any special code from your side.
>
> It should also not be necessary that you use any Aries dependencies in
> your user bundles. The only case where it is needed is when you want to
> use the JpaTemplate with DS.
>
> Christian
>
>
>
> On 08.10.2015 22:12, [email protected] wrote:
>> I'll see if I can put together a sample app replicating this. As for the
>> eclipselink enlistment, if it helps to know, I am making EL 'aware' of the
>> OSGI TransactionManager by specifying a 'target-platform' that acquires
> the
>> service, like in [1]. I think this is pretty standard practice though with
>> aries-jpa. I just do it from my own classes so that my actual persistence
>> unit bundles don't have to import aries-specific classes.
>>
>> [1]
>> public class OSGiTSWrapper extends JTATransactionController
>> {
>>
>>     @Override
>>     protected TransactionManager acquireTransactionManager() throws
> Exception
>>     {
>>       BundleContext ctx =
>> FrameworkUtil.getBundle(OSGiTSWrapper.class).getBundleContext();
>>
>>       if (ctx != null)
>>       {
>>         ServiceReference ref =
>> ctx.getServiceReference(TransactionManager.class.getName());
>>
>>         if (ref != null)
>>         {
>>           TransactionManager manager = (TransactionManager)
>> ctx.getService(ref);
>>           return manager;
>>         }
>>       }
>>
>>       return super.acquireTransactionManager();
>>     }
>>
>> }
>>


--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply via email to