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

com.jpattern.service.log.reader.TailCommand Maven / Gradle / Ivy

There is a newer version: 3.6.2
Show newest version
package com.jpattern.service.log.reader;

import com.jpattern.core.IServicesName;
import com.jpattern.core.command.NullCommand;
import com.jpattern.core.command.ACommand;
import com.jpattern.core.command.ICommand;
import com.jpattern.core.command.ICommandResult;
import com.jpattern.shared.util.GenericWrapper;


/**
 * 
 * @author Francesco Cina'
 *
 * 6 May 2011
 * 
 * 
 */
public class TailCommand extends ACommand {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private final GenericWrapper resultMessage;
    private final IFilter _messageFilter;
    private final long _lastReadedMessage;

    public TailCommand(GenericWrapper resultMessage, long lastReadedMessage, IFilter aMessageFilter) {
        this(resultMessage, lastReadedMessage, aMessageFilter, new NullCommand());
    }

    public TailCommand(GenericWrapper resultMessage, long lastReadedMessage, IFilter aMessageFilter, ICommand aPreviousCommand) {
        super(aPreviousCommand);
		this.resultMessage = resultMessage;
        _messageFilter = aMessageFilter;
        _lastReadedMessage = lastReadedMessage;
    }

    protected void internalRollBack(ICommandResult result) {
    }

    protected void result(ICommandResult result) {
        IMessageReader messageReader = ((ILoggerReaderService) getProvider().getService(IServicesName.LOGGER_READER_SERVICE)).messageReader(_messageFilter);
        resultMessage.setValue(messageReader.read(_lastReadedMessage));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy