Java tutorial
/** * RESTconfig - RESTful, versioned and secure web service for centralising application configuration data. * * Copyright (C) 2012 Pete Capra * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.petecapra.restconfig; import com.petecapra.restconfig.config.AppConfig; import com.petecapra.restconfig.health.DatabaseHealthCheck; import com.petecapra.restconfig.resource.ApplicationsResource; import com.petecapra.restconfig.resource.EnvironmentApplicationsResource; import com.petecapra.restconfig.resource.EnvironmentsResource; import com.yammer.dropwizard.Service; import com.yammer.dropwizard.config.Environment; import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class RESTConfigService extends Service<RESTConfigConfiguration> { public static void main(String[] args) throws Exception { new RESTConfigService().run(args); } protected RESTConfigService() { super("rest-config"); } @Override protected void initialize(RESTConfigConfiguration configuration, Environment environment) throws Exception { // TODO: externalise this and automatically scan context for resources and health checks AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class); //ctx.scan("com.petecapra.restconfig"); environment.addResource(ctx.getBean(EnvironmentsResource.class)); environment.addResource(ctx.getBean(ApplicationsResource.class)); environment.addResource(ctx.getBean(EnvironmentApplicationsResource.class)); environment.addHealthCheck(ctx.getBean(DatabaseHealthCheck.class)); } }