| 1 package org.sapia.soto.aop; 2 3 import org.sapia.soto.ConfigurationException; 4 5 import org.sapia.util.xml.confix.ObjectHandlerIF; 6 7 import java.util.ArrayList ; 8 import java.util.List ; 9 import java.util.Map ; 10 11 12 23 public class Group implements ObjectHandlerIF { 24 private String _id; 25 private List _defs = new ArrayList (); 26 private List _refs = new ArrayList (); 27 private List _advices = new ArrayList (); 28 29 32 public Group() { 33 super(); 34 } 35 36 41 public void setId(String id) { 42 _id = id; 43 } 44 45 50 public String getId() { 51 return _id; 52 } 53 54 59 public AdviceDef createAdviceDef() { 60 AdviceDef def = new AdviceDef(); 61 def.setId("null"); 62 _defs.add(def); 63 64 return def; 65 } 66 67 72 public AdviceRef createAdviceRef() { 73 AdviceRef ref = new AdviceRef(); 74 _refs.add(ref); 75 76 return ref; 77 } 78 79 84 public List getAdvices() throws ConfigurationException { 85 return _advices; 86 } 87 88 93 public void addAdvice(Advice adv) { 94 _advices.add(adv); 95 } 96 97 100 public void handleObject(String name, Object obj) 101 throws org.sapia.util.xml.confix.ConfigurationException { 102 if (obj instanceof Advice) { 103 _advices.add(obj); 104 } else { 105 throw new org.sapia.util.xml.confix.ConfigurationException(obj.getClass() 106 .getName() + 107 " is not an instance of " + Advice.class.getName()); 108 } 109 } 110 111 void resolve(Map defs) throws ConfigurationException { 112 AdviceRef ref; 113 AdviceDef def; 114 115 for (int i = 0; i < _defs.size(); i++) { 116 def = (AdviceDef) _defs.get(i); 117 _advices.add(def.getInstance()); 118 } 119 120 for (int i = 0; i < _refs.size(); i++) { 121 ref = (AdviceRef) _refs.get(i); 122 _advices.add(ref.resolve(defs)); 123 } 124 } 125 } 126 | Popular Tags |