KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > aop > GroupRef


1 package org.sapia.soto.aop;
2
3 import org.sapia.soto.ConfigurationException;
4
5 import java.util.List JavaDoc;
6 import java.util.Map JavaDoc;
7
8
9 /**
10  * An instance of this class refers to an advice group.
11  *
12  * @see org.sapia.soto.aop.Group
13  *
14  * @author Yanick Duchesne
15  * <dl>
16  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
17  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
18  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
19  * </dl>
20  */

21 public class GroupRef {
22   private String JavaDoc _id;
23
24   /**
25    * Constructor for AdviceRef.
26    */

27   public GroupRef() {
28     super();
29   }
30
31   /**
32    * Sets the identifier of the advice to which this instance refers.
33    *
34    * @param the identifier of an advice.
35    * @see AdviceDef
36    */

37   public void setId(String JavaDoc id) {
38     _id = id;
39   }
40
41   /**
42    * Returns a list of advices contained in the group corresponding to this instance's
43    * identifier.
44    *
45    * @param defs a <code>Map</code> containing id-to<code>Group</code>
46    * mappings.
47    */

48   public List JavaDoc resolve(Map JavaDoc defs) throws ConfigurationException {
49     if (_id == null) {
50       throw new ConfigurationException(
51         "'id' attribute not set on advice group reference");
52     }
53
54     Group group = (Group) defs.get(_id);
55
56     if (group == null) {
57       throw new ConfigurationException("No advice group matches ID: " + _id);
58     }
59
60     return group.getAdvices();
61   }
62 }
63
Popular Tags