Java Code Examples for io.dropwizard.setup.Environment#getApplicationContext()
The following examples show how to use
io.dropwizard.setup.Environment#getApplicationContext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KaramelServiceApplication.java From karamel with Apache License 2.0 | 6 votes |
public int getPort(Environment environment) { int defaultPort = 9090; MutableServletContextHandler h = environment.getApplicationContext(); if (h == null) { return defaultPort; } Server s = h.getServer(); if (s == null) { return defaultPort; } Connector[] c = s.getConnectors(); if (c != null && c.length > 0) { AbstractNetworkConnector anc = (AbstractNetworkConnector) c[0]; if (anc != null) { return anc.getLocalPort(); } } return defaultPort; }
Example 2
Source File: Pac4jBundle.java From dropwizard-pac4j with Apache License 2.0 | 3 votes |
/** * Override if needed, but prefer to exploit * {@link Pac4jFactory#setSessionEnabled(boolean)} first. * * @param environment * the dropwizard {@link Environment} * @since 1.1.0 */ protected void setupJettySession(Environment environment) { MutableServletContextHandler contextHandler = environment .getApplicationContext(); if (contextHandler.getSessionHandler() == null) { contextHandler.setSessionHandler(new SessionHandler()); } }