1 17 package org.apache.servicemix.jbi.servicedesc; 18 19 import java.util.ArrayList ; 20 import java.util.HashMap ; 21 import java.util.List ; 22 import java.util.Map ; 23 24 import javax.xml.namespace.QName ; 25 26 import org.apache.servicemix.jbi.framework.ComponentNameSpace; 27 import org.w3c.dom.DocumentFragment ; 28 29 34 public class InternalEndpoint extends AbstractServiceEndpoint { 35 36 39 private static final long serialVersionUID = -2710298087712302015L; 40 41 private String endpointName; 42 private QName serviceName; 43 private List interfaces = new ArrayList (); 44 private transient Map remotes = new HashMap (); 45 46 47 53 public InternalEndpoint(ComponentNameSpace componentName, String endpointName, QName serviceName) { 54 super(componentName); 55 this.endpointName = endpointName; 56 this.serviceName = serviceName; 57 } 58 59 68 public DocumentFragment getAsReference(QName operationName) { 69 return EndpointReferenceBuilder.getReference(this); 70 } 71 72 76 public String getEndpointName() { 77 return endpointName; 78 } 79 80 86 public QName [] getInterfaces() { 87 QName [] result = new QName [interfaces.size()]; 88 interfaces.toArray(result); 89 return result; 90 } 91 92 96 public void addInterface(QName name) { 97 interfaces.add(name); 98 } 99 100 104 public QName getServiceName() { 105 return serviceName; 106 } 107 108 112 public InternalEndpoint[] getRemoteEndpoints() { 113 InternalEndpoint[] result = new InternalEndpoint[remotes.size()]; 114 remotes.values().toArray(result); 115 return result; 116 } 117 118 public void addRemoteEndpoint(InternalEndpoint remote) { 119 remotes.put(remote.getComponentNameSpace(), remote); 120 } 121 122 public void removeRemoteEndpoint(InternalEndpoint remote) { 123 remotes.remove(remote.getComponentNameSpace()); 124 } 125 126 130 public boolean isLocal() { 131 return getComponentNameSpace() != null; 132 } 133 134 138 public boolean isClustered() { 139 return remotes != null && remotes.size() > 0; 140 } 141 142 146 public boolean equals(Object obj) { 147 boolean result = false; 148 if (obj != null && obj instanceof InternalEndpoint){ 149 InternalEndpoint other = (InternalEndpoint)obj; 150 result = other.serviceName.equals(this.serviceName) && 151 other.endpointName.equals(this.endpointName); 152 } 153 return result; 154 } 155 156 157 160 public int hashCode() { 161 return serviceName.hashCode() ^ 162 endpointName.hashCode() ; 163 } 164 165 168 public String toString() { 169 return "ServiceEndpoint[service=" + serviceName + ",endpoint=" + endpointName + "]"; 170 } 171 } | Popular Tags |