use of com.sun.xml.ws.server.ServerRtException in project metro-jax-ws by eclipse-ee4j.
the class AbstractInstanceResolver method findAnnotatedMethod.
/**
* Finds the method that has the given annotation, while making sure that
* there's only at most one such method.
*/
@Nullable
protected final Method findAnnotatedMethod(Class clazz, Class<? extends Annotation> annType) {
boolean once = false;
Method r = null;
for (Method method : clazz.getDeclaredMethods()) {
if (method.getAnnotation(annType) != null) {
if (once)
throw new ServerRtException(ServerMessages.ANNOTATION_ONLY_ONCE(annType));
if (method.getParameterTypes().length != 0)
throw new ServerRtException(ServerMessages.NOT_ZERO_PARAMETERS(method));
r = method;
once = true;
}
}
return r;
}
use of com.sun.xml.ws.server.ServerRtException in project metro-jax-ws by eclipse-ee4j.
the class SDDocumentSource method create.
/**
* Creates {@link SDDocumentSource} from resource path using resolvingClass to read the resource.
* Required for Jigsaw runtime.
*
* @param resolvingClass class used to read resource
* @param path resource path
*/
private static SDDocumentSource create(final String path, final Class<?> resolvingClass) {
return new SDDocumentSource() {
@Override
public XMLStreamReader read(XMLInputFactory xif) throws IOException, XMLStreamException {
InputStream is = inputStream();
return new TidyXMLStreamReader(xif.createXMLStreamReader(path, is), is);
}
@Override
public XMLStreamReader read() throws IOException, XMLStreamException {
InputStream is = inputStream();
return new TidyXMLStreamReader(XMLStreamReaderFactory.create(path, is, false), is);
}
@Override
public URL getSystemId() {
try {
return new URL("file://" + path);
} catch (MalformedURLException e) {
return null;
}
}
private InputStream inputStream() throws IOException {
java.lang.Module module = resolvingClass.getModule();
InputStream stream = module.getResourceAsStream(path);
if (stream != null) {
return stream;
}
throw new ServerRtException("cannot.load.wsdl", path);
}
};
}
use of com.sun.xml.ws.server.ServerRtException in project metro-jax-ws by eclipse-ee4j.
the class EndpointImpl method buildDocList.
/**
* Convert metadata sources using identity transform. So that we can
* reuse the Source object multiple times.
*/
private List<SDDocumentSource> buildDocList() {
List<SDDocumentSource> r = new ArrayList<>();
if (metadata != null) {
for (Source source : metadata) {
try {
XMLStreamBufferResult xsbr = XmlUtil.identityTransform(source, new XMLStreamBufferResult());
String systemId = source.getSystemId();
r.add(SDDocumentSource.create(new URL(systemId), xsbr.getXMLStreamBuffer()));
} catch (TransformerException | IOException | SAXException | ParserConfigurationException te) {
throw new ServerRtException("server.rt.err", te);
}
}
}
return r;
}
use of com.sun.xml.ws.server.ServerRtException in project metro-jax-ws by eclipse-ee4j.
the class XmlCatalogUtil method createEntityResolver.
/**
* Gets an EntityResolver using XML catalog
*/
public static EntityResolver createEntityResolver(@Nullable URL catalogUrl) {
ArrayList<URL> urlsArray = new ArrayList<>();
EntityResolver er;
if (catalogUrl != null) {
urlsArray.add(catalogUrl);
}
try {
er = createCatalogResolver(urlsArray);
} catch (Exception e) {
throw new ServerRtException("server.rt.err", e);
}
return er;
}
use of com.sun.xml.ws.server.ServerRtException in project metro-jax-ws by eclipse-ee4j.
the class DeploymentDescriptorParser method createBinding.
/**
* @param ddBindingId binding id explicitlyspecified in the DeploymentDescriptor or parameter
* @param implClass Endpoint Implementation class
* @param mtomEnabled represents mtom-enabled attribute in DD
* @param mtomThreshold threshold value specified in DD
* @return is returned with only MTOMFeature set resolving the various precendece rules
*/
private static WSBinding createBinding(String ddBindingId, Class implClass, String mtomEnabled, String mtomThreshold, String dataBindingMode) {
// Features specified through DD
WebServiceFeatureList features;
MTOMFeature mtomfeature = null;
if (mtomEnabled != null) {
if (mtomThreshold != null) {
mtomfeature = new MTOMFeature(Boolean.valueOf(mtomEnabled), Integer.parseInt(mtomThreshold));
} else {
mtomfeature = new MTOMFeature(Boolean.valueOf(mtomEnabled));
}
}
BindingID bindingID;
if (ddBindingId != null) {
bindingID = BindingID.parse(ddBindingId);
features = bindingID.createBuiltinFeatureList();
if (checkMtomConflict(features.get(MTOMFeature.class), mtomfeature)) {
throw new ServerRtException(ServerMessages.DD_MTOM_CONFLICT(ddBindingId, mtomEnabled));
}
} else {
bindingID = BindingID.parse(implClass);
// Since bindingID is coming from implclass,
// mtom through Feature annotation or DD takes precendece
features = new WebServiceFeatureList();
if (mtomfeature != null) {
// this wins over MTOM setting in bindingID
features.add(mtomfeature);
}
features.addAll(bindingID.createBuiltinFeatureList());
}
if (dataBindingMode != null) {
features.add(new DatabindingModeFeature(dataBindingMode));
}
return bindingID.createBinding(features.toArray());
}
Aggregations