Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Re: Aspect and Exception Handle

Hi ! This is the sample code that i sad in the early message.I hope for your helps.
 
// Method in the Class

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);

}

...../////////////////////// end class

}

// 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 !!");

}

}

 
Thanks !
 
Regards,
____________________________
Washington Costa P. Correia
CTA/ITA/IEC

Back to the top