javax.enterprise.inject.Vetoed Java Examples

The following examples show how to use javax.enterprise.inject.Vetoed. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SmallRyeReactiveMessagingProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
public void enableMetrics(BuildProducer<AnnotationsTransformerBuildItem> transformers,
        Capabilities capabilities, ReactiveMessagingConfiguration configuration) {
    boolean isMetricEnabled = capabilities.isPresent(Capability.METRICS) && configuration.metricsEnabled;
    if (!isMetricEnabled) {
        LOGGER.debug("Metric is disabled - vetoing the MetricDecorator");
        // We veto the Metric Decorator
        AnnotationsTransformerBuildItem veto = new AnnotationsTransformerBuildItem(new AnnotationsTransformer() {
            @Override
            public boolean appliesTo(AnnotationTarget.Kind kind) {
                return kind == org.jboss.jandex.AnnotationTarget.Kind.CLASS;
            }

            @Override
            public void transform(AnnotationsTransformer.TransformationContext ctx) {
                if (ctx.isClass() && ctx.getTarget().asClass().name().equals(
                        ReactiveMessagingDotNames.METRIC_DECORATOR)) {
                    ctx.transform().add(Vetoed.class).done();
                }
            }
        });
        transformers.produce(veto);
    }
}
 
Example #2
Source File: AnnotationsTransformerTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Override
public void transform(TransformationContext context) {
    if (context.isClass()) {
        if (context.getTarget().asClass().name().toString().equals(One.class.getName())) {
            // Veto bean class One
            context.transform().add(Vetoed.class).done();
        }
        if (context.getTarget().asClass().name().local().equals(IWantToBeABean.class.getSimpleName())) {
            context.transform().add(Dependent.class).done();
        }
    } else if (context.isField() && context.getTarget().asField().name().equals("seven")) {
        context.transform().add(Inject.class).done();
    }
}