View Javadoc

1   /*
2    * $Id: AbstractDataSourceFactoryBean.java 22117 2011-06-06 11:09:58Z dirk.olmes $
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  
11  package org.mule.transport.jdbc.config;
12  
13  import org.enhydra.jdbc.standard.StandardDataSource;
14  import org.springframework.beans.factory.config.AbstractFactoryBean;
15  
16  public class AbstractDataSourceFactoryBean extends AbstractFactoryBean<StandardDataSource>
17  {
18      protected String driverClassName;
19      protected int loginTimeout = -1;
20      protected String password;
21      protected int transactionIsolation;
22      protected String url;
23      protected String user;
24  
25      @Override
26      public Class<?> getObjectType()
27      {
28          return StandardDataSource.class;
29      }
30  
31      @Override
32      protected StandardDataSource createInstance() throws Exception
33      {
34          StandardDataSource dataSource = new StandardDataSource();
35          dataSource.setDriverName(driverClassName);
36          if (loginTimeout >= 0)
37          {
38              dataSource.setLoginTimeout(loginTimeout);
39          }
40          dataSource.setPassword(password);
41          dataSource.setTransactionIsolation(transactionIsolation);
42          dataSource.setUrl(url);
43          dataSource.setUser(user);
44          return dataSource;
45      }
46  
47      public String getPassword()
48      {
49          return password;
50      }
51  
52      public void setPassword(String password)
53      {
54          this.password = password;
55      }
56  
57      public void setUser(String user)
58      {
59          this.user = user;
60      }
61  
62      public String getUser()
63      {
64          return user;
65      }
66  
67      public void setUrl(String url)
68      {
69          this.url = url;
70      }
71  
72      public String getUrl()
73      {
74          return url;
75      }
76  
77      public void setTransactionIsolation(int transactionIsolation)
78      {
79          this.transactionIsolation = transactionIsolation;
80      }
81  
82      public int getTransactionIsolation()
83      {
84          return transactionIsolation;
85      }
86  
87      public void setLoginTimeout(int loginTimeout)
88      {
89          this.loginTimeout = loginTimeout;
90      }
91  
92      public int getLoginTimeout()
93      {
94          return loginTimeout;
95      }
96  }