private void validateAndSetMemberLevelWebServiceRef(WebServiceRef webServiceRef, Member member, 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.

            // get the effective type from the member type and WebServiceRef.type
            Class<?> memberType = InjectionHelper.getTypeFromMember(member);
            Class<?> effectiveType;
            if (memberType.getName().equals(Object.class.getName())) { //memberType is Object.class
                effectiveType = typeClass;
                // effectiveType could be Object here
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled() && typeClass.getName().equals(Object.class.getName())) {
                    Tr.debug(tc, "The member type and the @WebServiceRef.type on the " + member.getName() + " in " + member.getDeclaringClass().getName()
                                 + "are all Object.class, so can not infer one. Will try service type injection if the @WebServiceRef.value is a subclass of Service.class.");
                }

            } else { //memberType is not Object.class
                //we prefer subclass
                if (memberType.isAssignableFrom(typeClass)) {
                    effectiveType = typeClass;
                } else if (typeClass.isAssignableFrom(memberType)) {
                    effectiveType = memberType;
                } else {
                    Tr.error(tc, "error.service.ref.member.level.annotation.type.not.compatible",
                             member.getName(), member.getDeclaringClass().getName(), typeClass.getName(), memberType.getName());
                    throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.type.not.compatible",
                                                                  member.getName(), member.getDeclaringClass().getName(), typeClass.getName(), memberType.getName()));
                }
            }

            // validate and set value and type in WebServiceRefInfo
            if (effectiveType.getName().equals(Object.class.getName())) { // effectiveType can not be determined above, 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.member.level.annotation.type.not.inferred",
                             member.getName(), member.getDeclaringClass().getName());
                    throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.type.not.inferred",
                                                                  member.getName(), member.getDeclaringClass().getName()));
                }

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

            } else if (Service.class.isAssignableFrom(effectiveType)) { // service type injection case
                if (effectiveType.getName().equals(Service.class.getName())) { // effectiveType 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.member.level.annotation.wrong.value",
                                 member.getName(), member.getDeclaringClass(), valueClass.getName());
                        throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.wrong.value",
                                                                      member.getName(), member.getDeclaringClass(), valueClass.getName()));
                    }
                    wsrInfo.setServiceInterfaceClassName(valueClass.getName());
                    wsrInfo.setServiceRefTypeClassName(valueClass.getName());

                } else { //effectiveType 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(effectiveType.getName()) && !valueClass.getName().equals(Service.class.getName())) {
                        Tr.error(tc, "error.service.ref.member.level.annotation.value.and.type.not.same",
                                 member.getName(), member.getDeclaringClass().getName());
                        throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.value.and.type.not.same",
                                                                      member.getName(), member.getDeclaringClass().getName()));
                    }

                    wsrInfo.setServiceInterfaceClassName(effectiveType.getName());
                    wsrInfo.setServiceRefTypeClassName(effectiveType.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.member.level.annotation.wrong.value",
                             member.getName(), member.getDeclaringClass(), valueClass.getName());
                    throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.wrong.value",
                                                                  member.getName(), member.getDeclaringClass(), valueClass.getName()));
                }

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

        }

    }
private void validateAndSetMemberLevelWebServiceRef ( WebServiceRef webServiceRef , Member member , 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 { Class < ? > memberType = InjectionHelper . getTypeFromMember ( member ) ; Class < ? > effectiveType ; if ( memberType . getName ( ) . equals ( Object . class . getName ( ) ) ) { effectiveType = typeClass ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) && typeClass . getName ( ) . equals ( Object . class . getName ( ) ) ) { Tr . debug ( tc , "The member type and the @WebServiceRef.type on the " + member . getName ( ) + " in " + member . getDeclaringClass ( ) . getName ( ) + "are all Object.class, so can not infer one. Will try service type injection if the @WebServiceRef.value is a subclass of Service.class." ) ; } } else { if ( memberType . isAssignableFrom ( typeClass ) ) { effectiveType = typeClass ; } else if ( typeClass . isAssignableFrom ( memberType ) ) { effectiveType = memberType ; } else { Tr . error ( tc , "error.service.ref.member.level.annotation.type.not.compatible" , member . getName ( ) , member . getDeclaringClass ( ) . getName ( ) , typeClass . getName ( ) , memberType . getName ( ) ) ; throw new InjectionException ( Tr . formatMessage ( tc , "error.service.ref.member.level.annotation.type.not.compatible" , member . getName ( ) , member . getDeclaringClass ( ) . getName ( ) , typeClass . getName ( ) , memberType . getName ( ) ) ) ; } } if ( effectiveType . getName ( ) . equals ( Object . class . getName ( ) ) ) { if ( ! Service . class . isAssignableFrom ( valueClass ) || valueClass . getName ( ) . equals ( Service . class . getName ( ) ) ) { Tr . error ( tc , "error.service.ref.member.level.annotation.type.not.inferred" , member . getName ( ) , member . getDeclaringClass ( ) . getName ( ) ) ; throw new InjectionException ( Tr . formatMessage ( tc , "error.service.ref.member.level.annotation.type.not.inferred" , member . getName ( ) , member . getDeclaringClass ( ) . getName ( ) ) ) ; } wsrInfo . setServiceRefTypeClassName ( valueClass . getName ( ) ) ; wsrInfo . setServiceInterfaceClassName ( valueClass . getName ( ) ) ; } else if ( Service . class . isAssignableFrom ( effectiveType ) ) { if ( effectiveType . getName ( ) . equals ( Service . class . getName ( ) ) ) { if ( ! Service . class . isAssignableFrom ( valueClass ) || valueClass . getName ( ) . equals ( Service . class . getName ( ) ) ) { Tr . error ( tc , "error.service.ref.member.level.annotation.wrong.value" , member . getName ( ) , member . getDeclaringClass ( ) , valueClass . getName ( ) ) ; throw new InjectionException ( Tr . formatMessage ( tc , "error.service.ref.member.level.annotation.wrong.value" , member . getName ( ) , member . getDeclaringClass ( ) , valueClass . getName ( ) ) ) ; } wsrInfo . setServiceInterfaceClassName ( valueClass . getName ( ) ) ; wsrInfo . setServiceRefTypeClassName ( valueClass . getName ( ) ) ; } else { if ( ! valueClass . getName ( ) . equals ( effectiveType . getName ( ) ) && ! valueClass . getName ( ) . equals ( Service . class . getName ( ) ) ) { Tr . error ( tc , "error.service.ref.member.level.annotation.value.and.type.not.same" , member . getName ( ) , member . getDeclaringClass ( ) . getName ( ) ) ; throw new InjectionException ( Tr . formatMessage ( tc , "error.service.ref.member.level.annotation.value.and.type.not.same" , member . getName ( ) , member . getDeclaringClass ( ) . getName ( ) ) ) ; } wsrInfo . setServiceInterfaceClassName ( effectiveType . getName ( ) ) ; wsrInfo . setServiceRefTypeClassName ( effectiveType . getName ( ) ) ; } } else { if ( ! Service . class . isAssignableFrom ( valueClass ) || valueClass . getName ( ) . equals ( Service . class . getName ( ) ) ) { Tr . error ( tc , "error.service.ref.member.level.annotation.wrong.value" , member . getName ( ) , member . getDeclaringClass ( ) , valueClass . getName ( ) ) ; throw new InjectionException ( Tr . formatMessage ( tc , "error.service.ref.member.level.annotation.wrong.value" , member . getName ( ) , member . getDeclaringClass ( ) , valueClass . getName ( ) ) ) ; } wsrInfo . setServiceRefTypeClassName ( effectiveType . getName ( ) ) ; wsrInfo . setServiceInterfaceClassName ( valueClass . getName ( ) ) ; } } }
This method will be responsible for validating all of the rules that govern injection through member level WebServiceRef annotation.
It will also be responsible for setting the appropriate values on the WebServiceRefInfo instance.