1 29 30 package com.caucho.server.deploy; 31 32 import com.caucho.log.Log; 33 import com.caucho.util.L10N; 34 import com.caucho.vfs.Dependency; 35 36 import java.util.ArrayList ; 37 import java.util.Set ; 38 import java.util.logging.Level ; 39 import java.util.logging.Logger ; 40 41 44 public class DeployListGenerator<E extends DeployController> 45 extends DeployGenerator<E> implements Dependency { 46 private static final Logger log = Log.open(DeployListGenerator.class); 47 private static final L10N L = new L10N(DeployListGenerator.class); 48 49 private ArrayList <DeployGenerator<E>> _generatorList 50 = new ArrayList <DeployGenerator<E>>(); 51 52 55 public DeployListGenerator(DeployContainer container) 56 { 57 super(container); 58 } 59 60 63 public void add(DeployGenerator<E> deploy) 64 { 65 if (! _generatorList.contains(deploy)) 66 _generatorList.add(deploy); 67 } 68 69 72 public void remove(DeployGenerator<E> deploy) 73 { 74 _generatorList.remove(deploy); 75 } 76 77 80 public boolean isModified() 81 { 82 for (int i = _generatorList.size() - 1; i >= 0; i--) { 83 if (_generatorList.get(i).isModified()) 84 return true; 85 } 86 87 return false; 88 } 89 90 95 public void request() 96 { 97 for (int i = _generatorList.size() - 1; i >= 0; i--) { 98 _generatorList.get(i).request(); 99 } 100 } 101 102 105 public void update() 106 { 107 for (int i = 0; i < _generatorList.size(); i++) 108 _generatorList.get(i).update(); 109 } 110 111 114 public void fillDeployedKeys(Set <String > keys) 115 { 116 for (int i = 0; i < _generatorList.size(); i++) { 117 _generatorList.get(i).fillDeployedKeys(keys); 118 } 119 } 120 121 124 protected E generateController(String key) 125 { 126 for (int i = 0; i < _generatorList.size(); i++) { 127 E controller = _generatorList.get(i).generateController(key); 128 129 if (controller != null) { 130 for (int j = 0; j < _generatorList.size(); j++) { 132 DeployGenerator<E> generator = _generatorList.get(j); 133 134 controller = _generatorList.get(j).mergeController(controller, key); 136 } 137 138 return controller; 139 } 140 } 141 142 return null; 143 } 144 145 148 protected E mergeController(E controller, String key) 149 { 150 for (int i = 0; i < _generatorList.size(); i++) { 151 controller = _generatorList.get(i).mergeController(controller, key); 152 } 153 154 return controller; 155 } 156 157 160 @Override 161 protected void startImpl() 162 { 163 super.startImpl(); 164 165 for (int i = 0; i < _generatorList.size(); i++) { 166 _generatorList.get(i).start(); 167 } 168 } 169 170 173 @Override 174 protected void stopImpl() 175 { 176 for (int i = 0; i < _generatorList.size(); i++) { 177 _generatorList.get(i).stop(); 178 } 179 180 super.stopImpl(); 181 } 182 183 186 @Override 187 protected void destroyImpl() 188 { 189 ArrayList <DeployGenerator<E>> generatorList 190 = new ArrayList <DeployGenerator<E>>(_generatorList); 191 192 _generatorList.clear(); 193 194 for (int i = 0; i < generatorList.size(); i++) { 195 try { 196 generatorList.get(i).destroy(); 197 } catch (Throwable e) { 198 log.log(Level.FINE, e.toString(), e); 199 } 200 } 201 202 super.destroyImpl(); 203 } 204 205 public String toString() 206 { 207 return "DeployListGenerator[" + _generatorList + "]"; 208 } 209 } 210 | Popular Tags |