/** * Verifies if the endpoint implementor class has @WebService or @WebServiceProvider * annotation * * @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) { WebServiceProvider wsProvider = clz.getAnnotation(WebServiceProvider.class); WebService ws = clz.getAnnotation(WebService.class); 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; }
@RefreshScope @Bean public Provider transportSTSProviderBean() { try { final SecurityTokenServiceProvider provider = new SecurityTokenServiceProvider(); provider.setIssueOperation(transportIssueDelegate()); provider.setValidateOperation(transportValidateDelegate()); return provider; } catch (final Exception e) { throw new BeanCreationException(e.getMessage(), e); } }
private Provider getProviderInstance() { Class<?> clazz = getProviderType(); if (!isValidProviderType(clazz)) { // TODO This will change once deployment code it in place throw ExceptionFactory.makeWebServiceException(Messages.getMessage("InvalidProvider", clazz.getName())); } Provider provider = null; if (clazz == String.class) { provider = (Provider<String>)serviceInstance; } else if (clazz == Source.class) { provider = (Provider<Source>)serviceInstance; } else if (clazz == SOAPMessage.class) { provider = (Provider<SOAPMessage>)serviceInstance; } else if (clazz == DataSource.class) { provider = (Provider<DataSource>)serviceInstance; } else if (clazz == OMElement.class) { provider = (Provider<OMElement>)serviceInstance; } if (provider == null) { throw ExceptionFactory.makeWebServiceException( Messages.getMessage("InvalidProviderCreate", clazz.getName())); } return provider; }
private Class<?> getProviderType() { if (_providerType != null) { return _providerType; } Class providerType = null; Type[] giTypes = serviceImplClass.getGenericInterfaces(); for (Type giType : giTypes) { ParameterizedType paramType = null; try { paramType = (ParameterizedType)giType; } catch (ClassCastException e) { // this may not be a parameterized interface continue; } Class interfaceName = (Class)paramType.getRawType(); if (interfaceName == javax.xml.ws.Provider.class) { if (paramType.getActualTypeArguments().length > 1) { throw ExceptionFactory.makeWebServiceException(Messages.getMessage("pTypeErr")); } providerType = (Class)paramType.getActualTypeArguments()[0]; } } _providerType = providerType; return providerType; }
public EndpointDispatcher createEndpointDispatcher(MessageContext mc, Class serviceImpl, Object serviceInstance) { // TODO: This check should be based on the EndpointDescription processing of annotations // It is left this way for now because some tests have an @WebService annotation on // Provider-based endpoints as a pre-existing workaround. if (Provider.class.isAssignableFrom(serviceImpl)) { return new ProviderDispatcher(serviceImpl, serviceInstance); } else { return new JavaBeanDispatcher(serviceImpl, serviceInstance); } }
static Class getSEI(Class<?> clazz) { 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; } if (!clazz.isAnnotationPresent(WebService.class)) { throw new UtilException("util.handler.no.webservice.annotation", clazz.getCanonicalName()); } WebService webService = clazz.getAnnotation(WebService.class); String ei = webService.endpointInterface(); if (ei.length() > 0) { clazz = getClass(webService.endpointInterface()); if (!clazz.isAnnotationPresent(WebService.class)) { throw new UtilException("util.handler.endpoint.interface.no.webservice", webService.endpointInterface()); } return clazz; } return null; }
public WSDLServiceFactoryBean() { setServiceClass(Provider.class); }
/** * Get the endpoint provider instance * * @return Provider * @throws Exception */ public Provider getProvider() throws Exception { Provider p = getProviderInstance(); setProvider(p); return p; }
/** * Set the endpoint provider instance * * @param _provider */ public void setProvider(Provider _provider) { this.providerInstance = _provider; }