or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

bundles.mdcli.mdcore-application.mdenvironment-setup.mdindex.mdserver-config.md
tile.json

tessl/maven-io-dropwizard--dropwizard-core

Core components of the Dropwizard framework for building Java web applications

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/io.dropwizard/dropwizard-core@4.0.x

To install, run

npx @tessl/cli install tessl/maven-io-dropwizard--dropwizard-core@4.0.0

index.mddocs/

Dropwizard Core

Dropwizard Core provides the fundamental building blocks for creating production-ready Java web applications. It combines Jetty, Jersey, Jackson, and other proven libraries into a cohesive framework that enables rapid development of RESTful web services with built-in metrics, logging, health checks, and operational features.

Package Information

  • Package Name: io.dropwizard:dropwizard-core
  • Package Type: maven
  • Language: Java
  • Installation: Add to Maven pom.xml:
    <dependency>
      <groupId>io.dropwizard</groupId>
      <artifactId>dropwizard-core</artifactId>
      <version>4.0.14</version>
    </dependency>

Core Imports

import io.dropwizard.core.Application;
import io.dropwizard.core.Configuration;
import io.dropwizard.core.setup.Bootstrap;
import io.dropwizard.core.setup.Environment;

Basic Usage

import io.dropwizard.core.Application;
import io.dropwizard.core.Configuration;
import io.dropwizard.core.setup.Bootstrap;
import io.dropwizard.core.setup.Environment;

public class HelloWorldApplication extends Application<HelloWorldConfiguration> {
    public static void main(String[] args) throws Exception {
        new HelloWorldApplication().run(args);
    }

    @Override
    public String getName() {
        return "hello-world";
    }

    @Override
    public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) {
        // Add bundles to bootstrap
    }

    @Override
    public void run(HelloWorldConfiguration configuration, Environment environment) {
        // Register resources, health checks, tasks, etc.
        final HelloWorldResource resource = new HelloWorldResource(
            configuration.getTemplate(),
            configuration.getDefaultName()
        );
        environment.jersey().register(resource);
    }
}

public class HelloWorldConfiguration extends Configuration {
    @NotEmpty
    private String template = "Hello, %s!";

    @NotEmpty  
    private String defaultName = "Stranger";

    @JsonProperty
    public String getTemplate() {
        return template;
    }

    @JsonProperty
    public void setTemplate(String template) {
        this.template = template;
    }

    @JsonProperty
    public String getDefaultName() {
        return defaultName;
    }

    @JsonProperty
    public void setDefaultName(String name) {
        this.defaultName = name;
    }
}

Architecture

Dropwizard Core is built around several key components:

  • Application Lifecycle: Application class serves as the main entry point with configurable bootstrapping and runtime phases
  • Configuration Management: YAML-based configuration with type-safe binding via Jackson and Bean Validation
  • Environment Abstraction: Environment class provides unified access to Jersey, servlet, admin, lifecycle, and health subsystems
  • Command-Line Interface: Extensible CLI system with built-in server and configuration check commands
  • Server Factories: Pluggable server implementations (Default multi-connector, Simple single-connector)
  • Bundle System: Reusable application components that can be registered during bootstrap

Capabilities

Core Application Framework

Essential classes for building Dropwizard applications including the main Application class, Configuration base class, and Bootstrap setup.

public abstract class Application<T extends Configuration> {
    public abstract void run(T configuration, Environment environment) throws Exception;
    public void initialize(Bootstrap<T> bootstrap);
    public void run(String... arguments) throws Exception;
}

public class Configuration {
    public ServerFactory getServerFactory();
    public LoggingFactory getLoggingFactory();
    public MetricsFactory getMetricsFactory();
    public AdminFactory getAdminFactory();
    public Optional<HealthFactory> getHealthFactory();
}

Core Application Framework

Environment and Setup

Environment management providing access to Jersey, servlet container, admin interface, lifecycle management, and health checks.

public class Environment {
    public JerseyEnvironment jersey();
    public ServletEnvironment servlets(); 
    public AdminEnvironment admin();
    public LifecycleEnvironment lifecycle();
    public HealthEnvironment health();
    public MetricRegistry metrics();
    public HealthCheckRegistry healthChecks();
}

public class Bootstrap<T extends Configuration> {
    public void addBundle(ConfiguredBundle<? super T> bundle);
    public void addCommand(Command command);
    public MetricRegistry getMetricRegistry();
    public ObjectMapper getObjectMapper();
}

Environment and Setup

Command-Line Interface

Extensible command-line interface system with built-in commands for server management and configuration validation.

public abstract class Command {
    public Command(String name, String description);
    public abstract void configure(Subparser subparser);
    public abstract void run(Bootstrap<?> bootstrap, Namespace namespace) throws Exception;
}

public abstract class ConfiguredCommand<T extends Configuration> extends Command {
    protected abstract void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception;
}

Command-Line Interface

Server Configuration

Pluggable server factory system supporting different deployment patterns with configurable connectors and thread pools.

public interface ServerFactory extends Discoverable {
    Server build(Environment environment);
    void configure(Environment environment);
}

public class DefaultServerFactory extends AbstractServerFactory {
    // Multi-connector server supporting separate application and admin ports
}

public class SimpleServerFactory extends AbstractServerFactory {
    // Single-connector server combining application and admin on same port
}

Server Configuration

Bundle System and SSL Reload

Reusable application components and built-in bundles for common functionality like SSL certificate reloading.

public interface ConfiguredBundle<T> {
    default void run(T configuration, Environment environment) throws Exception;
    default void initialize(Bootstrap<?> bootstrap);
}

public class SslReloadBundle implements ConfiguredBundle<Configuration> {
    // Provides SSL certificate reloading capability via admin task
}

Bundle System

Common Types

// Base configuration class
public class Configuration {
    @Valid @NotNull
    private ServerFactory server = new DefaultServerFactory();
    
    @Valid @Nullable
    private LoggingFactory logging;
    
    @Valid @NotNull
    private MetricsFactory metrics = new MetricsFactory();
    
    @Valid @NotNull
    private AdminFactory admin = new AdminFactory();
    
    @Valid @Nullable
    private HealthFactory health;
}

// ConfiguredBundle interface for reusable components
public interface ConfiguredBundle<T> {
    default void run(T configuration, Environment environment) throws Exception;
    default void initialize(Bootstrap<?> bootstrap);
}

// Server factory interface for pluggable server implementations
public interface ServerFactory extends Discoverable {
    Server build(Environment environment);
    void configure(Environment environment);
}