/* (non-Javadoc)
@see eu.atos.sla.util.IModelConversion#getProviderFromProviderXML(eu.atos.sla.datamodel.parser.xml.Provider)
327957
@Override
    public IProvider getProviderFromProviderXML(eu.atos.sla.parser.data.Provider providerXML) {

        IProvider provider = new eu.atos.sla.datamodel.bean.Provider();

        if (providerXML.getUuid() != null) {

            provider.setUuid(providerXML.getUuid());
        } else {

            provider.setUuid(UUID.randomUUID().toString());
        }

        if (providerXML.getName() != null) {
            provider.setName(providerXML.getName());
        }

        return provider;
    }
205404
@Override
    public void onPrepareProviderResource(BeanCustomizerContext context) {

        EndpointInfo endpointInfo = context.getEndpointInfo();
        Set<ProviderResourceInfo> perRequestProviderAndPathInfos = endpointInfo.getPerRequestProviderAndPathInfos();
        Set<ProviderResourceInfo> singletonProviderAndPathInfos = endpointInfo.getSingletonProviderAndPathInfos();

        //The resources map may already exist on the context.  If it does we will want to add to it.
        Map<Class<?>, ManagedObject<?>> resourcesManagedbyCDI = (Map<Class<?>, ManagedObject<?>>)context.getContextObject();
        if (resourcesManagedbyCDI == null || !(resourcesManagedbyCDI instanceof ThreadBasedHashMap)) {
            resourcesManagedbyCDI = new ThreadBasedHashMap();//HashMap<Class<?>, ManagedObject<?>>();
        }

        CXFJaxRsProviderResourceHolder cxfPRHolder = context.getCxfRPHolder();
        for (ProviderResourceInfo p : perRequestProviderAndPathInfos) {
            /**
             * CDI customizer only check if the POJO type bean is CDI bean
             * because when EJB priority is higher than CDI, engine will take the bean as EJB but not CDI,
             * that means EJB already processes it, CDI should not process it again,
             * then CDI should not cache the bean's info in resourcesManagedbyCDI
             */
            if (p.getRuntimeType() != RuntimeType.POJO)
                continue;

            Class<?> clazz = p.getProviderResourceClass();
            if (!hasValidConstructor(clazz, false)) {
                continue;
            }

            Bean<?> bean = null;
            try {
                bean = getBeanFromCDI(clazz);
            } catch (Exception e1) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "ManagedObjectFactory failed to create bean", e1);
                }
            }

            if (bean != null) {

                String scopeName = bean.getScope().getName();
                p.setRuntimeType(RuntimeType.CDI);
                resourcesManagedbyCDI.put(p.getProviderResourceClass(), null);

                if (p.isJaxRsProvider()) {
                    //if CDI Scope is APPLICATION_SCOPE or DEPENDENT_SCOPE, report warning and no action: get provider from CDI
                    if (validSingletonScopeList.contains(scopeName)) {
                        logProviderMismatch(clazz, scopeName, "CDI");
                    }
                    //else report warning, keep using provider from rs: change to use RuntimeType.POJO
                    else {
                        p.setRuntimeType(RuntimeType.POJO);
                        resourcesManagedbyCDI.remove(p.getProviderResourceClass());
                        logProviderMismatch(clazz, scopeName, "JAXRS");
                    }
                } else {
                    if (!validRequestScopeList.contains(scopeName)) { //means this is @ApplicationScoped in CDI
                        logResourceMismatch(clazz, "PerRequest", scopeName, "CDI");
                    }

                }
            } else {

                if (shouldHandle(clazz, false)) {
                    p.setRuntimeType(RuntimeType.IMPLICITBEAN);
                    resourcesManagedbyCDI.put(clazz, null);
                }
                continue;

            }

        }
        for (ProviderResourceInfo o : singletonProviderAndPathInfos) {
            /**
             * CDI customizer only check if the POJO type bean is CDI bean
             * because when EJB priority is higher than CDI, engine will take the bean as EJB but not CDI,
             * that means EJB already processes it, CDI should not process it again,
             * then CDI should not cache the bean's info in resourcesManagedbyCDI
             */
            if (o.getRuntimeType() != RuntimeType.POJO)
                continue;

            Class<?> clazz = o.getProviderResourceClass();
            if (!hasValidConstructor(clazz, true)) {
                continue;
            }

            Bean<?> bean = null;
            try {
                bean = getBeanFromCDI(clazz);
            } catch (Exception e1) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "ManagedObjectFactory failed to create bean", e1);
                }
            }

            if (bean != null) {

                String scopeName = bean.getScope().getName();
                o.setRuntimeType(RuntimeType.CDI);
                resourcesManagedbyCDI.put(o.getProviderResourceClass(), null);
                if (o.isJaxRsProvider()) {
                    if (validSingletonScopeList.contains(scopeName)) {
                        logProviderMismatch(clazz, scopeName, "CDI");
                    }
                    //else report warning, keep using provider from rs: change to use RuntimeType.POJO
                    else {
                        o.setRuntimeType(RuntimeType.POJO);
                        resourcesManagedbyCDI.remove(clazz);
                        logProviderMismatch(clazz, scopeName, "JAXRS");
                    }

                    //Old check is this, need verify by using FAT:
                    //if CDI Scope is APPLICATION_SCOPE or DEPENDENT_SCOPE, report warning and no action: get provider from CDI
                    //else report warning and no action: get provider from CDI

                } else {
                    if (!validSingletonScopeList.contains(scopeName)) { // means CDI is per-request, then modify cxfPRHolder to per-request as well.
                        cxfPRHolder.removeResouceProvider(clazz);//remove from original ResourceProvider map and re-add the new one.
                        cxfPRHolder.addResouceProvider(clazz, new PerRequestResourceProvider(clazz));
                        logResourceMismatch(clazz, "Singleton", scopeName, "CDI");
                    }

                }
            } else {
                if (shouldHandle(clazz, false)) {
                    o.setRuntimeType(RuntimeType.IMPLICITBEAN);
                    resourcesManagedbyCDI.put(clazz, null);
                }
                continue;
            }

        }

        context.setContextObject(resourcesManagedbyCDI);

    }
956595
protected PackageExplorerLabelProvider getLabelProvider() {
		try {
			return (PackageExplorerLabelProvider) this.reflect.get(this, "fLabelProvider"); //$NON-NLS-1$
		} catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
			throw new Error(e);
		}
	}
1253709
@Override
    public void processXML() throws InjectionException
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "processXML : " + ivNameSpaceConfig.getPersistenceContextRefs());

        // d416151.3 Begins
        List<? extends PersistenceContextRef> pCtxtRefs = ivNameSpaceConfig.getPersistenceContextRefs();
        if (pCtxtRefs != null && pCtxtRefs.size() > 0)
        {
            for (PersistenceContextRef pCtxtRef : pCtxtRefs)
            {
                if (isTraceOn && tc.isDebugEnabled())
                    Tr.debug(tc, " pCtxtRef = " + pCtxtRef);

                // If XML has previously been read and an injection binding with the same
                // jndi name has been created, get the current injection binding and merge
                // the new PersistenceContext Ref into it.
                String jndiName = pCtxtRef.getName();
                InjectionBinding<PersistenceContext> injectionBinding = ivAllAnnotationsCollection.get(jndiName);
                if (injectionBinding != null)
                {
                    ((JPAPCtxtInjectionBinding) injectionBinding).merge(pCtxtRef);
                }
                else
                {
                    injectionBinding = new JPAPCtxtInjectionBinding(pCtxtRef, ivNameSpaceConfig, ivAttributeAccessor); // d662814
                    addInjectionBinding(injectionBinding);
                }

                ((AbstractJPAInjectionBinding<?>) injectionBinding).addRefComponents(jndiName); // F743-30682

                // Process any injection-targets that may be specified.    d429866.1
                // The code takes into account the possibility of duplicate InjectionTargets
                // and will only add if not already present, regardless of whether this is
                // a newly created binding, or a second one being merged.
                List<InjectionTarget> targets = pCtxtRef.getInjectionTargets();
                if (targets != null && !targets.isEmpty())
                {
                    for (InjectionTarget target : targets)
                    {
                        String injectionClassName = target.getInjectionTargetClassName();
                        String injectionName = target.getInjectionTargetName();
                        injectionBinding.addInjectionTarget(EntityManager.class,
                                                            injectionName,
                                                            injectionClassName);
                    }
                }
            }
        }
        // d416151.3 Ends
        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "processXML : " + ivAllAnnotationsCollection.size());
    }
311145
@Override
    public ITemplate getTemplateFromTemplateXML(eu.atos.sla.parser.data.wsag.Template templateXML,    String payload) throws ModelConversionException{
        ITemplate template = new Template();
        if (templateXML.getTemplateId() != null) {
            logger.debug("TemplateId at header will be used:{}", templateXML.getTemplateId());
            template.setUuid(templateXML.getTemplateId());
        } else {
            // uuid
            if (templateXML.getContext().getTemplateId() != null) {
                logger.debug("TemplateId in context will be used:{}", templateXML.getTemplateId());
                template.setUuid(templateXML.getContext().getTemplateId());
            }else{
                String templateId = UUID.randomUUID().toString();
                template.setUuid(templateId);
            }
        }
        
        if (templateXML.getContext().getService()!=null){
            template.setServiceId(templateXML.getContext().getService());
        }else{
            logger.error("Service is null, field must be informed");            
            throw new ModelConversionException("Service is null, field must be informed");
        }
        
        // Text
        template.setText(payload);
        // Name
        template.setName(templateXML.getName());
        template.setProvider(getProviderFromTemplate(templateXML));
        return template;
    }
864292
public static MetadataBuilder forProvider(Class<? extends RuleProvider> implementationType)
    {
        String id = implementationType.getSimpleName();

        RuleMetadata metadata = Annotations.getAnnotation(implementationType, RuleMetadata.class);
        if (metadata != null && !metadata.id().isEmpty())
            id = metadata.id();

        return forProvider(implementationType, id);
    }
355309
@FFDCIgnore(Exception.class)
    private void logProviderInfo(String providerName, ClassLoader loader) {
        try {
            if (PROVIDER_ECLIPSELINK.equals(providerName)) {
                // org.eclipse.persistence.Version.getVersion(): 2.6.4.v20160829-44060b6
                Class<?> Version = loadClass(loader, "org.eclipse.persistence.Version");
                String version = (String) Version.getMethod("getVersionString").invoke(Version.newInstance());
                Tr.info(tc, "JPA_THIRD_PARTY_PROV_INFO_CWWJP0053I", "EclipseLink", version);
            } else if (PROVIDER_HIBERNATE.equals(providerName)) {
                // org.hibernate.Version.getVersionString(): 5.2.6.Final
                Class<?> Version = loadClass(loader, "org.hibernate.Version");
                String version = (String) Version.getMethod("getVersionString").invoke(null);
                Tr.info(tc, "JPA_THIRD_PARTY_PROV_INFO_CWWJP0053I", "Hibernate", version);
            } else if (PROVIDER_OPENJPA.equals(providerName)) {
                // OpenJPAVersion.appendOpenJPABanner(sb): OpenJPA #.#.#\n version id: openjpa-#.#.#-r# \n Apache svn revision: #
                StringBuilder version = new StringBuilder();
                Class<?> OpenJPAVersion = loadClass(loader, "org.apache.openjpa.conf.OpenJPAVersion");
                OpenJPAVersion.getMethod("appendOpenJPABanner", StringBuilder.class).invoke(OpenJPAVersion.newInstance(), version);
                Tr.info(tc, "JPA_THIRD_PARTY_PROV_INFO_CWWJP0053I", "OpenJPA", version);
            } else {
                Tr.info(tc, "JPA_THIRD_PARTY_PROV_NAME_CWWJP0052I", providerName);
            }
        } catch (Exception x) {
            Tr.info(tc, "JPA_THIRD_PARTY_PROV_NAME_CWWJP0052I", providerName);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(this, tc, "unable to determine provider info", x);
        }
    }
854660
protected PackageExplorerContentProvider getContentProvider() {
		try {
			return (PackageExplorerContentProvider) this.reflect.get(this, "fContentProvider"); //$NON-NLS-1$
		} catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
			throw new Error(e);
		}
	}
737628
@Override
    public void processXML() throws InjectionException {

        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "processXML : " + this);

        List<? extends AdministeredObject> administeredObjectDefinitions = ivNameSpaceConfig.getJNDIEnvironmentRefs(AdministeredObject.class);

        if (administeredObjectDefinitions != null)
        {
            for (AdministeredObject administeredObject : administeredObjectDefinitions)
            {
                String jndiName = administeredObject.getName();
                InjectionBinding<AdministeredObjectDefinition> injectionBinding = ivAllAnnotationsCollection.get(jndiName);
                AdministeredObjectDefinitionInjectionBinding binding;

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

                binding.mergeXML(administeredObject);
            }
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "processXML : " + this);

    }
482931
public static String getFormatFromXmlReader(Reader xmlReader) {
        Map<String, String> attributes = getAttributesFromXmlReader(xmlReader);
        String baseDictUri = attributes.get(NAACCR_XML_ROOT_ATT_BASE_DICT);
        String recordType = attributes.get(NAACCR_XML_ROOT_ATT_REC_TYPE);
        if (baseDictUri != null && recordType != null) {
            String version = NaaccrXmlDictionaryUtils.extractVersionFromUri(baseDictUri);
            if (NaaccrFormat.isVersionSupported(version) && NaaccrFormat.isRecordTypeSupported(recordType))
                return NaaccrFormat.getInstance(version, recordType).toString();
        }

        return null;
    }
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;
    }
788950
public com.google.inject.Provider<org.eclipse.xtext.generator.parser.antlr.debug.parser.antlr.internal.InternalSimpleAntlrLexer> provideInternalSimpleAntlrLexer() {
		return org.eclipse.xtext.parser.antlr.LexerProvider.create(org.eclipse.xtext.generator.parser.antlr.debug.parser.antlr.internal.InternalSimpleAntlrLexer.class);
	}
548137
@Override
    public String getProviderEndpoints() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "getProviderEndpoints");
        String providerEndpoints = jcaConnectionFactory.getProviderEndpoints();
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "getProviderEndpoints", providerEndpoints);
        return providerEndpoints;
    }
1246776
private static ServiceProviderFinder _getServiceProviderFinderFromInitParam(ExternalContext context)
    {
        String initializerClassName = context.getInitParameter(SERVICE_PROVIDER_FINDER_PARAM);
        if (initializerClassName != null)
        {
            try
            {
                // get Class object
                Class<?> clazz = ClassUtils.classForName(initializerClassName);
                if (!ServiceProviderFinder.class.isAssignableFrom(clazz))
                {
                    throw new FacesException("Class " + clazz 
                            + " does not implement ServiceProviderFinder");
                }
                
                // create instance and return it
                return (ServiceProviderFinder) ClassUtils.newInstance(clazz);
            }
            catch (ClassNotFoundException cnfe)
            {
                throw new FacesException("Could not find class of specified ServiceProviderFinder", cnfe);
            }
        }
        return null;
    }
424010
public static HOTPProvider instantiateProvider(boolean allowTestProvider) {
        HOTPProvider resultProvider = null;
        ServiceLoader<HOTPProvider> loader = ServiceLoader.load(HOTPProvider.class);
        Iterator<HOTPProvider> iterator = loader.iterator();
        if (iterator.hasNext()) {
            while (iterator.hasNext()) {
                HOTPProvider provider = iterator.next();
                if (!"com.payneteasy.superfly.spring.TestHOTPProvider".equals(provider.getClass().getName())
                        || allowTestProvider) {
                    resultProvider = provider;
                    break;
                }
            }
        }
        return resultProvider;
    }
1171399
public com.google.api.ads.admanager.axis.v201808.GrpProvider getProvider() {
        return provider;
    }
525862
public void processXML()
                    throws InjectionException
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "processXML");

        for (int processorIndex = 0; processorIndex < ivProviders.size(); processorIndex++)
        {
            InjectionProcessorProvider<?, ?> provider = ivProviders.get(processorIndex);
            if (isProcessXMLNeeded(provider))
            {
                InjectionProcessor<?, ?> processor = getProcessor(processorIndex, provider);

                try
                {
                    processor.processXML();
                } catch (InjectionException iex)
                {
                    FFDCFilter.processException(iex, CLASS_NAME + ".processXML",
                                                "300", 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_XML_FROM_DD_CWNEN0009E", iex.getMessage());
                    throw iex;
                } catch (Throwable t)
                {
                    FFDCFilter.processException(t, CLASS_NAME + ".processXML",
                                                "768", this, new Object[] { processor });
                    // Include the cause stack in the logged message.             F53641
                    Tr.error(tc, "FAILED_TO_PROCESS_XML_FROM_DD_CWNEN0009E", t);
                    throw new InjectionConfigurationException("Failed to process xml from Deployment Descriptor.", t);
                }
            }
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "processXML");
    }