Search in sources :

Example 11 with MimetypesFileTypeMap

use of javax.activation.MimetypesFileTypeMap in project graylog2-server by Graylog2.

the class GenericBindings method configure.

@Override
protected void configure() {
    // This is holding all our metrics.
    bind(MetricRegistry.class).toProvider(MetricRegistryProvider.class).asEagerSingleton();
    // must not be a singleton!
    bind(LocalMetricRegistry.class).in(Scopes.NO_SCOPE);
    install(new FactoryModuleBuilder().build(DecodingProcessor.Factory.class));
    bind(ProcessBuffer.class).asEagerSingleton();
    bind(InputBuffer.class).to(InputBufferImpl.class);
    bind(NodeId.class).toProvider(NodeIdProvider.class);
    bind(ServiceManager.class).toProvider(ServiceManagerProvider.class).asEagerSingleton();
    bind(HashedWheelTimer.class).toInstance(new HashedWheelTimer());
    bind(ThroughputCounter.class);
    bind(EventBus.class).toProvider(EventBusProvider.class).in(Scopes.SINGLETON);
    bind(Semaphore.class).annotatedWith(Names.named("JournalSignal")).toInstance(new Semaphore(0));
    install(new FactoryModuleBuilder().build(new TypeLiteral<IOState.Factory<MessageInput>>() {
    }));
    bind(InputRegistry.class).asEagerSingleton();
    bind(OkHttpClient.class).toProvider(OkHttpClientProvider.class).asEagerSingleton();
    bind(OkHttpClient.class).annotatedWith(Names.named("systemHttpClient")).toProvider(SystemOkHttpClientProvider.class).asEagerSingleton();
    bind(MimetypesFileTypeMap.class).toInstance(new MimetypesFileTypeMap());
    bind(ExecutorService.class).annotatedWith(Names.named("proxiedRequestsExecutorService")).toProvider(ProxiedRequestsExecutorService.class).asEagerSingleton();
}
Also used : MimetypesFileTypeMap(javax.activation.MimetypesFileTypeMap) OkHttpClient(okhttp3.OkHttpClient) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) MessageInput(org.graylog2.plugin.inputs.MessageInput) HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer) Semaphore(java.util.concurrent.Semaphore) InputRegistry(org.graylog2.shared.inputs.InputRegistry) MetricRegistryProvider(org.graylog2.shared.bindings.providers.MetricRegistryProvider) EventBusProvider(org.graylog2.shared.bindings.providers.EventBusProvider) TypeLiteral(com.google.inject.TypeLiteral) ServiceManagerProvider(org.graylog2.shared.bindings.providers.ServiceManagerProvider) ProxiedRequestsExecutorService(org.graylog2.shared.bindings.providers.ProxiedRequestsExecutorService) IOState(org.graylog2.plugin.IOState) NodeId(org.graylog2.plugin.system.NodeId) SystemOkHttpClientProvider(org.graylog2.shared.bindings.providers.SystemOkHttpClientProvider) OkHttpClientProvider(org.graylog2.shared.bindings.providers.OkHttpClientProvider) ProxiedRequestsExecutorService(org.graylog2.shared.bindings.providers.ProxiedRequestsExecutorService) ExecutorService(java.util.concurrent.ExecutorService) InputBuffer(org.graylog2.plugin.buffers.InputBuffer) SystemOkHttpClientProvider(org.graylog2.shared.bindings.providers.SystemOkHttpClientProvider) ProcessBuffer(org.graylog2.shared.buffers.ProcessBuffer) LocalMetricRegistry(org.graylog2.plugin.LocalMetricRegistry)

Example 12 with MimetypesFileTypeMap

use of javax.activation.MimetypesFileTypeMap in project spring-framework by spring-projects.

the class MockServletContextTests method getMimeTypeWithCustomConfiguredType.

/**
	 * Introduced to dispel claims in a thread on Stack Overflow:
	 * <a href="http://stackoverflow.com/questions/22986109/testing-spring-managed-servlet">Testing Spring managed servlet</a>
	 */
@Test
public void getMimeTypeWithCustomConfiguredType() {
    FileTypeMap defaultFileTypeMap = FileTypeMap.getDefaultFileTypeMap();
    assertThat(defaultFileTypeMap, instanceOf(MimetypesFileTypeMap.class));
    MimetypesFileTypeMap mimetypesFileTypeMap = (MimetypesFileTypeMap) defaultFileTypeMap;
    mimetypesFileTypeMap.addMimeTypes("text/enigma    enigma");
    assertEquals("text/enigma", sc.getMimeType("filename.enigma"));
}
Also used : MimetypesFileTypeMap(javax.activation.MimetypesFileTypeMap) FileTypeMap(javax.activation.FileTypeMap) MimetypesFileTypeMap(javax.activation.MimetypesFileTypeMap) Test(org.junit.Test)

Example 13 with MimetypesFileTypeMap

use of javax.activation.MimetypesFileTypeMap in project netty by netty.

the class HttpStaticFileServerHandler method setContentTypeHeader.

/**
     * Sets the content type header for the HTTP Response
     *
     * @param response
     *            HTTP response
     * @param file
     *            file to extract content type
     */
private static void setContentTypeHeader(HttpResponse response, File file) {
    MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
    response.headers().set(HttpHeaderNames.CONTENT_TYPE, mimeTypesMap.getContentType(file.getPath()));
}
Also used : MimetypesFileTypeMap(javax.activation.MimetypesFileTypeMap)

Example 14 with MimetypesFileTypeMap

use of javax.activation.MimetypesFileTypeMap in project async-http-client by AsyncHttpClient.

the class HttpStaticFileServerHandler method setContentTypeHeader.

/**
     * Sets the content type header for the HTTP Response
     *
     * @param response
     *            HTTP response
     * @param file
     *            file to extract content type
     */
private static void setContentTypeHeader(HttpResponse response, File file) {
    MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
    response.headers().set(CONTENT_TYPE, mimeTypesMap.getContentType(file.getPath()));
}
Also used : MimetypesFileTypeMap(javax.activation.MimetypesFileTypeMap)

Aggregations

MimetypesFileTypeMap (javax.activation.MimetypesFileTypeMap)14 File (java.io.File)5 MimeType (javax.activation.MimeType)3 MimeTypeParseException (javax.activation.MimeTypeParseException)3 Before (org.junit.Before)3 Failure (org.junit.runner.notification.Failure)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 URL (java.net.URL)2 List (java.util.List)2 Map (java.util.Map)2 CoreLocale (app.hongs.CoreLocale)1 Action (app.hongs.action.anno.Action)1 IAction (app.hongs.dh.IAction)1 TypeLiteral (com.google.inject.TypeLiteral)1 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1