001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.catalina.deploy;
019:
020: import java.io.Serializable;
021: import java.util.ArrayList;
022: import java.util.Iterator;
023: import java.util.HashMap;
024:
025: /**
026: * Representation of a web service reference for a web application, as
027: * represented in a <code><service-ref></code> element in the
028: * deployment descriptor.
029: *
030: * @author Fabien Carrion
031: * @version $Revision: 513349 $ $Date: 2007-03-01 15:33:06 +0100 (jeu., 01 mars 2007) $
032: */
033:
034: public class ContextService extends ResourceBase implements
035: Serializable {
036:
037: // ------------------------------------------------------------- Properties
038:
039: /**
040: * The WebService reference name.
041: */
042: private String displayname = null;
043:
044: public String getDisplayname() {
045: return (this .displayname);
046: }
047:
048: public void setDisplayname(String displayname) {
049: this .displayname = displayname;
050: }
051:
052: /**
053: * An icon for this WebService.
054: */
055: private String icon = null;
056:
057: public String getIcon() {
058: return (this .icon);
059: }
060:
061: public void setIcon(String icon) {
062: this .icon = icon;
063: }
064:
065: /**
066: * Contains the location (relative to the root of
067: * the module) of the web service WSDL description.
068: */
069: private String wsdlfile = null;
070:
071: public String getWsdlfile() {
072: return (this .wsdlfile);
073: }
074:
075: public void setWsdlfile(String wsdlfile) {
076: this .wsdlfile = wsdlfile;
077: }
078:
079: /**
080: * A file specifying the correlation of the WSDL definition
081: * to the interfaces (Service Endpoint Interface, Service Interface).
082: */
083: private String jaxrpcmappingfile = null;
084:
085: public String getJaxrpcmappingfile() {
086: return (this .jaxrpcmappingfile);
087: }
088:
089: public void setJaxrpcmappingfile(String jaxrpcmappingfile) {
090: this .jaxrpcmappingfile = jaxrpcmappingfile;
091: }
092:
093: /**
094: * Declares the specific WSDL service element that is being referred to.
095: * It is not specified if no wsdl-file is declared or if WSDL contains only
096: * 1 service element.
097: *
098: * A service-qname is composed by a namespaceURI and a localpart.
099: * It must be defined if more than 1 service is declared in the WSDL.
100: *
101: * serviceqname[0] : namespaceURI
102: * serviceqname[1] : localpart
103: */
104: private String[] serviceqname = new String[2];
105:
106: public String[] getServiceqname() {
107: return (this .serviceqname);
108: }
109:
110: public String getServiceqname(int i) {
111: return this .serviceqname[i];
112: }
113:
114: public String getServiceqnameNamespaceURI() {
115: return this .serviceqname[0];
116: }
117:
118: public String getServiceqnameLocalpart() {
119: return this .serviceqname[1];
120: }
121:
122: public void setServiceqname(String[] serviceqname) {
123: this .serviceqname = serviceqname;
124: }
125:
126: public void setServiceqname(String serviceqname, int i) {
127: this .serviceqname[i] = serviceqname;
128: }
129:
130: public void setServiceqnameNamespaceURI(String namespaceuri) {
131: this .serviceqname[0] = namespaceuri;
132: }
133:
134: public void setServiceqnameLocalpart(String localpart) {
135: this .serviceqname[1] = localpart;
136: }
137:
138: /**
139: * Declares a client dependency on the container to resolving a Service Endpoint Interface
140: * to a WSDL port. It optionally associates the Service Endpoint Interface with a
141: * particular port-component.
142: *
143: */
144: public Iterator getServiceendpoints() {
145: return this .listProperties();
146: }
147:
148: public String getPortlink(String serviceendpoint) {
149: return (String) this .getProperty(serviceendpoint);
150: }
151:
152: public void addPortcomponent(String serviceendpoint, String portlink) {
153: if (portlink == null)
154: portlink = "";
155: this .setProperty(serviceendpoint, portlink);
156: }
157:
158: /**
159: * A list of Handlers to use for this service-ref.
160: *
161: * The instanciation of the handler have to be done.
162: */
163: private HashMap handlers = new HashMap();
164:
165: public Iterator getHandlers() {
166: return handlers.keySet().iterator();
167: }
168:
169: public ContextHandler getHandler(String handlername) {
170: return (ContextHandler) handlers.get(handlername);
171: }
172:
173: public void addHandler(ContextHandler handler) {
174: handlers.put(handler.getName(), handler);
175: }
176:
177: // --------------------------------------------------------- Public Methods
178:
179: /**
180: * Return a String representation of this object.
181: */
182: public String toString() {
183:
184: StringBuffer sb = new StringBuffer("ContextService[");
185: sb.append("name=");
186: sb.append(getName());
187: if (getDescription() != null) {
188: sb.append(", description=");
189: sb.append(getDescription());
190: }
191: if (getType() != null) {
192: sb.append(", type=");
193: sb.append(getType());
194: }
195: if (displayname != null) {
196: sb.append(", displayname=");
197: sb.append(displayname);
198: }
199: if (icon != null) {
200: sb.append(", icon=");
201: sb.append(icon);
202: }
203: if (wsdlfile != null) {
204: sb.append(", wsdl-file=");
205: sb.append(wsdlfile);
206: }
207: if (jaxrpcmappingfile != null) {
208: sb.append(", jaxrpc-mapping-file=");
209: sb.append(jaxrpcmappingfile);
210: }
211: if (serviceqname[0] != null) {
212: sb.append(", service-qname/namespaceURI=");
213: sb.append(serviceqname[0]);
214: }
215: if (serviceqname[1] != null) {
216: sb.append(", service-qname/localpart=");
217: sb.append(serviceqname[1]);
218: }
219: if (this .getServiceendpoints() != null) {
220: sb.append(", port-component/service-endpoint-interface=");
221: sb.append(this .getServiceendpoints());
222: }
223: if (handlers != null) {
224: sb.append(", handler=");
225: sb.append(handlers);
226: }
227: sb.append("]");
228: return (sb.toString());
229:
230: }
231:
232: }
|