<commit_before>package org.deegree.spring.bootstrap;

import org.deegree.spring.ApplicationContextHolder;
import org.deegree.spring.bootstrap.jaxb.BootstrapApplicationContextHolderConfig;
import org.deegree.workspace.ResourceBuilder;
import org.deegree.workspace.ResourceInitException;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;

public class BootstrapApplicationContextHolderBuilder implements ResourceBuilder<ApplicationContextHolder> {

    private final BootstrapApplicationContextHolderMetadata metadata;

    private final BootstrapApplicationContextHolderConfig config;

    public BootstrapApplicationContextHolderBuilder( BootstrapApplicationContextHolderMetadata metadata,
                                                     BootstrapApplicationContextHolderConfig config ) {

        this.metadata = metadata;
        this.config = config;
    }

    @Override
    public ApplicationContextHolder build() {
        try {
            final ConfigurableApplicationContext context;
            final String contextClass = config.getContextClass();
            if ( contextClass != null ) {
                context = new AnnotationConfigApplicationContext( Class.forName( contextClass ) );
            } else {
                final String contextConfigLocation = config.getContextConfigLocation();
                if ( contextConfigLocation == null ) {
                    throw new ResourceInitException(
                                                     "Both ContextClass and ContextConfigLocation are missing from BootstrapApplicationContextHolderConfig" );
                }

                context = new GenericXmlApplicationContext( contextConfigLocation );
            }

            return new ApplicationContextHolder( metadata, context );
        } catch ( Exception e ) {
            throw new ResourceInitException( "Couldn't build BootstrapApplicationContextHolder", e );
        }
    }
<commit_msg>additional debug logging<commit_after>package org.deegree.spring.bootstrap;

import org.deegree.spring.ApplicationContextHolder;
import org.deegree.spring.bootstrap.jaxb.BootstrapApplicationContextHolderConfig;
import org.deegree.workspace.ResourceBuilder;
import org.deegree.workspace.ResourceInitException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;

public class BootstrapApplicationContextHolderBuilder implements ResourceBuilder<ApplicationContextHolder> {
    
    private static final Logger LOG = LoggerFactory.getLogger( BootstrapApplicationContextHolderBuilder.class );

    private final BootstrapApplicationContextHolderMetadata metadata;

    private final BootstrapApplicationContextHolderConfig config;

    public BootstrapApplicationContextHolderBuilder( BootstrapApplicationContextHolderMetadata metadata,
                                                     BootstrapApplicationContextHolderConfig config ) {

        this.metadata = metadata;
        this.config = config;
    }

    @Override
    public ApplicationContextHolder build() {
        LOG.debug( "Building BootstrapApplicationContextHolder." );
        
        try {
            final ConfigurableApplicationContext context;
            final String contextClass = config.getContextClass();
            if ( contextClass != null ) {
                LOG.debug( "Using ContextClass {},", contextClass );                
                context = new AnnotationConfigApplicationContext( Class.forName( contextClass ) );
            } else {
                final String contextConfigLocation = config.getContextConfigLocation();
                if ( contextConfigLocation == null ) {
                    throw new ResourceInitException(
                                                     "Both ContextClass and ContextConfigLocation are missing from BootstrapApplicationContextHolderConfig" );
                }
                
                LOG.debug( "Using ContextConfigLocation {},", contextConfigLocation );
                context = new GenericXmlApplicationContext( contextConfigLocation );
            }

            return new ApplicationContextHolder( metadata, context );
        } catch ( Exception e ) {
            LOG.debug( "Couldn't build BootstrapApplicationContextHolder", e );
            throw new ResourceInitException( "Couldn't build BootstrapApplicationContextHolder", e );
        }
    }

{'fraction_non_alphanumeric': 0.05964172813487882, 'fraction_numerical': 0.00042149631190727084, 'mean_word_length': 2.8933552091878587, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4235904', 'n_tokens_mistral': 984, 'n_tokens_neox': 936, 'n_words': 223}