View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.tck.testmodels.mule;
8   
9   import org.mule.api.config.MuleConfiguration;
10  import org.mule.transaction.lookup.GenericTransactionManagerLookupFactory;
11  
12  import java.lang.reflect.InvocationHandler;
13  import java.lang.reflect.Method;
14  import java.lang.reflect.Proxy;
15  
16  import javax.transaction.TransactionManager;
17  
18  /**
19   * <code>TestTransactionManagerFactory</code> TODO
20   */
21  public class TestTransactionManagerFactory extends GenericTransactionManagerLookupFactory
22  {
23      public TransactionManager create(MuleConfiguration config) throws Exception
24      {
25          return (TransactionManager) Proxy.newProxyInstance(getClass().getClassLoader(),
26                                                             new Class[] {TransactionManager.class},
27                                                             new InternalInvocationHandler());
28      }
29  
30      public void initialise()
31      {
32          // shortcut super's implementation
33      }
34  
35      public class InternalInvocationHandler implements InvocationHandler
36      {
37          public TestTransactionManagerFactory getParent()
38          {
39              return TestTransactionManagerFactory.this;
40          }
41  
42          public Object invoke (Object proxy, Method method, Object[] args) throws Throwable
43          {
44              return null;
45          }
46  
47      }
48  }