/** * Provides connections available on current thread. * * @return connections available on current thread. */ public static Map<String, Connection> connections(){ return ConnectionsAccess.getConnectionMap(); }
/** * Returns a named connection attached to current thread and bound to name specified by argument. * @param dbName name of connection to retrieve. * @return a named connection attached to current thread and bound to name specified by argument. */ static Connection getConnection(String dbName){ return getConnectionMap().get(dbName); }
/** * Provides a names' list of current connections. * * @return a names' list of current connections. */ public static List<String> getCurrrentConnectionNames(){ return new ArrayList<>(ConnectionsAccess.getConnectionMap().keySet()); }
static List<Connection> getAllConnections(){ return new ArrayList<>(getConnectionMap().values()); } }
/** * Attaches a connection to a ThreadLocal and binds it to a name. * * @param dbName * @param connection */ static void attach(String dbName, Connection connection, String extraInfo) { if(ConnectionsAccess.getConnectionMap().get(dbName) != null){ throw new InternalException("You are opening a connection " + dbName + " without closing a previous one. Check your logic. Connection still remains on thread: " + ConnectionsAccess.getConnectionMap().get(dbName)); } ConnectionsAccess.getConnectionMap().put(dbName, connection); LogFilter.log(LOGGER, LogLevel.DEBUG, "Attached connection named: {}: to current thread: {}. Extra info: {}", dbName, connection, extraInfo); }
static void detach(String dbName){ LogFilter.log(LOGGER, LogLevel.DEBUG, "Detached connection named: {} from current thread: {}", dbName, getConnectionMap().get(dbName)); getConnectionMap().remove(dbName); }
/** * Provides connections available on current thread. * * @return connections available on current thread. */ public static Map<String, Connection> connections(){ return ConnectionsAccess.getConnectionMap(); }
/** * Provides connections available on current thread. * * @return connections available on current thread. */ public static Map<String, Connection> connections(){ return ConnectionsAccess.getConnectionMap(); }
/** * Returns a named connection attached to current thread and bound to name specified by argument. * @param dbName name of connection to retrieve. * @return a named connection attached to current thread and bound to name specified by argument. */ static Connection getConnection(String dbName){ return getConnectionMap().get(dbName); }
/** * Returns a named connection attached to current thread and bound to name specified by argument. * @param dbName name of connection to retrieve. * @return a named connection attached to current thread and bound to name specified by argument. */ static Connection getConnection(String dbName){ return getConnectionMap().get(dbName); }
static List<Connection> getAllConnections(){ return new ArrayList<>(getConnectionMap().values()); } }
static List<Connection> getAllConnections(){ return new ArrayList<Connection>(getConnectionMap().values()); } }
/** * Provides a names' list of current connections. * * @return a names' list of current connections. */ public static List<String> getCurrrentConnectionNames(){ return new ArrayList<>(ConnectionsAccess.getConnectionMap().keySet()); }
/** * Provides a names' list of current connections. * * @return a names' list of current connections. */ public static List<String> getCurrrentConnectionNames(){ return new ArrayList<String>(ConnectionsAccess.getConnectionMap().keySet()); }
static void detach(String dbName){ LogFilter.log(LOGGER, LogLevel.DEBUG, "Detached connection named: {} from current thread: {}", dbName, getConnectionMap().get(dbName)); getConnectionMap().remove(dbName); }
/** * Attaches a connection to a ThreadLocal and binds it to a name. * * @param dbName * @param connection */ static void attach(String dbName, Connection connection, String extraInfo) { if(ConnectionsAccess.getConnectionMap().get(dbName) != null){ throw new InternalException("You are opening a connection " + dbName + " without closing a previous one. Check your logic. Connection still remains on thread: " + ConnectionsAccess.getConnectionMap().get(dbName)); } ConnectionsAccess.getConnectionMap().put(dbName, connection); LogFilter.log(LOGGER, LogLevel.DEBUG, "Attached connection named: {}: to current thread: {}. Extra info: {}", dbName, connection, extraInfo); }
/** * Attaches a connection to a ThreadLocal and binds it to a name. * * @param dbName * @param connection */ static void attach(String dbName, Connection connection, String extraInfo) { if(ConnectionsAccess.getConnectionMap().get(dbName) != null){ throw new InternalException("You are opening a connection " + dbName + " without closing a previous one. Check your logic. Connection still remains on thread: " + ConnectionsAccess.getConnectionMap().get(dbName)); } ConnectionsAccess.getConnectionMap().put(dbName, connection); LogFilter.log(logger, "Attached connection: {} named: {} to current thread. Extra info: {}", connection, dbName, extraInfo); }
static void detach(String dbName){ LogFilter.log(logger, "Detached connection: {} from current thread", dbName); getConnectionMap().remove(dbName); }