[
https://issues.apache.org/jira/browse/ARIES-413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12912681#action_12912681
]
Bengt Rodehav commented on ARIES-413:
-------------------------------------
It's a much more compact notation. The risk is that it's too compact (might be
heard to see that it's constructor injection) but it's fine for me.
Have you thought about the cases where a factory method or a factory class is
used?
BTW one of the cases where I want to use this is to initialise a test fixture.
This involves creating an instance and then calling a "initialise" method. The
trick is that the "initialise" method shall have the transaction attribute
"RequiresNew". Something like this:
<bean id="fixture" class="se.digia.sts.refdata.test.RefdataFixtureService">
<tx:transaction method="initialise" value="RequiresNew" />
<jpa:context property="entityManager" unitname="refdataPU" />
</bean>
When calling initialise() from the constructor now transaction is created. But,
if I call the initialise() method "manually" from the client, after the
instance has been created, it works. I'm hoping that if I use a factory method
that instantiates the fixture and then calls initialise() a transaction will be
created. Do you think this will work? I guess it's not only about how the
factory method works but also if there is some implicit/explicit ordering
between the "tx: transaction" and the "jpa:context" tags in the example above.
> Injecting an entity manager using factory method
> ------------------------------------------------
>
> Key: ARIES-413
> URL: https://issues.apache.org/jira/browse/ARIES-413
> Project: Aries
> Issue Type: Improvement
> Components: JPA
> Affects Versions: 0.2
> Reporter: Bengt Rodehav
> Assignee: Timothy Ward
>
> It is only possible to use setter injection when injecting a JPA entity
> manager. The following injection types should also be supported since they
> are supported in the Blueprint spec:
> - Constructor injection
> - Factory method injection
> - Factory class injection
> An example of usage could be (using a factory method):
> <bean id="beanImpl" class="MyClass" factory-method="create">
> <argument>
> <jpa:context property="entityManager" unitname="myPU"/>
> </argument>
> </bean>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.