All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.devlibx.easy.app.dropwizard.proto.ProtobufBundle Maven / Gradle / Ivy

There is a newer version: 3.java-17.1
Show newest version
package io.github.devlibx.easy.app.dropwizard.proto;

import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.jersey.protobuf.InvalidProtocolBufferExceptionMapper;
import io.dropwizard.jersey.protobuf.ProtocolBufferMessageBodyProvider;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;

public class ProtobufBundle implements ConfiguredBundle {
    static boolean preservingProtoFieldNames;

    private Class protocolBufferMessageBodyProviderClass;

    public ProtobufBundle() {
        preservingProtoFieldNames = true;
        protocolBufferMessageBodyProviderClass = EasyProtocolBufferMessageBodyProvider.class;
    }

    public ProtobufBundle(boolean preservingProtoFieldNames) {
        ProtobufBundle.preservingProtoFieldNames = preservingProtoFieldNames;
        protocolBufferMessageBodyProviderClass = EasyProtocolBufferMessageBodyProvider.class;
    }

    public ProtobufBundle(boolean preservingProtoFieldNames, Class protocolBufferMessageBodyProviderClass) {
        ProtobufBundle.preservingProtoFieldNames = preservingProtoFieldNames;
        this.protocolBufferMessageBodyProviderClass = protocolBufferMessageBodyProviderClass;
    }

    public void initialize(Bootstrap bootstrap) {
    }

    public void run(C configuration, Environment environment) {
        environment.jersey().register(protocolBufferMessageBodyProviderClass);
        environment.jersey().register(InvalidProtocolBufferExceptionMapper.class);
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy