org.springframework.beans.factory.CannotLoadBeanClassException#javax.jws.WebService源码实例Demo

下面列出了org.springframework.beans.factory.CannotLoadBeanClassException#javax.jws.WebService 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * Initialize the JAX-WS port for this interceptor.
 */
public void prepare() {
	Class<?> ifc = getServiceInterface();
	if (ifc == null) {
		throw new IllegalArgumentException("Property 'serviceInterface' is required");
	}
	WebService ann = ifc.getAnnotation(WebService.class);
	if (ann != null) {
		applyDefaultsFromAnnotation(ann);
	}
	Service serviceToUse = getJaxWsService();
	if (serviceToUse == null) {
		serviceToUse = createJaxWsService();
	}
	this.portQName = getQName(getPortName() != null ? getPortName() : getServiceInterface().getName());
	Object stub = getPortStub(serviceToUse, (getPortName() != null ? this.portQName : null));
	preparePortStub(stub);
	this.portStub = stub;
}
 
源代码2 项目: TencentKona-8   文件: WebServiceVisitor.java
protected boolean shouldProcessMethod(ExecutableElement method, WebMethod webMethod) {
    builder.log("should process method: " + method.getSimpleName() + " hasWebMethods: " + hasWebMethods + " ");
    /*
    Fix for https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577
    if (hasWebMethods && webMethod == null) {
        builder.log("webMethod == null");
        return false;
    }
    */
    Collection<Modifier> modifiers = method.getModifiers();
    boolean staticFinal = modifiers.contains(Modifier.STATIC) || modifiers.contains(Modifier.FINAL);
    if (staticFinal) {
        if (webMethod != null) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_STATIC_OR_FINAL(method.getEnclosingElement(),
                    method), method);
        }
        return false;
    }
    boolean result = (endpointReferencesInterface ||
            method.getEnclosingElement().equals(typeElement) ||
            (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("endpointReferencesInterface: " + endpointReferencesInterface);
    builder.log("declaring class has WebService: " + (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("returning: " + result);
    return result;
}
 
/**
 * Initialize the JAX-WS port for this interceptor.
 */
public void prepare() {
	Class<?> ifc = getServiceInterface();
	Assert.notNull(ifc, "Property 'serviceInterface' is required");

	WebService ann = ifc.getAnnotation(WebService.class);
	if (ann != null) {
		applyDefaultsFromAnnotation(ann);
	}

	Service serviceToUse = getJaxWsService();
	if (serviceToUse == null) {
		serviceToUse = createJaxWsService();
	}

	this.portQName = getQName(getPortName() != null ? getPortName() : ifc.getName());
	Object stub = getPortStub(serviceToUse, (getPortName() != null ? this.portQName : null));
	preparePortStub(stub);
	this.portStub = stub;
}
 
源代码4 项目: lams   文件: JaxWsPortClientInterceptor.java
/**
 * Initialize the JAX-WS port for this interceptor.
 */
public void prepare() {
	Class<?> ifc = getServiceInterface();
	if (ifc == null) {
		throw new IllegalArgumentException("Property 'serviceInterface' is required");
	}
	WebService ann = ifc.getAnnotation(WebService.class);
	if (ann != null) {
		applyDefaultsFromAnnotation(ann);
	}
	Service serviceToUse = getJaxWsService();
	if (serviceToUse == null) {
		serviceToUse = createJaxWsService();
	}
	this.portQName = getQName(getPortName() != null ? getPortName() : getServiceInterface().getName());
	Object stub = getPortStub(serviceToUse, (getPortName() != null ? this.portQName : null));
	preparePortStub(stub);
	this.portStub = stub;
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: WebServiceVisitor.java
protected boolean shouldProcessMethod(ExecutableElement method, WebMethod webMethod) {
    builder.log("should process method: " + method.getSimpleName() + " hasWebMethods: " + hasWebMethods + " ");
    /*
    Fix for https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577
    if (hasWebMethods && webMethod == null) {
        builder.log("webMethod == null");
        return false;
    }
    */
    Collection<Modifier> modifiers = method.getModifiers();
    boolean staticFinal = modifiers.contains(Modifier.STATIC) || modifiers.contains(Modifier.FINAL);
    if (staticFinal) {
        if (webMethod != null) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_STATIC_OR_FINAL(method.getEnclosingElement(),
                    method), method);
        }
        return false;
    }
    boolean result = (endpointReferencesInterface ||
            method.getEnclosingElement().equals(typeElement) ||
            (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("endpointReferencesInterface: " + endpointReferencesInterface);
    builder.log("declaring class has WebService: " + (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("returning: " + result);
    return result;
}
 
源代码6 项目: openjdk-jdk9   文件: WebServiceVisitor.java
protected boolean shouldProcessMethod(ExecutableElement method, WebMethod webMethod) {
    builder.log("should process method: " + method.getSimpleName() + " hasWebMethods: " + hasWebMethods + " ");
    /*
    Fix for https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577
    if (hasWebMethods && webMethod == null) {
        builder.log("webMethod == null");
        return false;
    }
    */
    Collection<Modifier> modifiers = method.getModifiers();
    boolean staticFinal = modifiers.contains(Modifier.STATIC) || modifiers.contains(Modifier.FINAL);
    if (staticFinal) {
        if (webMethod != null) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_STATIC_OR_FINAL(method.getEnclosingElement(),
                    method), method);
        }
        return false;
    }
    boolean result = (endpointReferencesInterface ||
            method.getEnclosingElement().equals(typeElement) ||
            (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("endpointReferencesInterface: " + endpointReferencesInterface);
    builder.log("declaring class has WebService: " + (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("returning: " + result);
    return result;
}
 
源代码7 项目: cxf   文件: CodeGenBugTest.java
@Test
public void testCXF1048() throws Exception {

    env.put(ToolConstants.CFG_COMPILE, "compile");
    env.put(ToolConstants.CFG_IMPL, ToolConstants.CFG_IMPL);
    env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + "/classes");
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/cxf1048/test.wsdl"));
    processor.setContext(env);
    processor.execute();
    Class<?> clz = classLoader.loadClass("org.apache.hello_world_soap_http.PingSoapPortImpl");

    WebService webServiceAnn = AnnotationUtil.getPrivClassAnnotation(clz, WebService.class);
    assertEquals("org.apache.hello_world_soap_http.Ping", webServiceAnn.endpointInterface());
    assertEquals("GreeterSOAPService", webServiceAnn.serviceName());
    assertEquals("PingSoapPort", webServiceAnn.portName());
}
 
源代码8 项目: bearchoke   文件: JaxWsBeanPostProcessor.java
@Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (isWebService(bean)) {
            Bus bus = beanFactory.getBean(Bus.DEFAULT_BUS_ID, Bus.class);
            EndpointDefinitionParser.SpringEndpointImpl endpoint = new EndpointDefinitionParser.SpringEndpointImpl(bus, bean);

            WebService ws = bean.getClass().getAnnotation(WebService.class);
            endpoint.setAddress("/" + ws.serviceName());

            // capitalization is just a nice feature - totally optional
//            endpoint.setAddress("/" + StringUtils.capitalize(beanName));

            // adds ALL features registered / discovered by Spring
            Map<String, AbstractFeature> featureMap = beanFactory.getBeansOfType(AbstractFeature.class);
            endpoint.getFeatures().addAll(featureMap.values());

            // publish bean
            endpoint.publish();
        }

        return bean;
    }
 
源代码9 项目: hottub   文件: WebServiceVisitor.java
protected boolean shouldProcessMethod(ExecutableElement method, WebMethod webMethod) {
    builder.log("should process method: " + method.getSimpleName() + " hasWebMethods: " + hasWebMethods + " ");
    /*
    Fix for https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577
    if (hasWebMethods && webMethod == null) {
        builder.log("webMethod == null");
        return false;
    }
    */
    Collection<Modifier> modifiers = method.getModifiers();
    boolean staticFinal = modifiers.contains(Modifier.STATIC) || modifiers.contains(Modifier.FINAL);
    if (staticFinal) {
        if (webMethod != null) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_STATIC_OR_FINAL(method.getEnclosingElement(),
                    method), method);
        }
        return false;
    }
    boolean result = (endpointReferencesInterface ||
            method.getEnclosingElement().equals(typeElement) ||
            (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("endpointReferencesInterface: " + endpointReferencesInterface);
    builder.log("declaring class has WebService: " + (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("returning: " + result);
    return result;
}
 
源代码10 项目: openjdk-8   文件: WebServiceVisitor.java
protected void verifySeiAnnotations(WebService webService, TypeElement d) {
    if (webService.endpointInterface().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_ENDPOINTINTERFACE_ON_INTERFACE(
                d.getQualifiedName(), webService.endpointInterface()), d);
    }
    if (webService.serviceName().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT(
                "serviceName", d.getQualifiedName()), d);
    }
    if (webService.portName().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT(
                "portName", d.getQualifiedName()), d);
    }
}
 
/**
 * Initialize this client interceptor's properties from the given WebService annotation,
 * if necessary and possible (i.e. if "wsdlDocumentUrl", "namespaceUri", "serviceName"
 * and "portName" haven't been set but corresponding values are declared at the
 * annotation level of the specified service interface).
 * @param ann the WebService annotation found on the specified service interface
 */
protected void applyDefaultsFromAnnotation(WebService ann) {
	if (getWsdlDocumentUrl() == null) {
		String wsdl = ann.wsdlLocation();
		if (StringUtils.hasText(wsdl)) {
			try {
				setWsdlDocumentUrl(new URL(wsdl));
			}
			catch (MalformedURLException ex) {
				throw new IllegalStateException(
						"Encountered invalid @Service wsdlLocation value [" + wsdl + "]", ex);
			}
		}
	}
	if (getNamespaceUri() == null) {
		String ns = ann.targetNamespace();
		if (StringUtils.hasText(ns)) {
			setNamespaceUri(ns);
		}
	}
	if (getServiceName() == null) {
		String sn = ann.serviceName();
		if (StringUtils.hasText(sn)) {
			setServiceName(sn);
		}
	}
	if (getPortName() == null) {
		String pn = ann.portName();
		if (StringUtils.hasText(pn)) {
			setPortName(pn);
		}
	}
}
 
/**
 * Publish all {@link javax.jws.WebService} annotated beans in the
 * containing BeanFactory.
 * @see #publishEndpoint
 */
public void publishEndpoints() {
	Assert.state(this.beanFactory != null, "No BeanFactory set");

	Set<String> beanNames = new LinkedHashSet<>(this.beanFactory.getBeanDefinitionCount());
	Collections.addAll(beanNames, this.beanFactory.getBeanDefinitionNames());
	if (this.beanFactory instanceof ConfigurableBeanFactory) {
		Collections.addAll(beanNames, ((ConfigurableBeanFactory) this.beanFactory).getSingletonNames());
	}

	for (String beanName : beanNames) {
		try {
			Class<?> type = this.beanFactory.getType(beanName);
			if (type != null && !type.isInterface()) {
				WebService wsAnnotation = type.getAnnotation(WebService.class);
				WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
				if (wsAnnotation != null || wsProviderAnnotation != null) {
					Endpoint endpoint = createEndpoint(this.beanFactory.getBean(beanName));
					if (this.endpointProperties != null) {
						endpoint.setProperties(this.endpointProperties);
					}
					if (this.executor != null) {
						endpoint.setExecutor(this.executor);
					}
					if (wsAnnotation != null) {
						publishEndpoint(endpoint, wsAnnotation);
					}
					else {
						publishEndpoint(endpoint, wsProviderAnnotation);
					}
					this.publishedEndpoints.add(endpoint);
				}
			}
		}
		catch (CannotLoadBeanClassException ex) {
			// ignore beans where the class is not resolvable
		}
	}
}
 
源代码13 项目: rice   文件: RemoteTestHarness.java
@SuppressWarnings("unchecked")
/**
 * Creates a published endpoint from the passed in serviceImplementation and also returns a proxy implementation
 * of the passed in interface for clients to use to hit the created endpoint.
 */
public <T> T publishEndpointAndReturnProxy(Class<T> jaxWsAnnotatedInterface, T serviceImplementation) {
    if (jaxWsAnnotatedInterface.isInterface() &&
            jaxWsAnnotatedInterface.getAnnotation(WebService.class) != null &&
            jaxWsAnnotatedInterface.isInstance(serviceImplementation)) {

        String endpointUrl = getAvailableEndpointUrl();
        LOG.info("Publishing service to: " + endpointUrl);
        endpoint = Endpoint.publish(endpointUrl, serviceImplementation);

        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(jaxWsAnnotatedInterface);
        factory.setAddress(endpointUrl);

        T serviceProxy = (T) factory.create();

        /* Add the ImmutableCollectionsInInterceptor to mimic interceptors added in the KSB */
        Client cxfClient = ClientProxy.getClient(serviceProxy);
        cxfClient.getInInterceptors().add(new ImmutableCollectionsInInterceptor());

        return serviceProxy;
    } else {
        throw new IllegalArgumentException("Passed in interface class type must be annotated with @WebService " +
                "and object reference must be an implementing class of that interface.");

    }
}
 
源代码14 项目: cxf   文件: JaxWsImplementorInfo.java
private String getImplementorClassName() {
    for (WebService service : wsAnnotations) {
        if (!StringUtils.isEmpty(service.endpointInterface())) {
            return service.endpointInterface();
        }
    }
    return null;
}
 
源代码15 项目: BIMserver   文件: SService.java
public SService(SServicesMap servicesMap, SourceCodeFetcher sourceCodeFetcher, Class<? extends PublicInterface> interfaceClass) {
	this.servicesMap = servicesMap;
	this.sourceCodeFetcher = sourceCodeFetcher;
	this.interfaceClass = interfaceClass;
	this.nameSpace = interfaceClass.getAnnotation(WebService.class).targetNamespace();
	this.fullName = interfaceClass.getAnnotation(WebService.class).targetNamespace() + "." + interfaceClass.getAnnotation(WebService.class).name();
	this.simpleName = interfaceClass.getAnnotation(WebService.class).name();
}
 
源代码16 项目: TencentKona-8   文件: WebServiceAp.java
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (context.getRound() != 1) {
        return true;
    }
    context.incrementRound();
    WebService webService;
    WebServiceProvider webServiceProvider;
    WebServiceVisitor webServiceVisitor = new WebServiceWrapperGenerator(this, context);
    boolean processedEndpoint = false;
    Collection<TypeElement> classes = new ArrayList<TypeElement>();
    filterClasses(classes, roundEnv.getRootElements());
    for (TypeElement element : classes) {
        webServiceProvider = element.getAnnotation(WebServiceProvider.class);
        webService = element.getAnnotation(WebService.class);
        if (webServiceProvider != null) {
            if (webService != null) {
                processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_AND_WEBSERVICEPROVIDER(element.getQualifiedName()));
            }
            processedEndpoint = true;
        }

        if (webService == null) {
            continue;
        }

        element.accept(webServiceVisitor, null);
        processedEndpoint = true;
    }
    if (!processedEndpoint) {
        if (isCommandLineInvocation) {
            if (!ignoreNoWebServiceFoundWarning) {
                processWarning(WebserviceapMessages.WEBSERVICEAP_NO_WEBSERVICE_ENDPOINT_FOUND());
            }
        } else {
            processError(WebserviceapMessages.WEBSERVICEAP_NO_WEBSERVICE_ENDPOINT_FOUND());
        }
    }
    return true;
}
 
源代码17 项目: TencentKona-8   文件: WsgenOptions.java
/**
 * Get an implementation class annotated with @WebService annotation.
 */
private void validateEndpointClass() throws BadCommandLineException {
    Class clazz = null;
    for(String cls : endpoints){
        clazz = getClass(cls);
        if (clazz == null)
            continue;

        if (clazz.isEnum() || clazz.isInterface() ||
            clazz.isPrimitive()) {
            continue;
        }
        isImplClass = true;
        WebService webService = (WebService) clazz.getAnnotation(WebService.class);
        if(webService == null)
            continue;
        break;
    }
    if(clazz == null){
        throw new BadCommandLineException(WscompileMessages.WSGEN_CLASS_NOT_FOUND(endpoints.get(0)));
    }
    if(!isImplClass){
        throw new BadCommandLineException(WscompileMessages.WSGEN_CLASS_MUST_BE_IMPLEMENTATION_CLASS(clazz.getName()));
    }
    endpoint = clazz;
    validateBinding();
}
 
/**
 * Initialize this client interceptor's properties from the given WebService annotation,
 * if necessary and possible (i.e. if "wsdlDocumentUrl", "namespaceUri", "serviceName"
 * and "portName" haven't been set but corresponding values are declared at the
 * annotation level of the specified service interface).
 * @param ann the WebService annotation found on the specified service interface
 */
protected void applyDefaultsFromAnnotation(WebService ann) {
	if (getWsdlDocumentUrl() == null) {
		String wsdl = ann.wsdlLocation();
		if (StringUtils.hasText(wsdl)) {
			try {
				setWsdlDocumentUrl(new URL(wsdl));
			}
			catch (MalformedURLException ex) {
				throw new IllegalStateException(
						"Encountered invalid @Service wsdlLocation value [" + wsdl + "]", ex);
			}
		}
	}
	if (getNamespaceUri() == null) {
		String ns = ann.targetNamespace();
		if (StringUtils.hasText(ns)) {
			setNamespaceUri(ns);
		}
	}
	if (getServiceName() == null) {
		String sn = ann.serviceName();
		if (StringUtils.hasText(sn)) {
			setServiceName(sn);
		}
	}
	if (getPortName() == null) {
		String pn = ann.portName();
		if (StringUtils.hasText(pn)) {
			setPortName(pn);
		}
	}
}
 
/**
 * Publish all {@link javax.jws.WebService} annotated beans in the
 * containing BeanFactory.
 * @see #publishEndpoint
 */
public void publishEndpoints() {
	Assert.state(this.beanFactory != null, "No BeanFactory set");

	Set<String> beanNames = new LinkedHashSet<>(this.beanFactory.getBeanDefinitionCount());
	Collections.addAll(beanNames, this.beanFactory.getBeanDefinitionNames());
	if (this.beanFactory instanceof ConfigurableBeanFactory) {
		Collections.addAll(beanNames, ((ConfigurableBeanFactory) this.beanFactory).getSingletonNames());
	}

	for (String beanName : beanNames) {
		try {
			Class<?> type = this.beanFactory.getType(beanName);
			if (type != null && !type.isInterface()) {
				WebService wsAnnotation = type.getAnnotation(WebService.class);
				WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
				if (wsAnnotation != null || wsProviderAnnotation != null) {
					Endpoint endpoint = createEndpoint(this.beanFactory.getBean(beanName));
					if (this.endpointProperties != null) {
						endpoint.setProperties(this.endpointProperties);
					}
					if (this.executor != null) {
						endpoint.setExecutor(this.executor);
					}
					if (wsAnnotation != null) {
						publishEndpoint(endpoint, wsAnnotation);
					}
					else {
						publishEndpoint(endpoint, wsProviderAnnotation);
					}
					this.publishedEndpoints.add(endpoint);
				}
			}
		}
		catch (CannotLoadBeanClassException ex) {
			// ignore beans where the class is not resolvable
		}
	}
}
 
源代码20 项目: openjdk-8-source   文件: WsgenOptions.java
/**
 * Get an implementation class annotated with @WebService annotation.
 */
private void validateEndpointClass() throws BadCommandLineException {
    Class clazz = null;
    for(String cls : endpoints){
        clazz = getClass(cls);
        if (clazz == null)
            continue;

        if (clazz.isEnum() || clazz.isInterface() ||
            clazz.isPrimitive()) {
            continue;
        }
        isImplClass = true;
        WebService webService = (WebService) clazz.getAnnotation(WebService.class);
        if(webService == null)
            continue;
        break;
    }
    if(clazz == null){
        throw new BadCommandLineException(WscompileMessages.WSGEN_CLASS_NOT_FOUND(endpoints.get(0)));
    }
    if(!isImplClass){
        throw new BadCommandLineException(WscompileMessages.WSGEN_CLASS_MUST_BE_IMPLEMENTATION_CLASS(clazz.getName()));
    }
    endpoint = clazz;
    validateBinding();
}
 
源代码21 项目: jdk8u60   文件: WebServiceVisitor.java
protected void verifySeiAnnotations(WebService webService, TypeElement d) {
    if (webService.endpointInterface().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_ENDPOINTINTERFACE_ON_INTERFACE(
                d.getQualifiedName(), webService.endpointInterface()), d);
    }
    if (webService.serviceName().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT(
                "serviceName", d.getQualifiedName()), d);
    }
    if (webService.portName().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT(
                "portName", d.getQualifiedName()), d);
    }
}
 
源代码22 项目: jdk8u60   文件: WebServiceVisitor.java
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
源代码23 项目: jdk8u60   文件: WebServiceAp.java
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (context.getRound() != 1) {
        return true;
    }
    context.incrementRound();
    WebService webService;
    WebServiceProvider webServiceProvider;
    WebServiceVisitor webServiceVisitor = new WebServiceWrapperGenerator(this, context);
    boolean processedEndpoint = false;
    Collection<TypeElement> classes = new ArrayList<TypeElement>();
    filterClasses(classes, roundEnv.getRootElements());
    for (TypeElement element : classes) {
        webServiceProvider = element.getAnnotation(WebServiceProvider.class);
        webService = element.getAnnotation(WebService.class);
        if (webServiceProvider != null) {
            if (webService != null) {
                processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_AND_WEBSERVICEPROVIDER(element.getQualifiedName()));
            }
            processedEndpoint = true;
        }

        if (webService == null) {
            continue;
        }

        element.accept(webServiceVisitor, null);
        processedEndpoint = true;
    }
    if (!processedEndpoint) {
        if (isCommandLineInvocation) {
            if (!ignoreNoWebServiceFoundWarning) {
                processWarning(WebserviceapMessages.WEBSERVICEAP_NO_WEBSERVICE_ENDPOINT_FOUND());
            }
        } else {
            processError(WebserviceapMessages.WEBSERVICEAP_NO_WEBSERVICE_ENDPOINT_FOUND());
        }
    }
    return true;
}
 
源代码24 项目: tomee   文件: JaxWsUtils.java
public static String getServiceInterface(final Class<?> clazz) {
    WebService webService = clazz.getAnnotation(WebService.class);
    String endpointInterface = null;
    if (webService != null && webService.endpointInterface() != null) {
        endpointInterface = webService.endpointInterface().trim();
        if (endpointInterface.length() == 0) {
            endpointInterface = null;

        } else {
            return endpointInterface;
        }
    }

    // if the bean implements only one WebService class, that is the SEI
    for (final Class<?> intf : clazz.getInterfaces()) {
        // interface MUST also have a @WebService
        webService = intf.getAnnotation(WebService.class);
        if (webService != null) {
            if (endpointInterface == null) {
                endpointInterface = intf.getName();
            } else {
                // multiple endpoint interfaces
                endpointInterface = null;
                break;
            }
        }
    }

    return endpointInterface;
}
 
源代码25 项目: openjdk-jdk8u   文件: WebServiceVisitor.java
protected void verifySeiAnnotations(WebService webService, TypeElement d) {
    if (webService.endpointInterface().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_ENDPOINTINTERFACE_ON_INTERFACE(
                d.getQualifiedName(), webService.endpointInterface()), d);
    }
    if (webService.serviceName().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT(
                "serviceName", d.getQualifiedName()), d);
    }
    if (webService.portName().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT(
                "portName", d.getQualifiedName()), d);
    }
}
 
源代码26 项目: openjdk-jdk8u   文件: WebServiceVisitor.java
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
/**
 * Publish all {@link javax.jws.WebService} annotated beans in the
 * containing BeanFactory.
 * @see #publishEndpoint
 */
public void publishEndpoints() {
	Set<String> beanNames = new LinkedHashSet<String>(this.beanFactory.getBeanDefinitionCount());
	beanNames.addAll(Arrays.asList(this.beanFactory.getBeanDefinitionNames()));
	if (this.beanFactory instanceof ConfigurableBeanFactory) {
		beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames()));
	}
	for (String beanName : beanNames) {
		try {
			Class<?> type = this.beanFactory.getType(beanName);
			if (type != null && !type.isInterface()) {
				WebService wsAnnotation = type.getAnnotation(WebService.class);
				WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
				if (wsAnnotation != null || wsProviderAnnotation != null) {
					Endpoint endpoint = createEndpoint(this.beanFactory.getBean(beanName));
					if (this.endpointProperties != null) {
						endpoint.setProperties(this.endpointProperties);
					}
					if (this.executor != null) {
						endpoint.setExecutor(this.executor);
					}
					if (wsAnnotation != null) {
						publishEndpoint(endpoint, wsAnnotation);
					}
					else {
						publishEndpoint(endpoint, wsProviderAnnotation);
					}
					this.publishedEndpoints.add(endpoint);
				}
			}
		}
		catch (CannotLoadBeanClassException ex) {
			// ignore beans where the class is not resolvable
		}
	}
}
 
源代码28 项目: openjdk-8-source   文件: WebServiceVisitor.java
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
源代码29 项目: openjdk-8-source   文件: WebServiceAp.java
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (context.getRound() != 1) {
        return true;
    }
    context.incrementRound();
    WebService webService;
    WebServiceProvider webServiceProvider;
    WebServiceVisitor webServiceVisitor = new WebServiceWrapperGenerator(this, context);
    boolean processedEndpoint = false;
    Collection<TypeElement> classes = new ArrayList<TypeElement>();
    filterClasses(classes, roundEnv.getRootElements());
    for (TypeElement element : classes) {
        webServiceProvider = element.getAnnotation(WebServiceProvider.class);
        webService = element.getAnnotation(WebService.class);
        if (webServiceProvider != null) {
            if (webService != null) {
                processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_AND_WEBSERVICEPROVIDER(element.getQualifiedName()));
            }
            processedEndpoint = true;
        }

        if (webService == null) {
            continue;
        }

        element.accept(webServiceVisitor, null);
        processedEndpoint = true;
    }
    if (!processedEndpoint) {
        if (isCommandLineInvocation) {
            if (!ignoreNoWebServiceFoundWarning) {
                processWarning(WebserviceapMessages.WEBSERVICEAP_NO_WEBSERVICE_ENDPOINT_FOUND());
            }
        } else {
            processError(WebserviceapMessages.WEBSERVICEAP_NO_WEBSERVICE_ENDPOINT_FOUND());
        }
    }
    return true;
}
 
源代码30 项目: cxf   文件: JaxWsImplementorInfoTest.java
@Test
public void testWebServiceAnnotation() throws Exception {
    assertTrue(JaxWsImplementorInfo.
               ifAnnotationLoadedByOtherClassLoader(CalculatorImpl.class, WebService.class));
    assertFalse(JaxWsImplementorInfo.
                ifAnnotationLoadedByOtherClassLoader(CalculatorImpl.class, WebServiceProvider.class));

}