Exemplo n.º 1
0
 // 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);
   }
 }
Exemplo n.º 2
0
  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();
      }
    }
  }
Exemplo n.º 3
0
 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();
   }
 }
Exemplo n.º 4
0
 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);
     }
   }
 }
Exemplo n.º 5
0
 public static synchronized Set allIdentityTokenized() {
   HashSet out = new HashSet();
   out.addAll(tokensToTokenized.values());
   // System.err.println( "allIdentityTokenized(): " + out );
   return Collections.unmodifiableSet(out);
 }
Exemplo n.º 6
0
 public static synchronized Set allIdentityTokens() {
   Set out = Collections.unmodifiableSet(tokensToTokenized.keySet());
   // System.err.println( "allIdentityTokens(): " + out );
   return out;
 }
Exemplo n.º 7
0
 // must be called with class' lock
 private static boolean isIncorporated(IdentityTokenized idt) {
   return tokensToTokenized.keySet().contains(idt.getIdentityToken());
 }