HistoryLogging

This is a rough rendering of a page from the old Prevayler wiki. Please see the new wiki for current documentation.

What do you think of giving Prevayler hooks to make some kinds of things easier to the application writer? Here are some ideas to make CommandHistory logging easier to the developers:

public interface CommandListener {
   public void commandSaved(CommandSaveEvent e);
   public void commandExecuted(CommandExecutedEvent e);
}

The programmer could register his command listeners when the application started (or any other interesting point in time) and have a very nice and practical way to log stuff.

CarlosVillela



AlexandreNodari pointed out that having multiple listeners could help, so that we would have the following:

public interface CommandSaveListener {
   void commandSaved(CommandSaveEvent e);
}

public interface CommandExecuteListener {
   void commandExecuted(CommandExecutedEvent e);
}

public interface CommandListener
extends CommandSaveListener, CommandExecuteListener {
   public void commandSaved(CommandSaveEvent e);
   public void commandExecuted(CommandExecutedEvent e);
}

I think this is flexible enough, and performatic enough to do the job. What do you think?

CarlosVillela



By the way, I forgot to define what are the events these listeners receive. Here they are:

public class CommandSaveEvent {
    private Command command;
    private java.util.Date savedTime;

    // getters and setters here
}

public class CommandExecuteEvent {
    private Command command;
    private java.util.Date executedTime;

    // getters and setters here
}

I can't think of any more information we can add here. Any ideas?

CarlosVillela