use of com.sun.xml.ws.model.ReflectAnnotationReader in project metro-jax-ws by eclipse-ee4j.
the class EndpointFactory method getDefaultServiceName.
@NotNull
public static QName getDefaultServiceName(Class<?> implType, boolean isStandard, MetadataReader metadataReader) {
if (metadataReader == null) {
metadataReader = new ReflectAnnotationReader();
}
QName serviceName;
WebServiceProvider wsProvider = metadataReader.getAnnotation(WebServiceProvider.class, implType);
if (wsProvider != null) {
String tns = wsProvider.targetNamespace();
String local = wsProvider.serviceName();
serviceName = new QName(tns, local);
} else {
serviceName = RuntimeModeler.getServiceName(implType, metadataReader, isStandard);
}
assert serviceName != null;
return serviceName;
}
use of com.sun.xml.ws.model.ReflectAnnotationReader in project metro-jax-ws by eclipse-ee4j.
the class EndpointFactory method getDefaultPortName.
@NotNull
public static QName getDefaultPortName(QName serviceName, Class<?> implType, boolean isStandard, MetadataReader metadataReader) {
if (metadataReader == null) {
metadataReader = new ReflectAnnotationReader();
}
QName portName;
WebServiceProvider wsProvider = metadataReader.getAnnotation(WebServiceProvider.class, implType);
if (wsProvider != null) {
String tns = wsProvider.targetNamespace();
String local = wsProvider.portName();
portName = new QName(tns, local);
} else {
portName = RuntimeModeler.getPortName(implType, metadataReader, serviceName.getNamespaceURI(), isStandard);
}
assert portName != null;
return portName;
}
use of com.sun.xml.ws.model.ReflectAnnotationReader in project metro-jax-ws by eclipse-ee4j.
the class EndpointFactory method verifyImplementorClass.
/**
* Verifies if the endpoint implementor class has @WebService or @WebServiceProvider
* annotation; passing MetadataReader instance allows to read annotations from
* xml descriptor instead of class's annotations
*
* @return
* true if it is a Provider or AsyncProvider endpoint
* false otherwise
* @throws java.lang.IllegalArgumentException
* If it doesn't have any one of @WebService or @WebServiceProvider
* If it has both @WebService and @WebServiceProvider annotations
*/
public static boolean verifyImplementorClass(Class<?> clz, MetadataReader metadataReader) {
if (metadataReader == null) {
metadataReader = new ReflectAnnotationReader();
}
WebServiceProvider wsProvider = metadataReader.getAnnotation(WebServiceProvider.class, clz);
WebService ws = metadataReader.getAnnotation(WebService.class, clz);
if (wsProvider == null && ws == null) {
throw new IllegalArgumentException(clz + " has neither @WebService nor @WebServiceProvider annotation");
}
if (wsProvider != null && ws != null) {
throw new IllegalArgumentException(clz + " has both @WebService and @WebServiceProvider annotations");
}
if (wsProvider != null) {
if (Provider.class.isAssignableFrom(clz) || AsyncProvider.class.isAssignableFrom(clz)) {
return true;
}
throw new IllegalArgumentException(clz + " doesn't implement Provider or AsyncProvider interface");
}
return false;
}
use of com.sun.xml.ws.model.ReflectAnnotationReader in project metro-jax-ws by eclipse-ee4j.
the class HandlerAnnotationProcessor method getSEI.
static Class getSEI(Class<?> clazz, MetadataReader metadataReader) {
if (metadataReader == null) {
metadataReader = new ReflectAnnotationReader();
}
if (Provider.class.isAssignableFrom(clazz) || AsyncProvider.class.isAssignableFrom(clazz)) {
// No SEI for Provider Implementation
return null;
}
if (Service.class.isAssignableFrom(clazz)) {
// No SEI for Service class
return null;
}
WebService webService = metadataReader.getAnnotation(WebService.class, clazz);
if (webService == null) {
throw new UtilException("util.handler.no.webservice.annotation", clazz.getCanonicalName());
}
String ei = webService.endpointInterface();
if (ei.length() > 0) {
clazz = getClass(webService.endpointInterface());
WebService ws = metadataReader.getAnnotation(WebService.class, clazz);
if (ws == null) {
throw new UtilException("util.handler.endpoint.interface.no.webservice", webService.endpointInterface());
}
return clazz;
}
return null;
}
use of com.sun.xml.ws.model.ReflectAnnotationReader in project metro-jax-ws by eclipse-ee4j.
the class HandlerAnnotationProcessor method buildHandlerInfo.
/**
* <p>This method is called by
* {@link EndpointFactory} when
* they have an annotated class.
*
* <p>If there is no handler chain annotation on the class,
* this method will return null. Otherwise it will load the
* class and call the parseHandlerFile method to read the
* information.
*
* @return A HandlerAnnotationInfo object that stores the
* handlers and roles. Will return null if the class passed
* in has no handler chain annotation.
*/
public static HandlerAnnotationInfo buildHandlerInfo(@NotNull Class<?> clazz, QName serviceName, QName portName, WSBinding binding) {
MetadataReader metadataReader = EndpointFactory.getExternalMetadatReader(clazz, binding);
if (metadataReader == null) {
metadataReader = new ReflectAnnotationReader();
}
// clazz = checkClass(clazz);
HandlerChain handlerChain = metadataReader.getAnnotation(HandlerChain.class, clazz);
if (handlerChain == null) {
clazz = getSEI(clazz, metadataReader);
if (clazz != null)
handlerChain = metadataReader.getAnnotation(HandlerChain.class, clazz);
if (handlerChain == null)
return null;
}
if (clazz.getAnnotation(SOAPMessageHandlers.class) != null) {
throw new UtilException("util.handler.cannot.combine.soapmessagehandlers");
}
InputStream iStream = getFileAsStream(clazz, handlerChain);
XMLStreamReader reader = XMLStreamReaderFactory.create(null, iStream, true);
XMLStreamReaderUtil.nextElementContent(reader);
HandlerAnnotationInfo handlerAnnInfo = HandlerChainsModel.parseHandlerFile(reader, clazz.getClassLoader(), serviceName, portName, binding);
try {
reader.close();
iStream.close();
} catch (XMLStreamException | IOException e) {
e.printStackTrace();
throw new UtilException(e.getMessage());
}
return handlerAnnInfo;
}
Aggregations