private void validateAndSetClassLevelWebServiceRef(WebServiceRef webServiceRef, Class<?> instanceClass, WebServiceRefInfo wsrInfo) throws InjectionException {
        // Save off these annotation attributes for use later.
        Class<?> typeClass = webServiceRef.type();
        Class<?> valueClass = webServiceRef.value();

        // If the @WebServiceRef's lookup is specified, then no other attributes should be present. Only name can be specified with lookup.
        if (webServiceRef.lookup() != null && !webServiceRef.lookup().isEmpty()) {
            if (!typeClass.getName().equals(Object.class.getName())
                || !valueClass.getName().equals(Service.class.getName())
                || !webServiceRef.wsdlLocation().isEmpty()
                || !webServiceRef.mappedName().isEmpty()) {

                Tr.error(tc, "error.service.ref.annotation.lookup.redundant.attributes");
                throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.annotation.lookup.redundant.attributes"));
            }

        } else { // Otherwise, no 'lookup' attribute is present, then do our normal validations.

            if (webServiceRef.name().isEmpty()) {
                //For class level WebServiceRef, the 'name' and 'type' must be specified.
                Tr.error(tc, "error.service.ref.class.level.annotation.name.or.type.absent",
                         instanceClass.getName());
                throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.class.level.annotation.name.or.type.absent",
                                                              instanceClass.getName()));

            }

            if (typeClass.getName().equals(Object.class.getName())) { // type is not specified, so try service type injection
                // in this case the 'value' attribute MUST specify a subclass of javax.xml.ws.Service
                if (!Service.class.isAssignableFrom(valueClass) || valueClass.getName().equals(Service.class.getName())) {
                    Tr.error(tc, "error.service.ref.class.level.annotation.name.or.type.absent",
                             instanceClass.getName());
                    throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.class.level.annotation.name.or.type.absent",
                                                                  instanceClass.getName()));
                }

                wsrInfo.setServiceInterfaceClassName(valueClass.getName());
                wsrInfo.setServiceRefTypeClassName(valueClass.getName());

            } else if (Service.class.isAssignableFrom(typeClass)) { // service type injection case
                if (typeClass.getName().equals(Service.class.getName())) { // typeClass is javax.xml.ws.Service
                    // in this case the 'value' attribute MUST specify a subclass of javax.xml.ws.Service
                    if (!Service.class.isAssignableFrom(valueClass) || valueClass.getName().equals(Service.class.getName())) {
                        Tr.error(tc, "error.service.ref.class.level.annotation.wrong.value",
                                 instanceClass.getName(), valueClass.getName());
                        throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.class.level.annotation.wrong.value",
                                                                      instanceClass.getName(), valueClass.getName()));
                    }

                    wsrInfo.setServiceInterfaceClassName(valueClass.getName());
                    wsrInfo.setServiceRefTypeClassName(valueClass.getName());

                } else { //typeClass is a subclass of javax.xml.ws.Service
                    // in this case the 'value' attribute MUST be the same as 'type' or use default javax.xml.ws.Service
                    if (!valueClass.getName().equals(typeClass.getName()) && !valueClass.getName().equals(Service.class.getName())) {
                        Tr.error(tc, "error.service.ref.class.level.annotation.value.and.type.not.same",
                                 instanceClass.getName());
                        throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.class.level.annotation.value.and.type.not.same",
                                                                      instanceClass.getName()));
                    }

                    wsrInfo.setServiceInterfaceClassName(typeClass.getName());
                    wsrInfo.setServiceRefTypeClassName(typeClass.getName());
                }

            } else { // port type injection case
                // in this case the 'value' attribute MUST specify a subclass of javax.xml.ws.Service
                if (!Service.class.isAssignableFrom(valueClass) || valueClass.getName().equals(Service.class.getName())) {
                    Tr.error(tc, "error.service.ref.class.level.annotation.wrong.value",
                             instanceClass.getName(), valueClass.getName());
                    throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.class.level.annotation.wrong.value",
                                                                  instanceClass.getName(), valueClass.getName()));
                }

                wsrInfo.setServiceInterfaceClassName(valueClass.getName());
                wsrInfo.setServiceRefTypeClassName(typeClass.getName());
            }
        }
    }
private void validateAndSetClassLevelWebServiceRef ( WebServiceRef webServiceRef , Class < ? > instanceClass , WebServiceRefInfo wsrInfo ) throws InjectionException { Class < ? > typeClass = webServiceRef . type ( ) ; Class < ? > valueClass = webServiceRef . value ( ) ; if ( webServiceRef . lookup ( ) != null && ! webServiceRef . lookup ( ) . isEmpty ( ) ) { if ( ! typeClass . getName ( ) . equals ( Object . class . getName ( ) ) || ! valueClass . getName ( ) . equals ( Service . class . getName ( ) ) || ! webServiceRef . wsdlLocation ( ) . isEmpty ( ) || ! webServiceRef . mappedName ( ) . isEmpty ( ) ) { Tr . error ( tc , "error.service.ref.annotation.lookup.redundant.attributes" ) ; throw new InjectionException ( Tr . formatMessage ( tc , "error.service.ref.annotation.lookup.redundant.attributes" ) ) ; } } else { if ( webServiceRef . name ( ) . isEmpty ( ) ) { Tr . error ( tc , "error.service.ref.class.level.annotation.name.or.type.absent" , instanceClass . getName ( ) ) ; throw new InjectionException ( Tr . formatMessage ( tc , "error.service.ref.class.level.annotation.name.or.type.absent" , instanceClass . getName ( ) ) ) ; } if ( typeClass . getName ( ) . equals ( Object . class . getName ( ) ) ) { if ( ! Service . class . isAssignableFrom ( valueClass ) || valueClass . getName ( ) . equals ( Service . class . getName ( ) ) ) { Tr . error ( tc , "error.service.ref.class.level.annotation.name.or.type.absent" , instanceClass . getName ( ) ) ; throw new InjectionException ( Tr . formatMessage ( tc , "error.service.ref.class.level.annotation.name.or.type.absent" , instanceClass . getName ( ) ) ) ; } wsrInfo . setServiceInterfaceClassName ( valueClass . getName ( ) ) ; wsrInfo . setServiceRefTypeClassName ( valueClass . getName ( ) ) ; } else if ( Service . class . isAssignableFrom ( typeClass ) ) { if ( typeClass . getName ( ) . equals ( Service . class . getName ( ) ) ) { if ( ! Service . class . isAssignableFrom ( valueClass ) || valueClass . getName ( ) . equals ( Service . class . getName ( ) ) ) { Tr . error ( tc , "error.service.ref.class.level.annotation.wrong.value" , instanceClass . getName ( ) , valueClass . getName ( ) ) ; throw new InjectionException ( Tr . formatMessage ( tc , "error.service.ref.class.level.annotation.wrong.value" , instanceClass . getName ( ) , valueClass . getName ( ) ) ) ; } wsrInfo . setServiceInterfaceClassName ( valueClass . getName ( ) ) ; wsrInfo . setServiceRefTypeClassName ( valueClass . getName ( ) ) ; } else { if ( ! valueClass . getName ( ) . equals ( typeClass . getName ( ) ) && ! valueClass . getName ( ) . equals ( Service . class . getName ( ) ) ) { Tr . error ( tc , "error.service.ref.class.level.annotation.value.and.type.not.same" , instanceClass . getName ( ) ) ; throw new InjectionException ( Tr . formatMessage ( tc , "error.service.ref.class.level.annotation.value.and.type.not.same" , instanceClass . getName ( ) ) ) ; } wsrInfo . setServiceInterfaceClassName ( typeClass . getName ( ) ) ; wsrInfo . setServiceRefTypeClassName ( typeClass . getName ( ) ) ; } } else { if ( ! Service . class . isAssignableFrom ( valueClass ) || valueClass . getName ( ) . equals ( Service . class . getName ( ) ) ) { Tr . error ( tc , "error.service.ref.class.level.annotation.wrong.value" , instanceClass . getName ( ) , valueClass . getName ( ) ) ; throw new InjectionException ( Tr . formatMessage ( tc , "error.service.ref.class.level.annotation.wrong.value" , instanceClass . getName ( ) , valueClass . getName ( ) ) ) ; } wsrInfo . setServiceInterfaceClassName ( valueClass . getName ( ) ) ; wsrInfo . setServiceRefTypeClassName ( typeClass . getName ( ) ) ; } } }
This method will be responsible for validating all of the rules that govern injection through class level WebServiceRef annotation.
It will also be responsible for setting the appropriate values on the WebServiceRefInfo instance.