io.quarkus.arc.deployment.BeanContainerListenerBuildItem Java Examples
The following examples show how to use
io.quarkus.arc.deployment.BeanContainerListenerBuildItem.
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: HibernateOrmProcessor.java From quarkus with Apache License 2.0 | 7 votes |
@BuildStep @Record(STATIC_INIT) public void build(HibernateOrmRecorder recorder, Capabilities capabilities, BuildProducer<BeanContainerListenerBuildItem> buildProducer, List<PersistenceUnitDescriptorBuildItem> descriptors, JpaEntitiesBuildItem jpaEntities, List<NonJpaModelBuildItem> nonJpaModels) throws Exception { if (!hasEntities(jpaEntities, nonJpaModels)) { return; } MultiTenancyStrategy strategy = MultiTenancyStrategy .valueOf(hibernateConfig.multitenant.orElse(MultiTenancyStrategy.NONE.name())); buildProducer.produce(new BeanContainerListenerBuildItem( recorder.initializeJpa(capabilities.isPresent(Capability.TRANSACTIONS), strategy, hibernateConfig.multitenantSchemaDatasource.orElse(null)))); // Bootstrap all persistence units for (PersistenceUnitDescriptorBuildItem persistenceUnitDescriptor : descriptors) { buildProducer.produce(new BeanContainerListenerBuildItem( recorder.registerPersistenceUnit(persistenceUnitDescriptor.getDescriptor().getName()))); } buildProducer.produce(new BeanContainerListenerBuildItem(recorder.initDefaultPersistenceUnit())); }
Example #2
Source File: InfinispanClientProcessor.java From quarkus with Apache License 2.0 | 6 votes |
@BuildStep @Record(ExecutionTime.STATIC_INIT) BeanContainerListenerBuildItem build(InfinispanRecorder recorder, InfinispanPropertiesBuildItem builderBuildItem) { Properties properties = builderBuildItem.getProperties(); InfinispanClientBuildTimeConfig conf = infinispanClient; if (log.isDebugEnabled()) { log.debugf("Applying micro profile configuration: %s", conf); } int maxEntries = conf.nearCacheMaxEntries; // Only write the entries if it is a valid number and it isn't already configured if (maxEntries > 0 && !properties.containsKey(ConfigurationProperties.NEAR_CACHE_MODE)) { // This is already empty so no need for putIfAbsent properties.put(ConfigurationProperties.NEAR_CACHE_MODE, NearCacheMode.INVALIDATED.toString()); properties.putIfAbsent(ConfigurationProperties.NEAR_CACHE_MAX_ENTRIES, maxEntries); } return new BeanContainerListenerBuildItem(recorder.configureInfinispan(properties)); }
Example #3
Source File: LiquibaseProcessor.java From tutorials with MIT License | 6 votes |
@Record(ExecutionTime.STATIC_INIT) @BuildStep void build(BuildProducer<AdditionalBeanBuildItem> additionalBeanProducer, BuildProducer<FeatureBuildItem> featureProducer, LiquibaseRecorder recorder, BuildProducer<BeanContainerListenerBuildItem> containerListenerProducer, DataSourceInitializedBuildItem dataSourceInitializedBuildItem) { featureProducer.produce(new FeatureBuildItem("liquibase")); AdditionalBeanBuildItem unremovableProducer = AdditionalBeanBuildItem.unremovableOf(LiquibaseProducer.class); additionalBeanProducer.produce(unremovableProducer); containerListenerProducer.produce( new BeanContainerListenerBuildItem(recorder.setLiquibaseConfig(liquibaseConfig))); }
Example #4
Source File: HibernateOrmProcessor.java From quarkus with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @BuildStep @Record(STATIC_INIT) public void build(RecorderContext recorderContext, HibernateOrmRecorder recorder, Capabilities capabilities, JpaEntitiesBuildItem domainObjects, List<NonJpaModelBuildItem> nonJpaModelBuildItems, List<PersistenceUnitDescriptorBuildItem> persistenceUnitDescriptorBuildItems, List<HibernateOrmIntegrationBuildItem> integrations, //Used to make sure ORM integrations are performed before this item ProxyDefinitionsBuildItem proxyDefinitions, BuildProducer<FeatureBuildItem> feature, BuildProducer<BeanContainerListenerBuildItem> beanContainerListener) throws Exception { feature.produce(new FeatureBuildItem(Feature.HIBERNATE_ORM)); final boolean enableORM = hasEntities(domainObjects, nonJpaModelBuildItems); final boolean hibernateReactivePresent = capabilities.isPresent(Capability.HIBERNATE_REACTIVE); //The Hibernate Reactive extension is able to handle registration of PersistenceProviders for both reactive and //traditional blocking Hibernate, by depending on this module and delegating to this code. //So when the Hibernate Reactive extension is present, trust that it will register its own PersistenceProvider //which will be responsible to decide which type of ORM to bootstrap. //But if the extension is not present, we need to register our own PersistenceProvider - even if the ORM is not enabled! if (!hibernateReactivePresent) { recorder.callHibernateFeatureInit(enableORM); } if (!enableORM) { // we can bail out early return; } recorder.enlistPersistenceUnit(domainObjects.getEntityClassNames()); final QuarkusScanner scanner = buildQuarkusScanner(domainObjects); //now we serialize the XML and class list to bytecode, to remove the need to re-parse the XML on JVM startup recorderContext.registerNonDefaultConstructor(ParsedPersistenceXmlDescriptor.class.getDeclaredConstructor(URL.class), (i) -> Collections.singletonList(i.getPersistenceUnitRootUrl())); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); // inspect service files for additional integrators Collection<Class<? extends Integrator>> integratorClasses = new LinkedHashSet<>(); for (String integratorClassName : ServiceUtil.classNamesNamedIn(classLoader, INTEGRATOR_SERVICE_FILE)) { integratorClasses.add((Class<? extends Integrator>) recorderContext.classProxy(integratorClassName)); } List<ParsedPersistenceXmlDescriptor> allDescriptors = new ArrayList<>(); for (PersistenceUnitDescriptorBuildItem pud : persistenceUnitDescriptorBuildItems) { allDescriptors.add(pud.getDescriptor()); } beanContainerListener .produce(new BeanContainerListenerBuildItem( recorder.initMetadata(allDescriptors, scanner, integratorClasses, proxyDefinitions.getProxies(), getMultiTenancyStrategy()))); }
Example #5
Source File: HttpSecurityProcessor.java From quarkus with Apache License 2.0 | 4 votes |
@BuildStep @Record(ExecutionTime.STATIC_INIT) void setupAuthenticationMechanisms( HttpSecurityRecorder recorder, BuildProducer<FilterBuildItem> filterBuildItemBuildProducer, BuildProducer<AdditionalBeanBuildItem> beanProducer, Capabilities capabilities, BuildProducer<BeanContainerListenerBuildItem> beanContainerListenerBuildItemBuildProducer, HttpBuildTimeConfig buildTimeConfig, List<HttpSecurityPolicyBuildItem> httpSecurityPolicyBuildItemList) { Map<String, Supplier<HttpSecurityPolicy>> policyMap = new HashMap<>(); for (HttpSecurityPolicyBuildItem e : httpSecurityPolicyBuildItemList) { if (policyMap.containsKey(e.getName())) { throw new RuntimeException("Multiple HTTP security policies defined with name " + e.getName()); } policyMap.put(e.getName(), e.policySupplier); } if (buildTimeConfig.auth.form.enabled) { } else if (buildTimeConfig.auth.basic) { beanProducer.produce(AdditionalBeanBuildItem.unremovableOf(BasicAuthenticationMechanism.class)); } if (capabilities.isPresent(Capability.SECURITY)) { beanProducer .produce(AdditionalBeanBuildItem.builder().setUnremovable().addBeanClass(HttpAuthenticator.class) .addBeanClass(HttpAuthorizer.class).build()); filterBuildItemBuildProducer .produce(new FilterBuildItem( recorder.authenticationMechanismHandler(buildTimeConfig.auth.proactive), FilterBuildItem.AUTHENTICATION)); filterBuildItemBuildProducer .produce(new FilterBuildItem(recorder.permissionCheckHandler(), FilterBuildItem.AUTHORIZATION)); if (!buildTimeConfig.auth.permissions.isEmpty()) { beanContainerListenerBuildItemBuildProducer .produce(new BeanContainerListenerBuildItem(recorder.initPermissions(buildTimeConfig, policyMap))); } } else { if (!buildTimeConfig.auth.permissions.isEmpty()) { throw new IllegalStateException("HTTP permissions have been set however security is not enabled"); } } }
Example #6
Source File: RestClientProcessor.java From quarkus with Apache License 2.0 | 4 votes |
@Record(ExecutionTime.STATIC_INIT) @BuildStep BeanContainerListenerBuildItem fixExtension(RestClientRecorder restClientRecorder) { return new BeanContainerListenerBuildItem(restClientRecorder.hackAroundExtension()); }
Example #7
Source File: KafkaStreamsProcessor.java From quarkus with Apache License 2.0 | 4 votes |
@BuildStep @Record(ExecutionTime.STATIC_INIT) BeanContainerListenerBuildItem processBuildTimeConfig(KafkaStreamsRecorder recorder, LaunchModeBuildItem launchMode) { Properties kafkaStreamsProperties = buildKafkaStreamsProperties(launchMode.getLaunchMode()); return new BeanContainerListenerBuildItem(recorder.configure(kafkaStreamsProperties)); }
Example #8
Source File: KeycloakProcessor.java From keycloak with Apache License 2.0 | 4 votes |
@Record(ExecutionTime.STATIC_INIT) @BuildStep void configureDataSource(KeycloakRecorder recorder, BuildProducer<BeanContainerListenerBuildItem> container) { container.produce(new BeanContainerListenerBuildItem(recorder.configureDataSource())); }