| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.apache.camel.spring.spi; |
| 18 |
|
|
| 19 |
|
import org.apache.camel.Processor; |
| 20 |
|
import org.apache.camel.spi.Policy; |
| 21 |
|
import org.apache.commons.logging.Log; |
| 22 |
|
import org.apache.commons.logging.LogFactory; |
| 23 |
|
import org.springframework.transaction.support.TransactionTemplate; |
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
public class SpringTransactionPolicy<E> implements Policy<E> { |
| 31 |
0 |
private static final transient Log LOG = LogFactory.getLog(SpringTransactionPolicy.class); |
| 32 |
|
private TransactionTemplate template; |
| 33 |
|
|
| 34 |
0 |
public SpringTransactionPolicy(TransactionTemplate template) { |
| 35 |
0 |
this.template = template; |
| 36 |
0 |
} |
| 37 |
|
|
| 38 |
|
public Processor wrap(Processor processor) { |
| 39 |
0 |
final TransactionTemplate transactionTemplate = getTemplate(); |
| 40 |
0 |
if (transactionTemplate == null) { |
| 41 |
0 |
LOG.warn("No TransactionTemplate available so transactions will not be enabled!"); |
| 42 |
0 |
return processor; |
| 43 |
|
} |
| 44 |
|
|
| 45 |
0 |
TransactionInterceptor answer = new TransactionInterceptor(transactionTemplate); |
| 46 |
0 |
answer.setProcessor(processor); |
| 47 |
0 |
return answer; |
| 48 |
|
} |
| 49 |
|
|
| 50 |
|
public TransactionTemplate getTemplate() { |
| 51 |
0 |
return template; |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
public void setTemplate(TransactionTemplate template) { |
| 55 |
0 |
this.template = template; |
| 56 |
0 |
} |
| 57 |
|
} |