<commit_before>package org.jboss.seam.faces.environment;

import javax.enterprise.context.ApplicationScoped;
import javax.faces.application.Application;
import javax.faces.application.ApplicationWrapper;
import javax.faces.convert.Converter;
import javax.faces.validator.Validator;
import javax.inject.Inject;

import org.jboss.logging.Logger;
import org.jboss.seam.faces.util.BeanManagerUtils;

/**
 * Provides contextual lifecycle and @{link Inject} support for JSF artifacts such as {@link Converter}, {@link Validator}.
 *
 * @author <a href="mailto:<EMAIL>><NAME>, III</a>
 */
@ApplicationScoped
public class SeamApplicationWrapper extends ApplicationWrapper {
    private transient final Logger log = Logger.getLogger(SeamApplicationWrapper.class);

    private Application parent;

    @Inject
    BeanManagerUtils managerUtils;

    @Override
    public Application getWrapped() {
        return parent;
    }

    @Override
    public Converter createConverter(final Class<?> targetClass) {
        log.debugf("Creating converter for targetClass %s", targetClass.getName());
        Converter result = parent.createConverter(targetClass);
        result = attemptExtension(result);
        return result;
    }

    @Override
    public Converter createConverter(final String converterId) {
        log.debugf("Creating converter for converterId %s", converterId);
        Converter result = parent.createConverter(converterId);
        result = attemptExtension(result);
        return result;
    }

    @Override
    public Validator createValidator(final String validatorId) {
        log.debugf("Creating validator for validatorId %s", validatorId);
        Validator result = parent.createValidator(validatorId);
        result = attemptExtension(result);
        return result;
    }

    @SuppressWarnings("unchecked")
    private <T> T attemptExtension(final T base) {
        T result = base;

        if (base == null) {
            log.warnf("Cannot attempt extension on null");
            return null;
        }

        log.debugf("Extending class: %s", base.getClass().getName());
        if (managerUtils.isDependentScoped(base.getClass())) {
            managerUtils.injectNonContextualInstance(result);
        } else {
            result = (T) managerUtils.getContextualInstance(base.getClass());
        }

        if (result == null) {
            if (!base.getClass().getName().startsWith("javax.")) {
                log.warnf("Using JSF provided instance, unable to find a BeanManaged instance for class %s", base.getClass()
                        .getName());
            }
            result = base;
        }<commit_msg>SEAMFACES-171: Removed dispensable warning from SeamApplicationWrapper<commit_after>package org.jboss.seam.faces.environment;

import javax.enterprise.context.ApplicationScoped;
import javax.faces.application.Application;
import javax.faces.application.ApplicationWrapper;
import javax.faces.convert.Converter;
import javax.faces.validator.Validator;
import javax.inject.Inject;

import org.jboss.logging.Logger;
import org.jboss.seam.faces.util.BeanManagerUtils;

/**
 * Provides contextual lifecycle and @{link Inject} support for JSF artifacts such as {@link Converter}, {@link Validator}.
 *
 * @author <a href="mailto:<EMAIL>><NAME>, III</a>
 */
@ApplicationScoped
public class SeamApplicationWrapper extends ApplicationWrapper {
    private transient final Logger log = Logger.getLogger(SeamApplicationWrapper.class);

    private Application parent;

    @Inject
    BeanManagerUtils managerUtils;

    @Override
    public Application getWrapped() {
        return parent;
    }

    @Override
    public Converter createConverter(final Class<?> targetClass) {
        log.debugf("Creating converter for targetClass %s", targetClass.getName());
        Converter result = parent.createConverter(targetClass);
        result = attemptExtension(result);
        return result;
    }

    @Override
    public Converter createConverter(final String converterId) {
        log.debugf("Creating converter for converterId %s", converterId);
        Converter result = parent.createConverter(converterId);
        result = attemptExtension(result);
        return result;
    }

    @Override
    public Validator createValidator(final String validatorId) {
        log.debugf("Creating validator for validatorId %s", validatorId);
        Validator result = parent.createValidator(validatorId);
        result = attemptExtension(result);
        return result;
    }

    @SuppressWarnings("unchecked")
    private <T> T attemptExtension(final T base) {
        T result = base;

        if (base == null) {
            return null;
        }

        log.debugf("Extending class: %s", base.getClass().getName());
        if (managerUtils.isDependentScoped(base.getClass())) {
            managerUtils.injectNonContextualInstance(result);
        } else {
            result = (T) managerUtils.getContextualInstance(base.getClass());
        }

        if (result == null) {
            if (!base.getClass().getName().startsWith("javax.")) {
                log.warnf("Using JSF provided instance, unable to find a BeanManaged instance for class %s", base.getClass()
                        .getName());
            }
            result = base;
        }
{'fraction_non_alphanumeric': 0.10161836657884833, 'fraction_numerical': 0.0005645464809936018, 'mean_word_length': 3.0916089299461125, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5566396', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1363, 'n_words': 344}