package com.fitbank.common;

import com.fitbank.dto.management.Detail;

public class ThreadLogger {
    private Object obj;

    private Class  c;

    @SuppressWarnings("unchecked")
    public ThreadLogger(Detail pDetail, Integer pTotal) throws Exception {
        this.c = Class.forName("com.fitbank.general.helper.ThreadLogger");
        this.obj = this.c.getConstructor(Detail.class, Integer.class).newInstance(pDetail, pTotal);
    }

    /**
     * Marca como ejecutada una de las tareas internas
     * 
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public void checkpoint() throws Exception {
        this.c.getMethod("checkpoint", null).invoke(this.obj, null);
    }

    /**
     * Finaliza la ejecución del proceso.
     * 
     * @param pMessage
     *            Mensaje de finalización del proceso
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public void finish(String pMessage) throws Exception {
        this.c.getMethod("finish", String.class).invoke(this.obj, pMessage);
    }
}
