View Javadoc

1   /*
2    * $Id: OracleDataSourceFactoryBean.java 22114 2011-06-06 11:09:22Z 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  public class OracleDataSourceFactoryBean extends AbstractDataSourceFactoryBean
14  {
15      private static final String DEFAULT_HOST = "localhost";
16      private static final String DEFAULT_INSTANCE = "orcl";
17      private static final int DEFAULT_PORT = 1521;
18      private static final String DRIVER_CLASS_NAME = "oracle.jdbc.driver.OracleDriver";
19      private static final String JDBC_URL_PREFIX = "jdbc:oracle:thin:@";
20  
21      protected String host = DEFAULT_HOST;
22      protected int port = DEFAULT_PORT;
23      protected String instance = DEFAULT_INSTANCE;
24  
25      public OracleDataSourceFactoryBean()
26      {
27          super();
28          driverClassName = DRIVER_CLASS_NAME;
29          updateUrl();
30      }
31  
32      protected void updateUrl()
33      {
34          StringBuilder buf = new StringBuilder(JDBC_URL_PREFIX);
35          buf.append(host);
36          buf.append(":");
37          buf.append(port);
38          buf.append(":");
39          buf.append(instance);
40  
41          url = buf.toString();
42      }
43  
44      public String getHost()
45      {
46          return host;
47      }
48  
49      public void setHost(String host)
50      {
51          this.host = host;
52          updateUrl();
53      }
54  
55      public int getPort()
56      {
57          return port;
58      }
59  
60      public void setPort(int port)
61      {
62          this.port = port;
63          updateUrl();
64      }
65  
66      public String getInstance()
67      {
68          return instance;
69      }
70  
71      public void setInstance(String instance)
72      {
73          this.instance = instance;
74          updateUrl();
75      }
76  }