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: */package org.apache.geronimo.webservices.builder;
017:
018: import java.net.URI;
019: import java.net.URISyntaxException;
020: import java.util.Collections;
021: import java.util.HashMap;
022: import java.util.Map;
023: import java.util.jar.JarFile;
024:
025: import org.apache.geronimo.common.DeploymentException;
026: import org.apache.geronimo.xbeans.j2ee.JavaWsdlMappingType;
027: import org.apache.geronimo.xbeans.j2ee.ServiceEndpointInterfaceMappingType;
028:
029: /**
030: * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
031: */
032: public class SharedPortInfo {
033:
034: private String jaxrpcMappingFile;
035: private String wsdlLocation;
036: private JavaWsdlMappingType javaWsdlMapping;
037: private SchemaInfoBuilder schemaInfoBuilder;
038: private DescriptorVersion ddVersion;
039:
040: public SharedPortInfo(String wsdlLocation, String jaxrpcMappingFile) {
041: this (wsdlLocation, jaxrpcMappingFile, DescriptorVersion.UNKNOWN);
042: }
043:
044: public SharedPortInfo(String wsdlLocation,
045: String jaxrpcMappingFile, DescriptorVersion ddVersion) {
046: this .wsdlLocation = wsdlLocation;
047: this .jaxrpcMappingFile = jaxrpcMappingFile;
048: this .ddVersion = ddVersion;
049: }
050:
051: public DescriptorVersion getDescriptorVersion() {
052: return this .ddVersion;
053: }
054:
055: public String getWsdlLocation() {
056: return this .wsdlLocation;
057: }
058:
059: public String getJaxrpcMappingFile() {
060: return this .jaxrpcMappingFile;
061: }
062:
063: public void initialize(JarFile moduleFile)
064: throws DeploymentException {
065: if (this .jaxrpcMappingFile == null) {
066: throw new DeploymentException(
067: "JAX-RPC mapping file is required.");
068: }
069: if (this .wsdlLocation == null) {
070: throw new DeploymentException("WSDL file is required.");
071: }
072:
073: if (this .javaWsdlMapping == null) {
074: URI jaxrpcMappingURI;
075: try {
076: jaxrpcMappingURI = new URI(this .jaxrpcMappingFile);
077: } catch (URISyntaxException e) {
078: throw new DeploymentException(
079: "Could not construct jaxrpc mapping uri from "
080: + this .jaxrpcMappingFile, e);
081: }
082:
083: this .javaWsdlMapping = WSDescriptorParser
084: .readJaxrpcMapping(moduleFile, jaxrpcMappingURI);
085: }
086:
087: if (this .schemaInfoBuilder == null) {
088: URI wsdlURI;
089: try {
090: wsdlURI = new URI(this .wsdlLocation);
091: } catch (URISyntaxException e) {
092: throw new DeploymentException(
093: "could not construct wsdl uri from "
094: + this .wsdlLocation, e);
095: }
096:
097: this .schemaInfoBuilder = new SchemaInfoBuilder(moduleFile,
098: wsdlURI);
099: }
100: }
101:
102: public JavaWsdlMappingType getJavaWsdlMapping() {
103: return this .javaWsdlMapping;
104: }
105:
106: public SchemaInfoBuilder getSchemaInfoBuilder() {
107: return schemaInfoBuilder;
108: }
109:
110: public Map<String, ServiceEndpointInterfaceMappingType> getSEIMappings() {
111: if (this .javaWsdlMapping == null) {
112: return Collections.emptyMap();
113: }
114: HashMap<String, ServiceEndpointInterfaceMappingType> seiMappings = new HashMap<String, ServiceEndpointInterfaceMappingType>();
115: ServiceEndpointInterfaceMappingType[] mappings = this .javaWsdlMapping
116: .getServiceEndpointInterfaceMappingArray();
117: for (ServiceEndpointInterfaceMappingType seiMapping : mappings) {
118: seiMappings.put(seiMapping.getServiceEndpointInterface()
119: .getStringValue().trim(), seiMapping);
120: }
121: return seiMappings;
122: }
123:
124: }
|