<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">

  <import resource="classpath:jbpm/configuration-template/assets.xml" />

  <bean id="jbpmEMF" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="org.jbpm.persistence.spring.local"/>
    <property name="persistenceXmlLocation" value="classpath:jbpm/persistence-local.xml"/>
  </bean>

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

  <bean id="runtimeEnvironment" class="org.kie.spring.factorybeans.RuntimeEnvironmentFactoryBean">
    <property name="type" value="DEFAULT"/>
    <property name="entityManagerFactory" ref="jbpmEMF"/>
    <property name="transactionManager" ref="jbpmTxManager"/>
    <property name="assets" ref="assets"/>
    <property name="environmentEntries" ref="env" />
  </bean>


  <util:map id="env" key-type="java.lang.String" value-type="java.lang.Object">
    <entry>
      <key>
        <util:constant
            static-field="org.kie.api.runtime.EnvironmentName.USE_LOCAL_TRANSACTIONS" />
      </key>
      <value>true</value>
    </entry>
  </util:map>

  <bean id="logService" class="org.jbpm.process.audit.JPAAuditLogService" depends-on="runtimeEnvironment">
    <constructor-arg value="#{runtimeEnvironment.environment}"/>
    <constructor-arg value="STANDALONE_LOCAL"/>
  </bean>
</beans>
