All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ow2.bonita.persistence.log.LoggerArchiver Maven / Gradle / Ivy

/**
 * Copyright (C) 2007  Bull S. A. S.
 * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation
 * version 2.1 of the License.
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License along with this
 * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 * Floor, Boston, MA  02110-1301, USA.
 **/
package org.ow2.bonita.persistence.log;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.ow2.bonita.facade.def.majorElement.PackageFullDefinition;
import org.ow2.bonita.facade.runtime.ProcessFullInstance;
import org.ow2.bonita.services.Archivable;
import org.ow2.bonita.services.Archiver;

/**
 * This implementation of History does nothing: it never archive though
 * returning empty set, true and null values.
 *
 * @author Pierre Vigneras
 * @date Feb 15, 2008
 */
public class LoggerArchiver implements Archiver {

  public static final Logger LOG = Logger.getLogger(LoggerArchiver.class.getName());
  private final Level level;

  public LoggerArchiver() {
    this(Level.FINE);
  }

  public LoggerArchiver(String levelName) {
    this(Level.parse(levelName));
  }

  public LoggerArchiver(final Level level) {
    this.level = level;
  }

  private void log(Archivable archivable) {
    if (LOG.isLoggable(level)) {
      LOG.log(level, "Archiving: " + archivable);
    }
  }

  public void archive(ProcessFullInstance processInst) {
    log(processInst);
  }

  public void archive(PackageFullDefinition packageDef) {
    log(packageDef);
  }
  
  public void remove(PackageFullDefinition package1) {
    if (LOG.isLoggable(level)) {
      LOG.log(level, "Removing: " + package1);
    }
  }
  public void remove(ProcessFullInstance processInst) {
    if (LOG.isLoggable(level)) {
      LOG.log(level, "Removing: " + processInst);
    }
  }
  
  public void clear() {
    if (LOG.isLoggable(level)) {
      LOG.log(level, "Clearing archiver");
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy