package lemming;

import lemming.lemma.LemmaResource;
import lemming.pos.PosResource;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.server.ResourceConfig;

import javax.ws.rs.ApplicationPath;
import java.util.logging.Level;
import java.util.logging.Logger;

@ApplicationPath("/api")
public class Application extends ResourceConfig {

    public Application() {
        Logger logger = Logger.getLogger(Application.class.getName());

        // configure lemma resource logging
        ResourceConfig lemmaResourceConfig = new ResourceConfig(LemmaResource.class);
        lemmaResourceConfig.register(new LoggingFeature(logger, Level.ALL, LoggingFeature.Verbosity.PAYLOAD_ANY,
               LoggingFeature.DEFAULT_MAX_ENTITY_SIZE));

        // configure pos resource logging
        ResourceConfig posResourceConfig = new ResourceConfig(PosResource.class);
        posResourceConfig.register(new LoggingFeature(logger, Level.ALL, LoggingFeature.Verbosity.PAYLOAD_ANY,
                LoggingFeature.DEFAULT_MAX_ENTITY_SIZE));

        packages("lemming.context");
        packages("lemming.lemma");
        packages("lemming.pos");
        register(JacksonFeature.class);
    }
}

@@ -7,24 +7,64 @@
 e lemming;%0A%0A
+import lemming.context.ContextResource;%0A
 import lemmi
@@ -215,32 +215,81 @@
 LoggingFeature;%0A
+import org.glassfish.jersey.message.GZipEncoder;%0A
 import org.glass
@@ -322,16 +322,74 @@
 eConfig;
+%0Aimport org.glassfish.jersey.server.filter.EncodingFilter;
 %0A%0Aimport
@@ -559,17 +559,16 @@
 onfig %7B%0A
-%0A
     publ
@@ -654,24 +654,462 @@
 etName());%0A%0A
+        // configure context resource logging%0A        ResourceConfig contextResourceConfig = new ResourceConfig(ContextResource.class);%0A        contextResourceConfig.register(new LoggingFeature(logger, Level.ALL, LoggingFeature.Verbosity.PAYLOAD_ANY,%0A                LoggingFeature.DEFAULT_MAX_ENTITY_SIZE));%0A        // enable gzip encoder for context resource%0A        EncodingFilter.enableFor(contextResourceConfig, GZipEncoder.class);%0A%0A
         // c
@@ -1387,32 +1387,156 @@
 X_ENTITY_SIZE));
+%0A        // enable gzip encoder for lemma resource%0A        EncodingFilter.enableFor(lemmaResourceConfig, GZipEncoder.class);
 %0A%0A        // con
@@ -1813,16 +1813,136 @@
 _SIZE));
+%0A        // enable gzip encoder for pos resource%0A        EncodingFilter.enableFor(posResourceConfig, GZipEncoder.class);
 %0A%0A      
@@ -2076,20 +2076,195 @@
 ure.class);%0A
+        // enable logging%0A        register(LoggingFeature.class);%0A        // enable gzip encoding%0A        register(EncodingFilter.class);%0A        register(GZipEncoder.class);%0A
     %7D%0A%7D%0A

Enable gzip compression for jersey resources.