Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Antwort: [aspectj-dev] using AspectJ to deal with exceptions



Hi Eric,
something like

Object around(int portnumber):newSocket(portnumber){
      int pnumber=portnumber;
      while(true)
      try{
            return proceed(pnumber++);
      }catch(BindException ex){
            if (pnumber>MAX_PORT_RANGE)
                  throw ex;
      }
      return null; //will never be reached;
}

should do the job;
kind regards
   Arno

Arno Schmidmeier (sic)
AspectSoft
www.aspectsoft.de
mailto:Arno@xxxxxxxxxxxxx

c/o DaimlerChrysler Bank
Fon/Fax: +49 (711) 2574 - 6144


                                                                                                                                                
                      eeoam@xxxxxxxxx                                                                                                           
                      Gesendet von:              An:      aspectj-dev@xxxxxxxxxxx                                                               
                      aspectj-dev-admin@         Kopie:                                                                                         
                      eclipse.org                Thema:   [aspectj-dev] using AspectJ to deal with exceptions                                   
                                                                                                                                                
                                                                                                                                                
                      03.06.2004 20:30                                                                                                          
                      Bitte antworten an                                                                                                        
                      aspectj-dev                                                                                                               
                                                                                                                                                
                                                                                                                                                




I have the following statement:

socket = new ServerSocket(port).

if java.net.BindException is thrown then then the port is already in which
case I wish to increment the port number and try again. I wish to keep this
up until either I get a free port or we run out of ports.

Can aspectj make this algorithm any easier/elegant to implement than Java?

Eric Macaulay




Back to the top