private Method getDeclaredMethod(Class<?> endpointClass, Method method) { if (!method.getDeclaringClass().equals(endpointClass)) { try { method = endpointClass.getMethod(method.getName(), method.getParameterTypes()); } catch (SecurityException e) { throw new ServiceConstructionException(e); } catch (NoSuchMethodException e) { return isWebMethod(method) ? method : null; } } return method; }
private Method getProviderServiceObjectMethod(Method m, Class<?> serviceObjectClass) { if (!Provider.class.isAssignableFrom(serviceObjectClass)) { return m; } Class<?> currentSvcClass = serviceObjectClass; Class<?> genericType = null; while (currentSvcClass != null) { genericType = getProviderGenericType(currentSvcClass); if (genericType != null) { break; } // Check superclass until top currentSvcClass = currentSvcClass.getSuperclass(); } // Should never happens if (genericType == null) { return m; } try { return serviceObjectClass.getMethod("invoke", genericType); } catch (Exception e) { throw new ServiceConstructionException(e); } }
public void bind(OperationInfo o, Method... methods) { Method [] newMethods = new Method[methods.length]; int i = 0; for (Method m : methods) { try { newMethods[i] = getImplementationMethod(m); i++; } catch (NoSuchMethodException e) { if (m.getName().endsWith("Async") && (Future.class.equals(m.getReturnType()) || Response.class.equals(m.getReturnType()))) { newMethods[i] = m; i++; continue; } Class<?> endpointClass = implInfo.getImplementorClass(); Message msg = new Message("SEI_METHOD_NOT_FOUND", LOG, m.getName(), endpointClass.getName()); throw new ServiceConstructionException(msg, e); } } super.bind(o, newMethods); }
protected void bindOperation(OperationInfo op, Method method) { try { // Find the Async method which returns a Response Method responseMethod = ReflectionUtil.getDeclaredMethod(method.getDeclaringClass(), method.getName() + "Async", method.getParameterTypes()); // Find the Async method whic has a Future & AsyncResultHandler List<Class<?>> asyncHandlerParams = Arrays.asList(method.getParameterTypes()); //copy it to may it non-readonly asyncHandlerParams = new ArrayList<>(asyncHandlerParams); asyncHandlerParams.add(AsyncHandler.class); Method futureMethod = ReflectionUtil .getDeclaredMethod(method.getDeclaringClass(), method.getName() + "Async", asyncHandlerParams.toArray(new Class<?>[0])); getMethodDispatcher().bind(op, method, responseMethod, futureMethod); } catch (SecurityException e) { throw new ServiceConstructionException(e); } catch (NoSuchMethodException e) { getMethodDispatcher().bind(op, method); } }
public JAXWSProviderMethodDispatcher(JaxWsImplementorInfo implInfo) { try { invoke = ReflectionUtil.getMethod(implInfo.getImplementorClass(), "invoke", new Class[] {implInfo.getProviderParameterType()}); ReflectionUtil.setAccessible(invoke); } catch (Exception e1) { //fall back to the raw Provider provided invoke method try { invoke = Provider.class.getMethod("invoke", new Class[] {Object.class}); } catch (Exception e) { throw new ServiceConstructionException(e); } } }
@Override protected Class<?> getBeanClass(Class<?> exClass) { try { if (java.rmi.ServerException.class.isAssignableFrom(exClass) || java.rmi.RemoteException.class.isAssignableFrom(exClass) || "javax.xml.ws".equals(PackageUtils.getPackageName(exClass))) { return null; } Method getFaultInfo = exClass.getMethod("getFaultInfo", new Class[0]); return getFaultInfo.getReturnType(); } catch (SecurityException e) { throw new ServiceConstructionException(e); } catch (NoSuchMethodException e) { //ignore for now } WebFault fault = exClass.getAnnotation(WebFault.class); if (fault != null && !StringUtils.isEmpty(fault.faultBean())) { try { return ClassLoaderUtils.loadClass(fault.faultBean(), exClass); } catch (ClassNotFoundException e1) { //ignore } } return super.getBeanClass(exClass); }
@Override public void setServiceClass(Class<?> serviceClass) { if (serviceClass == null) { Message message = new Message("SERVICECLASS_MUST_BE_SET", LOG); throw new ServiceConstructionException(message); } setJaxWsImplementorInfo(new JaxWsImplementorInfo(serviceClass)); super.setServiceClass(getJaxWsImplementorInfo().getEndpointClass()); super.setServiceType(getJaxWsImplementorInfo().getSEIType()); } @Override
private Method getDeclaredMethod(Class<?> endpointClass, Method method) { if (!method.getDeclaringClass().equals(endpointClass)) { try { method = endpointClass.getMethod(method.getName(), method.getParameterTypes()); } catch (SecurityException e) { throw new ServiceConstructionException(e); } catch (NoSuchMethodException e) { return isWebMethod(method) ? method : null; } } return method; }
protected void initializeWSDLOperationsForProvider() { Class<?> c = getProviderParameterType(getServiceClass()); if (c == null) { throw new ServiceConstructionException(new Message("INVALID_PROVIDER_EXC", LOG)); throw new ServiceConstructionException(e);
private URL composeUrl(String s) { try { URIResolver resolver = new URIResolver(null, s, getClass()); if (resolver.isResolved()) { return resolver.getURI().toURL(); } throw new ServiceConstructionException(new Message("COULD_NOT_RESOLVE_URL", LOG, s)); } catch (IOException e) { throw new ServiceConstructionException(new Message("COULD_NOT_RESOLVE_URL", LOG, s), e); } }
public void addListener(Destination d, Endpoint e) { synchronized (d) { if (d.getMessageObserver() != null) { throw new ServiceConstructionException(new Message("ALREADY_RUNNING", LOG, e.getEndpointInfo().getAddress())); } super.addListener(d, e); } }
public WSDLServiceFactory(Bus b, URL url) { setBus(b); wsdlUrl = url; try { // use wsdl manager to parse wsdl or get cached definition definition = getBus().getExtension(WSDLManager.class).getDefinition(wsdlUrl); } catch (WSDLException ex) { throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex); } } public WSDLServiceFactory(Bus b, String url) {
public WSDLServiceFactory(Bus b, String url, QName sn) { setBus(b); wsdlUrl = url; try { // use wsdl manager to parse wsdl or get cached definition definition = getBus().getExtension(WSDLManager.class).getDefinition(url); } catch (WSDLException ex) { throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex); } serviceName = sn; }
public WSDLServiceFactory(Bus b, String url) { setBus(b); wsdlUrl = url; try { // use wsdl manager to parse wsdl or get cached definition definition = getBus().getExtension(WSDLManager.class).getDefinition(url); } catch (WSDLException ex) { throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex); } }
public WSDLServiceFactory(Bus b, String url) { setBus(b); try { // use wsdl manager to parse wsdl or get cached definition definition = getBus().getExtension(WSDLManager.class).getDefinition(url); } catch (WSDLException ex) { throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex); } }
public WSDLServiceFactory(Bus b, String url, QName sn) { setBus(b); try { // use wsdl manager to parse wsdl or get cached definition definition = getBus().getExtension(WSDLManager.class).getDefinition(url); } catch (WSDLException ex) { throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex); } serviceName = sn; }
protected InterfaceInfo getInterfaceInfo() { if (getEndpointInfo() != null) { return getEndpointInfo().getInterface(); } QName qn = this.getInterfaceName(); for (ServiceInfo si : getService().getServiceInfos()) { if (qn.equals(si.getInterface().getName())) { return si.getInterface(); } } throw new ServiceConstructionException(new Message("COULD_NOT_FIND_PORTTYPE", LOG, qn)); }
@Override public void setServiceClass(Class<?> serviceClass) { if (serviceClass == null) { Message message = new Message("SERVICECLASS_MUST_BE_SET", LOG); throw new ServiceConstructionException(message); } setJaxWsImplementorInfo(new JaxWsImplementorInfo(serviceClass)); super.setServiceClass(getJaxWsImplementorInfo().getEndpointClass()); super.setServiceType(getJaxWsImplementorInfo().getSEIType()); } @Override
protected void initializeServiceModel() { if (isFromWsdl()) { buildServiceFromWSDL(getWsdlURL()); } else if (getServiceClass() != null) { buildServiceFromClass(); } else { throw new ServiceConstructionException(new Message("NO_WSDL_NO_SERVICE_CLASS_PROVIDED", LOG, getWsdlURL())); } if (isValidate()) { validateServiceModel(); } }