1 22 package org.jboss.test.kernel.deployment.jboss.beans.servicepojo; 23 24 30 public abstract class AbstractService 31 { 32 public static final String CONSTRUCTED = "CONSTRUCTED"; 33 public static final String CREATED = "CREATED"; 34 public static final String STARTED = "STARTED"; 35 public static final String STOPPED = "STOPPED"; 36 public static final String DESTROYED = "DESTROYED"; 37 public static final String FAILED = "FAILED"; 38 39 41 protected String name; 42 protected String state = CONSTRUCTED; 43 44 46 public AbstractService(String name) 47 { 48 this.name = name; 49 log("CTOR"); 50 } 51 52 54 public String getName() 55 { 56 return name; 57 } 58 59 public String getState() 60 { 61 return state; 62 } 63 64 66 public void create() throws Exception 67 { 68 state = CREATED; 69 log("create()"); 70 } 71 72 public void start() throws Exception 73 { 74 state = STARTED; 75 log("start()"); 76 } 77 78 public void stop() throws Exception 79 { 80 state = STOPPED; 81 log("stop()"); 82 } 83 84 public void destroy() throws Exception 85 { 86 state = DESTROYED; 87 log("destroy()"); 88 } 89 90 92 public void log(Object message) 93 { 94 System.out.println(getName() + " - " + message); 95 } 96 97 99 public String toString() 100 { 101 StringBuffer sbuf = new StringBuffer (); 102 sbuf 103 .append(getClass().getName()) 104 .append("[ name=").append(name) 105 .append(", state=").append(state) 106 .append(" ]"); 107 108 return sbuf.toString(); 109 } 110 } 111 | Popular Tags |