Gets the injection binding for a JNDI name. The caller is responsible for
calling {@link #processDeferredReferenceData}.
339965
public InjectionBinding<?> getInjectionBinding(NamingConstants.JavaColonNamespace namespace, String name) throws NamingException {
        if (namespace == NamingConstants.JavaColonNamespace.COMP) {
            return lookup(compLock, compBindings, name);
        }
        if (namespace == NamingConstants.JavaColonNamespace.COMP_ENV) {
            return lookup(compLock, compEnvBindings, name);
        }
        if (namespace == this.namespace) {
            NonCompBinding nonCompBinding = lookup(nonCompEnvLock, nonCompBindings, name);
            return nonCompBinding == null ? null : nonCompBinding.binding;
        }
        return null;
    }
1168791
protected XExpression getInferredFrom(JvmTypeReference typeReference) {
		if (InferredTypeIndicator.isInferred(typeReference)) {
			XComputedTypeReference computed = (XComputedTypeReference) typeReference;
			if (computed.getEquivalent() instanceof XComputedTypeReference) {
				XComputedTypeReference inferred = (XComputedTypeReference) computed.getEquivalent();
				IJvmTypeReferenceProvider typeProvider = inferred.getTypeProvider();
				if (typeProvider instanceof DemandTypeReferenceProvider) {
					return ((DemandTypeReferenceProvider) typeProvider).expression;
				}
			}
		}
		return null;
	}
57148
@Override
    public InjectionBinding<PersistenceUnit> createInjectionBinding
                    (PersistenceUnit annotation, Class<?> instanceClass, Member member, String jndiName)
                                    throws InjectionException
    {
        JPAPUnitInjectionBinding injectionBindingResource = new JPAPUnitInjectionBinding(annotation, ivNameSpaceConfig);
        return injectionBindingResource;
    }
532011
public void processBindings()
                    throws InjectionException
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "processBindings");

        if (ivProcessors != null) // RTC115266
        {
            for (InjectionProcessor<?, ?> processor : ivProcessors)
            {
                if (processor != null)
                {
                    try
                    {
                        InjectionProcessorContextImpl.processBindings(processor);
                    } catch (InjectionException iex)
                    {
                        FFDCFilter.processException(iex, CLASS_NAME + ".processBindings",
                                                    "480", this, new Object[] { processor });
                        // Include the cause message in the logged message, and don't
                        // unnecessarily wrap the exception.                          F53641
                        Tr.error(tc, "FAILED_TO_PROCESS_BINDINGS_CWNEN0011E", iex.getMessage());
                        throw iex;
                    } catch (Throwable t)
                    {
                        FFDCFilter.processException(t, CLASS_NAME + ".processBindings",
                                                    "815", this, new Object[] { processor });
                        // Include the cause stack in the logged message.             F53641
                        Tr.error(tc, "FAILED_TO_PROCESS_BINDINGS_CWNEN0011E", t);
                        throw new InjectionException("Failed to process bindings for metadata", t);
                    }
                }
            }
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "processBindings");
    }
1325430
@Override
    public void processXML() throws InjectionException {

        List<? extends JMSDestination> jmsDestinationDefinitions = ivNameSpaceConfig.getJNDIEnvironmentRefs(JMSDestination.class);

        if (jmsDestinationDefinitions != null) {
            for (JMSDestination jmsDestination : jmsDestinationDefinitions) {
                String jndiName = jmsDestination.getName();
                InjectionBinding<JMSDestinationDefinition> injectionBinding = ivAllAnnotationsCollection.get(jndiName);
                JMSDestinationDefinitionInjectionBinding binding;

                if (injectionBinding != null) {
                    binding = (JMSDestinationDefinitionInjectionBinding) injectionBinding;
                } else {
                    binding = new JMSDestinationDefinitionInjectionBinding(jndiName, ivNameSpaceConfig);
                    addInjectionBinding(binding);
                }

                binding.mergeXML(jmsDestination);
            }
        }

    }
297920
@Override
    public InjectionBinding<WebServiceRef> createOverrideInjectionBinding(Class<?> instanceClass, Member member,
                                                                          Resource resource, String jndiName) throws InjectionException {

        Class<?> typeClass = resource.type();

        if (member != null) {
            Class<?> inferredType = InjectionHelper.getTypeFromMember(member);
            if (typeClass.getName().equals(Object.class.getName())) { //default
                typeClass = inferredType;
            } else {
                if (!inferredType.isAssignableFrom(typeClass)) {
                    Tr.error(tc, "error.service.ref.member.level.annotation.type.not.compatible",
                             member.getName(), member.getDeclaringClass().getName(), typeClass.getName(), inferredType.getName());
                    throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.type.not.compatible",
                                                                  member.getName(), member.getDeclaringClass().getName(), typeClass.getName(), inferredType.getName()));
                }
            }
        }

        InjectionBinding<WebServiceRef> binding;

        //only service type injections are possible with the @Resource annotation
        if (Service.class.isAssignableFrom(typeClass)) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "The @Resource annotation found has type=" + typeClass.getName() + " and is refers to a JAX-WS service reference");
            }
            binding = WebServiceRefBindingBuilder.createWebServiceRefBindingFromResource(resource, ivNameSpaceConfig, typeClass, jndiName);
        } else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "The @Resource annotation found did not refer to a web service reference type.");
            }
            binding = null;
        }

        return binding;
    }
215389
@Override
	public String getQualifiedName(char innerClassDelimiter) {
		if (references != null && !references.isEmpty()) {
			StringBuilder result = new StringBuilder();
			for(JvmTypeReference reference: references) {
				if (result.length() > 0) {
					result.append(getDelimiter());
				}
				result.append(reference.getQualifiedName(innerClassDelimiter));
			}
			return result.toString();
		}
		return super.getIdentifier();
	}
61248
private void updateInjectionBinding(String jndiName, InjectionBinding<A> injectionBinding) // d675172
    {
        // If the annotation didn't have a name or the binding implementation
        // constructor did not set it, then the binding needs to be updated
        // with the default name or name (if not set by constructor).   // d682415
        if (!jndiName.equals(injectionBinding.getJndiName())) // d675172.1
        {
            injectionBinding.setJndiName(jndiName);
        }
    }
796747
public ParameterBinding getBindingFor(String name) {

        Assert.hasText(name, PARAMETER_NAME_MISSING);

        for (ParameterBinding binding : bindings) {
            if (binding.hasName(name)) {
                return binding;
            }
        }

        throw new IllegalArgumentException(String.format("No parameter binding found for name %s!", name));
    }
723727
@Override
    public InjectionBinding<WebServiceRef> createInjectionBinding(WebServiceRef webServiceRef, Class<?> instanceClass, Member member, String jndiName) throws InjectionException {
        InjectionBinding<WebServiceRef> binding;

        WebServiceRefInfo wsrInfo = WebServiceRefInfoBuilder.buildWebServiceRefInfo(webServiceRef, instanceClass.getClassLoader());
        wsrInfo.setClientMetaData(JaxWsMetaDataManager.getJaxWsClientMetaData(ivNameSpaceConfig.getModuleMetaData()));
        if (member == null) { //Annotated on class
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Creating new injection binding for @WebServiceRef annotation found on the " + instanceClass.getName() + " class.");
            }

            this.validateAndSetClassLevelWebServiceRef(webServiceRef, instanceClass, wsrInfo);

            // Now add the @HandlerChain instance
            javax.jws.HandlerChain hcAnnot = instanceClass.getAnnotation(javax.jws.HandlerChain.class);
            if (hcAnnot != null) {
                wsrInfo.setHandlerChainAnnotation(hcAnnot);
                wsrInfo.setHandlerChainDeclaringClassName(instanceClass.getName());
            }

            binding = new WebServiceRefBinding(wsrInfo, ivNameSpaceConfig);

        } else if (member instanceof Method) { //Annotated on method
            Method method = (Method) member;
            wsrInfo.setJndiName(jndiName);

            // Send the wsrInfo to this call so that both the 'type' and 'value' properties can be set correctly
            this.validateAndSetMemberLevelWebServiceRef(webServiceRef, method, wsrInfo);

            // Now add the @HandlerChain instance
            javax.jws.HandlerChain hcAnnot = method.getAnnotation(javax.jws.HandlerChain.class);
            if (hcAnnot != null) {
                wsrInfo.setHandlerChainAnnotation(hcAnnot);
                wsrInfo.setHandlerChainDeclaringClassName(instanceClass.getName());
            }

            //MTOM, RespectBinding, Addressing  
            //Merge any features that might be set on the field (@MTOM, @RespectBinding, @Addressing)
            //Note that we only support features for port-component-ref type injections.
            //For a port-component-ref type injection, the "Service SEI class" will be set on
            //'wsrMetadata'.
            if (wsrInfo.getServiceRefTypeClassName() != null) {
                handleMTOM(webServiceRef, wsrInfo, method.getAnnotation(MTOM.class));
                handleRespectBinding(webServiceRef, wsrInfo, method.getAnnotation(RespectBinding.class));
                handleAddressing(webServiceRef, wsrInfo, method.getAnnotation(Addressing.class));
            }

            // Create binding for @WebServiceRef annotation
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Creating new injection binding for the @WebServiceRef annotation on the " + method.getName() + " method in the "
                             + method.getDeclaringClass().getName() + " class.");
            }
            binding = new WebServiceRefBinding(wsrInfo, ivNameSpaceConfig);
            addInjectionBinding(binding);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Successfully created an injection binding for the @WebServiceRef annotation on the " + method.getName() + " method in the "
                             + method.getDeclaringClass().getName() + " class.");
            }

        } else { //Annotated on field
            Field field = (Field) member;
            wsrInfo.setJndiName(jndiName);

            // Send the wsrInfo to this call so that both the 'type' and 'value' properties can be set correctly
            this.validateAndSetMemberLevelWebServiceRef(webServiceRef, field, wsrInfo);

            // Now add the @HandlerChain instance
            javax.jws.HandlerChain hcAnnot = field.getAnnotation(javax.jws.HandlerChain.class);
            if (hcAnnot != null) {
                wsrInfo.setHandlerChainAnnotation(hcAnnot);
                wsrInfo.setHandlerChainDeclaringClassName(instanceClass.getName());
            }

            //MTOM, RespectBinding, Addressing  
            // Merge any features that might be set on the field (@MTOM, @RespectBinding, @Addressing)
            // Note that we only support features for port-component-ref type injections.
            // For a port-component-ref type injection, the "Service SEI class" will be set on
            // 'wsrMetadata'.
            if (wsrInfo.getServiceRefTypeClassName() != null) {
                handleMTOM(webServiceRef, wsrInfo, field.getAnnotation(MTOM.class));
                handleRespectBinding(webServiceRef, wsrInfo, field.getAnnotation(RespectBinding.class));
                handleAddressing(webServiceRef, wsrInfo, field.getAnnotation(Addressing.class));
            }

            // Create binding for @WebServiceRef annotation
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Creating new injection binding for the @WebServiceRef annotation on the " + field.getName() + " field in the "
                             + field.getDeclaringClass().getName() + " class.");
            }
            binding = new WebServiceRefBinding(wsrInfo, ivNameSpaceConfig);
            addInjectionBinding(binding);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Successfully created an injection binding for the @WebServiceRef annotation on the " + field.getName() + " field in the "
                             + field.getDeclaringClass().getName() + " class. HashCode=" + Integer.toHexString(System.identityHashCode(this)));
            }
        }

        return binding;
    }
199754
public String getBindingListenerName() {
        ServiceReference<?> ref = bindingListener.getServiceReference();
        Object serviceDescription = ref.getProperty(Constants.SERVICE_DESCRIPTION);
        if (serviceDescription instanceof String) {
            return (String) serviceDescription;
        }

        return bindingListener.getService().getClass().getName() + " (" + ref.getBundle().getSymbolicName() + ')';
    }
618471
public BindingType getBindingFromInterfaceName(DescriptionType descriptionType, String interfaceName)
    {
        for (Object nextElement : descriptionType.getImportOrIncludeOrTypes())
        {
            Object nextType = null;
            if (nextElement instanceof JAXBElement)
                nextType = ((JAXBElement)nextElement).getValue();
            // Create the service type
            if (nextType instanceof BindingType)
            {
                QName qname = ((BindingType)nextType).getInterface();
                if (interfaceName.equalsIgnoreCase(qname.getLocalPart()))
                    return (BindingType)nextType;
            }
        }
        return null;
    }
24733
@SuppressWarnings("unchecked")
  public T getReferenceTargetElement(ModelElementInstance referenceSourceElement) {
    String identifier = getReferenceIdentifier(referenceSourceElement);
    ModelElementInstance referenceTargetElement = referenceSourceElement.getModelInstance().getModelElementById(identifier);
    if (referenceTargetElement != null) {
      try {
        return (T) referenceTargetElement;

      } catch(ClassCastException e) {
        throw new ModelReferenceException("Element " + referenceSourceElement + " references element " + referenceTargetElement + " of wrong type. "
          + "Expecting " + referenceTargetAttribute.getOwningElementType() + " got " + referenceTargetElement.getElementType());
      }
    }
    else {
      return null;
    }
  }
106016
@Override
    public void resolve(InjectionBinding<Context> binding)
                    throws InjectionException {
        final String methodName = "resolve";
        if (tc.isEntryEnabled()) {
            Tr.entry(tc, methodName, binding);
        }
        Class<?> injectionType = binding.getInjectionClassType();

        if (tc.isDebugEnabled()) {
            Tr.debug(tc,
                     "Setting the ContextObjectFactory on the ContextInjectionBinding for type {0}",
                     injectionType);
        }
        Reference ref = new Reference(injectionType.getName());
        binding.setReferenceObject(ref, ContextObjectFactory.class);

        if (tc.isEntryEnabled())
            Tr.exit(tc, methodName, binding);
    }
1083578
public OSGiInjectionScopeData getInjectionScopeData(ComponentMetaData cmd, NamingConstants.JavaColonNamespace namespace) {
        if (cmd == null) {
            return null;
        }

        if (namespace == NamingConstants.JavaColonNamespace.GLOBAL) {
            return globalScopeData;
        }

        if (namespace == NamingConstants.JavaColonNamespace.COMP || namespace == NamingConstants.JavaColonNamespace.COMP_ENV) {
            OSGiInjectionScopeData isd = (OSGiInjectionScopeData) cmd.getMetaData(componentMetaDataSlot);

            if (isd == null) {
                ModuleMetaData mmd = cmd.getModuleMetaData();
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "trying module " + mmd);
                }

                // WAR java:comp is shared across all components, so the
                // bindings are stored in the module metadata.
                isd = (OSGiInjectionScopeData) cmd.getModuleMetaData().getMetaData(moduleMetaDataSlot);
                if (isd == null || !isd.isCompAllowed()) {
                    return null;
                }
            }

            return isd;
        }

        ModuleMetaData mmd = cmd.getModuleMetaData();
        if (namespace == NamingConstants.JavaColonNamespace.MODULE) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "trying " + mmd);
            }
            return (OSGiInjectionScopeData) mmd.getMetaData(moduleMetaDataSlot);
        }

        if (namespace == NamingConstants.JavaColonNamespace.APP) {
            ApplicationMetaData amd = mmd.getApplicationMetaData();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "trying " + amd);
            }
            return (OSGiInjectionScopeData) amd.getMetaData(applicationMetaDataSlot);
        }

        return null;
    }
982918
public static String getDataSourceIdentifier(WSJdbcWrapper jdbcWrapper) {
        DSConfig config = jdbcWrapper.dsConfig.get();
        return config.jndiName == null ? config.id : config.jndiName;
    }
531856
private static NameProvider getDefaultNameProvider() {
        NameProvider nameProvider = null;
        try {
            String providerClass = System.getProperty("org.joda.time.DateTimeZone.NameProvider");
            if (providerClass != null) {
                try {
                    // do not initialize the class until the type has been checked
                    Class<?> cls = Class.forName(providerClass, false, DateTimeZone.class.getClassLoader());
                    if (!NameProvider.class.isAssignableFrom(cls)) {
                        throw new IllegalArgumentException("System property referred to class that does not implement " + NameProvider.class);
                    }
                    nameProvider = cls.asSubclass(NameProvider.class).getConstructor().newInstance();
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
            }
        } catch (SecurityException ex) {
            // ignore
        }

        if (nameProvider == null) {
            nameProvider = new DefaultNameProvider();
        }

        return nameProvider;
    }