Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MuleTransactionManagerFactoryBean |
|
| 1.6666666666666667;1.667 |
1 | /* | |
2 | * $Id: MuleTransactionManagerFactoryBean.java 19191 2010-08-25 21:05:23Z tcarlson $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
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 | * Creates a reference to the TransactionManager configured on the MuleContext. This is useful when you need to inject | |
22 | * the TransactionManager into other objects such as XA data Sources. | |
23 | * | |
24 | * In order to use this factory bean you must have a transaction manager configured in the context i.e. | |
25 | * <code><jbossts:transaction-manager/></code> | |
26 | */ | |
27 | 0 | public class MuleTransactionManagerFactoryBean extends AbstractFactoryBean implements MuleContextAware |
28 | { | |
29 | private MuleContext muleContext; | |
30 | ||
31 | public void setMuleContext(MuleContext context) | |
32 | { | |
33 | 0 | muleContext = context; |
34 | 0 | } |
35 | ||
36 | public Class getObjectType() | |
37 | { | |
38 | 0 | return TransactionManager.class; |
39 | } | |
40 | ||
41 | protected Object createInstance() throws Exception | |
42 | { | |
43 | 0 | if(muleContext.getTransactionManager()==null) |
44 | { | |
45 | 0 | throw new BeanCreationException("you must have a transaction manager configured inside the context when using " + getClass().getName()); |
46 | } | |
47 | 0 | return muleContext.getTransactionManager(); |
48 | } | |
49 | } |