1 /*
2 * Copyright (c) 2002-2025, City of Paris
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice
10 * and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice
13 * and the following disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * License 1.0
33 */
34 package fr.paris.lutece.util.pool.service;
35
36 import java.sql.Connection;
37
38 import java.util.Map;
39
40 import javax.sql.DataSource;
41
42 import org.apache.logging.log4j.Logger;
43
44 /**
45 * Database Connection Service Interface
46 */
47 public interface ConnectionService
48 {
49 int INFO_NOT_AVAILABLE = -1;
50
51 /**
52 * Get a connection
53 *
54 * @return A database connection
55 */
56 Connection getConnection( );
57
58 /**
59 * Release the connection
60 *
61 * @param conn
62 * The connection to release
63 */
64 void freeConnection( Connection conn );
65
66 /**
67 * Free all connections
68 */
69 void release( );
70
71 /**
72 * Initialize pool parameters
73 *
74 * @param htParamsConnectionPool
75 * Parameters
76 */
77 void init( Map<String, String> htParamsConnectionPool );
78
79 /**
80 * Define the pool name
81 *
82 * @param strPoolName
83 * The pool name
84 */
85 void setPoolName( String strPoolName );
86
87 /**
88 * Gets the pool name
89 *
90 * @return The pool name
91 */
92 String getPoolName( );
93
94 /**
95 * Define the logger
96 *
97 * @param logger
98 * The logger
99 */
100 void setLogger( Logger logger );
101
102 /**
103 * Gets the logger
104 *
105 * @return The logger
106 */
107 Logger getLogger( );
108
109 /**
110 * Gets the number of opened connections
111 *
112 * @return The current connections count
113 */
114 int getCurrentConnections( );
115
116 /**
117 * Gets the max connections
118 *
119 * @return The max connections count
120 */
121 int getMaxConnections( );
122
123 /**
124 * Gets the pool manager provider
125 *
126 * @return The pool manager
127 */
128 String getPoolProvider( );
129
130 /**
131 * Get datasource
132 *
133 * @return A data source object
134 */
135 DataSource getDataSource( );
136 }