1 22 package org.jboss.test.webservice.handlerflow; 23 24 import org.jboss.logging.Logger; 25 26 import javax.xml.rpc.handler.Handler ; 27 import java.util.ArrayList ; 28 29 public final class HandlerTracker 30 { 31 private static final Logger log = Logger.getLogger(HandlerTracker.class); 32 33 private static ArrayList protocol = new ArrayList (); 34 35 private HandlerTracker() 37 { 38 } 39 40 public static String [] getProtocol() 41 { 42 String [] arr = new String [protocol.size()]; 43 protocol.toArray(arr); 44 return arr; 45 } 46 47 public static void trackInit(Handler handler) 48 { 49 String hName = handler.getClass().getName(); 50 hName = hName.substring(hName.lastIndexOf(".") + 1); 51 String msg = hName + " init " + trackerInfo(handler); 52 protocol.add(msg); 53 log.info(msg); 54 } 55 56 public static void trackDestroy(Handler handler) 57 { 58 String hName = handler.getClass().getName(); 59 hName = hName.substring(hName.lastIndexOf(".") + 1); 60 String msg = hName + " destroy " + trackerInfo(handler); 61 protocol.add(msg); 62 log.info(msg); 63 } 64 65 public static void trackHandleRequest(Handler handler) 66 { 67 String hName = handler.getClass().getName(); 68 hName = hName.substring(hName.lastIndexOf(".") + 1); 69 String msg = hName + " handleRequest " + trackerInfo(handler); 70 protocol.add(msg); 71 log.info(msg); 72 } 73 74 public static void trackHandleResponse(Handler handler) 75 { 76 String hName = handler.getClass().getName(); 77 hName = hName.substring(hName.lastIndexOf(".") + 1); 78 String msg = hName + " handleResponse " + trackerInfo(handler); 79 protocol.add(msg); 80 log.info(msg); 81 } 82 83 public static void trackHandleFault(Handler handler) 84 { 85 String hName = handler.getClass().getName(); 86 hName = hName.substring(hName.lastIndexOf(".") + 1); 87 String msg = hName + " handleFault " + trackerInfo(handler); 88 protocol.add(msg); 89 log.info(msg); 90 } 91 92 public static void trackMessage(String msg) 93 { 94 protocol.add(msg); 95 log.info(msg); 96 } 97 98 public static void clear() 99 { 100 protocol.clear(); 101 log.info("clear [tracker=" + HandlerTracker.class.hashCode() + "]"); 102 } 103 104 private static String trackerInfo(Handler handler) 105 { 106 String hstr = "handler=" + handler.hashCode(); 107 String tstr = "tracker=" + HandlerTracker.class.hashCode(); 108 return "[" + hstr + "," + tstr + "]"; 109 } 110 } 111 | Popular Tags |