Coverage Report - org.mule.providers.oracle.jms.OracleJmsConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
OracleJmsConnector
0%
0/24
N/A
1.833
 
 1  
 /*
 2  
  * $Id: OracleJmsConnector.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.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  
  * Extends the standard Mule JMS Provider with functionality specific to Oracle's JMS
 26  
  * implementation based on Advanced Queueing (Oracle AQ).
 27  
  * 
 28  
  * @see OracleJmsSupport
 29  
  * @see org.mule.providers.jms.JmsConnector
 30  
  * @see <a href="http://otn.oracle.com/pls/db102/">Streams Advanced Queuing</a>
 31  
  */
 32  
 public class OracleJmsConnector extends AbstractOracleJmsConnector
 33  
 {
 34  
 
 35  
     /**
 36  
      * The JDBC URL for the Oracle database. For example,
 37  
      * {@code jdbc:oracle:oci:@myhost}
 38  
      */
 39  
     private String url;
 40  
 
 41  
     /**
 42  
      * Since many connections are opened and closed, we use a connection pool to
 43  
      * obtain the JDBC connection.
 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  
             // Register the Oracle JDBC driver.
 58  0
             Driver oracleDriver = new OracleDriver();
 59  
             // Deregister first just in case the driver has already been registered.
 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  
 }