1 18 package org.apache.activemq.systest; 19 20 26 public class AgentStopper { 27 private Exception firstException; 28 29 32 public void stop(Agent service) { 33 if (service != null) { 34 try { 35 service.stop(this); 36 } 37 catch (Exception e) { 38 onException(service, e); 39 } 40 } 41 } 42 43 public void onException(Object owner, Exception e) { 44 logError(owner, e); 45 if (firstException == null) { 46 firstException = e; 47 } 48 } 49 50 53 public void throwFirstException() throws Exception { 54 if (firstException != null) { 55 throw firstException; 56 } 57 } 58 59 protected void logError(Object service, Exception e) { 60 System.err.println("Could not stop service: " + service + ". Reason: " + e); 61 e.printStackTrace(System.err); 62 } 63 64 } 65 | Popular Tags |