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.jaxws;
018
019 import java.io.Serializable;
020 import java.io.StringWriter;
021
022 import javax.xml.bind.JAXBContext;
023 import javax.xml.bind.JAXBElement;
024 import javax.xml.bind.Marshaller;
025 import javax.xml.namespace.QName;
026
027 public class PortInfo implements Serializable {
028
029 private String serviceName;
030
031 private String portName;
032
033 private String seiInterfaceName;
034
035 private String wsdlFile;
036
037 private String servletLink;
038
039 private String handlersAsXML;
040
041 private boolean mtomEnabled;
042
043 private String binding;
044
045 private QName wsdlPort;
046
047 private QName wsdlService;
048
049 private String location;
050
051 public String getPortName() {
052 return portName;
053 }
054
055 public void setPortName(String pn) {
056 portName = pn;
057 }
058
059 public String getServiceEndpointInterfaceName() {
060 return seiInterfaceName;
061 }
062
063 public void setServiceEndpointInterfaceName(String sei) {
064 seiInterfaceName = sei;
065 }
066
067 public String getServiceLink() {
068 return servletLink;
069 }
070
071 public void setServiceLink(String sl) {
072 servletLink = sl;
073 }
074
075 public String getWsdlFile() {
076 return wsdlFile;
077 }
078
079 public void setWsdlFile(String wf) {
080 wsdlFile = wf;
081 }
082
083 public String getServiceName() {
084 return serviceName;
085 }
086
087 public void setServiceName(String sn) {
088 serviceName = sn;
089 }
090
091 public void setEnableMTOM(boolean mtomEnabled) {
092 this.mtomEnabled = mtomEnabled;
093 }
094
095 public boolean isMTOMEnabled() {
096 return this.mtomEnabled;
097 }
098
099 public void setProtocolBinding(String binding) {
100 this.binding = binding;
101 }
102
103 public String getProtocolBinding() {
104 return binding;
105 }
106
107 /*
108 * This is a bit tricky here since JAXB generated classes are not serializable,
109 * so serialize the handler chain to XML and pass it as a String.
110 */
111
112 public void setHandlers(Class type, Object handlerChain) throws Exception {
113 if (handlerChain == null) {
114 return;
115 }
116
117 JAXBContext ctx = JAXBContext.newInstance(type);
118 Marshaller m = ctx.createMarshaller();
119 StringWriter writer = new StringWriter();
120 /*
121 * Since HandlerChainsType is a type, have to wrap it into some element
122 */
123 QName rootElement = new QName("", "root");
124 JAXBElement element =
125 new JAXBElement(rootElement, type, handlerChain);
126 m.marshal(element, writer);
127
128 this.handlersAsXML = writer.toString();
129 }
130
131 public <T>T getHandlers(Class<T> type) throws Exception {
132 return HandlerChainsUtils.toHandlerChains(this.handlersAsXML, type);
133 }
134
135 public QName getWsdlPort() {
136 return wsdlPort;
137 }
138
139 public void setWsdlPort(QName wsdlPort) {
140 this.wsdlPort = wsdlPort;
141 }
142
143 public QName getWsdlService() {
144 return wsdlService;
145 }
146
147 public void setWsdlService(QName wsdlService) {
148 this.wsdlService = wsdlService;
149 }
150
151 public String getLocation() {
152 return location;
153 }
154
155 public void setLocation(String location) {
156 this.location = location;
157 }
158
159 /*
160 * private String serviceName; private String portName; private String
161 * seiInterfaceName; private String wsdlFile; private String servletLink;
162 */
163 public String toString() {
164 return "[" + serviceName + ":" + portName + ":" + seiInterfaceName
165 + ":" + wsdlFile + "]";
166 }
167
168 public String getHandlersAsXML() {
169 return handlersAsXML;
170 }
171
172 public void setHandlersAsXML(String handlersAsXML) {
173 this.handlersAsXML = handlersAsXML;
174 }
175 }