KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > config > ServiceRef


1 package org.sapia.soto.config;
2
3 import org.sapia.soto.NotFoundException;
4 import org.sapia.soto.SotoContainer;
5
6 import org.sapia.util.xml.confix.ConfigurationException;
7 import org.sapia.util.xml.confix.ObjectCreationCallback;
8
9
10 /**
11  * This class implements the <code>soto:serviceRef</code> tag.
12  *
13  * @author Yanick Duchesne
14  * <dl>
15  * <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>
16  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
17  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
18  * </dl>
19  */

20 public class ServiceRef implements ObjectCreationCallback {
21   private String JavaDoc _id;
22   private SotoContainer _cont;
23
24   /**
25    * Constructor for ServiceRef.
26    */

27   public ServiceRef(SotoContainer container) {
28     _cont = container;
29   }
30
31   /**
32    * Sets the ID of the service to which this instance refers.
33    */

34   public void setId(String JavaDoc id) {
35     _id = id;
36   }
37
38   /**
39    * @see org.sapia.util.xml.confix.ObjectCreationCallback#onCreate()
40    */

41   public Object JavaDoc onCreate() throws ConfigurationException {
42     try {
43       return _cont.lookup(_id);
44     } catch (NotFoundException e) {
45       throw new ConfigurationException("Could not retrieve service", e);
46     }
47   }
48 }
49
Popular Tags