1 29 30 package com.caucho.server.e_app; 31 32 import com.caucho.log.Log; 33 import com.caucho.management.j2ee.J2EEApplication; 34 import com.caucho.management.j2ee.J2EEManagedObject; 35 import com.caucho.server.deploy.DeployControllerAdmin; 36 import com.caucho.server.deploy.EnvironmentDeployController; 37 import com.caucho.server.webapp.WebAppContainer; 38 import com.caucho.server.webapp.WebAppController; 39 import com.caucho.util.L10N; 40 import com.caucho.vfs.Path; 41 42 import javax.servlet.jsp.el.ELException ; 43 import java.util.ArrayList ; 44 import java.util.logging.Level ; 45 import java.util.logging.Logger ; 46 47 50 public class EarDeployController 51 extends EnvironmentDeployController<EnterpriseApplication,EarConfig> { 52 private static final Logger log = Log.open(EarDeployController.class); 53 private static final L10N L = new L10N(EarDeployController.class); 54 55 private WebAppContainer _container; 56 57 59 private Path _earRootDir; 61 62 private ArrayList <EarConfig> _eAppDefaults = new ArrayList <EarConfig>(); 63 64 private EarAdmin _admin = new EarAdmin(this); 65 private J2EEApplication _j2eeAdmin; 66 67 EarDeployController(String name, 68 WebAppContainer container, EarConfig config) 69 { 70 super(config); 71 72 _container = container; 73 74 if (container != null) { 75 _eAppDefaults.addAll(container.getEarDefaultList()); 76 } 77 } 78 79 EarDeployController(String name, Path rootDirectory, 80 WebAppContainer container) 81 { 82 super(name, rootDirectory); 83 84 _container = container; 85 86 if (container != null) { 87 _eAppDefaults.addAll(container.getEarDefaultList()); 88 } 89 } 90 91 94 public void setId(String name) 95 { 96 getVariableMap().put("name", name); 97 98 } 100 101 104 public Path getEarRootDir() 105 { 106 return _earRootDir; 107 } 108 109 112 public void setEarRootDir(Path rootDir) 113 { 114 _earRootDir = rootDir; 115 } 116 117 120 @Override 121 protected DeployControllerAdmin getDeployAdmin() 122 { 123 return _admin; 124 } 125 126 @Override 127 protected void initEnd() 128 { 129 super.initEnd(); 130 131 _j2eeAdmin = new J2EEApplication(this); 132 J2EEManagedObject.register(_j2eeAdmin); 133 } 134 135 138 public WebAppController findWebAppController(String name) 139 { 140 try { 141 EnterpriseApplication eApp = request(); 142 143 if (eApp != null) 144 return eApp.findWebAppEntry(name); 145 else 146 return null; 147 } catch (Throwable e) { 148 log.log(Level.FINER, e.toString(), e); 149 150 return null; 151 } 152 } 153 154 157 protected EnterpriseApplication instantiateDeployInstance() 158 { 159 return new EnterpriseApplication(_container, this, getId()); 160 } 161 162 protected Path calculateRootDirectory() 163 throws ELException 164 { 165 Path rootDir = getRootDirectory(); 166 EnterpriseApplication eApp = getDeployInstance(); 167 168 if (rootDir == null && eApp != null) 169 rootDir = eApp.getRootDirectory(); 170 171 return rootDir; 172 } 173 174 @Override 175 public boolean destroy() 176 { 177 Thread thread = Thread.currentThread(); 178 ClassLoader oldLoader = thread.getContextClassLoader(); 179 180 try { 181 thread.setContextClassLoader(getParentClassLoader()); 182 J2EEManagedObject.unregister(_j2eeAdmin); 183 } finally { 184 thread.setContextClassLoader(oldLoader); 185 } 186 187 return super.destroy(); 188 } 189 190 193 public boolean equals(Object o) 194 { 195 if (! (o instanceof EarDeployController)) 196 return false; 197 198 EarDeployController entry = (EarDeployController) o; 199 200 return getId().equals(entry.getId()); 201 } 202 203 204 207 public String toString() 208 { 209 return "EarDeployController[" + getId() + "]"; 210 } 211 } 212 | Popular Tags |