<commit_before>package com.vaadin.grails.server

import com.vaadin.grails.Vaadin
import com.vaadin.navigator.Navigator
import com.vaadin.navigator.ViewProvider
import com.vaadin.server.UIClassSelectionEvent
import com.vaadin.server.UICreateEvent
import com.vaadin.shared.communication.PushMode
import com.vaadin.shared.ui.ui.Transport
import com.vaadin.ui.UI
import org.apache.log4j.Logger
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
import org.springframework.web.util.UrlPathHelper

/**
 * An {@link com.vaadin.server.UIProvider} implementation that uses mappings
 * provided by a {@link UriMappingsHolder}.
 *
 * @author <NAME>
 */
@Component("uiProvider")
@Scope("prototype")
class UriMappingsAwareUIProvider extends com.vaadin.server.UIProvider {

    private static final def log = Logger.getLogger(UriMappingsAwareUIProvider)

    final def pathHelper = new UrlPathHelper()

    @Autowired
    UriMappingsHolder uriMappings

    protected Navigator createNavigator(UI ui) {
        def navigator = new Navigator(ui, ui)
        def viewProvider = Vaadin.newInstance(ViewProvider, ui.class)
        navigator.addProvider(viewProvider)
        navigator
    }

    @Override
    UI createInstance(UICreateEvent event) {
        def uiClass = event.getUIClass()
        def ui = Vaadin.newInstance(uiClass)
        def path = pathHelper.getPathWithinApplication(event.request)
        def fragments = uriMappings.getAllFragments(path)
        if (fragments?.size() > 0) {
            ui.navigator = createNavigator(ui)
        }
        ui
    }

    @Override
    Class<? extends UI> getUIClass(UIClassSelectionEvent event) {<commit_msg>Bugfix<commit_after>package com.vaadin.grails.server

import com.vaadin.grails.Vaadin
import com.vaadin.navigator.Navigator
import com.vaadin.navigator.ViewProvider
import com.vaadin.server.UIClassSelectionEvent
import com.vaadin.server.UICreateEvent
import com.vaadin.shared.communication.PushMode
import com.vaadin.shared.ui.ui.Transport
import com.vaadin.ui.UI
import org.apache.log4j.Logger
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
import org.springframework.web.util.UrlPathHelper

/**
 * An {@link com.vaadin.server.UIProvider} implementation that uses mappings
 * provided by a {@link UriMappingsHolder}.
 *
 * @author <NAME>
 */
@Component("uiProvider")
@Scope("prototype")
class UriMappingsAwareUIProvider extends com.vaadin.server.UIProvider {

    private static final def log = Logger.getLogger(UriMappingsAwareUIProvider)

    final def pathHelper = new UrlPathHelper()

    @Autowired
    UriMappingsHolder uriMappings

    protected Navigator createNavigator(UI ui) {
        def navigator = new Navigator(ui, ui)
        def viewProvider = Vaadin.newInstance(ViewProvider, ui.class)
        navigator.addProvider(viewProvider)
        navigator
    }

    @Override
    UI createInstance(UICreateEvent event) {
        def uiClass = event.getUIClass()
        def ui = Vaadin.newInstance(uiClass)
        def path = uriMappings.getPath(uiClass)
        def fragments = uriMappings.getAllFragments(path)
        if (fragments?.size() > 0) {
            ui.navigator = createNavigator(ui)
        }
        ui
    }

    @Override
    Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
{'fraction_non_alphanumeric': 0.08851331996562589, 'fraction_numerical': 0.0011458034947006588, 'mean_word_length': 3.9322033898305087, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '7255009', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1003, 'n_words': 210}