Exemple

Cette section fournit un exemple d’application basée sur Spring Boot permettant la recherche de document.


@SpringBootApplication
@ComponentScan("com.flower.docs.security.authentication")
@Import(ClientSecurityConfiguration.class)
@ImportResource({ "classpath:flower-docs-services-webservices.xml" })
public class Sample implements CommandLineRunner
{
    private static final Logger LOGGER = LoggerFactory.getLogger(Sample.class);

    public static void main(String[] args)
    {
        SpringApplication.run(Sample.class, args);
    }

    @Autowired
    private Authenticator authenticator;

    @Autowired
    private DocumentService documentService;

    @Override
    public void run(String... arg0) throws Exception
    {
        authenticator.authenticate("GEC");
        SearchRequest request = SearchRequestBuilder.init().max(0).build();
        SearchResponse response = documentService.search(request);
        LOGGER.info("Found {} documents", response.getFound());
    }
}