Beispiel #1
0
 private void bindPLoggerFactory(PLoggerBinder binder) {
   final String binderClassName = binder.getClass().getName();
   PLogger pLogger = binder.getLogger(binder.getClass().getName());
   pLogger.info(
       "PLoggerFactory.initialize() bind:{} cl:{}",
       binderClassName,
       binder.getClass().getClassLoader());
   // Set binder to static LoggerFactory
   // Should we unset binder at shutdown hook or stop()?
   PLoggerFactory.initialize(binder);
 }
  /* (non-Javadoc)
   * @see com.navercorp.pinpoint.bootstrap.plugin.transformer.PinpointClassFileTransformer#transform(com.navercorp.pinpoint.bootstrap.plugin.PinpointInstrument, java.lang.ClassLoader, java.lang.String, java.lang.Class, java.security.ProtectionDomain, byte[])
   */
  @Override
  public byte[] transform(
      Instrumentor instrumentContext,
      ClassLoader loader,
      String className,
      Class<?> classBeingRedefined,
      ProtectionDomain protectionDomain,
      byte[] classfileBuffer)
      throws InstrumentException {
    if (logger.isInfoEnabled()) {
      logger.info("Modify {}", className);
    }

    try {
      InstrumentClass target =
          instrumentContext.getInstrumentClass(loader, className, classfileBuffer);

      if (!target.isInterceptable()) {
        return null;
      }

      List<InstrumentMethod> methodList = target.getDeclaredMethods(METHOD_FILTER);
      for (InstrumentMethod method : methodList) {
        if (logger.isTraceEnabled()) {
          logger.trace(
              "### c={}, m={}, params={}",
              new Object[] {
                className, method.getName(), Arrays.toString(method.getParameterTypes())
              });
        }

        method.addInterceptor(
            BasicMethodInterceptor.class.getName(), va(SpringBeansConstants.SERVICE_TYPE));
      }

      return target.toBytecode();
    } catch (Exception e) {
      logger.warn("modify fail. Cause:{}", e.getMessage(), e);
      return null;
    }
  }