コード例 #1
0
  /**
   * Returns a log wrapper for the given <code>batch</code> which logs a calls to its methods if
   * <code>logWriterProvider</code> returns a {@link LogWriter} instance for <code>batch</code>.
   * Otherwise returns <code>batch</code>.
   *
   * @param batch
   * @param logWriterProvider
   * @return
   * @throws IllegalArgumentException if either argument is <code>null</code>
   */
  public static Batch create(Batch batch, LogWriterProvider logWriterProvider) {
    if (batch == null) {
      throw new IllegalArgumentException("Batch must not be null");
    }
    if (logWriterProvider == null) {
      throw new IllegalArgumentException("LogWriterProvider must not be null");
    }

    LogWriter logWriter = logWriterProvider.getLogWriter(batch);
    if (logWriter == null) {
      return batch;
    } else {
      return new BatchLogger(batch, logWriter);
    }
  }
コード例 #2
0
  /**
   * Returns a log wrapper for the given <code>sessionInfo</code> which logs a calls to its methods
   * if <code>logWriterProvider</code> returns a {@link LogWriter} instance for <code>sessionInfo
   * </code>. Otherwise returns <code>sessionInfo</code>.
   *
   * @param sessionInfo
   * @param logWriterProvider
   * @return
   * @throws IllegalArgumentException if either argument is <code>null</code>
   */
  public static SessionInfo create(SessionInfo sessionInfo, LogWriterProvider logWriterProvider) {
    if (sessionInfo == null) {
      throw new IllegalArgumentException("SessionInfo must not be null");
    }
    if (logWriterProvider == null) {
      throw new IllegalArgumentException("LogWriterProvider must not be null");
    }

    LogWriter logWriter = logWriterProvider.getLogWriter(sessionInfo);
    if (logWriter == null) {
      return sessionInfo;
    } else {
      return new SessionInfoLogger(sessionInfo, logWriter);
    }
  }
コード例 #3
0
  /**
   * Returns a log wrapper for the given <code>idFactory</code> which logs a calls to its methods if
   * <code>logWriterProvider</code> returns a {@link LogWriter} instance for <code>idFactory</code>.
   * Otherwise returns <code>idFactory</code>.
   *
   * @param idFactory
   * @param logWriterProvider
   * @return
   * @throws IllegalArgumentException if either argument is <code>null</code>
   */
  public static IdFactory create(IdFactory idFactory, LogWriterProvider logWriterProvider) {
    if (idFactory == null) {
      throw new IllegalArgumentException("IdFactory must not be null");
    }
    if (logWriterProvider == null) {
      throw new IllegalArgumentException("LogWriterProvider must not be null");
    }

    LogWriter logWriter = logWriterProvider.getLogWriter(idFactory);
    if (logWriter == null) {
      return idFactory;
    } else {
      return new IdFactoryLogger(idFactory, logWriter);
    }
  }
コード例 #4
0
  /**
   * Returns a log wrapper for the given <code>qValueFactory</code> which logs a calls to its
   * methods if <code>logWriterProvider</code> returns a {@link LogWriter} instance for <code>
   * qValueFactory</code>. Otherwise returns <code>qValueFactory</code>.
   *
   * @param qValueFactory
   * @param logWriterProvider
   * @return
   * @throws IllegalArgumentException if either argument is <code>null</code>
   */
  public static QValueFactory create(
      QValueFactory qValueFactory, LogWriterProvider logWriterProvider) {
    if (qValueFactory == null) {
      throw new IllegalArgumentException("QValueFactory must not be null");
    }
    if (logWriterProvider == null) {
      throw new IllegalArgumentException("LogWriterProvider must not be null");
    }

    LogWriter logWriter = logWriterProvider.getLogWriter(qValueFactory);
    if (logWriter == null) {
      return qValueFactory;
    } else {
      return new QValueFactoryLogger(qValueFactory, logWriter);
    }
  }
コード例 #5
0
  /**
   * Returns a log wrapper for the given <code>service</code> which logs a calls to its methods if
   * <code>logWriterProvider</code> returns a {@link LogWriter} instance for <code>service</code>.
   * Otherwise returns <code>service</code>.
   *
   * @param service
   * @param logWriterProvider
   * @return
   * @throws IllegalArgumentException if either argument is <code>null</code>
   */
  public static RepositoryService create(
      RepositoryService service, LogWriterProvider logWriterProvider) {
    if (service == null) {
      throw new IllegalArgumentException("Service must not be null");
    }
    if (logWriterProvider == null) {
      throw new IllegalArgumentException("LogWriterProvider must not be null");
    }

    LogWriter logWriter = logWriterProvider.getLogWriter(service);
    if (logWriter == null) {
      return service;
    } else {
      return new ServiceLogger(service, logWriterProvider, logWriter);
    }
  }