1
2
3
4
5
6
7
8
9
10 package org.mule.config.spring.factories;
11
12 import org.mule.api.MuleContext;
13 import org.mule.api.context.MuleContextAware;
14
15 import javax.transaction.TransactionManager;
16
17 import org.springframework.beans.factory.BeanCreationException;
18 import org.springframework.beans.factory.config.AbstractFactoryBean;
19
20
21
22
23
24
25
26
27
28
29
30
31 public class MuleTransactionManagerFactoryBean extends AbstractFactoryBean<TransactionManager> implements MuleContextAware
32 {
33 private MuleContext muleContext;
34
35 @Override
36 public void setMuleContext(MuleContext context)
37 {
38 muleContext = context;
39 }
40
41 @Override
42 public Class<?> getObjectType()
43 {
44 return TransactionManager.class;
45 }
46
47 @Override
48 protected TransactionManager createInstance() throws Exception
49 {
50 if (muleContext.getTransactionManager() == null)
51 {
52 throw new BeanCreationException("you must have a transaction manager configured inside the context when using " + getClass().getName());
53 }
54 return muleContext.getTransactionManager();
55 }
56 }