1/* 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26package com.sun.xml.internal.ws.addressing.v200408; 27 28import javax.xml.bind.JAXBContext; 29import javax.xml.bind.JAXBException; 30import javax.xml.bind.Marshaller; 31import javax.xml.namespace.QName; 32import javax.xml.ws.WebServiceException; 33 34import com.sun.xml.internal.ws.addressing.WsaTubeHelper; 35import com.sun.xml.internal.ws.api.WSBinding; 36import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; 37import com.sun.xml.internal.ws.api.model.SEIModel; 38import org.w3c.dom.Element; 39 40/** 41 * @author Arun Gupta 42 */ 43public class WsaTubeHelperImpl extends WsaTubeHelper { 44 static final JAXBContext jc; 45 46 static { 47 try { 48 jc = JAXBContext.newInstance(ProblemAction.class, 49 ProblemHeaderQName.class); 50 } catch (JAXBException e) { 51 throw new WebServiceException(e); 52 } 53 } 54 55 public WsaTubeHelperImpl(WSDLPort wsdlPort, SEIModel seiModel, WSBinding binding) { 56 super(binding,seiModel,wsdlPort); 57 } 58 59 private Marshaller createMarshaller() throws JAXBException { 60 Marshaller marshaller = jc.createMarshaller(); 61 marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); 62 return marshaller; 63 } 64 65 @Override 66 public final void getProblemActionDetail(String action, Element element) { 67 ProblemAction pa = new ProblemAction(action); 68 try { 69 createMarshaller().marshal(pa, element); 70 } catch (JAXBException e) { 71 throw new WebServiceException(e); 72 } 73 } 74 75 @Override 76 public final void getInvalidMapDetail(QName name, Element element) { 77 ProblemHeaderQName phq = new ProblemHeaderQName(name); 78 try { 79 createMarshaller().marshal(phq, element); 80 } catch (JAXBException e) { 81 throw new WebServiceException(e); 82 } 83 } 84 85 @Override 86 public final void getMapRequiredDetail(QName name, Element element) { 87 getInvalidMapDetail(name, element); 88 } 89} 90