Registration of alternative P6SpyDriver

2003-11-22
2003-11-22
  • chris opler
    chris opler
    2003-11-22

    The issue is about the instantiation and use of alternatives to com.p6spy.engine.spy.P6SpyDriver.   I setup my config to use an alternative Driver, but the DriverManager always returns com.p6spy.engine.spy.P6SpyDriver rather than the one I've configured.  The alternative I've written dutifully registers itself with the P6SpyDriver Code:

      public BCastDriver()
        throws ClassNotFoundException, InstantiationException,
          IllegalAccessException, SQLException {
        super(BCastDriver.class.getName(), new P6CoreFactory());
     
      }

      public static void initMethod() {
     
        P6SpyDriverCore.initMethod(BCastDriver.class.getName());

      }

    Looking at P6SpyDriverCore, the driver class name I am passing in in 'initMethod' is not getting used:

    we see:
      <code>
                // register drivers and wrappers
                classType = "driver";
                i = driverNames.iterator();
                while (i.hasNext()) {
                    P6SpyDriver spy = null;
                    // register P6 first if you are using it
                    if (hasModules) {
                        spy = new P6SpyDriver();
                        DriverManager.registerDriver(spy);
                    }
      </code>
    instead of something like:

       <code>
                // register drivers and wrappers
                classType = "driver";
                i = driverNames.iterator();
                while (i.hasNext()) {
                    P6SpyDriverCore spy = null;
                    // register P6 first if you are using it
                    if (hasModules) {
                        spy = (P6SpyDriverCore) Class.forName(spydriver).newInstance();
                        DriverManager.registerDriver(spy);
                    }
       </code>
    There is probably a good reason for this.