KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > remoting > detection > Detection


1 /***************************************
2  * *
3  * JBoss: The OpenSource J2EE WebOS *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  ***************************************/

9 package org.jboss.remoting.detection;
10
11 import java.io.Serializable JavaDoc;
12 import org.jboss.remoting.InvokerLocator;
13 import org.jboss.remoting.ident.Identity;
14
15 /**
16  * Detection is an MBean Notification that is fired by
17  * Detectors when remote servers are found or lost on the Network.
18  *
19  * @author <a HREF="mailto:jhaynie@vocalocity.net">Jeff Haynie</a>
20  * @version $Revision: 1.3 $
21  */

22 public class Detection implements Serializable JavaDoc
23 {
24    static final long serialVersionUID = -7560953564286960592L;
25
26    private final ServerInvokerMetadata[] serverInvokers;
27    private final Identity identity;
28    private final int hashCode;
29
30    public Detection(Identity identity, ServerInvokerMetadata[] serverInvokers)
31    {
32       this.serverInvokers = serverInvokers;
33       this.identity = identity;
34       this.hashCode = identity.hashCode();
35    }
36
37    public boolean equals(Object JavaDoc obj)
38    {
39       if(obj instanceof Detection)
40       {
41          return hashCode == obj.hashCode();
42       }
43       return false;
44    }
45
46    public int hashCode()
47    {
48       return hashCode;
49    }
50
51    public String JavaDoc toString()
52    {
53       return "Detection [identity:" + identity + ",locators:" + (serverInvokers == null ? 0 : serverInvokers.length) + "]";
54    }
55
56    /**
57     * return the jboss identity
58     *
59     * @return
60     */

61    public final Identity getIdentity()
62    {
63       return identity;
64    }
65
66    /**
67     * return the locators for the server
68     *
69     * @return
70     */

71    public final InvokerLocator[] getLocators()
72    {
73       InvokerLocator[] locators = new InvokerLocator[serverInvokers.length];
74       for(int x = 0; x < serverInvokers.length; x++)
75       {
76          locators[x] = serverInvokers[x].getInvokerLocator();
77       }
78       return locators;
79    }
80
81    /**
82     * Gets all the server invoker metadata for the servers running on
83     * specified server. Will include locator and supported subsystems
84     * for that locator.
85     *
86     * @return
87     */

88    public final ServerInvokerMetadata[] getServerInvokers()
89    {
90       return serverInvokers;
91    }
92 }
93
Popular Tags