org.nuiton.eugene.plugin.writer.BaseChainedFileWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-eugene-plugin Show documentation
Show all versions of maven-eugene-plugin Show documentation
maven plugin to use the eugene library
/*
* *##%
* EUGene :: Maven plugin
* Copyright (C) 2006 - 2009 CodeLutin
*
* This program 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, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* ##%*
*/
package org.nuiton.eugene.plugin.writer;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.nuiton.eugene.models.object.ObjectModel;
import org.nuiton.eugene.models.state.StateModel;
import org.nuiton.eugene.writer.AbstractChainedFileWriter;
import org.nuiton.eugene.writer.ChainedFileWriterConfiguration;
import java.util.Map;
import java.util.Set;
/**
* Surcharge de l'implentation abstraite pour avoir le logger de la console maven.
*
* @author tchemit
* @since 2.0.0
*/
public abstract class BaseChainedFileWriter extends AbstractChainedFileWriter {
/**
* Logger
*/
private Log log;
protected BaseChainedFileWriter(String... propertyNameAndDescriptions) {
super(propertyNameAndDescriptions);
}
public void setLog(Log log) {
this.log = log;
}
public Log getLog() {
if (log == null) {
log = new SystemStreamLog();
}
return log;
}
@Override
protected void initWriter(ChainedFileWriterConfiguration configuration) {
super.initWriter(configuration);
// log writer config
StringBuilder buffer = new StringBuilder();
Set> set = getAuthorizedPropertyDescriptions().entrySet();
if (set.isEmpty()) {
buffer.append("Writer [").append(getInputProtocol()).append("]").append(" does not use any specific properties.");
} else {
buffer.append("Writer [").append(getInputProtocol()).append("]").append(" use ").append(properties.size()).append(" properties :");
if (getLog().isInfoEnabled()) {
for (Map.Entry e : set) {
String key = e.getKey();
Object value = properties.get(key);
if (value != null) {
buffer.append("\n").append(" [").append(key).append("] (").append(e.getValue()).append(") : ").append(value);
}
}
}
}
getLog().info(buffer.toString());
}
protected boolean acceptObjectModelOrStateModel(String modelType) {
modelType = modelType.trim().toLowerCase();
return ObjectModel.NAME.equals(modelType) || StateModel.NAME.equals(modelType);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy