Search in sources :

Example 1 with Crypto

use of org.cojen.tupl.ext.Crypto in project Tupl by cojen.

the class RedoEventPrinter method main.

/**
 * @param args [0]: base file, [1]: first log number to read from, [2]: optional crypto
 * class; remaining args are passed to its constructor as separate parameters
 */
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
    var baseFile = new java.io.File(args[0]);
    long logId = Long.parseLong(args[1]);
    Crypto crypto = null;
    if (args.length > 2) {
        Class clazz = Class.forName(args[2]);
        var types = new Class[args.length - 3];
        var params = new String[types.length];
        for (int i = 0; i < types.length; i++) {
            types[i] = String.class;
            params[i] = args[i + 3];
        }
        crypto = (Crypto) clazz.getConstructor(types).newInstance((Object[]) params);
    }
    EventListener listener = (type, message, messageArgs) -> {
        System.out.println(String.format(message, messageArgs));
    };
    new RedoLog(crypto, baseFile, logId, 0, null).replay(new RedoEventPrinter(listener, EventType.DEBUG), null, null, null);
}
Also used : Crypto(org.cojen.tupl.ext.Crypto) EventType(org.cojen.tupl.diag.EventType) EventListener(org.cojen.tupl.diag.EventListener) WeakPool(org.cojen.tupl.util.WeakPool) Crypto(org.cojen.tupl.ext.Crypto) EventListener(org.cojen.tupl.diag.EventListener)

Aggregations

EventListener (org.cojen.tupl.diag.EventListener)1 EventType (org.cojen.tupl.diag.EventType)1 Crypto (org.cojen.tupl.ext.Crypto)1 WeakPool (org.cojen.tupl.util.WeakPool)1