001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)EndpointInfoImpl.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.internal.security.config;
030:
031: import java.net.URI;
032:
033: /**
034: * Endpoint interface provides a means to define the three attributes that
035: * uniquely identify an endpoint.
036: * TODO: Replace this with Endpoint ( do away with redundancy ).
037: *
038: * @author Sun Microsystems, Inc.
039: */
040: public class EndpointInfoImpl implements EndpointInfo {
041: /** Local Endpoint Name. */
042: private String mName = null;
043:
044: /** Service Local Name. */
045: private String mServiceName = null;
046:
047: /** Target Namespace. */
048: private URI mTns = null;
049:
050: /** Component Id */
051: private String mComponentId;
052:
053: /**
054: * @param endpt is the Endpoint to extract the EndpointInfo from
055: * @throws java.net.URISyntaxException if the Namespace URI is in the incorrect
056: * format.
057: */
058: public EndpointInfoImpl(com.sun.jbi.binding.security.Endpoint endpt)
059: throws java.net.URISyntaxException {
060: mName = endpt.getEndpointName();
061:
062: mServiceName = endpt.getServiceName().getLocalPart();
063:
064: mTns = new java.net.URI(endpt.getServiceName()
065: .getNamespaceURI());
066:
067: mComponentId = endpt.getComponentId();
068: }
069:
070: /**
071: * Creates a new instance of EndpointInfo.
072: *
073: * @param name is the local name of the Endpoint
074: * @param service is the local name of the parent Service
075: * @param tns is the TargetNamespace for the Endpoint
076: * @param compId is the name of the Component Id to which this Endpoint is deployed
077: */
078: public EndpointInfoImpl(String name, String service, URI tns,
079: String compId) {
080:
081: this (name, service, tns);
082: mComponentId = compId;
083: }
084:
085: /**
086: * Creates a new instance of EndpointInfo.
087: *
088: * @param name is the local name of the Endpoint
089: * @param service is the local name of the parent Service
090: * @param tns is the TargetNamespace for the Endpoint
091: */
092: public EndpointInfoImpl(String name, String service, URI tns) {
093: mName = name;
094: mServiceName = service;
095: mTns = tns;
096: mComponentId = "";
097: }
098:
099: /**
100: * Get the Local name of the endpoint.
101: *
102: * @return the Local Name of the Endpoint
103: */
104: public String getName() {
105: return mName;
106: }
107:
108: /**
109: * Get the Local Name of the parent Service that contains this Endpoint.
110: *
111: * @return the local name of the Parenter Service
112: */
113: public String getServiceName() {
114: return mServiceName;
115: }
116:
117: /**
118: * Get the targetNamespace URI for the Endpoint.
119: * @return the targetNamespace URI for the Endpoint
120: */
121: public java.net.URI getTargetNamespace() {
122: return mTns;
123: }
124:
125: /**
126: *
127: * Get the Component Id associated with the Endpoint.
128: *
129: * @return the Component Id
130: * @deprecated
131: */
132: public String getComponentId() {
133: return mComponentId;
134: }
135:
136: /**
137: *
138: * @param obj to compare
139: * @return true if the other Endpoint is equal to this one.
140: */
141: public boolean equals(Object obj) {
142: if (obj instanceof EndpointInfo) {
143: EndpointInfo otherEndpoint = (EndpointInfo) obj;
144:
145: if (getName().equals(otherEndpoint.getName())
146: && getServiceName().equals(
147: otherEndpoint.getServiceName())
148: && getTargetNamespace().equals(
149: otherEndpoint.getTargetNamespace())) {
150: return true;
151: }
152: }
153: return false;
154: }
155:
156: /**
157: * hashCode.
158: *
159: * @return the hashcode
160: */
161: public int hashCode() {
162: return (getName().hashCode() + getServiceName().hashCode() + getTargetNamespace()
163: .hashCode());
164: }
165:
166: }
|