From: remm Date: Thu, 6 Apr 2006 14:13:54 +0000 (+0000) Subject: - Add "support" (note: not in NamingContextListener yet) for service-ref (after all... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d5ba733c18db3a50dedad9c2ba25f33889930ae8;p=tomcat7.0 - Add "support" (note: not in NamingContextListener yet) for service-ref (after all, there's support for all other elements, so ...). - Submitted by Fabien Carrion. git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@391991 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/deploy/ContextService.java b/java/org/apache/catalina/deploy/ContextService.java new file mode 100644 index 000000000..1930502b8 --- /dev/null +++ b/java/org/apache/catalina/deploy/ContextService.java @@ -0,0 +1,235 @@ +/* + * Copyright 2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.catalina.deploy; + +import java.io.Serializable; + +/** + * Representation of a web service reference for a web application, as + * represented in a <service-ref> element in the + * deployment descriptor. + * + * @author Fabien Carrion + * @version $Revision: 303342 $ $Date: 2005-03-15 23:29:49 -0700 (Web, 15 Mar 2006) $ + */ + +public class ContextService extends ResourceBase implements Serializable { + + + // ------------------------------------------------------------- Properties + + + /** + * The WebService reference name. + */ + private String displayname = null; + + public String getDisplayname() { + return (this.displayname); + } + + public void setDisplayname(String displayname) { + this.displayname = displayname; + } + + /** + * An icon for this WebService. + */ + private String icon = null; + + public String getIcon() { + return (this.icon); + } + + public void setIcon(String icon) { + this.icon = icon; + } + + /** + * An icon for this WebService. + */ + private String serviceinterface = null; + + public String getServiceinterface() { + return (this.serviceinterface); + } + + public void setServiceinterface(String serviceinterface) { + this.serviceinterface = serviceinterface; + } + + /** + * Contains the location (relative to the root of + * the module) of the web service WSDL description. + */ + private String wsdlfile = null; + + public String getWsdlfile() { + return (this.wsdlfile); + } + + public void setWsdlfile(String wsdlfile) { + this.wsdlfile = wsdlfile; + } + + /** + * A file specifying the correlation of the WSDL definition + * to the interfaces (Service Endpoint Interface, Service Interface). + */ + private String jaxrpcmappingfile = null; + + public String getJaxrpcmappingfile() { + return (this.jaxrpcmappingfile); + } + + public void setJaxrpcmappingfile(String jaxrpcmappingfile) { + this.jaxrpcmappingfile = jaxrpcmappingfile; + } + + /** + * Declares the specific WSDL service element that is being referred to. + * It is not specified if no wsdl-file is declared or if WSDL contains only + * 1 service element. + * + * A service-qname is composed by a namespaceURI and a localpart. + * It must be defined if more than 1 service is declared in the WSDL. + * + * serviceqname[0] : namespaceURI + * serviceqname[1] : localpart + */ + private String[] serviceqname = new String[2]; + + public String[] getServiceqname() { + return (this.serviceqname); + } + + public void setServiceqname(String[] serviceqname) { + this.serviceqname = serviceqname; + } + + public void setServiceqname(String serviceqname, int i) { + this.serviceqname[i] = serviceqname; + } + + public void setNamespaceURI(String namespaceuri) { + this.serviceqname[0] = namespaceuri; + } + + public void setLocalpart(String localpart) { + this.serviceqname[1] = localpart; + } + + /** + * Declares a client dependency on the container to resolving a Service Endpoint Interface + * to a WSDL port. It optionally associates the Service Endpoint Interface with a + * particular port-component. + * + * portcomponent[0] : service-endpoint-interface + * portcomponent[1] : port-component-link + */ + private String[] portcomponent = new String[2]; + + public String[] getPortcomponent() { + return (this.portcomponent); + } + + public void setPortcomponent(String[] portcomponent) { + this.portcomponent = portcomponent; + } + + public void setPortcomponent(String portcomponent, int i) { + this.portcomponent[i] = portcomponent; + } + + public void setServiceendpoint(String serviceendpoint) { + this.portcomponent[0] = serviceendpoint; + } + + public void setPortlink(String portlink) { + this.portcomponent[1] = portlink; + } + + /** + * A list of Handler to use for this service-ref. + * + * The instanciation of the handler have to be done. + */ + private String handler = null; + + public String getHandler() { + return (this.handler); + } + + public void setHandler(String handler) { + this.handler = handler; + } + + + // --------------------------------------------------------- Public Methods + + + /** + * Return a String representation of this object. + */ + public String toString() { + + StringBuffer sb = new StringBuffer("ContextService["); + sb.append("name="); + sb.append(getName()); + if (getDescription() != null) { + sb.append(", description="); + sb.append(getDescription()); + } + if (getType() != null) { + sb.append(", type="); + sb.append(getType()); + } + if (displayname != null) { + sb.append(", displayname="); + sb.append(displayname); + } + if (icon != null) { + sb.append(", icon="); + sb.append(icon); + } + if (wsdlfile != null) { + sb.append(", wsdl-file="); + sb.append(wsdlfile); + } + if (jaxrpcmappingfile != null) { + sb.append(", jaxrpc-mapping-file="); + sb.append(jaxrpcmappingfile); + } + if (serviceqname != null) { + sb.append(", service-qname="); + sb.append(serviceqname); + } + if (portcomponent != null) { + sb.append(", port-component="); + sb.append(portcomponent); + } + if (handler != null) { + sb.append(", handler="); + sb.append(handler); + } + sb.append("]"); + return (sb.toString()); + + } + +} diff --git a/java/org/apache/catalina/deploy/NamingResources.java b/java/org/apache/catalina/deploy/NamingResources.java index 18036aa3c..fdb06356c 100644 --- a/java/org/apache/catalina/deploy/NamingResources.java +++ b/java/org/apache/catalina/deploy/NamingResources.java @@ -108,10 +108,16 @@ public class NamingResources implements Serializable { /** + * The web service references for this web application, keyed by name. + */ + private HashMap services = new HashMap(); + + + /** * The transaction for this webapp. */ private ContextTransaction transaction = null; - + /** * The property change support for this component. @@ -325,6 +331,28 @@ public class NamingResources implements Serializable { /** + * Add a web service reference for this web application. + * + * @param service New web service reference + */ + public void addService(ContextService service) { + + if (entries.containsKey(service.getName())) { + return; + } else { + entries.put(service.getName(), service.getType()); + } + + synchronized (services) { + service.setNamingResources(this); + services.put(service.getName(), service); + } + support.firePropertyChange("service", null, service); + + } + + + /** * Return the EJB resource reference with the specified name, if any; * otherwise, return null. * @@ -533,6 +561,35 @@ public class NamingResources implements Serializable { /** + * Return the web service reference for the specified + * name, if any; otherwise return null. + * + * @param name Name of the desired web service + */ + public ContextService findService(String name) { + + synchronized (services) { + return ((ContextService) services.get(name)); + } + + } + + + /** + * Return the defined web service references for this application. If + * none have been defined, a zero-length array is returned. + */ + public ContextService[] findServices() { + + synchronized (services) { + ContextService results[] = new ContextService[services.size()]; + return ((ContextService[]) services.values().toArray(results)); + } + + } + + + /** * Return true if the name specified already exists. */ public boolean exists(String name) { @@ -702,4 +759,25 @@ public class NamingResources implements Serializable { } + /** + * Remove any web service reference with the specified name. + * + * @param name Name of the web service reference to remove + */ + public void removeService(String name) { + + entries.remove(name); + + ContextService service = null; + synchronized (services) { + service = (ContextService) services.remove(name); + } + if (service != null) { + support.firePropertyChange("service", service, null); + service.setNamingResources(null); + } + + } + + } diff --git a/java/org/apache/catalina/startup/WebRuleSet.java b/java/org/apache/catalina/startup/WebRuleSet.java index 2518eb723..e0db69418 100644 --- a/java/org/apache/catalina/startup/WebRuleSet.java +++ b/java/org/apache/catalina/startup/WebRuleSet.java @@ -369,6 +369,40 @@ public class WebRuleSet extends RuleSetBase { digester.addCallMethod(prefix + "web-app/security-role/role-name", "addSecurityRole", 0); + digester.addObjectCreate(prefix + "web-app/service-ref", + "org.apache.catalina.deploy.ContextService"); + digester.addRule(prefix + "web-app/service-ref", + new SetNextNamingRule("addService", + "org.apache.catalina.deploy.ContextService")); + + digester.addCallMethod(prefix + "web-app/service-ref/description", + "setDescription", 0); + digester.addCallMethod(prefix + "web-app/service-ref/display-name", + "setDisplayname", 0); + digester.addCallMethod(prefix + "web-app/service-ref/icon", + "setIcon", 0); + digester.addCallMethod(prefix + "web-app/service-ref/service-ref-name", + "setName", 0); + digester.addCallMethod(prefix + "web-app/service-ref/service-interface", + "setServiceinterface", 0); + digester.addCallMethod(prefix + "web-app/service-ref/wsdl-file", + "setWsdlfile", 0); + digester.addCallMethod(prefix + "web-app/service-ref/jaxrpc-mapping-file", + "setJaxrpcmappingfile", 0); + digester.addCallMethod(prefix + "web-app/service-ref/service-qname/namespaceURI", + "setNamespaceURI", 0); + digester.addCallMethod(prefix + "web-app/service-ref/service-qname/localpart", + "setLocalpart", 0); + digester.addCallMethod(prefix + + "web-app/service-ref/port-component/service-endpoint-interface", + "setServiceendpoint", 0); + digester.addCallMethod(prefix + "web-app/service-ref/port-component/port-component-link", + "setPortlink", 0); + digester.addCallMethod(prefix + "web-app/service-ref/handler", + "setHandler", 0); + digester.addCallMethod(prefix + "web-app/service-ref/service-ref-type", + "setType", 0); + digester.addRule(prefix + "web-app/servlet", new WrapperCreateRule()); digester.addSetNext(prefix + "web-app/servlet",