<commit_before>package se.l4.dust.jaxrs.resteasy;

import org.jboss.resteasy.core.Dispatcher;
import org.jboss.resteasy.plugins.providers.ByteArrayProvider;
import org.jboss.resteasy.plugins.providers.DataSourceProvider;
import org.jboss.resteasy.plugins.providers.DefaultTextPlain;
import org.jboss.resteasy.plugins.providers.FileProvider;
import org.jboss.resteasy.plugins.providers.FormUrlEncodedProvider;
import org.jboss.resteasy.plugins.providers.IIOImageProvider;
import org.jboss.resteasy.plugins.providers.InputStreamProvider;
import org.jboss.resteasy.plugins.providers.StreamingOutputProvider;
import org.jboss.resteasy.plugins.providers.StringTextStar;
import org.jboss.resteasy.spi.Registry;
import org.jboss.resteasy.spi.ResteasyProviderFactory;

import se.l4.crayon.CrayonModule;
import se.l4.crayon.annotation.Contribution;
import se.l4.dust.api.template.RenderingContext;
import se.l4.dust.jaxrs.WebModule;
import se.l4.dust.jaxrs.internal.template.TemplateWriter;
import se.l4.dust.jaxrs.resteasy.internal.ReloadingDispatcher;
import se.l4.dust.jaxrs.resteasy.internal.ResteasyConfiguration;
import se.l4.dust.jaxrs.resteasy.internal.ResteasyContext;
import se.l4.dust.jaxrs.resteasy.internal.ResteasyRenderingContext;
import se.l4.dust.jaxrs.spi.Configuration;
import se.l4.dust.jaxrs.spi.RequestContext;

import com.google.inject.Provides;
import com.google.inject.Singleton;

/**
 * Module for that activates Resteasy.
 * 
 * @author <NAME>
 *
 */
public class ResteasyModule
	extends CrayonModule
{

	@Override
	protected void configure()
	{
		install(new WebModule());
		
		// Bind a Resteasy factory
		ResteasyProviderFactory factory = new ResteasyProviderFactory();
		bind(ResteasyProviderFactory.class).toInstance(factory);
		ResteasyProviderFactory.setInstance(factory);
		
		// Bind a dispatcher
		bind(Dispatcher.class).to(ReloadingDispatcher.class);
		
		// Bind SPI interfaces 
		bind(Configuration.class).to(ResteasyConfiguration.class);
		bind(RequestContext.class).to(ResteasyContext.class);
		bind(RenderingContext.class).to(ResteasyRenderingContext.class);
	}
	
	@Provides
	@Singleton
	public Registry provideRegistry(Dispatcher dispatcher)
	{
		return dispatcher.getRegistry();
	}
	
	@Contribution(name="jax-rs-providers")
	public void contributeDefaultMessageProviders(ResteasyProviderFactory factory,
			ByteArrayProvider p1,
			DefaultTextPlain p2,<commit_msg>Ability to inject a few more context classes<commit_after>package se.l4.dust.jaxrs.resteasy;

import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;

import org.jboss.resteasy.core.Dispatcher;
import org.jboss.resteasy.plugins.providers.ByteArrayProvider;
import org.jboss.resteasy.plugins.providers.DataSourceProvider;
import org.jboss.resteasy.plugins.providers.DefaultTextPlain;
import org.jboss.resteasy.plugins.providers.FileProvider;
import org.jboss.resteasy.plugins.providers.FormUrlEncodedProvider;
import org.jboss.resteasy.plugins.providers.IIOImageProvider;
import org.jboss.resteasy.plugins.providers.InputStreamProvider;
import org.jboss.resteasy.plugins.providers.StreamingOutputProvider;
import org.jboss.resteasy.plugins.providers.StringTextStar;
import org.jboss.resteasy.spi.Registry;
import org.jboss.resteasy.spi.ResteasyProviderFactory;

import se.l4.crayon.CrayonModule;
import se.l4.crayon.annotation.Contribution;
import se.l4.dust.api.template.RenderingContext;
import se.l4.dust.jaxrs.WebModule;
import se.l4.dust.jaxrs.internal.template.TemplateWriter;
import se.l4.dust.jaxrs.resteasy.internal.ReloadingDispatcher;
import se.l4.dust.jaxrs.resteasy.internal.ResteasyConfiguration;
import se.l4.dust.jaxrs.resteasy.internal.ResteasyContext;
import se.l4.dust.jaxrs.resteasy.internal.ResteasyRenderingContext;
import se.l4.dust.jaxrs.spi.Configuration;
import se.l4.dust.jaxrs.spi.RequestContext;

import com.google.inject.Provides;
import com.google.inject.Singleton;

/**
 * Module for that activates Resteasy.
 * 
 * @author <NAME>
 *
 */
public class ResteasyModule
	extends CrayonModule
{

	@Override
	protected void configure()
	{
		install(new WebModule());
		
		// Bind a Resteasy factory
		ResteasyProviderFactory factory = new ResteasyProviderFactory();
		bind(ResteasyProviderFactory.class).toInstance(factory);
		ResteasyProviderFactory.setInstance(factory);
		
		// Bind a dispatcher
		bind(Dispatcher.class).to(ReloadingDispatcher.class);
		
		// Bind SPI interfaces 
		bind(Configuration.class).to(ResteasyConfiguration.class);
		bind(RequestContext.class).to(ResteasyContext.class);
		bind(RenderingContext.class).to(ResteasyRenderingContext.class);
	}
	
	@Provides
	@Singleton
	public Registry provideRegistry(Dispatcher dispatcher)
	{
		return dispatcher.getRegistry();
	}
	
	@Provides
	public UriInfo provideUriInfo()
	{
		return ResteasyProviderFactory.getContextData(UriInfo.class);
	}
	
	@Provides
	public Request provideRequest()
	{
		return ResteasyProviderFactory.getContextData(Request.class);
	}
	
	@Contribution(name="jax-rs-providers")
	public void contributeDefaultMessageProviders(ResteasyProviderFactory factory,
			ByteArrayProvider p1,
			DefaultTextPlain p2,
{'fraction_non_alphanumeric': 0.1037037037037037, 'fraction_numerical': 0.005458089668615985, 'mean_word_length': 6.0, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2656779', 'n_tokens_mistral': 1803, 'n_tokens_neox': 1633, 'n_words': 236}