001: /*
002: * Copyright (c) 1998-2007 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Emil Ong
028: */
029:
030: package com.caucho.soap.jaxws.handlerchain;
031:
032: import java.util.*;
033: import javax.xml.bind.annotation.*;
034: import javax.xml.namespace.QName;
035: import javax.xml.ws.handler.PortInfo;
036:
037: @XmlRootElement(name="handler-chains",namespace="http://java.sun.com/xml/ns/javaee")
038: public class HandlerChain {
039: private QName _portNamePattern;
040: private String _bindingId;
041: private List<Handler> _handlers;
042:
043: @XmlElement(name="handler",namespace="http://java.sun.com/xml/ns/javaee")
044: public List<Handler> getHandler() {
045: if (_handlers == null)
046: _handlers = new ArrayList<Handler>();
047:
048: return _handlers;
049: }
050:
051: public void setHandler(List<Handler> handlers) {
052: _handlers = handlers;
053: }
054:
055: @XmlElement(name="port-name-pattern",namespace="http://java.sun.com/xml/ns/javaee")
056: public QName getPortNamePattern() {
057: return _portNamePattern;
058: }
059:
060: public void setPortNamePattern(QName portNamePattern) {
061: _portNamePattern = portNamePattern;
062: }
063:
064: @XmlElement(name="protocol-bindings",namespace="http://java.sun.com/xml/ns/javaee")
065: public String getBindingID() {
066: return _bindingId;
067: }
068:
069: public void setBindingID(String protocolBindings) {
070: if ("##SOAP11_HTTP".equals(protocolBindings))
071: _bindingId = "http://schemas.xmlsoap.org/wsdl/soap/http";
072:
073: else if ("##SOAP11_HTTP_MTOM".equals(protocolBindings))
074: _bindingId = "http://schemas.xmlsoap.org/wsdl/soap/http?mtom=true";
075:
076: else if ("##SOAP12_HTTP".equals(protocolBindings))
077: _bindingId = "http://www.w3.org/2003/05/soap/bindings/HTTP/";
078:
079: else if ("##SOAP12_HTTP_MTOM".equals(protocolBindings))
080: _bindingId = "http://www.w3.org/2003/05/soap/bindings/HTTP/?mtom=true";
081:
082: else if ("##XML_HTTP".equals(protocolBindings))
083: _bindingId = "http://www.w3.org/2004/08/wsdl/http";
084:
085: else
086: _bindingId = protocolBindings; // XXX??
087: }
088:
089: public boolean isDefault() {
090: return _bindingId == null && _portNamePattern == null;
091: }
092:
093: public List<javax.xml.ws.handler.Handler> toHandlerList() {
094: List<javax.xml.ws.handler.Handler> list = new ArrayList<javax.xml.ws.handler.Handler>();
095:
096: for (Handler handler : getHandler())
097: list.add(handler.toHandler());
098:
099: return list;
100: }
101: }
|