// must be called with class' lock private static void incorporate(IdentityTokenized idt) { tokensToTokenized.put(idt.getIdentityToken(), idt); if (idt instanceof PooledDataSource) { unclosedPooledDataSources.add(idt); mc.attemptManagePooledDataSource((PooledDataSource) idt); } }
static { classNamesToConnectionTesters.put( C3P0Defaults.connectionTesterClassName(), C3P0Defaults.connectionTester()); String userManagementCoordinator = C3P0ConfigUtils.getPropsFileConfigProperty(MC_PARAM); if (userManagementCoordinator != null) { try { mc = (ManagementCoordinator) Class.forName(userManagementCoordinator).newInstance(); } catch (Exception e) { if (logger.isLoggable(MLevel.WARNING)) logger.log( MLevel.WARNING, "Could not instantiate user-specified ManagementCoordinator " + userManagementCoordinator + ". Using NullManagementCoordinator (c3p0 JMX management disabled!)", e); mc = new NullManagementCoordinator(); } } else { try { Class.forName("java.lang.management.ManagementFactory"); mc = (ManagementCoordinator) Class.forName("com.mchange.v2.c3p0.management.ActiveManagementCoordinator") .newInstance(); } catch (Exception e) { if (logger.isLoggable(MLevel.INFO)) logger.log( MLevel.INFO, "jdk1.5 management interfaces unavailable... JMX support disabled.", e); mc = new NullManagementCoordinator(); } } }
public static ConnectionTester getConnectionTester(String className) { try { ConnectionTester out = (ConnectionTester) classNamesToConnectionTesters.get(className); if (out == null) { out = (ConnectionTester) Class.forName(className).newInstance(); classNamesToConnectionTesters.put(className, out); } return out; } catch (Exception e) { if (logger.isLoggable(MLevel.WARNING)) logger.log( MLevel.WARNING, "Could not create for find ConnectionTester with class name '" + className + "'. Using default.", e); return C3P0Defaults.connectionTester(); } }
public static ConnectionCustomizer getConnectionCustomizer(String className) throws SQLException { if (className == null) return null; else { try { ConnectionCustomizer out = (ConnectionCustomizer) classNamesToConnectionCustomizers.get(className); if (out == null) { out = (ConnectionCustomizer) Class.forName(className).newInstance(); classNamesToConnectionCustomizers.put(className, out); } return out; } catch (Exception e) { if (logger.isLoggable(MLevel.WARNING)) logger.log( MLevel.WARNING, "Could not create for find ConnectionCustomizer with class name '" + className + "'.", e); throw SqlUtils.toSQLException(e); } } }
public static synchronized Set allIdentityTokenized() { HashSet out = new HashSet(); out.addAll(tokensToTokenized.values()); // System.err.println( "allIdentityTokenized(): " + out ); return Collections.unmodifiableSet(out); }
public static synchronized Set allIdentityTokens() { Set out = Collections.unmodifiableSet(tokensToTokenized.keySet()); // System.err.println( "allIdentityTokens(): " + out ); return out; }
// must be called with class' lock private static boolean isIncorporated(IdentityTokenized idt) { return tokensToTokenized.keySet().contains(idt.getIdentityToken()); }