title: Working with configuration properties in Jersey
body: <p>I use java/jetty self-hosted server and jersey-2 for java RESTful api.
  Application has application.properties file with properties.</p>
  
  <p><code>ConfigurationProperties</code> class reads and loads properties file into <code>java.util.Properties</code> class.</p>
  
  <p>Jetty server instantiation is done in the following way.</p>
  
  <pre><code>     // Create and register resources
      final ResourceConfig resourceConfig = new ApiServiceConfig()
              .register(new DependencyInjectionBinder());
  
      ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
  
      contextHandler.setContextPath("/mydomain/api");
      Server jettyServer = new Server(8585);
      jettyServer.setHandler(contextHandler);
  
      ServletHolder jerseyServlet = new ServletHolder(new ServletContainer(resourceConfig));
      contextHandler.addServlet(jerseyServlet, "/*");
  
      // Create web context. Can't use.
      //WebApplicationContext webContext = getWebApplicationContext();
      // Add web context to servlet event listener.
      //contextHandler.addEventListener(new ContextLoaderListener(webContext));
  
      try {
          jettyServer.start();
          jettyServer.join();
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } finally {
          jettyServer.destroy();
      }
  </code></pre>
  
  <p>I can't use Spring <code>AnnotationConfigWebApplicationContext</code> as it requires commons-logging dependency which doesn't work in java-8. </p>
  
  <p>How can I register Properties with jetty/jersey context and how can I retrieve values later(eg.: <code>context.getProperty("prop.name")</code>)? </p>