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 public class MuleTransactionManagerFactoryBean extends AbstractFactoryBean implements MuleContextAware
28 {
29 private MuleContext muleContext;
30
31 public void setMuleContext(MuleContext context)
32 {
33 muleContext = context;
34 }
35
36 public Class getObjectType()
37 {
38 return TransactionManager.class;
39 }
40
41 protected Object createInstance() throws Exception
42 {
43 if(muleContext.getTransactionManager()==null)
44 {
45 throw new BeanCreationException("you must have a transaction manager configured inside the context when using " + getClass().getName());
46 }
47 return muleContext.getTransactionManager();
48 }
49 }