aries-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bengt Rodehav <be...@rodehav.com>
Subject Re: Blueprint, factory method and JPA
Date Fri, 17 Sep 2010 10:08:19 GMT
Thanks for you reply Timothy,

The reason why I want to use a factory method (a factory class would work
too) is that I have a singleton pattern underneath. I need to make sure
that, after construction of the BusinessUnitServiceImpl instance, I need to
set a static variable to that instance. I've had a hard time to find away
around this - it probably requires major restructuring on my side. I do
think that as far as dependency injection is concerned the following methods
should be supported:

- setter injection
- constructor injection
- factory method
- factory class

I also believe that all of those are included in the Blueprint spec - aren't
they? Then, any integration to Blueprint (like aries JPA) should support
those injection methods. I will think more about your hint:

Managed persistence context objects do not need to be shared between beans
> as the context propagates with the active transaction.


I might be able to use that, however, currently I support both in-OSGi and
out-of-OSGi tests and I would like to access the entity manager in the same
way. That's why I set the static variable to the injected instance in the
OSGi case. When I'm not in OSGi I manually create the entity manager but in
both scenarios I access the entity manager in the same way.

Hope that makes some sense,

/Bengt

2010/9/17 Timothy Ward <timothyjward@hotmail.com>

>
>
> Hi Bengt,
>
> This is actually a case that isn't covered by the existing JPA blueprint
> integration. The  and  elements are effectively specialized property
>  elements. As such your example is effectively:
>
>
> <bean id="businessUnitServiceImpl"
> class="se.digia.sts.refdata.impl.BusinessUnitServiceImpl"
> factory-method="create">
>   <argument>
>     <property name="entityManager" ref="magic_internal_JPA_bean_name"/>
>   </argument>
> </bean>
> This obviously is garbage from a blueprint point of view. To progress your
> application development the only option currently is to expose a setter
> method on the "businessUnitServiceImpl" bean.
>
> If this isn't possible for some reason, then please raise a JIRA
> enhancement against the Aries JPA container, and I'll look at adding this
> support. I would like to check though, why is it necessary to pass the
> context to the factory method? Managed persistence context objects do not
> need to be shared between beans as the context propagates with the active
> transaction.
>
> Regards,
>
> Tim
>
>
>
> ________________________________
> > Date: Fri, 17 Sep 2010 08:42:01 +0200
> > Subject: Blueprint, factory method and JPA
> > From: bengt@rodehav.com
> > To: aries-user@incubator.apache.org
> >
> > I'm trying to use a factory method with Aries Blueprint. I need to pass
> > a JPA entity manager as an argument to the factory method. I'm trying
> > the following:
> >
> >> class="se.digia.sts.refdata.impl.BusinessUnitServiceImpl"
> > factory-method="create">
> >
> >
> >
> >
> >
> > However, Aries seems to object against this syntax. How can I
> > accomplish this? All the samples I've seen where "jpa:context..." is
> > involved always use setter injection, never in combination with the
> > "" tag.
> >
> > I'm using version 0.2-incubating of Aries.
> >
> > /Bengt
> >
> >
>
>

Mime
View raw message