1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.providers.oracle.jms; |
12 | |
|
13 | |
import org.mule.umo.lifecycle.InitialisationException; |
14 | |
|
15 | |
import java.sql.Driver; |
16 | |
import java.sql.DriverManager; |
17 | |
import java.sql.SQLException; |
18 | |
|
19 | |
import javax.jms.JMSException; |
20 | |
|
21 | |
import oracle.jdbc.driver.OracleDriver; |
22 | |
import oracle.jdbc.pool.OracleDataSource; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public class OracleJmsConnector extends AbstractOracleJmsConnector |
33 | |
{ |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
private String url; |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | 0 | private OracleDataSource jdbcConnectionPool = null; |
46 | |
|
47 | |
public OracleJmsConnector() |
48 | |
{ |
49 | 0 | super(); |
50 | |
|
51 | 0 | } |
52 | |
|
53 | |
protected void doInitialise() throws InitialisationException |
54 | |
{ |
55 | |
try |
56 | |
{ |
57 | |
|
58 | 0 | Driver oracleDriver = new OracleDriver(); |
59 | |
|
60 | 0 | DriverManager.deregisterDriver(oracleDriver); |
61 | 0 | DriverManager.registerDriver(oracleDriver); |
62 | |
|
63 | 0 | jdbcConnectionPool = new OracleDataSource(); |
64 | 0 | jdbcConnectionPool.setDataSourceName("Mule Oracle AQ Provider"); |
65 | 0 | jdbcConnectionPool.setUser(username); |
66 | 0 | jdbcConnectionPool.setPassword(password); |
67 | 0 | jdbcConnectionPool.setURL(url); |
68 | |
|
69 | |
} |
70 | 0 | catch (SQLException e) |
71 | |
{ |
72 | 0 | throw new InitialisationException(e, this); |
73 | 0 | } |
74 | 0 | super.doInitialise(); |
75 | 0 | } |
76 | |
|
77 | |
public java.sql.Connection getJdbcConnection() throws JMSException |
78 | |
{ |
79 | |
try |
80 | |
{ |
81 | 0 | logger.debug("Getting queue/topic connection from pool, URL = " |
82 | |
+ getJdbcConnectionPool().getURL() + ", user = " + getJdbcConnectionPool().getUser()); |
83 | 0 | return getJdbcConnectionPool().getConnection(); |
84 | |
} |
85 | 0 | catch (SQLException e) |
86 | |
{ |
87 | 0 | throw new JMSException("Unable to open JDBC connection: " + e.getMessage()); |
88 | |
} |
89 | |
} |
90 | |
|
91 | |
public String getUrl() |
92 | |
{ |
93 | 0 | return url; |
94 | |
} |
95 | |
|
96 | |
public void setUrl(String url) |
97 | |
{ |
98 | 0 | this.url = url; |
99 | 0 | } |
100 | |
|
101 | |
public OracleDataSource getJdbcConnectionPool() |
102 | |
{ |
103 | 0 | return jdbcConnectionPool; |
104 | |
} |
105 | |
|
106 | |
} |