The solution i found sofar:

Get the TransactionManagerFactory With this TransactionManagerFactory i 
create a Spring JPA Platformtransactionmanager, which gets inserted in a 
Camel SpringTransactionPolicy.

<reference id="hibernateEntityManagerFactory" 
interface="javax.persistence.EntityManagerFactory" 
filter="(osgi.unit.name=pydio2xbound_mssql_persistence_unit)" 
availability="mandatory"/>

<reference id="wellspectDaoService" 
interface="de.hmm.medit.esb.xbound.pydio2xbound.wellspect.persistence.dao.spi.WellspectDaoService"/>

<bean id="jpaTransactionManager" 
class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="hibernateEntityManagerFactory"/>
</bean>

<bean id="jpaPropagationRequired" 
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
    <property name="transactionManager" ref="jpaTransactionManager"/>
    <property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/>
</bean>

<bean id="daoProcessor" 
class="de.hmm.medit.esb.xbound.pydio2xbound.wellspect.aggregation.camel.impl.DaoProcessor">
    <property name="entityManagerFactory" ref="hibernateEntityManagerFactory"/>
    <property name="wellspectDaoService" ref="wellspectDaoService"/>
</bean>



This setup does createEntityManager(), doBegin() ect. on behalf of the 
Camel route.
For persistence in mid route i call the OSGi service method using the in 
route created EntityManager:

@Override
public void persistDetectingDuplicatesMSSQL(WellspectAuftragsDatei 
wellspectAuftragsDatei, EntityManager entityManager) {
    entityManager.persist(wellspectAuftragsDatei);

etc...


Notice i disabled @Transactional to avoid Aries byte weaving this method, 
effectively deactivating Aries on this method call.
Extracting the, by this thread created, EntityManager from the 
EnityManagerFactory needed some research in Spring and is handled within 
the DaoProcessor:

EntityManager entityManager = 
EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory);




-- 
-- 
------------------
OPS4J - http://www.ops4j.org - [email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to