I have a class called ControladorImpressaoDAV that extends ControladorBase:
public class ControladorImpressaoDAV extends ControladorBase {
.
.
.
}
public abstract class ControladorBase implements IProcessamentoDispatcher, EventHandler<WorkerStateEvent> {
.
.
.
public void handle(WorkerStateEvent evento) {
StatusRetorno status = (StatusRetorno) evento.getSource().getValue();
despacharProcessamento(StatusProcessamento.FINALIZADO, status);
if (status == StatusRetorno.SUCESSO)
exibirMensagemSucesso();
else
exibirMensagemErro(status);
}
.
.
.
}
as the behavior is the same when the JavaFX calls handle method, there is no need in override this method in ControladorImpressaoDAV. However I can intercept this method, when in a ControladorImpressaoDAV instance, only when I override this method:
@Pointcut("execution(* com.hrgi.pdv.controladores.ControladorImpressaoDAV.handle(..))")
protected void terminouImprimirDAV(){}
Is there a way I can intercept the handle method only when it is in a ControladorImpressaoDAV instance without override the handle method?
Extend your base class something like this
public abstract class ControladorBase implements IProcessamentoDispatcher, EventHandler<WorkerStateEvent> {
.
.
.
public void handle(WorkerStateEvent evento) {
handled(evento);
StatusRetorno status = (StatusRetorno) evento.getSource().getValue();
despacharProcessamento(StatusProcessamento.FINALIZADO, status);
if (status == StatusRetorno.SUCESSO)
exibirMensagemSucesso();
else
exibirMensagemErro(status);
}
protected void handled(WorkerStateEvent evento){};
.
.
.
}
Now any subclass can get information about handled event if needed by oveeriding method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.