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