KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > rmi > naming > remote > discovery > ServiceDiscoveryEvent


1 package org.sapia.ubik.rmi.naming.remote.discovery;
2
3 import java.rmi.RemoteException JavaDoc;
4 import java.util.Properties JavaDoc;
5
6 import org.sapia.ubik.rmi.server.StubContainer;
7
8
9 /**
10  * This class models an event that is triggered by the binding of a new object in
11  * the <code>ReliableRemoteContext</code>.
12  * <p>
13  * Client-side <code>ServiceDiscoListener</code>s are used to trap instances of this
14  * class.
15  * <p>
16  * This allows client apps to be notified when new services are bound into the JNDI.
17  *
18  * @author Yanick Duchesne
19  * <dl>
20  * <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>
21  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
22  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
23  * </dl>
24  */

25 public class ServiceDiscoveryEvent {
26   private Properties JavaDoc _attributes;
27   private String JavaDoc _name;
28   private Object JavaDoc _service;
29
30   /**
31    * Constructor for ServiceDiscoveryEvent.
32    */

33   public ServiceDiscoveryEvent(Properties JavaDoc attributes, String JavaDoc name, Object JavaDoc service) {
34     _name = name;
35     _service = service;
36     _attributes = attributes;
37   }
38
39   /**
40    * Returns the name under which the service was bound.
41    *
42    * @return a name.
43    */

44   public String JavaDoc getName() {
45     return _name;
46   }
47
48   /**
49    * Returns the service that was bound.
50    *
51    * @return an <code>Object</code>.
52    */

53   public Object JavaDoc getService() throws RemoteException JavaDoc {
54     if (_service instanceof StubContainer) {
55       return ((StubContainer) _service).toStub(Thread.currentThread()
56                                                      .getContextClassLoader());
57     }
58
59     return _service;
60   }
61
62   /**
63    * @return the <code>Properties</code> corresponding to the attributes
64    * used to bind the service within this instance.
65    */

66   public Properties JavaDoc getAttributes() {
67     return _attributes;
68   }
69
70   public String JavaDoc toString() {
71     return "[ name=" + _name + ", service=" + _service + ", attributes=" +
72     _attributes + " ]";
73   }
74 }
75
Popular Tags