1 28 29 package com.caucho.config.core; 30 31 import com.caucho.util.L10N; 32 33 import javax.annotation.PostConstruct; 34 import java.util.ArrayList ; 35 36 39 public class ResinChoose extends ResinControl { 40 private static final L10N L = new L10N(ResinWhen.class); 41 42 private ArrayList <ResinWhen> _whenList = new ArrayList <ResinWhen>(); 43 private ResinWhen _otherwise; 44 45 48 public void addWhen(ResinWhen when) 49 { 50 _whenList.add(when); 51 } 52 53 56 public void setOtherwise(ResinWhen when) 57 { 58 _otherwise = when; 59 _otherwise.setTest(true); 60 } 61 62 @PostConstruct 63 public void init() 64 throws Throwable 65 { 66 Object object = getObject(); 67 68 if (object == null) 69 return; 70 71 for (int i = 0; i < _whenList.size(); i++) { 72 ResinWhen when = _whenList.get(i); 73 74 if (when.configure(object)) 75 return; 76 } 77 78 if (_otherwise != null) 79 _otherwise.configure(object); 80 } 81 } 82 83 | Popular Tags |