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

org.sdase.commons.server.weld.DropwizardWeldHelper Maven / Gradle / Ivy

Go to download

A libraries to bootstrap services easily that follow the patterns and specifications promoted by the SDA SE

There is a newer version: 7.2.3
Show newest version
package org.sdase.commons.server.weld;

import io.dropwizard.core.Application;
import org.jboss.weld.environment.se.WeldContainer;
import org.sdase.commons.server.weld.internal.WeldSupport;

/**
 * Start a Dropwizard application with Weld support.
 *
 * 

This is used to create the Application class inside the Weld Context, so that the Application, * or instances produced by the Application, can be injected. * *

Example usage: * *

 *   public static void main(final String[] args) throws Exception {
 *     DropwizardWeldHelper.run(Application.class, args);
 *   }
 * 
*/ public class DropwizardWeldHelper { // We are rethrowing a generic exception that we have no control over, ignore the warning public static > void run(Class applicationClass, String... arguments) throws Exception { // NOSONAR WeldSupport.initializeCDIProviderIfRequired(); // We are not calling shutdown on the weld container, as it has an automatic shutdown hook on // application exit, // so ignore the warning. Calling shutdown here is dangerous, as Application.run isn't blocking // as one would // expect and that would cause the weld container to be unloaded directly after startup while // the application is // still running. WeldContainer weldContainer = WeldSupport.createWeldContainer(); // NOSONAR weldContainer.select(applicationClass).getHandle().get().run(arguments); } private DropwizardWeldHelper() { // No public constructor } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy