1 29 30 package com.caucho.server.host; 31 32 import com.caucho.config.Config; 33 import com.caucho.log.Log; 34 import com.caucho.server.deploy.DeployContainer; 35 import com.caucho.server.deploy.DeployGenerator; 36 37 import java.util.Set ; 38 import java.util.logging.Logger ; 39 40 43 public class HostSingleDeployGenerator 44 extends DeployGenerator<HostController> { 45 private static final Logger log = Log.open(HostSingleDeployGenerator.class); 46 47 private HostContainer _container; 48 49 private HostConfig _config; 50 51 private HostController _controller; 52 53 56 public HostSingleDeployGenerator(DeployContainer<HostController> container) 57 { 58 super(container); 59 } 60 61 64 public HostSingleDeployGenerator(DeployContainer<HostController> container, 65 HostContainer hostContainer, HostConfig config) 66 throws Exception 67 { 68 super(container); 69 70 _container = hostContainer; 71 72 _config = config; 73 74 init(); 75 } 76 77 80 public HostContainer getContainer() 81 { 82 return _container; 83 } 84 85 88 public ClassLoader getParentClassLoader() 89 { 90 return _container.getClassLoader(); 91 } 92 93 96 protected Logger getLog() 97 { 98 return log; 99 } 100 101 104 @Override 105 public void initImpl() 106 { 107 super.initImpl(); 108 109 String hostName = null; 110 String id = null; 111 112 String rawId = _config.getId(); 113 String rawHostName = _config.getHostName(); 114 115 if (rawId != null) { 116 id = Config.evalString(rawId); 117 118 if (id.equals("*")) id = ""; 120 } 121 122 if (rawHostName != null) { 123 hostName = Config.evalString(rawHostName); 124 125 if (rawHostName.equals("*")) hostName = ""; 127 } 128 129 if (hostName != null) { 130 _controller = new HostController(hostName, _config, _container, null); 131 132 if (id != null) 133 _controller.addHostAlias(id); 134 } 135 else if (id != null) 136 _controller = new HostController(id, _config, _container, null); 137 else 138 _controller = new HostController("", _config, _container, null); 139 } 140 141 144 protected void fillDeployedKeys(Set <String > keys) 145 { 146 keys.add(_controller.getName()); 147 } 148 149 152 public HostController generateController(String name) 153 { 154 if (_controller.isNameMatch(name)) { 155 return new HostController(_controller.getName(), _config, 156 _container, null); 157 } 158 else 159 return null; 160 } 161 162 165 public HostController mergeController(HostController controller, 166 String name) 167 { 168 173 if (_controller.isNameMatch(name)) 175 return controller.merge(_controller); 176 else 177 return controller; 178 } 179 180 public Throwable getConfigException() 181 { 182 Throwable configException = super.getConfigException(); 183 184 if (configException == null && _controller != null) 185 configException = _controller.getConfigException(); 186 187 return configException; 188 } 189 190 public String toString() 191 { 192 if (_config == null) 193 return "HostSingleDeployGenerator[]"; 194 else 195 return "HostSingleDeployGenerator[" + _config.getHostName() + "]"; 196 } 197 } 198 | Popular Tags |