1 29 30 package com.caucho.server.host; 31 32 import com.caucho.management.server.HostMXBean; 33 import com.caucho.management.server.WebAppMXBean; 34 import com.caucho.server.deploy.DeployControllerAdmin; 35 import com.caucho.server.deploy.DeployException; 36 import com.caucho.server.webapp.WebAppController; 37 import com.caucho.util.L10N; 38 import com.caucho.vfs.Path; 39 40 import java.util.ArrayList ; 41 42 45 public class HostAdmin extends DeployControllerAdmin<HostController> 46 implements HostMXBean 47 { 48 private static final L10N L = new L10N(HostAdmin.class); 49 50 53 public HostAdmin(HostController controller) 54 { 55 super(controller); 56 } 57 58 public String getName() 59 { 60 String name = getController().getName(); 61 62 if (name == null || name.equals("")) 63 return "default"; 64 else 65 return name; 66 } 67 68 public String getHostName() 69 { 70 return getController().getHostName(); 71 } 72 73 public String getURL() 74 { 75 Host host = getHost(); 76 77 if (host != null) 78 return host.getURL(); 79 else 80 return null; 81 } 82 83 86 public String getRootDirectory() 87 { 88 Path path = null; 89 90 Host host = getHost(); 91 92 if (host != null) 93 path = host.getRootDirectory(); 94 95 if (path != null) 96 return path.getNativePath(); 97 else 98 return null; 99 } 100 101 104 public String getDocumentDirectory() 105 { 106 Path path = null; 107 108 Host host = getHost(); 109 110 if (host != null) 111 path = host.getDocumentDirectory(); 112 113 if (path != null) 114 return path.getNativePath(); 115 else 116 return null; 117 } 118 119 122 public String getWarDirectory() 123 { 124 Path path = null; 125 126 Host host = getHost(); 127 128 if (host != null) 129 path = host.getWarDir(); 130 131 if (path != null) 132 return path.getNativePath(); 133 else 134 return null; 135 } 136 137 public String getWarExpandDirectory() 138 { 139 Path path = null; 140 141 Host host = getHost(); 142 143 if (host != null) 144 path = host.getWarExpandDir(); 145 146 if (path != null) 147 return path.getNativePath(); 148 else 149 return null; 150 } 151 152 155 public void updateWebAppDeploy(String name) 156 throws DeployException 157 { 158 Host host = getHost(); 159 160 try { 161 if (host != null) 162 host.updateWebAppDeploy(name); 163 } catch (Throwable e) { 164 throw new DeployException(e); 165 } 166 } 167 168 171 public void updateEarDeploy(String name) 172 throws DeployException 173 { 174 Host host = getHost(); 175 176 try { 177 if (host != null) 178 host.updateEarDeploy(name); 179 } catch (Throwable e) { 180 throw new DeployException(e); 181 } 182 } 183 184 187 public void expandEarDeploy(String name) 188 { 189 Host host = getHost(); 190 191 if (host != null) 192 host.expandEarDeploy(name); 193 } 194 195 198 public void startEarDeploy(String name) 199 { 200 Host host = getHost(); 201 202 if (host != null) 203 host.startEarDeploy(name); 204 } 205 206 209 public WebAppMXBean []getWebApps() 210 { 211 Host host = getHost(); 212 213 if (host == null) 214 return new WebAppMXBean[0]; 215 216 ArrayList <WebAppController> webappList = host.getWebAppList(); 217 218 WebAppMXBean []webapps = new WebAppMXBean[webappList.size()]; 219 220 for (int i = 0; i < webapps.length; i++) { 221 WebAppController controller = webappList.get(i); 222 223 webapps[i] = controller.getAdmin(); 224 } 225 226 return webapps; 227 } 228 229 232 protected Host getHost() 233 { 234 return getController().getDeployInstance(); 235 } 236 237 240 public String toString() 241 { 242 return "HostAdmin[" + getName() + "]"; 243 } 244 } 245 | Popular Tags |