1 16 17 18 package org.apache.commons.modeler.demo; 19 20 21 import java.util.HashMap ; 22 23 24 31 32 public class Server { 33 34 35 37 38 41 public Server() { 42 43 super(); 44 45 } 46 47 48 54 public Server(int port, String shutdown) { 55 56 super(); 57 setPort(port); 58 setShutdown(shutdown); 59 60 } 61 62 63 65 66 69 private HashMap services = new HashMap (); 70 71 72 74 75 78 private int port = 8005; 79 80 public int getPort() { 81 return (this.port); 82 } 83 84 public void setPort(int port) { 85 this.port = port; 86 } 87 88 89 92 private String shutdown = "SHUTDOWN"; 93 94 public String getShutdown() { 95 return (this.shutdown); 96 } 97 98 public void setShutdown(String shutdown) { 99 this.shutdown = shutdown; 100 } 101 102 104 105 110 public void addService(Service service) { 111 112 services.put(service.getName(), service); 113 114 } 115 116 117 122 public Service findService(String name) { 123 124 return ((Service) services.get(name)); 125 126 } 127 128 129 132 public Service[] findServices() { 133 134 Service results[] = new Service[services.size()]; 135 return ((Service[]) services.values().toArray(results)); 136 137 } 138 139 140 145 public void removeService(Service service) { 146 147 services.remove(service.getName()); 148 149 } 150 151 152 155 public String toString() { 156 157 StringBuffer sb = new StringBuffer ("Server["); 158 sb.append("port="); 159 sb.append(port); 160 sb.append(", shutdown="); 161 sb.append(shutdown); 162 sb.append("]"); 163 return (sb.toString()); 164 165 } 166 167 168 } 169 | Popular Tags |