com.arjuna.webservices11.wsaddr.JAXBContextUnmarshalAction Maven / Gradle / Ivy
The newest version!
/*
Copyright The Narayana Authors
SPDX-License-Identifier: Apache-2.0
*/
package com.arjuna.webservices11.wsaddr;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import javax.xml.transform.Source;
import jakarta.xml.ws.EndpointReference;
import jakarta.xml.ws.WebServiceException;
import java.security.PrivilegedAction;
/**
* @author Gytis Trikleris
*/
public final class JAXBContextUnmarshalAction implements PrivilegedAction {
private final JAXBContext jaxbContext;
private final Source source;
private final Class endpointReferenceClass;
private JAXBContextUnmarshalAction(final JAXBContext jaxbContext, final Source source,
final Class endpointReferenceClass) {
this.jaxbContext = jaxbContext;
this.source = source;
this.endpointReferenceClass = endpointReferenceClass;
}
public static JAXBContextUnmarshalAction getInstance(
final JAXBContext jaxbContext, final Source source, final Class endpointReferenceClass) {
return new JAXBContextUnmarshalAction<>(jaxbContext, source, endpointReferenceClass);
}
@Override
public T run() {
try {
return jaxbContext.createUnmarshaller().unmarshal(source, endpointReferenceClass).getValue();
} catch (final JAXBException e) {
throw new WebServiceException("Error unmarshalling NativeEndpointReference ", e);
} catch (final ClassCastException e) {
throw new WebServiceException("Source did not contain NativeEndpointReference", e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy