KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > remoting > network > NetworkInstance


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.network;
10
11 import java.io.Serializable JavaDoc;
12 import org.jboss.remoting.InvokerLocator;
13 import org.jboss.remoting.detection.ServerInvokerMetadata;
14 import org.jboss.remoting.ident.Identity;
15
16 /**
17  * NetworkInstance is an object that represents an Identity and its InvokerLocators.
18  *
19  * @author <a HREF="mailto:jhaynie@vocalocity.net">Jeff Haynie</a>
20  * @version $Revision: 1.3 $
21  */

22 public class NetworkInstance implements Serializable JavaDoc
23 {
24    static final long serialVersionUID = -1745108606611832280L;
25
26    private final Identity identity;
27    private final ServerInvokerMetadata serverInvokers[];
28    private final InvokerLocator locators[];
29    private final int hashCode;
30
31    public NetworkInstance(Identity identity, InvokerLocator locators[])
32    {
33       this.identity = identity;
34       this.locators = locators;
35       this.hashCode = this.identity.hashCode();
36       this.serverInvokers = null;
37    }
38
39    public NetworkInstance(Identity identity, ServerInvokerMetadata serverInvokers[])
40    {
41       this.identity = identity;
42       this.locators = null;
43       this.hashCode = this.identity.hashCode();
44       this.serverInvokers = serverInvokers;
45    }
46
47    public final Identity getIdentity()
48    {
49       return identity;
50    }
51
52    public final InvokerLocator[] getLocators()
53    {
54       if(locators != null)
55       {
56          return locators;
57       }
58       else
59       {
60          InvokerLocator[] locators = new InvokerLocator[serverInvokers.length];
61          for(int x = 0; x < serverInvokers.length; x++)
62          {
63             locators[x] = serverInvokers[x].getInvokerLocator();
64          }
65          return locators;
66       }
67
68    }
69
70    /**
71     * Gets all the server invoker metadata for the servers running on
72     * specified server. Will include locator and supported subsystems
73     * for that locator.
74     *
75     * @return
76     */

77    public final ServerInvokerMetadata[] getServerInvokers()
78    {
79       return serverInvokers;
80    }
81
82
83    public String JavaDoc toString()
84    {
85       return "NetworkInstance [identity:" + identity + ",locator count:" + (serverInvokers == null ? 0 : serverInvokers.length) + "]";
86    }
87
88    public boolean equals(Object JavaDoc obj)
89    {
90       return hashCode == obj.hashCode();
91    }
92
93    public int hashCode()
94    {
95       return hashCode;
96    }
97 }
98
Popular Tags