001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.axis2.description;
020:
021: import org.apache.axiom.om.OMAbstractFactory;
022: import org.apache.axiom.om.OMElement;
023: import org.apache.axiom.om.OMFactory;
024: import org.apache.axiom.om.OMNamespace;
025: import org.apache.axis2.AxisFault;
026: import org.apache.axis2.util.WSDLSerializationUtil;
027:
028: import java.util.HashMap;
029: import java.util.Map;
030:
031: public class AxisEndpoint extends AxisDescription {
032:
033: // The name of the endpoint
034: private String name;
035:
036: // The binding reffered to by the endpoint
037: private AxisBinding binding;
038:
039: // The address of the endpoint
040: private String endpointURL;
041:
042: // The alias used for the endpoint
043: private String alias;
044:
045: private Map options;
046:
047: public String getEndpointURL() {
048: return endpointURL;
049: }
050:
051: public void setEndpointURL(String endpointURL) {
052: this .endpointURL = endpointURL;
053: }
054:
055: public AxisEndpoint() {
056: options = new HashMap();
057: }
058:
059: public void setProperty(String name, Object value) {
060: options.put(name, value);
061: }
062:
063: /**
064: * @param name name of the property to search for
065: * @return the value of the property, or null if the property is not found
066: */
067: public Object getProperty(String name) {
068: Object obj = options.get(name);
069: if (obj != null) {
070: return obj;
071: }
072:
073: return null;
074: }
075:
076: public String getAlias() {
077: return alias;
078: }
079:
080: public void setAlias(String alias) {
081: this .alias = alias;
082: }
083:
084: public String getName() {
085: return name;
086: }
087:
088: public void setName(String name) {
089: this .name = name;
090: }
091:
092: public AxisBinding getBinding() {
093: return binding;
094: }
095:
096: public void setBinding(AxisBinding binding) {
097: this .binding = binding;
098: }
099:
100: public Object getKey() {
101: //ToDO
102: return null; //To change body of implemented methods use File | Settings | File Templates.
103: }
104:
105: public void engageModule(AxisModule axisModule) throws AxisFault {
106: throw new UnsupportedOperationException(
107: "Sorry we do not support this");
108: }
109:
110: public boolean isEngaged(String moduleName) {
111: throw new UnsupportedOperationException(
112: "axisMessage.isEngaged() is not supported");
113: }
114:
115: public OMElement toWSDL20(OMNamespace wsdl, OMNamespace tns,
116: OMNamespace whttp, String epr) {
117: String property;
118: String name;
119: if (epr.startsWith("https://")) {
120: // The reason to do this is to have camel case
121: String endpointName = this .getName();
122: name = WSDL2Constants.DEFAULT_HTTPS_PREFIX
123: + endpointName.substring(0, 1).toUpperCase()
124: + endpointName.substring(1);
125: } else {
126: name = this .getName();
127: }
128: OMFactory omFactory = OMAbstractFactory.getOMFactory();
129: OMElement endpointElement = omFactory.createOMElement(
130: WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
131: endpointElement.addAttribute(omFactory.createOMAttribute(
132: WSDL2Constants.ATTRIBUTE_NAME, null, name));
133: endpointElement.addAttribute(omFactory.createOMAttribute(
134: WSDL2Constants.BINDING_LOCAL_NAME, null, tns
135: .getPrefix()
136: + ":" + getBinding().getName().getLocalPart()));
137: endpointElement.addAttribute(omFactory.createOMAttribute(
138: WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
139: Object authenticationScheme = this .options
140: .get(WSDL2Constants.ATTR_WHTTP_AUTHENTICATION_TYPE);
141: if (authenticationScheme != null) {
142: endpointElement.addAttribute(omFactory.createOMAttribute(
143: WSDL2Constants.ATTRIBUTE_AUTHENTICATION_TYPE,
144: whttp, authenticationScheme.toString()));
145: }
146: property = (String) options
147: .get(WSDL2Constants.ATTR_WHTTP_AUTHENTICATION_REALM);
148: if (property != null) {
149: endpointElement.addAttribute(omFactory.createOMAttribute(
150: WSDL2Constants.ATTRIBUTE_AUTHENTICATION_REALM,
151: whttp, property));
152: }
153: WSDLSerializationUtil.addWSDLDocumentationElement(this ,
154: endpointElement, omFactory, wsdl);
155: return endpointElement;
156: }
157:
158: public AxisService getAxisService() {
159: return (AxisService) parent;
160: }
161:
162: public void setParent(AxisService service) {
163: parent = service;
164: }
165: }
|