javax.enterprise.inject.Produces Java Examples
The following examples show how to use
javax.enterprise.inject.Produces.
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: RegistryStorageProducer.java From apicurio-registry with Apache License 2.0 | 6 votes |
@Produces @ApplicationScoped @Current public RegistryStorage realImpl() { List<RegistryStorage> list = storages.stream().collect(Collectors.toList()); RegistryStorage impl = null; if (list.size() == 1) { impl = list.get(0); } else { for (RegistryStorage rs : list) { if (rs instanceof InMemoryRegistryStorage == false) { impl = rs; break; } } } if (impl != null) { log.info(String.format("Using RegistryStore: %s", impl.getClass().getName())); return impl; } throw new IllegalStateException("Should not be here ... ?!"); }
Example #2
Source File: DatawaveConfigPropertyProducer.java From datawave with Apache License 2.0 | 6 votes |
@Produces @Dependent @ConfigProperty(name = "ignored") // we actually don't need the name public List<Float> produceFloatListConfiguration(InjectionPoint injectionPoint) { String propertyValue = getStringPropertyValue(injectionPoint); String[] values = StringUtils.split(propertyValue, ","); ArrayList<Float> list = new ArrayList<>(); if (values != null) { for (String value : values) { try { list.add(Float.parseFloat(value)); } catch (NumberFormatException nfe) { ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class); throw new RuntimeException("Error while converting Float property '" + configProperty.name() + "' value: " + value + " of " + propertyValue + " happening in bean " + injectionPoint.getBean(), nfe); } } } return list; }
Example #3
Source File: ClientProducers.java From smallrye-reactive-messaging with Apache License 2.0 | 6 votes |
@Produces @Named("my-named-options") public AmqpClientOptions getNamedOptions() { // You can use the produced options to configure the TLS connection PemKeyCertOptions keycert = new PemKeyCertOptions() .addCertPath("./tls/tls.crt") .addKeyPath("./tls/tls.key"); PemTrustOptions trust = new PemTrustOptions().addCertPath("./tlc/ca.crt"); return new AmqpClientOptions() .setSsl(true) .setPemKeyCertOptions(keycert) .setPemTrustOptions(trust) .addEnabledSaslMechanism("EXTERNAL") .setHostnameVerificationAlgorithm("") .setConnectTimeout(30000) .setReconnectInterval(5000) .setContainerId("my-container"); }
Example #4
Source File: KafkaRegistryConfiguration.java From apicurio-registry with Apache License 2.0 | 6 votes |
@Produces @ApplicationScoped public CloseableSupplier<Boolean> livenessCheck( @RegistryProperties( value = {"registry.kafka.common", "registry.kafka.liveness-check"}, empties = {"ssl.endpoint.identification.algorithm="} ) Properties properties ) { AdminClient admin = AdminClient.create(properties); return new CloseableSupplier<Boolean>() { @Override public void close() { admin.close(); } @Override public Boolean get() { return (admin.listTopics() != null); } }; }
Example #5
Source File: StreamsRegistryConfiguration.java From apicurio-registry with Apache License 2.0 | 6 votes |
@Produces @ApplicationScoped public ReadOnlyKeyValueStore<Long, Str.TupleValue> globalIdKeyValueStore( KafkaStreams streams, HostInfo storageLocalHost, StreamsProperties properties ) { return new DistributedReadOnlyKeyValueStore<>( streams, storageLocalHost, properties.getGlobalIdStoreName(), Serdes.Long(), ProtoSerde.parsedWith(Str.TupleValue.parser()), new DefaultGrpcChannelProvider(), true, (filter, over, id, tuple) -> true ); }
Example #6
Source File: DatawaveConfigPropertyProducer.java From datawave with Apache License 2.0 | 6 votes |
@Produces @Dependent @ConfigProperty(name = "ignored") // we actually don't need the name public List<Long> produceLongListConfiguration(InjectionPoint injectionPoint) { String propertyValue = getStringPropertyValue(injectionPoint); String[] values = StringUtils.split(propertyValue, ","); ArrayList<Long> list = new ArrayList<>(); if (values != null) { for (String value : values) { try { list.add(Long.parseLong(value)); } catch (NumberFormatException nfe) { ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class); throw new RuntimeException("Error while converting Long property '" + configProperty.name() + "' value: " + value + " of " + propertyValue + " happening in bean " + injectionPoint.getBean(), nfe); } } } return list; }
Example #7
Source File: StreamsRegistryConfiguration.java From apicurio-registry with Apache License 2.0 | 5 votes |
@Produces @Singleton public HostInfo storageLocalHost(StreamsProperties props) { String appServer = props.getApplicationServer(); String[] hostPort = appServer.split(":"); log.info("Application server gRPC: '{}'", appServer); return new HostInfo(hostPort[0], Integer.parseInt(hostPort[1])); }
Example #8
Source File: InfinispanClientProducer.java From quarkus with Apache License 2.0 | 5 votes |
@io.quarkus.infinispan.client.Remote @Produces public <K, V> RemoteCache<K, V> getRemoteCache(InjectionPoint injectionPoint, RemoteCacheManager cacheManager) { Set<Annotation> annotationSet = injectionPoint.getQualifiers(); final io.quarkus.infinispan.client.Remote remote = getRemoteAnnotation(annotationSet); if (remote != null && !remote.value().isEmpty()) { return cacheManager.getCache(remote.value()); } return cacheManager.getCache(); }
Example #9
Source File: KafkaRegistryConfiguration.java From apicurio-registry with Apache License 2.0 | 5 votes |
@Produces @ApplicationScoped public ProducerActions<Cmmn.UUID, Str.StorageValue> storageProducer( @RegistryProperties( value = {"registry.kafka.common", "registry.kafka.storage-producer"}, empties = {"ssl.endpoint.identification.algorithm="} ) Properties properties ) { return new AsyncProducer<>( properties, ProtoSerde.parsedWith(Cmmn.UUID.parser()), ProtoSerde.parsedWith(Str.StorageValue.parser()) ); }
Example #10
Source File: MetricProducer.java From smallrye-metrics with Apache License 2.0 | 5 votes |
@Produces <T extends Number> Gauge<T> getGauge(InjectionPoint ip) { // A forwarding Gauge must be returned as the Gauge creation happens when the declaring bean gets instantiated and the corresponding Gauge can be injected before which leads to producing a null value return () -> { // TODO: better error report when the gauge doesn't exist SortedMap<MetricID, Gauge> gauges = applicationRegistry.getGauges(); String name = metricName.of(ip); MetricID gaugeId = new MetricID(name); return ((Gauge<T>) gauges.get(gaugeId)).getValue(); }; }
Example #11
Source File: IfBuildProfileTest.java From quarkus with Apache License 2.0 | 5 votes |
@Produces FooBean testFooBean() { return new FooBean() { @Override public String foo() { return "foo from test"; } }; }
Example #12
Source File: TopologyProducer.java From quarkus-quickstarts with Apache License 2.0 | 5 votes |
@Produces public Topology buildTopology() { StreamsBuilder builder = new StreamsBuilder(); JsonbSerde<WeatherStation> weatherStationSerde = new JsonbSerde<>(WeatherStation.class); JsonbSerde<Aggregation> aggregationSerde = new JsonbSerde<>(Aggregation.class); KeyValueBytesStoreSupplier storeSupplier = Stores.persistentKeyValueStore(WEATHER_STATIONS_STORE); GlobalKTable<Integer, WeatherStation> stations = builder.globalTable( WEATHER_STATIONS_TOPIC, Consumed.with(Serdes.Integer(), weatherStationSerde)); builder.stream( TEMPERATURE_VALUES_TOPIC, Consumed.with(Serdes.Integer(), Serdes.String())) .join( stations, (stationId, timestampAndValue) -> stationId, (timestampAndValue, station) -> { String[] parts = timestampAndValue.split(";"); return new TemperatureMeasurement(station.id, station.name, Instant.parse(parts[0]), Double.valueOf(parts[1])); }) .groupByKey() .aggregate( Aggregation::new, (stationId, value, aggregation) -> aggregation.updateFrom(value), Materialized.<Integer, Aggregation> as(storeSupplier) .withKeySerde(Serdes.Integer()) .withValueSerde(aggregationSerde)) .toStream() .to( TEMPERATURES_AGGREGATED_TOPIC, Produced.with(Serdes.Integer(), aggregationSerde)); return builder.build(); }
Example #13
Source File: StreamsRegistryConfiguration.java From apicurio-registry with Apache License 2.0 | 5 votes |
@Produces @Singleton public KafkaStreams storageStreams( StreamsProperties properties, ForeachAction<? super String, ? super Str.Data> dataDispatcher, ArtifactTypeUtilProviderFactory factory ) { Topology topology = new StreamsTopologyProvider(properties, dataDispatcher, factory).get(); KafkaStreams streams = new KafkaStreams(topology, properties.getProperties()); streams.setGlobalStateRestoreListener(new LoggingStateRestoreListener()); return streams; }
Example #14
Source File: AmqpConfiguration.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Produces @Named("my-topic-config2") public AmqpClientOptions options2() { return new AmqpClientOptions() .setHost("localhost") .setPort(5672) .setUsername("smallrye") .setPassword("smallrye"); }
Example #15
Source File: KafkaReceiverApplication.java From eda-tutorial with Apache License 2.0 | 5 votes |
@Produces @Named("kafka") public KafkaComponent kafka() { KafkaComponent kafkaComponent = new KafkaComponent(); KafkaConfiguration configuration = new KafkaConfiguration(); configuration.setBrokers("localhost:9092"); kafkaComponent.setConfiguration(configuration); return kafkaComponent; }
Example #16
Source File: StreamsRegistryConfiguration.java From apicurio-registry with Apache License 2.0 | 5 votes |
@Produces @Singleton public WaitForDataService waitForDataServiceImpl( ReadOnlyKeyValueStore<String, Str.Data> storageKeyValueStore, ForeachActionDispatcher<String, Str.Data> storageDispatcher ) { return new WaitForDataService(storageKeyValueStore, storageDispatcher); }
Example #17
Source File: UnlessBuildProfileTest.java From quarkus with Apache License 2.0 | 5 votes |
@Produces @UnlessBuildProfile("test") PingBean notTestPingBean() { return new PingBean() { @Override String ping() { return "ping not test"; } }; }
Example #18
Source File: StreamsRegistryConfiguration.java From apicurio-registry with Apache License 2.0 | 5 votes |
@Produces @Singleton public LocalService<AsyncBiFunctionService.WithSerdes<Void, Void, KafkaStreams.State>> localStateService( StateService localService ) { return new LocalService<>( StateService.NAME, localService ); }
Example #19
Source File: ChannelProducer.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
/** * Injects {@code Multi<Message<X>>} and {@code Multi<X>}. It also matches the injection of * {@code Publisher<Message<X>>} and {@code Publisher<X>}. * * @param injectionPoint the injection point * @param <T> the first generic parameter (either Message or X) * @return the Multi to be injected */ @Produces @Channel("") // Stream name is ignored during type-safe resolution <T> Multi<T> produceMulti(InjectionPoint injectionPoint) { Type first = getFirstParameter(injectionPoint.getType()); if (TypeUtils.isAssignable(first, Message.class)) { return cast(Multi.createFrom().publisher(getPublisher(injectionPoint))); } else { return cast(Multi.createFrom().publisher(getPublisher(injectionPoint)).map(Message::getPayload)); } }
Example #20
Source File: ConfigSourceProvider.java From smallrye-config with Apache License 2.0 | 5 votes |
@Produces @Name("") public ConfigSource produceConfigSource(final InjectionPoint injectionPoint) { Set<Annotation> qualifiers = injectionPoint.getQualifiers(); String name = getName(qualifiers); return configSourceMap.get(name); }
Example #21
Source File: RawClaimTypeProducer.java From smallrye-jwt with Apache License 2.0 | 5 votes |
@Produces @Claim("") Set<String> getClaimAsSet(InjectionPoint ip) { CDILogging.log.getClaimAsSet(ip); if (currentToken == null) { return null; } String name = getName(ip); return (Set<String>) JsonUtils.convert(Set.class, currentToken.getClaim(name)); }
Example #22
Source File: KafkaStreamsPipeline.java From quarkus with Apache License 2.0 | 5 votes |
@Produces public Topology buildTopology() { StreamsBuilder builder = new StreamsBuilder(); ObjectMapperSerde<Category> categorySerde = new ObjectMapperSerde<>(Category.class); ObjectMapperSerde<Customer> customerSerde = new ObjectMapperSerde<>(Customer.class); ObjectMapperSerde<EnrichedCustomer> enrichedCustomerSerde = new ObjectMapperSerde<>(EnrichedCustomer.class); KTable<Integer, Category> categories = builder.table( "streams-test-categories", Consumed.with(Serdes.Integer(), categorySerde)); KStream<Integer, EnrichedCustomer> customers = builder .stream("streams-test-customers", Consumed.with(Serdes.Integer(), customerSerde)) .selectKey((id, customer) -> customer.category) .join( categories, (customer, category) -> { return new EnrichedCustomer(customer.id, customer.name, category); }, Joined.with(Serdes.Integer(), customerSerde, categorySerde)); KeyValueBytesStoreSupplier storeSupplier = Stores.inMemoryKeyValueStore("countstore"); customers.groupByKey() .count(Materialized.<Integer, Long> as(storeSupplier)); customers.selectKey((categoryId, customer) -> customer.id) .to("streams-test-customers-processed", Produced.with(Serdes.Integer(), enrichedCustomerSerde)); return builder.build(); }
Example #23
Source File: CamelRouteProducer.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Produces RoutesBuilder producedRoute() { return new RouteBuilder() { @Override public void configure() throws Exception { from("direct:produced") .id("produced") .to("log:produced"); } }; }
Example #24
Source File: AxonConfiguration.java From cdi with Apache License 2.0 | 5 votes |
/** * Produces the entity manager provider. * * @return entity manager provider. */ @Produces @ApplicationScoped public EntityManagerProvider entityManagerProvider( EntityManager entityManager) { return new SimpleEntityManagerProvider(entityManager); }
Example #25
Source File: IfBuildProfileTest.java From quarkus with Apache License 2.0 | 5 votes |
@Produces @IfBuildProfile("dev") GreetingBean devGreetingBean(BarBean barBean) { return new GreetingBean() { @Override String greet() { return "hello from dev"; } }; }
Example #26
Source File: MailClientProducer.java From quarkus with Apache License 2.0 | 5 votes |
@Singleton @Produces @Deprecated public io.vertx.reactivex.ext.mail.MailClient rxMailClient() { LOGGER.warn( "`io.vertx.reactivex.ext.mail.MailClient` is deprecated and will be removed in a future version - it is " + "recommended to switch to `io.vertx.mutiny.ext.mail.MailClient`"); return io.vertx.reactivex.ext.mail.MailClient.newInstance(client); }
Example #27
Source File: MySQLPoolProducer.java From quarkus with Apache License 2.0 | 5 votes |
/** * Produces the RX MySQL Pool instance. The instance is created lazily. * * @return the RX MySQL pool instance * @deprecated The RX API is deprecated and will be removed in the future, use {@link #mutinyMySQLPool()} instead. */ @Singleton @Produces @Deprecated public io.vertx.reactivex.mysqlclient.MySQLPool rxMySQLPool() { LOGGER.warn( "`io.vertx.reactivex.mysqlclient.MySQLPool` is deprecated and will be removed in a future version - it is " + "recommended to switch to `io.vertx.mutiny.mysqlclient.MySQLPool`"); return io.vertx.reactivex.mysqlclient.MySQLPool.newInstance(mysqlPool); }
Example #28
Source File: DatawaveConfigPropertyProducer.java From datawave with Apache License 2.0 | 5 votes |
@Override @Alternative @Specializes @Produces @Dependent @ConfigProperty(name = "ignored") // we actually don't need the name public Float produceFloatConfiguration(InjectionPoint injectionPoint) { return super.produceFloatConfiguration(injectionPoint); }
Example #29
Source File: CamelProducers.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Produces FluentProducerTemplate camelFluentProducerTemplate(InjectionPoint injectionPoint) { final FluentProducerTemplate template = this.context.createFluentProducerTemplate(); final Produce produce = injectionPoint.getAnnotated().getAnnotation(Produce.class); if (ObjectHelper.isNotEmpty(produce) && ObjectHelper.isNotEmpty(produce.value())) { template.setDefaultEndpointUri(produce.value()); } return template; }
Example #30
Source File: DefaultTemplateEngineProducer.java From krazo with Apache License 2.0 | 5 votes |
@Produces @ViewEngineConfig public TemplateEngine getTemplateEngine() { ITemplateResolver resolver = new ServletContextTemplateResolver(this.servletContext); TemplateEngine engine = new TemplateEngine(); engine.setTemplateResolver(resolver); return engine; }