Search in sources :

Example 1 with EventListener

use of io.micronaut.runtime.event.annotation.EventListener in project micronaut-gcp by micronaut-projects.

the class GoogleClientExample method onStartup.

@EventListener
public void onStartup(StartupEvent event) {
    AccessSecretVersionResponse response = client.accessSecretVersion(AccessSecretVersionRequest.newBuilder().setName(SecretVersionName.of("my-cloud-project", "secretName", "latest").toString()).build());
    String secret = response.getPayload().getData().toStringUtf8();
}
Also used : AccessSecretVersionResponse(com.google.cloud.secretmanager.v1.AccessSecretVersionResponse) EventListener(io.micronaut.runtime.event.annotation.EventListener)

Example 2 with EventListener

use of io.micronaut.runtime.event.annotation.EventListener in project micronaut-starter by micronaut-projects.

the class GenerationListener method onApplicationGenerated.

@EventListener
void onApplicationGenerated(ApplicationGeneratingEvent event) {
    GeneratorContext context = event.getSource();
    List<SelectedFeature> features = context.getFeatures().stream().map(SelectedFeature::new).collect(Collectors.toList());
    Generated generated = new Generated(context.getApplicationType(), context.getLanguage(), context.getBuildTool(), context.getTestFramework(), context.getJdkVersion());
    generated.setSelectedFeatures(features);
    if (analyticsOperations != null) {
        analyticsOperations.applicationGenerated(generated).whenComplete((httpStatus, throwable) -> {
            if (throwable != null) {
                if (LOG.isErrorEnabled()) {
                    LOG.error("Error occurred reporting analytics: " + throwable.getMessage(), throwable);
                }
            }
        });
    }
}
Also used : SelectedFeature(io.micronaut.starter.analytics.SelectedFeature) Generated(io.micronaut.starter.analytics.Generated) GeneratorContext(io.micronaut.starter.application.generator.GeneratorContext) EventListener(io.micronaut.runtime.event.annotation.EventListener)

Aggregations

EventListener (io.micronaut.runtime.event.annotation.EventListener)2 AccessSecretVersionResponse (com.google.cloud.secretmanager.v1.AccessSecretVersionResponse)1 Generated (io.micronaut.starter.analytics.Generated)1 SelectedFeature (io.micronaut.starter.analytics.SelectedFeature)1 GeneratorContext (io.micronaut.starter.application.generator.GeneratorContext)1