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