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.Map;
021: import java.util.jar.JarFile;
022:
023: import javax.wsdl.Definition;
024: import javax.wsdl.Port;
025: import javax.xml.namespace.QName;
026:
027: import org.apache.geronimo.common.DeploymentException;
028: import org.apache.geronimo.xbeans.j2ee.JavaWsdlMappingType;
029: import org.apache.geronimo.xbeans.j2ee.PortComponentHandlerType;
030: import org.apache.geronimo.xbeans.j2ee.ServiceEndpointInterfaceMappingType;
031:
032: /**
033: * @version $Rev: 561663 $ $Date: 2007-07-31 22:15:55 -0700 (Tue, 31 Jul 2007) $
034: */
035: public class PortInfo {
036: private final String portComponentName;
037: private final QName portQName;
038: private final String seInterfaceName;
039: private final PortComponentHandlerType[] handlers;
040: private final SharedPortInfo sharedPortInfo;
041:
042: // set after initialize is called
043: private SchemaInfoBuilder schemaInfoBuilder;
044: private JavaWsdlMappingType javaWsdlMapping;
045: private Port port;
046: private ServiceEndpointInterfaceMappingType seiMapping;
047: private URI contextURI;
048: private String location;
049:
050: public PortInfo(SharedPortInfo sharedPortInfo,
051: String portComponentName, QName portQName,
052: String seiInterfaceName,
053: PortComponentHandlerType[] handlers, String location) {
054: this .sharedPortInfo = sharedPortInfo;
055: this .portComponentName = portComponentName;
056: this .portQName = portQName;
057: this .seInterfaceName = seiInterfaceName;
058: this .handlers = handlers;
059: this .location = location;
060: }
061:
062: public DescriptorVersion getDescriptorVersion() {
063: return this .sharedPortInfo.getDescriptorVersion();
064: }
065:
066: public String getWsdlLocation() {
067: return this .sharedPortInfo.getWsdlLocation();
068: }
069:
070: public String getPortComponentName() {
071: return portComponentName;
072: }
073:
074: public QName getPortQName() {
075: return portQName;
076: }
077:
078: public Port getPort() {
079: return port;
080: }
081:
082: public SchemaInfoBuilder getSchemaInfoBuilder() {
083: return schemaInfoBuilder;
084: }
085:
086: public Definition getDefinition() {
087: return schemaInfoBuilder.getDefinition();
088: }
089:
090: public JavaWsdlMappingType getJavaWsdlMapping() {
091: return javaWsdlMapping;
092: }
093:
094: public String getServiceEndpointInterfaceName() {
095: return seInterfaceName;
096: }
097:
098: public ServiceEndpointInterfaceMappingType getServiceEndpointInterfaceMapping() {
099: return seiMapping;
100: }
101:
102: public PortComponentHandlerType[] getHandlers() {
103: return handlers;
104: }
105:
106: public URI getContextURI() {
107: return contextURI;
108: }
109:
110: public void initialize(JarFile moduleFile)
111: throws DeploymentException {
112: this .sharedPortInfo.initialize(moduleFile);
113:
114: this .schemaInfoBuilder = this .sharedPortInfo
115: .getSchemaInfoBuilder();
116: this .javaWsdlMapping = this .sharedPortInfo.getJavaWsdlMapping();
117:
118: QName portQName = getPortQName();
119: String portComponentName = getPortComponentName();
120: String seiInterfaceName = getServiceEndpointInterfaceName();
121:
122: Map wsdlPortMap = this .schemaInfoBuilder.getPortMap();
123: Port wsdlPort = (Port) wsdlPortMap
124: .get(portQName.getLocalPart());
125: if (wsdlPort == null) {
126: throw new DeploymentException(
127: "No WSDL Port definition for port-component "
128: + portComponentName);
129: }
130: this .port = wsdlPort;
131:
132: this .seiMapping = this .sharedPortInfo.getSEIMappings().get(
133: seiInterfaceName);
134:
135: this .location = this .schemaInfoBuilder.movePortLocation(
136: portQName.getLocalPart(), this .location);
137:
138: try {
139: this .contextURI = new URI(this .location);
140: } catch (URISyntaxException e) {
141: throw new DeploymentException(
142: "Could not construct URI for web service location",
143: e);
144: }
145: }
146: }
|