Use Dropwizard (2)-Configure classification Configuredbundle

Source: Internet
Author: User

Objective

It is unavoidable to use Dropwizard as the service framework. Continuous learning. The last time you used feign in Dropwizard, using Hystrix, was a basic primer. The next step is optimization based on this.

Separate the logic that needs to use the configuration from the application.

In the beginning of the demo, because do not know dropwizard how to spread the class, how to inject, put all the initialization of everything into the application to new out. Now we find a way to detach some of the configuration logic.

Now pull out the feign base configuration:

 Public classConnectivitybundleImplementsconfiguredbundle@Override     Public void Run(helloworldconfiguration Configuration, Environment environment)throwsException {//init hystrix configmap<string, object> hystrixconfig = Configuration.Gethystrixconfig(); for(FinalMap.Entry<string, object> config:hystrixconfig.EntrySet()) {ConfigurationManager.getconfiginstance().SetProperty(config.GetKey(), CONFIG.GetValue()); System. out.println(config.GetKey()); }    }@Override     Public void Initialize(bootstrap<?> Bootstrap) {    }}

Then, add it in the application.
Com.test.HelloWorldApplication

@Overridepublicvoidinitialize(Bootstrap<HelloWorldConfiguration> bootstrap) {    bootstrap.addBundle(newConnectivityBundle());}

Use Dropwizard (2)-Configure classification Configuredbundle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.