public void jMenuFileCon_actionPerformed(ActionEvent e) {
....
if(result == CaixaLogon.OK_OPTION){
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
UnicastRemoteObject.exportObject(this);
myServerObject = (IJogo) Naming.lookup("rmi://" + servidor.getText() + "/Serv");
Logon.setEnabled(true);
jMenuFileCon.setEnabled(false);
}
catch (RemoteException ex2) {
message = "Erro ao Iniciar Conexão";
title = "Servidor Indisponível ! :-(" ;
CaixaLogon.showMessageDialog(contentPane,message,title,CaixaLogon.NO_OPTION);
}
catch (MalformedURLException ex2) {
message = "Erro ao Iniciar Conexão";
title = "Servidor Indisponível ! :-(" ;
CaixaLogon.showMessageDialog(contentPane,message,title,CaixaLogon.NO_OPTION);
}
catch (NotBoundException ex2) {
message = "Erro ao Iniciar Conexão";
title = "Servidor Indisponível ! :-(" ;
CaixaLogon.showMessageDialog(contentPane,message,title,CaixaLogon.NO_OPTION);
}
// Aspect to replace the catch block.
public aspect HandlerTeste {
pointcut erro(): call(* ClassName.jMenuFileCon_actionPerformed(..));
pointcut erro(): handler(MalformedURLException+);
before(ClassName cl): erro() && target(cl){
// to have access to variables in the class like message,title and Caixa.Logon to replace the bloc catch to // aspect
System.out.println("Tratamento de runtimeexceptio !!");
System.out.println("Trate o erro aqui !!");
}
}