Class Configuration

  • Direct Known Subclasses:
    HelloWorldConfiguration

    public class Configuration
    extends Object
    An object representation of the YAML configuration file. Extend this with your own configuration properties, and they'll be parsed from the YAML file as well.

    For example, given a YAML file with this:

     name: "Random Person"
     age: 43
     # ... etc ...
     
    And a configuration like this:
     public class ExampleConfiguration extends Configuration {
         \@NotNull
         private String name;
    
         \@Min(1)
         \@Max(120)
         private int age;
    
         \@JsonProperty
         public String getName() {
             return name;
         }
    
         \@JsonProperty
         public void setName(String name) {
             this.name = name;
         }
    
         \@JsonProperty
         public int getAge() {
             return age;
         }
    
         \@JsonProperty
         public void setAge(int age) {
             this.age = age;
         }
     }
     

    Dropwizard will parse the given YAML file and provide an ExampleConfiguration instance to your application whose getName() method will return "Random Person" and whose getAge() method will return 43.

    See Also:
    YAML Cookbook
    • Constructor Detail

      • Configuration

        public Configuration()
    • Method Detail

      • getServerFactory

        public ServerFactory getServerFactory()
        Returns the server-specific section of the configuration file.
        Returns:
        server-specific configuration parameters
      • setServerFactory

        public void setServerFactory​(ServerFactory factory)
        Sets the HTTP-specific section of the configuration file.
      • getLoggingFactory

        public LoggingFactory getLoggingFactory()
        Returns the logging-specific section of the configuration file.
        Returns:
        logging-specific configuration parameters
      • setLoggingFactory

        public void setLoggingFactory​(LoggingFactory factory)
        Sets the logging-specific section of the configuration file.
      • setMetricsFactory

        public void setMetricsFactory​(MetricsFactory metrics)
      • getAdminFactory

        public AdminFactory getAdminFactory()
        Returns the admin interface-specific section of the configuration file.
        Returns:
        admin interface-specific configuration parameters
        Since:
        2.0
      • setAdminFactory

        public void setAdminFactory​(AdminFactory admin)
        Sets the admin interface-specific section of the configuration file.
        Since:
        2.0
      • getHealthFactory

        public Optional<HealthFactory> getHealthFactory()
        Returns the health interface-specific section of the configuration file.
        Returns:
        health interface-specific configuration parameters
        Since:
        2.1
      • setHealthFactory

        public void setHealthFactory​(HealthFactory health)
        Sets the health interface-specific section of the configuration file.
        Since:
        2.1