View Javadoc

1   /*
2    * Copyright 2002-2005 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.jencks.factory;
18  
19  import org.apache.geronimo.transaction.context.TransactionContextManager;
20  import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
21  import org.springframework.beans.factory.FactoryBean;
22  import org.springframework.beans.factory.InitializingBean;
23  
24  /***
25   * This FactoryBean creates and configures the TransactionManagerContext
26   * of Geronimo.
27   *
28   * @author Thierry Templier
29   * @see org.apache.geronimo.transaction.log.UnrecoverableLog
30   * @see org.apache.geronimo.transaction.log.HOWLLog
31   */
32  public class TransactionContextManagerFactoryBean implements FactoryBean, InitializingBean {
33  
34      private TransactionManagerImpl transactionManagerImpl;
35      private TransactionContextManager transactionContextManager;
36  
37      public Object getObject() throws Exception {
38          return transactionContextManager;
39      }
40  
41      public Class getObjectType() {
42          return TransactionContextManager.class;
43      }
44  
45      public boolean isSingleton() {
46          return true;
47      }
48  
49      public TransactionManagerImpl getTransactionManagerImpl() {
50          return transactionManagerImpl;
51      }
52  
53      public void setTransactionManagerImpl(TransactionManagerImpl transactionManagerImpl) {
54          this.transactionManagerImpl = transactionManagerImpl;
55      }
56  
57      /***
58       * This method initializes the transaction context manager basing on
59       * the Geronimo implementation of the transaction manager and a dedicated
60       * transaction log.
61       * <p/>
62       * It specifies too an unspecified transaction context for the transaction
63       * context manager instanciated.
64       */
65      public void afterPropertiesSet() throws Exception {
66          //Instanciate the transaction context manager
67          this.transactionContextManager = new TransactionContextManager(this.transactionManagerImpl,
68                  this.transactionManagerImpl);
69  
70          //TODO to uncomment?!
71          this.transactionContextManager.newUnspecifiedTransactionContext();
72      }
73  
74  }