KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > ubik > UbikLayer


1 package org.sapia.soto.ubik;
2
3 import org.sapia.soto.Layer;
4 import org.sapia.soto.ServiceMetaData;
5
6 import javax.naming.ConfigurationException JavaDoc;
7
8
9 /**
10  * This layer binds a service to a remote Ubik JNDI server, under a name that is given
11  * through configuration. If no name is specified, the service's identifier is used - implying
12  * that the service was indeed assigned an identifier.
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 UbikLayer implements Layer {
22   private NamingService _svc;
23   private String JavaDoc _name;
24
25   /**
26    * Constructor for UbikLayer.
27    */

28   public UbikLayer() {
29     super();
30   }
31
32   /**
33    * Sets the naming service instance that will be used to internally bind
34    * the service passed to this layer.
35    *
36    * @param svc a <code>NamingService</code>.
37    */

38   public void setNamingService(NamingService svc) {
39     _svc = svc;
40   }
41
42   /**
43    * @param name the name under which to bind the service that will be
44    * passed to this instance.
45    */

46   public void setJndiName(String JavaDoc name) {
47     _name = name;
48   }
49
50   /**
51    * @see org.sapia.soto.Layer#init(ServiceMetaData)
52    */

53   public void init(ServiceMetaData meta) throws Exception JavaDoc {
54     if (_svc == null) {
55       throw new ConfigurationException JavaDoc("This layer expects a " +
56         NamingService.class.getName() +
57         " instance to be passed to it in a <namingService> element");
58     }
59
60     if (_name == null) {
61       if (meta.getServiceID() == null) {
62         throw new org.sapia.soto.ConfigurationException(
63           "No 'jndiName' specified under which to bind the service: " +
64           meta.getService().getClass().getName());
65       }
66
67       System.out.println("binding: " + meta.getServiceID());
68       _svc.bind(meta.getServiceID(), meta.getService());
69     } else {
70       _svc.bind(_name, meta.getService());
71     }
72   }
73
74   /**
75    * @see org.sapia.soto.Layer#start(org.sapia.soto.ServiceMetaData)
76    */

77   public void start(ServiceMetaData meta) throws Exception JavaDoc {
78   }
79
80   /**
81    * @see org.sapia.soto.Layer#dispose()
82    */

83   public void dispose() {
84   }
85 }
86
Popular Tags