public void visitClass()

in modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessor.java [76:220]


    public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
        
        boolean hasJaxwsAnnotation = false;
        
        // Process @ServiceMode annotation - JCA 11013
    	if ( clazz.getAnnotation(ServiceMode.class) != null ) {
    		addSOAPIntent(type);
    		hasJaxwsAnnotation = true;
    	}
    	
        // Process @WebService annotation - POJO_8029, POJO_8030
        WebService webServiceAnnotation = clazz.getAnnotation(WebService.class);
        org.oasisopen.sca.annotation.Service serviceAnnotation = clazz.getAnnotation(org.oasisopen.sca.annotation.Service.class);
        
        if (webServiceAnnotation != null &&
            serviceAnnotation == null) {
            String serviceName = clazz.getSimpleName();
            serviceName = getValue(webServiceAnnotation.name(), serviceName);
            
            String serviceInterfaceClassName = webServiceAnnotation.endpointInterface();
            
            String wsdlLocation = webServiceAnnotation.wsdlLocation();
            
            try {
                createService(type, clazz, serviceName, serviceInterfaceClassName, wsdlLocation, false);
            } catch (InvalidInterfaceException e) {
                throw new IntrospectionException(e);
            }
            hasJaxwsAnnotation = true;
        }
        
        // Process @WebServiceProvider annotation - JCA_11015, POJO_8034
        WebServiceProvider webServiceProviderAnnotation = clazz.getAnnotation(WebServiceProvider.class);
        if (webServiceProviderAnnotation != null) {
            // if the implmentation already has a service set, use it's name
            // and the new service, which uses the implementation as an interface,
            // will be replaced 
            String serviceName = clazz.getSimpleName();
            
            if (type.getServices().size() > 0){
                serviceName = ((Service)type.getServices().get(0)).getName();
            } 
            
            // the annotation may specify a service name
            serviceName = getValue(webServiceProviderAnnotation.serviceName(), serviceName);
            
            String wsdlLocation = webServiceProviderAnnotation.wsdlLocation();
            
            // Make sure that there is a service with an interface
            // based on the implementation class and have it replace 
            // any service with the same name
            try {
                createService(type, clazz, serviceName, null, wsdlLocation, true);
            } catch (InvalidInterfaceException e) {
                throw new IntrospectionException(e);
            }
            
            // Make sure all service references are remotable
            for ( Service service : type.getServices() ) {
                service.getInterfaceContract().getInterface().setRemotable(true);
            }
            
            hasJaxwsAnnotation = true;
        }         
        
        // Process @WebParam and @WebResult annotations - POJO_8031, POJO_8032
        Class<?> interfaze = clazz;
        Method[] implMethods = interfaze.getDeclaredMethods();
        for ( Service service : type.getServices() ) {
            JavaInterface javaInterface = (JavaInterface)service.getInterfaceContract().getInterface();
            interfaze = javaInterface.getJavaClass();
            
            if (interfaze == null){
                // this interface has come from an @WebService enpointInterface annotation
                // so hasn't been resolved. Use the implementation class as the interface
                interfaze = clazz;
            }
            
            boolean hasHeaderParam = false;
            for (Method method : interfaze.getDeclaredMethods()){
                // find the impl method for this service method    
                for (int i = 0; i < implMethods.length; i++){ 
                    Method implMethod = implMethods[i];
                    if (implMethod.getName().equals(method.getName())){
                        for (int j = 0; j < implMethod.getParameterTypes().length; j++) {
                            WebParam webParamAnnotation = getParameterAnnotation(implMethod, j, WebParam.class); 
                            if (webParamAnnotation != null &&
                                webParamAnnotation.header()) {
                                hasHeaderParam = true;
                                break;
                            }
                        }
                        
                        WebResult webResultAnnotation = implMethod.getAnnotation(WebResult.class);
                        if (webResultAnnotation != null &&
                            webResultAnnotation.header()){
                            hasHeaderParam = true;
                            break;
                        }
                    }
                }
            } 
            
            if (hasHeaderParam){                   
                // Add a SOAP intent to the service
                addSOAPIntent(service);
                hasJaxwsAnnotation = true;
            }
        }
        
        // Process @SOAPBinding annotation - POJO_8033
        if ( clazz.getAnnotation(SOAPBinding.class) != null ) {
            // If the implementation is annotated with @SOAPBinding,
            // give all services a SOAP intent
            for ( Service service : type.getServices() ) {
                addSOAPIntent(service);
            }
            hasJaxwsAnnotation = true;
        }                           
        
        
   	  // Process @BindingType annotation - POJO_8037
        BindingType bindingType = clazz.getAnnotation(BindingType.class);
    	
    	if ( bindingType != null ) {
    		String bindingTypeValue = bindingType.value();    	
    		for ( Service service : type.getServices() ) {
    			addBindingTypeIntent(service, bindingTypeValue);
    		}
    		hasJaxwsAnnotation = true;
    	}
    	
        if (hasJaxwsAnnotation == true){        
            // Note that services are based on JAXWS annotations in case 
            // we need to know later. Add a ws binding and a JAXWS annotation
            // implies a WS binding
            for ( Service service : type.getServices() ) {
                service.setJAXWSService(true);
                createWSBinding(type, service);                               
            }
        }
        
 
                              	
    }