JIRA created: https://issues.apache.org/jira/browse/ARIES-413
<https://issues.apache.org/jira/browse/ARIES-413>/Bengt 2010/9/17 Bengt Rodehav <[email protected]> > Timoty, > > I won't argue singletons with you. I think you're probably right, it was > just the way things used to work and not supporting a factory method > requires me to change the existing design. Nevertheless, I'll try to work > around this (by changing the design). > > I will however create a JIRA as well since I generally think that all > Blueprint injection methods should be supported (and I actually am a bit > biased towards factory based solutions). > > /Bengt > > > The reason why a factory method would be beneficial but the under > > 2010/9/17 Timothy Ward <[email protected]> > > >> >> Hi Bengt >> >> I'm not certain why you would want to write a singleton this way. The >> blueprint container ensures that you only get one instance of the bean (the >> default scope is singleton). >> >> I'm also not sure why making this change would make your testing >> different, rather than passing the EntityManager to a factory method you >> would pass it to an instance method on the object you create... From that >> point on the access is completely identical. >> >> I believe you are correct that the JPA blueprint support should cope with >> constructor injection as well as setter injection, so I suggest that you >> raise a JIRA and we can get it into the 0.3 stream. >> >> Regards, >> >> Tim >> >> >> ________________________________ >> > Date: Fri, 17 Sep 2010 12:08:19 +0200 >> > Subject: Re: Blueprint, factory method and JPA >> > From: [email protected] >> > To: [email protected] >> > >> > 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 >> >> >> > >> > >> > 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: >> > >> > >> >> class="se.digia.sts.refdata.impl.BusinessUnitServiceImpl" >> > factory-method="create"> >> > >> > >> > >> > >> > 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: [email protected] >> >> To: [email protected] >> >> >> >> 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 >> >> >> >> >> > >> > >> >> > >
