This method is called when an @WebServiceRef annotation with a name that has already been processed is found on
additional fields or methods. This allows us to validate and augment any existing metadata for this service
reference.
16184
@Override
    public void merge(WebServiceRef webServiceRef, Class<?> instanceClass, Member member) throws InjectionException {

        mergeWSRInfo(webServiceRef, instanceClass, member);

        // The former value should override the later one, i.e. the settings in DD should override the ones in annotation,
        // but we prefer the subclass.
        Class<?> annoType = webServiceRef.type();
        if (!annoType.getName().equals(Object.class.getName())) {
            Class<?> existingType = loadClass(wsrInfo.getServiceRefTypeClassName());

            if (!existingType.getName().equals(Object.class.getName())) {
                //prefer the subclass
                if (existingType.isAssignableFrom(annoType)) {
                    wsrInfo.setServiceRefTypeClassName(annoType.getName());
                } else if (annoType.isAssignableFrom(existingType)) {
                    wsrInfo.setServiceRefTypeClassName(existingType.getName());
                } else { // conflict
                    String msgKey;
                    Object[] inserts;
                    if (member != null) {
                        msgKey = "error.service.ref.type.mismatch.for.member";
                        inserts = new Object[] { wsrInfo.getJndiName(), member.getName(), member.getDeclaringClass().getName(),
                                                annoType.getName(), existingType.getName() };
                    } else {
                        msgKey = "error.service.ref.type.mismatch.for.class";
                        inserts = new Object[] { wsrInfo.getJndiName(), annoType.getName(), existingType.getName() };
                    }
                    Tr.error(tc, msgKey, inserts);
                    throw new InjectionException(Tr.formatMessage(tc, msgKey, inserts));
                }
            } else {
                wsrInfo.setServiceRefTypeClassName(annoType.getName());
            }
        }

        Class<?> annoValue = webServiceRef.value();
        if (!annoValue.getName().equals(Service.class.getName())) {
            Class<?> existingValue = loadClass(wsrInfo.getServiceInterfaceClassName());

            if (!existingValue.getName().equals(Service.class.getName())) {
                //prefer the subclass
                if (existingValue.isAssignableFrom(annoValue)) {
                    wsrInfo.setServiceInterfaceClassName(annoValue.getName());
                } else if (annoValue.isAssignableFrom(existingValue)) {
                    wsrInfo.setServiceInterfaceClassName(existingValue.getName());
                } else { // conflict
                    String msgKey;
                    Object[] inserts;
                    if (member != null) {
                        msgKey = "error.service.interface.mismatch.for.member";
                        inserts = new Object[] { wsrInfo.getJndiName(), member.getName(), member.getDeclaringClass().getName(), annoValue.getName(),
                                                existingValue.getName() };
                    } else {
                        msgKey = "error.service.interface.mismatch.for.class";
                        inserts = new Object[] { wsrInfo.getJndiName(), annoValue.getName(), existingValue.getName() };
                    }
                    Tr.error(tc, msgKey, inserts);
                    throw new InjectionException(Tr.formatMessage(tc, msgKey, inserts));
                }
            } else {
                wsrInfo.setServiceInterfaceClassName(annoValue.getName());
            }
        }

        // Validate and set value and type
        if (member == null) {
            validateAndSetClassLevelWebServiceRef(instanceClass);
        } else {
            // If the wsrInfo service ref type hasn't been set, the infer it from the member.
            validateAndSetMemberLevelWebServiceRef(member);
        }

        // now check the WSDL locations
        if (webServiceRef.wsdlLocation() != null && !webServiceRef.wsdlLocation().isEmpty()) {
            processExistingWSDL(webServiceRef.wsdlLocation(), member);
        }

        // now check to see if there was an @HandlerChain annotation on this member
        HandlerChain handlerChainInstance = null;
        if (member == null) {
            handlerChainInstance = instanceClass.getAnnotation(HandlerChain.class);
        } else if (member instanceof Field) {
            Field field = (Field) member;
            handlerChainInstance = field.getAnnotation(HandlerChain.class);
        } else if (member instanceof Method) {
            Method method = (Method) member;
            handlerChainInstance = method.getAnnotation(HandlerChain.class);
        }
        if (handlerChainInstance != null) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "@HandlerChain annotation found with @WebServiceRef annotation, jndiName: " + webServiceRef.name());
            }
            wsrInfo.setHandlerChainDeclaringClassName(instanceClass.getName());
            wsrInfo.setHandlerChainAnnotation(handlerChainInstance);
        }

    }
454703
@Override
    protected void findReferencedClassNames(final Set<String> referencedClassNames) {
        if (this.referencedClassNames != null) {
            referencedClassNames.addAll(this.referencedClassNames);
        }
        getMethodInfo().findReferencedClassNames(referencedClassNames);
        getFieldInfo().findReferencedClassNames(referencedClassNames);
        getAnnotationInfo().findReferencedClassNames(referencedClassNames);
        if (annotationDefaultParamValues != null) {
            annotationDefaultParamValues.findReferencedClassNames(referencedClassNames);
        }
        final ClassTypeSignature classSig = getTypeSignature();
        if (classSig != null) {
            classSig.findReferencedClassNames(referencedClassNames);
        }
        // Remove any self-references
        referencedClassNames.remove(name);
    }
672177
private void initBeanNameDefaulted(EnhancedAnnotation<T> annotatedAnnotation) {
        if (annotatedAnnotation.isAnnotationPresent(Named.class)) {
            if (!"".equals(annotatedAnnotation.getAnnotation(Named.class).value())) {
                throw MetadataLogger.LOG.valueOnNamedStereotype(annotatedAnnotation);
            }
            beanNameDefaulted = true;
        }
    }
1233659
@Override
    public void preprocess(ServiceModel serviceModel) {

        if (renameShapes == null || renameShapes.isEmpty()) return;
        // sanity check
        for (Entry<String, String> entry : renameShapes.entrySet()) {

            String originalName = entry.getKey();
            String newName = entry.getValue();
            Shape originalShape = serviceModel.getShapes().get(originalName);

            if (originalShape == null) {
                throw new IllegalStateException(
                        String.format("Cannot find shape [%s] in the model when processing "
                                + "customization config renameShapes.%s", originalName, originalName));
            }
            if (serviceModel.getShapes().containsKey(newName)) {
                throw new IllegalStateException(
                        String.format("The shape [%s] for the new name is already in the model when processing "
                                + "customization config renameShapes.%s", newName, originalName));
            }
        }

        for (Entry<String, Shape> entry : serviceModel.getShapes().entrySet()) {
            String shapeName = entry.getKey();
            Shape shape = entry.getValue();

            preprocess_RenameMemberShapes(shapeName, shape);
        }
        for (Operation operation : serviceModel.getOperations().values()) {

            if (operation.getInput() != null) {
                preprocess_RenameInputShape(operation.getInput());
            }
            if (operation.getOutput() != null) {
                preprocess_RenameOutputShape(operation.getOutput());
            }
            if (operation.getErrors() != null) {
                for (ErrorMap error : operation.getErrors()) {
                    preprocess_RenameErrorShape(error);
                }
            }
        }
        for (Entry<String, String> entry : renameShapes.entrySet()) {
            String originalName = entry.getKey();
            String newName = entry.getValue();

            Shape shape = serviceModel.getShapes().remove(originalName);
            serviceModel.getShapes().put(newName, shape);
        }
    }
891831
protected void ensureTraceObjectFieldAnnotated() {
        if (traceObjectFieldAnnotationVisitor == null && getTraceObjectFieldType() != null) {
            visitAnnotation(TRACE_OBJECT_FIELD_TYPE.getDescriptor(), true);

            // Save and restore the reference to the traceObjectFieldAnnotationVisitor
            // so subclasses don't believe it existed prior to processing
            TraceObjectFieldAnnotationVisitor av = traceObjectFieldAnnotationVisitor;
            traceObjectFieldAnnotationVisitor = null;
            av.visit("fieldName", getTraceObjectFieldName());
            av.visit("fieldDesc", getTraceObjectFieldType().getDescriptor());
            av.visitEnd();
            traceObjectFieldAnnotationVisitor = av;
        }
    }
318929
public void addName(String name)
   {
      if (names.contains(name))
      {
         throw new IllegalArgumentException("already contains: " + name);
      }
      indexes.add(name);
      names.add(name);
      dirty = true;
   }
315788
private void processIdentifierField(Field field) {
    Identifier identifier = field.getAnnotation(Identifier.class);
    boolean autoGenerated = identifier.autoGenerated();
    IdentifierMetadata identifierMetadata = new IdentifierMetadata(field, autoGenerated);
    entityMetadata.setIdentifierMetadata(identifierMetadata);
  }
1025079
@Override
    public void validate() throws OpsGenieClientValidationException {
        super.validate();
        if (getName() == null)
            throw OpsGenieClientValidationException.missingMandatoryProperty(OpsGenieClientConstants.API.NAME);
    }
619737
private static void validateClassAnnotations(
            Class<?> type, AnnotationCache cache, Set<Warning> warnings, Set<String> includedFields, Set<String> excludedFields) {

        boolean usesWithOnlyTheseFields = !includedFields.isEmpty();
        boolean usesWithIgnoredFields = !excludedFields.isEmpty();
        boolean hasNaturalId = cache.hasClassAnnotation(type, SupportedAnnotations.NATURALID);
        boolean hasSurrogateKey = warnings.contains(Warning.SURROGATE_KEY);
        boolean hasVersionedEntity = warnings.contains(Warning.IDENTICAL_COPY_FOR_VERSIONED_ENTITY);

        validate(hasNaturalId && usesWithOnlyTheseFields, "you can't use withOnlyTheseFields when fields are marked with @NaturalId.");
        validate(hasNaturalId && usesWithIgnoredFields, "you can't use withIgnoredFields when fields are marked with @NaturalId.");
        validate(hasNaturalId && hasSurrogateKey,
            "you can't suppress Warning.SURROGATE_KEY when fields are marked @NaturalId.");
        validate(hasNaturalId && hasVersionedEntity,
            "you can't suppress Warning.IDENTICAL_COPY_FOR_VERSIONED_ENTITY when fields are marked with @NaturalId.");
    }
361974
def validate_metadata(self, existing):
        
        self.metadata = [
            c.name for c in self.values_axes if c.metadata is not None]
1243044
public void addAnnotations( Annotated other)
    {
    for( Iterator<String> otherAnnotations = other.getAnnotations(); otherAnnotations.hasNext();)
      {
      String name = otherAnnotations.next();
      if( getAnnotation( name) == null)
        {
        setAnnotation( name, other.getAnnotation( name));
        }
      }
    }
1238805
@Override
    public void componentMetaDataCreated(MetaDataEvent<ComponentMetaData> event) {
        JaccService js = jaccService.getService();
        if (js != null) {
            MetaData metaData = event.getMetaData();
            if (metaData instanceof BeanMetaData) {
                BeanMetaData bmd = (BeanMetaData) metaData;
                js.propagateEJBRoles(bmd.j2eeName.getApplication(), bmd.j2eeName.getModule(), bmd.enterpriseBeanName, bmd.ivRoleLinkMap,
                                     JaccUtil.convertMethodInfoList(JaccUtil.mergeMethodInfos(bmd)));
            }
        }
    }
972098
public static void validateObserverMethod(ObserverMethod<?> observerMethod, BeanManager beanManager, ObserverMethod<?> originalObserverMethod) {
        Set<Annotation> qualifiers = observerMethod.getObservedQualifiers();
        if (observerMethod.getBeanClass() == null) {
            throw EventLogger.LOG.observerMethodsMethodReturnsNull("getBeanClass", observerMethod);
        }
        if (observerMethod.getObservedType() == null) {
            throw EventLogger.LOG.observerMethodsMethodReturnsNull("getObservedType", observerMethod);
        }
        Bindings.validateQualifiers(qualifiers, beanManager, observerMethod, "ObserverMethod.getObservedQualifiers");
        if (observerMethod.getReception() == null) {
            throw EventLogger.LOG.observerMethodsMethodReturnsNull("getReception", observerMethod);
        }
        if (observerMethod.getTransactionPhase() == null) {
            throw EventLogger.LOG.observerMethodsMethodReturnsNull("getTransactionPhase", observerMethod);
        }
        if (originalObserverMethod != null && (!observerMethod.getBeanClass().equals(originalObserverMethod.getBeanClass()))) {
            throw EventLogger.LOG.beanClassMismatch(originalObserverMethod, observerMethod);
        }
        if (!(observerMethod instanceof SyntheticObserverMethod) && !hasNotifyOverriden(observerMethod.getClass(), observerMethod)) {
            throw EventLogger.LOG.notifyMethodNotImplemented(observerMethod);
        }
    }
1180356
private void processProperty(ApiModelProperty apiModelPropertyAnnotation, Model model) {
        if (apiModelPropertyAnnotation == null) {
            return;
        }

        String apiModelPropertyAccess = apiModelPropertyAnnotation.access();
        String apiModelPropertyName = apiModelPropertyAnnotation.name();

        // If the @ApiModelProperty is not populated with both #name and #access, skip it
        if (apiModelPropertyAccess.isEmpty() || apiModelPropertyName.isEmpty()) {
            return;
        }

        // Check to see if the value of @ApiModelProperty#access is one to exclude.
        // If so, remove it from the previously-calculated model.
        if (apiModelPropertyAccessExclusions.contains(apiModelPropertyAccess)) {
            model.getProperties().remove(apiModelPropertyName);
        }
    }
61629
private void processPropertyOverride(PropertyMetadata propertyMetadata) {
    String qualifiedName = field.getQualifiedName() + "." + propertyMetadata.getField().getName();
    Property override = entityMetadata.getPropertyOverride(qualifiedName);
    if (override != null) {
      String mappedName = override.name();
      if (mappedName != null && mappedName.trim().length() > 0) {
        propertyMetadata.setMappedName(mappedName);
      }
      propertyMetadata.setIndexed(override.indexed());
      propertyMetadata.setOptional(override.optional());
    }
  }
796713
private static void validate(@NotNull EntityMetadata entityMetadata) {
        if (StringUtils.isEmpty(entityMetadata.getTableName())) {
            throw new MetadataException(String.format("Invalid table name: \"%s\"", entityMetadata.getTableName()));
        }

        if (entityMetadata.getPartitionKeySize() < 1) {
            throw new MetadataException(String.format("Entity \"%s\"must contains primary key", entityMetadata.getTableName()));
        }
    }
816346
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());
            }

        }

    }