public void attemptManageC3P0Registry() {
    try {
      ObjectName name = new ObjectName(regName);
      C3P0RegistryManager mbean = new C3P0RegistryManager();

      if (mbs.isRegistered(name)) {
        if (logger.isLoggable(MLevel.WARNING)) {
          logger.warning(
              "A C3P0Registry mbean is already registered. "
                  + "This probably means that an application using c3p0 was undeployed, "
                  + "but not all PooledDataSources were closed prior to undeployment. "
                  + "This may lead to resource leaks over time. Please take care to close "
                  + "all PooledDataSources.");
        }
        mbs.unregisterMBean(name);
      }
      mbs.registerMBean(mbean, name);
    } catch (Exception e) {
      if (logger.isLoggable(MLevel.WARNING))
        logger.log(
            MLevel.WARNING,
            "Failed to set up C3P0RegistryManager mBean. "
                + "[c3p0 will still function normally, but management via JMX may not be possible.]",
            e);
    }
  }
 public void attemptUnmanageC3P0Registry() {
   try {
     ObjectName name = new ObjectName(regName);
     if (mbs.isRegistered(name)) {
       mbs.unregisterMBean(name);
       if (logger.isLoggable(MLevel.FINER))
         logger.log(MLevel.FINER, "C3P0Registry mbean unregistered.");
     } else if (logger.isLoggable(MLevel.FINE))
       logger.fine(
           "The C3P0Registry mbean was not found in the registry, so could not be unregistered.");
   } catch (Exception e) {
     if (logger.isLoggable(MLevel.WARNING))
       logger.log(
           MLevel.WARNING,
           "An Exception occurred while trying to unregister the C3P0RegistryManager mBean." + e);
   }
 }
예제 #3
0
 public void attemptUnmanagePooledDataSource(PooledDataSource pds) {
   String nameStr = getPdsObjectNameStr(pds);
   try {
     ObjectName name = new ObjectName(nameStr);
     if (mbs.isRegistered(name)) {
       mbs.unregisterMBean(name);
       if (logger.isLoggable(MLevel.FINER))
         logger.log(MLevel.FINER, "MBean: " + nameStr + " unregistered.");
     } else if (logger.isLoggable(MLevel.FINE))
       logger.fine(
           "The mbean "
               + nameStr
               + " was not found in the registry, so could not be unregistered.");
   } catch (Exception e) {
     if (logger.isLoggable(MLevel.WARNING))
       logger.log(
           MLevel.WARNING,
           "An Exception occurred while unregistering mBean. [" + nameStr + "] " + e);
   }
 }
  public void attemptManagePooledDataSource(PooledDataSource pds) {
    String name = null;
    try {
      name = getPdsObjectNameStr(pds);
      ObjectName oname = new ObjectName(name);
      if (mbs.isRegistered(oname)) {
        if (logger.isLoggable(MLevel.WARNING))
          logger.warning(
              "You are attempting to register an mbean '"
                  + name
                  + "', but an mbean by that name is already registered. "
                  + "The new mbean will replace the old one in the MBean server. "
                  + (EXCLUDE_IDENTITY_TOKEN
                      ? "Since you have excluded the guaranteed-unique identity token, you must take care to give each PooledDataSource a unique dataSourceName."
                      : "This should not happen unless you have (pathologically) modified the DataSource's guaranteed-unique identityToken."));
      }

      // PooledDataSourceManager mbean = new PooledDataSourceManager( pds );
      // mbs.registerMBean(mbean, ObjectName.getInstance(name));
      // if (logger.isLoggable(MLevel.FINER))
      //    logger.log(MLevel.FINER, "MBean: " + name + " registered.");

      // DynamicPooledDataSourceManagerMBean registers itself on construction (and logs its own
      // registration)
      DynamicPooledDataSourceManagerMBean mbean =
          new DynamicPooledDataSourceManagerMBean(pds, name, mbs);
    } catch (Exception e) {
      if (logger.isLoggable(MLevel.WARNING))
        logger.log(
            MLevel.WARNING,
            "Failed to set up a PooledDataSourceManager mBean. [ "
                + (name == null ? pds.toString() : name)
                + " ] c3p0 will still function normally, but management of this DataSource by JMX may not be possible.",
            e);
    }
  }