Example usage for org.springframework.context.annotation AnnotationConfigApplicationContext getBeansWithAnnotation

List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext getBeansWithAnnotation

Introduction

In this page you can find the example usage for org.springframework.context.annotation AnnotationConfigApplicationContext getBeansWithAnnotation.

Prototype

@Override
    public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType)
            throws BeansException 

Source Link

Usage

From source file:org.geosdi.geoplatform.experimental.dropwizard.app.CoreServiceApp.java

@Override
public void run(CoreServiceConfig t, Environment e) throws Exception {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(CoreOAuth2ServiceLoader.class);
    ctx.refresh();// www .j av a  2s  .  c  o m
    ctx.registerShutdownHook();
    ctx.start();

    e.jersey().register(
            new JacksonMessageBodyProvider(new GPJacksonSupport().getDefaultMapper(), e.getValidator()));
    e.jersey().register(new OAuth2ExceptionProvider());
    e.jersey().register(new OAuthProvider<>(new CoreOAuthAuthenticator(t), "protected-resources"));
    e.healthChecks().register("service-health-check", new CoreServiceHealthCheck());

    Map<String, Object> resources = ctx.getBeansWithAnnotation(Path.class);

    for (Map.Entry<String, Object> entry : resources.entrySet()) {
        e.jersey().register(entry.getValue());
    }
}