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