<commit_before>package com.danielfireman.gci.jooby;

import com.danielfireman.gci.GarbageCollectorControlInterceptor;
import com.danielfireman.gci.ShedResponse;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.jooby.Request;
import org.jooby.Response;
import org.jooby.Route;
import org.jooby.Status;

/**
 * Jooby filter that uses {@link GarbageCollectorControlInterceptor} to control garbage
 * collection and decide whether to shed requests.
 *
 * @author danielfireman
 * @see GarbageCollectorControlInterceptor
 */
@Singleton
public class JoobyGciFilter implements Route.Filter {

    private GarbageCollectorControlInterceptor gci;

    @Inject
    JoobyGciFilter(GarbageCollectorControlInterceptor gci) {
        this.gci = gci;
    }

    public void handle(Request request, Response response, Route.Chain chain) throws Throwable {
        ShedResponse shedResponse = gci.before();
        if (shedResponse.shouldShed) {
            String duration = Double.toString(((double)shedResponse.unavailabilityDuration.toMillis())/1000d);<commit_msg>Adding new construtor, to be used by example application<commit_after>package com.danielfireman.gci.jooby;

import com.danielfireman.gci.GarbageCollectorControlInterceptor;
import com.danielfireman.gci.ShedResponse;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.jooby.Request;
import org.jooby.Response;
import org.jooby.Route;
import org.jooby.Status;

/**
 * Jooby filter that uses {@link GarbageCollectorControlInterceptor} to control garbage
 * collection and decide whether to shed requests.
 *
 * @author danielfireman
 * @see GarbageCollectorControlInterceptor
 */
@Singleton
public class JoobyGciFilter implements Route.Filter {

    private GarbageCollectorControlInterceptor gci;

    @Inject
    public JoobyGciFilter(GarbageCollectorControlInterceptor gci) {
        System.out.println("Garbage Collector Control Interceptor activated.");
        this.gci = gci;
    }

    /**
     * Creates a new {@code JoobyGciFilter} with default parameters
     * @see com.danielfireman.gci.GarbageCollectorControlInterceptor#GarbageCollectorControlInterceptor()
     */
    public JoobyGciFilter() {
        this(new GarbageCollectorControlInterceptor());
    }

    public void handle(Request request, Response response, Route.Chain chain) throws Throwable {
        ShedResponse shedResponse = gci.before();
        if (shedResponse.shouldShed) {
            String duration = Double.toString(((double)shedResponse.unavailabilityDuration.toMillis())/1000d);
{'fraction_non_alphanumeric': 0.08498253783469151, 'fraction_numerical': 0.0031043849437330227, 'mean_word_length': 4.616557734204793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2018034', 'n_tokens_mistral': 764, 'n_tokens_neox': 746, 'n_words': 167}