1 9 package org.jboss.remoting.network; 10 11 import java.io.Serializable ; 12 import org.jboss.remoting.InvokerLocator; 13 import org.jboss.remoting.detection.ServerInvokerMetadata; 14 import org.jboss.remoting.ident.Identity; 15 16 22 public class NetworkInstance implements Serializable 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 77 public final ServerInvokerMetadata[] getServerInvokers() 78 { 79 return serverInvokers; 80 } 81 82 83 public String toString() 84 { 85 return "NetworkInstance [identity:" + identity + ",locator count:" + (serverInvokers == null ? 0 : serverInvokers.length) + "]"; 86 } 87 88 public boolean equals(Object obj) 89 { 90 return hashCode == obj.hashCode(); 91 } 92 93 public int hashCode() 94 { 95 return hashCode; 96 } 97 } 98 | Popular Tags |