Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get applicationContextPath in dropwizard 1.0.0

We are using server configuration in yml file which looks like as below

server:
type: simple

connector:
  type: http
  port: 8061

applicationContextPath: /administration
adminContextPath: /admin

#disable the registration of default Jersey ExceptionMappers
registerDefaultExceptionMappers: false

I want to get "applicationContextPath" when I start my dropwizard service.

I am trying to get it using

environment.getApplicationContext().getContextPath();

but I am getting "/" i.e. default value. Is there anyway to get this.

like image 359
jack Avatar asked Oct 30 '22 20:10

jack


1 Answers

In order get applicationContextPath we need to get ServerFactory from Configuration and parse it to SimpleServerFactory as below:

((SimpleServerFactory) getConfiguration().getServerFactory()).getApplicationContextPath()
like image 73
jack Avatar answered Nov 15 '22 06:11

jack