Move stuff around
parent
47bd14f6c6
commit
0e6a595612
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Brett Wooldridge
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zaxxer.hikari.pool;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.zaxxer.hikari.proxy.ConnectionState;
|
||||
|
||||
/**
|
||||
* Mediator pattern interfaces.
|
||||
*
|
||||
* @author Brett Wooldridge
|
||||
*/
|
||||
public interface Mediators
|
||||
{
|
||||
JdbcMediator getJdbcMediator();
|
||||
|
||||
PoolEntryMediator getConnectionStateMediator();
|
||||
|
||||
PoolMediator getPoolMediator();
|
||||
|
||||
interface JdbcMediator
|
||||
{
|
||||
/**
|
||||
* Check whether the connection is alive or not.
|
||||
*
|
||||
* @param connection the connection to test
|
||||
* @return true if the connection is alive, false if it is not alive or we timed out
|
||||
*/
|
||||
boolean isConnectionAlive(Connection connection);
|
||||
|
||||
Throwable getLastConnectionFailure();
|
||||
|
||||
/**
|
||||
* Close connection and eat any exception.
|
||||
*
|
||||
* @param connection the connection to close
|
||||
* @param closureReason the reason the connection was closed (if known)
|
||||
*/
|
||||
void quietlyCloseConnection(Connection connection, String closureReason);
|
||||
|
||||
/**
|
||||
* Get the raw DataSource that the pool is managing.
|
||||
*
|
||||
* @return the underlying DataSource
|
||||
*/
|
||||
DataSource getUnwrappedDataSource();
|
||||
}
|
||||
|
||||
interface PoolMediator
|
||||
{
|
||||
void registerMBeans();
|
||||
|
||||
void unregisterMBeans();
|
||||
|
||||
void shutdownTimeoutExecutor();
|
||||
}
|
||||
|
||||
interface PoolEntryMediator
|
||||
{
|
||||
PoolEntry newPoolEntry() throws Exception;
|
||||
|
||||
void resetConnectionState(Connection connection, ConnectionState liveState, int dirtyBits) throws SQLException;
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Brett Wooldridge
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zaxxer.hikari.pool;
|
||||
|
||||
/**
|
||||
* A custom exception thrown if pool initialization fails.
|
||||
*
|
||||
* @author Brett Wooldridge
|
||||
*/
|
||||
public class PoolInitializationException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 929872118275916520L;
|
||||
|
||||
/**
|
||||
* Construct an exception, possibly wrapping the provided Throwable as the cause.
|
||||
* @param t the Throwable to wrap
|
||||
*/
|
||||
public PoolInitializationException(Throwable t)
|
||||
{
|
||||
super("Exception during pool initialization: " + t.getMessage(), t);
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Brett Wooldridge
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zaxxer.hikari.proxy;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brett Wooldridge
|
||||
*/
|
||||
final class ClosedConnection
|
||||
{
|
||||
public static final Connection CLOSED_CONNECTION = getClosedConnection();
|
||||
|
||||
private static Connection getClosedConnection()
|
||||
{
|
||||
InvocationHandler handler = new InvocationHandler() {
|
||||
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
|
||||
{
|
||||
final String methodName = method.getName();
|
||||
if ("abort".equals(methodName)) {
|
||||
return Void.TYPE;
|
||||
}
|
||||
else if ("isValid".equals(methodName)) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
else if ("toString".equals(methodName)) {
|
||||
return ClosedConnection.class.getCanonicalName();
|
||||
}
|
||||
|
||||
throw new SQLException("Connection is closed");
|
||||
}
|
||||
};
|
||||
|
||||
return (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(),
|
||||
new Class[] { Connection.class },
|
||||
handler);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Brett Wooldridge
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zaxxer.hikari.proxy;
|
||||
|
||||
/**
|
||||
* @author brettw
|
||||
*
|
||||
*/
|
||||
public interface ConnectionState
|
||||
{
|
||||
int getNetworkTimeoutState();
|
||||
|
||||
int getTransactionIsolationState();
|
||||
|
||||
String getCatalogState();
|
||||
|
||||
boolean getAutoCommitState();
|
||||
|
||||
boolean getReadOnlyState();
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013, 2014 Brett Wooldridge
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zaxxer.hikari.proxy;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import com.zaxxer.hikari.pool.PoolEntry;
|
||||
|
||||
/**
|
||||
* The interface used by the Connection proxy and through which all interaction
|
||||
* by other classes flow.
|
||||
*
|
||||
* @author Brett Wooldridge
|
||||
*/
|
||||
public interface IHikariConnectionProxy extends Connection
|
||||
{
|
||||
/**
|
||||
* Get the ConcurrentBag entry that is associated in the pool with the underlying connection.
|
||||
*
|
||||
* @return the PoolBagEntry
|
||||
*/
|
||||
PoolEntry getPoolEntry();
|
||||
|
||||
/**
|
||||
* Check if the provided SQLException contains a SQLSTATE that indicates
|
||||
* a disconnection from the server.
|
||||
*
|
||||
* @param sqle the SQLException to check
|
||||
* @return return the passed in exception
|
||||
*/
|
||||
SQLException checkException(SQLException sqle);
|
||||
|
||||
/**
|
||||
* Called by Statement and its subclasses when they are closed to remove them
|
||||
* from the tracking list.
|
||||
*
|
||||
* @param statement the Statement to remove from tracking
|
||||
*/
|
||||
void untrackStatement(Statement statement);
|
||||
|
||||
/**
|
||||
* Sets the commit state of the connection to dirty.
|
||||
*/
|
||||
void markCommitStateDirty();
|
||||
}
|
Loading…
Reference in New Issue