--- /dev/null
+/*\r
+ * Copyright 2006 The Apache Software Foundation.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+\r
+package org.apache.catalina.deploy;\r
+\r
+import java.io.Serializable;\r
+\r
+/**\r
+ * Representation of a web service reference for a web application, as\r
+ * represented in a <code><service-ref></code> element in the\r
+ * deployment descriptor.\r
+ *\r
+ * @author Fabien Carrion\r
+ * @version $Revision: 303342 $ $Date: 2005-03-15 23:29:49 -0700 (Web, 15 Mar 2006) $\r
+ */\r
+\r
+public class ContextService extends ResourceBase implements Serializable {\r
+\r
+\r
+ // ------------------------------------------------------------- Properties\r
+\r
+\r
+ /**\r
+ * The WebService reference name.\r
+ */\r
+ private String displayname = null;\r
+\r
+ public String getDisplayname() {\r
+ return (this.displayname);\r
+ }\r
+\r
+ public void setDisplayname(String displayname) {\r
+ this.displayname = displayname;\r
+ }\r
+\r
+ /**\r
+ * An icon for this WebService.\r
+ */\r
+ private String icon = null;\r
+\r
+ public String getIcon() {\r
+ return (this.icon);\r
+ }\r
+\r
+ public void setIcon(String icon) {\r
+ this.icon = icon;\r
+ }\r
+\r
+ /**\r
+ * An icon for this WebService.\r
+ */\r
+ private String serviceinterface = null;\r
+\r
+ public String getServiceinterface() {\r
+ return (this.serviceinterface);\r
+ }\r
+\r
+ public void setServiceinterface(String serviceinterface) {\r
+ this.serviceinterface = serviceinterface;\r
+ }\r
+\r
+ /**\r
+ * Contains the location (relative to the root of\r
+ * the module) of the web service WSDL description.\r
+ */\r
+ private String wsdlfile = null;\r
+\r
+ public String getWsdlfile() {\r
+ return (this.wsdlfile);\r
+ }\r
+\r
+ public void setWsdlfile(String wsdlfile) {\r
+ this.wsdlfile = wsdlfile;\r
+ }\r
+\r
+ /**\r
+ * A file specifying the correlation of the WSDL definition\r
+ * to the interfaces (Service Endpoint Interface, Service Interface). \r
+ */\r
+ private String jaxrpcmappingfile = null;\r
+\r
+ public String getJaxrpcmappingfile() {\r
+ return (this.jaxrpcmappingfile);\r
+ }\r
+\r
+ public void setJaxrpcmappingfile(String jaxrpcmappingfile) {\r
+ this.jaxrpcmappingfile = jaxrpcmappingfile;\r
+ }\r
+\r
+ /**\r
+ * Declares the specific WSDL service element that is being referred to.\r
+ * It is not specified if no wsdl-file is declared or if WSDL contains only\r
+ * 1 service element.\r
+ *\r
+ * A service-qname is composed by a namespaceURI and a localpart.\r
+ * It must be defined if more than 1 service is declared in the WSDL.\r
+ *\r
+ * serviceqname[0] : namespaceURI\r
+ * serviceqname[1] : localpart\r
+ */\r
+ private String[] serviceqname = new String[2];\r
+\r
+ public String[] getServiceqname() {\r
+ return (this.serviceqname);\r
+ }\r
+\r
+ public void setServiceqname(String[] serviceqname) {\r
+ this.serviceqname = serviceqname;\r
+ }\r
+\r
+ public void setServiceqname(String serviceqname, int i) {\r
+ this.serviceqname[i] = serviceqname;\r
+ }\r
+\r
+ public void setNamespaceURI(String namespaceuri) {\r
+ this.serviceqname[0] = namespaceuri;\r
+ }\r
+\r
+ public void setLocalpart(String localpart) {\r
+ this.serviceqname[1] = localpart;\r
+ }\r
+\r
+ /**\r
+ * Declares a client dependency on the container to resolving a Service Endpoint Interface\r
+ * to a WSDL port. It optionally associates the Service Endpoint Interface with a\r
+ * particular port-component.\r
+ *\r
+ * portcomponent[0] : service-endpoint-interface\r
+ * portcomponent[1] : port-component-link\r
+ */\r
+ private String[] portcomponent = new String[2];\r
+\r
+ public String[] getPortcomponent() {\r
+ return (this.portcomponent);\r
+ }\r
+\r
+ public void setPortcomponent(String[] portcomponent) {\r
+ this.portcomponent = portcomponent;\r
+ }\r
+\r
+ public void setPortcomponent(String portcomponent, int i) {\r
+ this.portcomponent[i] = portcomponent;\r
+ }\r
+\r
+ public void setServiceendpoint(String serviceendpoint) {\r
+ this.portcomponent[0] = serviceendpoint;\r
+ }\r
+\r
+ public void setPortlink(String portlink) {\r
+ this.portcomponent[1] = portlink;\r
+ }\r
+\r
+ /**\r
+ * A list of Handler to use for this service-ref.\r
+ *\r
+ * The instanciation of the handler have to be done.\r
+ */\r
+ private String handler = null;\r
+\r
+ public String getHandler() {\r
+ return (this.handler);\r
+ }\r
+\r
+ public void setHandler(String handler) {\r
+ this.handler = handler;\r
+ }\r
+\r
+\r
+ // --------------------------------------------------------- Public Methods\r
+\r
+\r
+ /**\r
+ * Return a String representation of this object.\r
+ */\r
+ public String toString() {\r
+\r
+ StringBuffer sb = new StringBuffer("ContextService[");\r
+ sb.append("name=");\r
+ sb.append(getName());\r
+ if (getDescription() != null) {\r
+ sb.append(", description=");\r
+ sb.append(getDescription());\r
+ }\r
+ if (getType() != null) {\r
+ sb.append(", type=");\r
+ sb.append(getType());\r
+ }\r
+ if (displayname != null) {\r
+ sb.append(", displayname=");\r
+ sb.append(displayname);\r
+ }\r
+ if (icon != null) {\r
+ sb.append(", icon=");\r
+ sb.append(icon);\r
+ }\r
+ if (wsdlfile != null) {\r
+ sb.append(", wsdl-file=");\r
+ sb.append(wsdlfile);\r
+ }\r
+ if (jaxrpcmappingfile != null) {\r
+ sb.append(", jaxrpc-mapping-file=");\r
+ sb.append(jaxrpcmappingfile);\r
+ }\r
+ if (serviceqname != null) {\r
+ sb.append(", service-qname=");\r
+ sb.append(serviceqname);\r
+ }\r
+ if (portcomponent != null) {\r
+ sb.append(", port-component=");\r
+ sb.append(portcomponent);\r
+ }\r
+ if (handler != null) {\r
+ sb.append(", handler=");\r
+ sb.append(handler);\r
+ }\r
+ sb.append("]");\r
+ return (sb.toString());\r
+\r
+ }\r
+\r
+}\r
\r
\r
/**\r
+ * The web service references for this web application, keyed by name.\r
+ */\r
+ private HashMap services = new HashMap();\r
+\r
+\r
+ /**\r
* The transaction for this webapp.\r
*/\r
private ContextTransaction transaction = null;\r
- \r
+\r
\r
/**\r
* The property change support for this component.\r
\r
\r
/**\r
+ * Add a web service reference for this web application.\r
+ *\r
+ * @param service New web service reference\r
+ */\r
+ public void addService(ContextService service) {\r
+ \r
+ if (entries.containsKey(service.getName())) {\r
+ return;\r
+ } else {\r
+ entries.put(service.getName(), service.getType());\r
+ }\r
+ \r
+ synchronized (services) {\r
+ service.setNamingResources(this);\r
+ services.put(service.getName(), service);\r
+ }\r
+ support.firePropertyChange("service", null, service);\r
+ \r
+ }\r
+\r
+\r
+ /**\r
* Return the EJB resource reference with the specified name, if any;\r
* otherwise, return <code>null</code>.\r
*\r
\r
\r
/**\r
+ * Return the web service reference for the specified\r
+ * name, if any; otherwise return <code>null</code>.\r
+ *\r
+ * @param name Name of the desired web service\r
+ */\r
+ public ContextService findService(String name) {\r
+\r
+ synchronized (services) {\r
+ return ((ContextService) services.get(name));\r
+ }\r
+\r
+ }\r
+\r
+\r
+ /**\r
+ * Return the defined web service references for this application. If\r
+ * none have been defined, a zero-length array is returned.\r
+ */\r
+ public ContextService[] findServices() {\r
+ \r
+ synchronized (services) {\r
+ ContextService results[] = new ContextService[services.size()];\r
+ return ((ContextService[]) services.values().toArray(results));\r
+ }\r
+ \r
+ }\r
+\r
+\r
+ /**\r
* Return true if the name specified already exists.\r
*/\r
public boolean exists(String name) {\r
}\r
\r
\r
+ /**\r
+ * Remove any web service reference with the specified name.\r
+ *\r
+ * @param name Name of the web service reference to remove\r
+ */\r
+ public void removeService(String name) {\r
+ \r
+ entries.remove(name);\r
+ \r
+ ContextService service = null;\r
+ synchronized (services) {\r
+ service = (ContextService) services.remove(name);\r
+ }\r
+ if (service != null) {\r
+ support.firePropertyChange("service", service, null);\r
+ service.setNamingResources(null);\r
+ }\r
+ \r
+ }\r
+\r
+\r
}\r
digester.addCallMethod(prefix + "web-app/security-role/role-name",\r
"addSecurityRole", 0);\r
\r
+ digester.addObjectCreate(prefix + "web-app/service-ref",\r
+ "org.apache.catalina.deploy.ContextService");\r
+ digester.addRule(prefix + "web-app/service-ref",\r
+ new SetNextNamingRule("addService",\r
+ "org.apache.catalina.deploy.ContextService"));\r
+ \r
+ digester.addCallMethod(prefix + "web-app/service-ref/description",\r
+ "setDescription", 0);\r
+ digester.addCallMethod(prefix + "web-app/service-ref/display-name",\r
+ "setDisplayname", 0);\r
+ digester.addCallMethod(prefix + "web-app/service-ref/icon",\r
+ "setIcon", 0);\r
+ digester.addCallMethod(prefix + "web-app/service-ref/service-ref-name",\r
+ "setName", 0);\r
+ digester.addCallMethod(prefix + "web-app/service-ref/service-interface",\r
+ "setServiceinterface", 0);\r
+ digester.addCallMethod(prefix + "web-app/service-ref/wsdl-file",\r
+ "setWsdlfile", 0);\r
+ digester.addCallMethod(prefix + "web-app/service-ref/jaxrpc-mapping-file",\r
+ "setJaxrpcmappingfile", 0);\r
+ digester.addCallMethod(prefix + "web-app/service-ref/service-qname/namespaceURI",\r
+ "setNamespaceURI", 0);\r
+ digester.addCallMethod(prefix + "web-app/service-ref/service-qname/localpart",\r
+ "setLocalpart", 0);\r
+ digester.addCallMethod(prefix + \r
+ "web-app/service-ref/port-component/service-endpoint-interface",\r
+ "setServiceendpoint", 0);\r
+ digester.addCallMethod(prefix + "web-app/service-ref/port-component/port-component-link",\r
+ "setPortlink", 0);\r
+ digester.addCallMethod(prefix + "web-app/service-ref/handler",\r
+ "setHandler", 0);\r
+ digester.addCallMethod(prefix + "web-app/service-ref/service-ref-type",\r
+ "setType", 0);\r
+ \r
digester.addRule(prefix + "web-app/servlet",\r
new WrapperCreateRule());\r
digester.addSetNext(prefix + "web-app/servlet",\r