<commit_before>//
// This file is part of the OpenNMS(R) Application.
//
// OpenNMS(R) is Copyright (C) 2006 The OpenNMS Group, Inc.  All rights reserved.
// OpenNMS(R) is a derivative work, containing both original code, included code and modified
// code that was published under the GNU General Public License. Copyrights for modified 
// and included code are below.
//
// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
//
// Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.                                                            
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//    
// For more information contact: 
//   OpenNMS Licensing       <<EMAIL>>
//   http://www.opennms.org/
//   http://www.opennms.com/
//
// Tab Size = 8

package org.opennms.netmgt.config;

import java.beans.PropertyVetoException;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Iterator;

import javax.sql.DataSource;

import org.exolab.castor.jdo.conf.Database;
import org.exolab.castor.jdo.conf.Param;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.InputSource;

import com.mchange.v2.c3p0.ComboPooledDataSource;

public class C3P0ConnectionFactory implements DataSource {
    
    /*
     * Just hacked for now to get model-import working in OpenNMS
     * TODO: fix this with a properties file or such
     */
    private static final int DEFAULT_AQUIRE_INCREMENT = 5;
    private static final int DEFAULT_RETRY_ATTEMPTS = 1;
    private static final int DEFAULT_RETRY_DELAY = 0;  //TODO: need to learn this one
    private static final boolean DEFAULT_AUTOCOMMIT_ON_CLOSE = false;
    private static final boolean DEFAULT_BREAK_AFTER_ACQUIRE_FAILURE = false;
    private static final int DEFAULT_CHECKOUT_TIMEOUT = 0;
    private static final String DEFAULT_TESTER_CLASS_NAME = null;
    private static final String DEFAULT_POOL_DESCRIPTION = "OpenNMS C3P0 Connection Pool";

    private static final boolean DEFAULT_FORCE_IGNORE_UNRESOLVED_TRANSACTION = false;
    private static final String DEFAULT_IDENTITY_TOKEN = null;
    private static final int DEFAULT_IDLE_CONNECTION_TEST_PERIOD = 1800;
    private static final int DEFAULT_INITIAL_POOL_SIZE = 25;
    private static final int DEFAULT_LOGIN_TIMEOUT = 3000;
    private static final PrintWriter DEFAULT_LOG_WRITER = null;
    private static final int DEFAUT_MAX_IDLE_TIME = 1800;
    private static final int DEFAULT_MAX_POOL_SIZE = 256;
    private static final int DEFAULT_MAX_STATEMENTS = 0;
    private static final int DEFAULT_MAX_STATEMENTS_PER_CONNECTION = 0;
    private static final int DEFAULT_MIN_POOL_SIZE = 10;
    private static final int DEFAULT_NUM_HELPER_THREADS = 0;
    private static final String DEFAULT_PERFERRED_TEST_QUERY = null;
    private static final int DEFAULT_PROPERTY_CYCLE = 0;
    private static final boolean DEFAULT_SET_TEST_CONNECTION_ON_CHECKIN = false;
    private static final boolean DEFAULT_SET_TEST_CONNECTION_ON_CHECKOUT = false;
    private static final boolean DEFAULT_USES_TRADITIONAL_REFLECTIVE_PROXIES = false;
    
    private ComboPooledDataSource m_pool;
    private String m_user;<commit_msg>A bit of maintenance: added Copyright and GPL info, orgainzied imports, got rid of some "unused" warninings in the C3P0ConnectionFactory.<commit_after>//
// This file is part of the OpenNMS(R) Application.
//
// OpenNMS(R) is Copyright (C) 2006 The OpenNMS Group, Inc.  All rights reserved.
// OpenNMS(R) is a derivative work, containing both original code, included code and modified
// code that was published under the GNU General Public License. Copyrights for modified 
// and included code are below.
//
// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
//
// Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.                                                            
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//    
// For more information contact: 
//   OpenNMS Licensing       <<EMAIL>>
//   http://www.opennms.org/
//   http://www.opennms.com/
//
// Tab Size = 8

package org.opennms.netmgt.config;

import java.beans.PropertyVetoException;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Iterator;

import javax.sql.DataSource;

import org.exolab.castor.jdo.conf.Database;
import org.exolab.castor.jdo.conf.Param;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.InputSource;

import com.mchange.v2.c3p0.ComboPooledDataSource;

public class C3P0ConnectionFactory implements DataSource {
    
/*    private static final int DEFAULT_AQUIRE_INCREMENT = 5;
    private static final int DEFAULT_RETRY_ATTEMPTS = 1;
    private static final int DEFAULT_RETRY_DELAY = 0;  //TODO: need to learn this one
    private static final boolean DEFAULT_AUTOCOMMIT_ON_CLOSE = false;
    private static final boolean DEFAULT_BREAK_AFTER_ACQUIRE_FAILURE = false;
    private static final int DEFAULT_CHECKOUT_TIMEOUT = 0;
    private static final String DEFAULT_TESTER_CLASS_NAME = null;
    private static final String DEFAULT_POOL_DESCRIPTION = "OpenNMS C3P0 Connection Pool";

    private static final boolean DEFAULT_FORCE_IGNORE_UNRESOLVED_TRANSACTION = false;
    private static final String DEFAULT_IDENTITY_TOKEN = null;
    private static final int DEFAULT_IDLE_CONNECTION_TEST_PERIOD = 1800;
    private static final int DEFAULT_INITIAL_POOL_SIZE = 25;
    private static final int DEFAULT_LOGIN_TIMEOUT = 3000;
    private static final PrintWriter DEFAULT_LOG_WRITER = null;
    private static final int DEFAUT_MAX_IDLE_TIME = 1800;
    private static final int DEFAULT_MAX_POOL_SIZE = 256;
    private static final int DEFAULT_MAX_STATEMENTS = 0;
    private static final int DEFAULT_MAX_STATEMENTS_PER_CONNECTION = 0;
    private static final int DEFAULT_MIN_POOL_SIZE = 10;
    private static final int DEFAULT_NUM_HELPER_THREADS = 0;
    private static final String DEFAULT_PERFERRED_TEST_QUERY = null;
    private static final int DEFAULT_PROPERTY_CYCLE = 0;
    private static final boolean DEFAULT_SET_TEST_CONNECTION_ON_CHECKIN = false;
    private static final boolean DEFAULT_SET_TEST_CONNECTION_ON_CHECKOUT = false;
    private static final boolean DEFAULT_USES_TRADITIONAL_REFLECTIVE_PROXIES = false;
*/    
    private ComboPooledDataSource m_pool;
    private String m_user;
{'fraction_non_alphanumeric': 0.06542056074766354, 'fraction_numerical': 0.015494343334972946, 'mean_word_length': 3.818127962085308, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1796077', 'n_tokens_mistral': 2409, 'n_tokens_neox': 2312, 'n_words': 841}