Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arc - resource provider SPI #48

Merged
merged 3 commits into from
Oct 9, 2018
Merged

Arc - resource provider SPI #48

merged 3 commits into from
Oct 9, 2018

Conversation

mkouba
Copy link
Contributor

@mkouba mkouba commented Oct 5, 2018

The PR should be ready now. I'll add some more description and comments tomorrow.

@mkouba mkouba requested review from Sanne and stuartwdouglas and removed request for Sanne October 8, 2018 16:16
@mkouba
Copy link
Contributor Author

mkouba commented Oct 9, 2018

Ok, so this is not a high priority issue but I'd like to have it merged. What's changed?

  • Arc has a simple SPI ResourceReferenceProvider which makes it possible to resolve non-CDI field injection points, such as Java EE resources; it does iterate over all service providers for each field which is annotated with a resource annotation added via BeanProcessor.Builder.addResourceAnnotations()
  • HibernateCdiResourceProcessor
    • registers PersistenceContext and PersistenceUnit as resource annotations and JPAResourceReferenceProvider; thus any CDI bean can e.g. do @PersistenceContext EntityManager
    • all persistence units found are bootstrapped; previously only PUs for which a CDI producer was found were registered
    • if there is no EM/EMF CDI producer found a default one is added; i.e. @Inject EntityManager works without any CDI producer defined
  • There are two important CDI beans:
    • org.jboss.shamrock.jpa.runtime.JPAConfig - holds a map of bootstrapped persistence units; has @PreDestroy callback to close them
    • TransactionEntityManagers - request scoped bean that holds a map of TransactionScopedEntityManager used when JTA is enabled; has @PreDestroy callback to clean them up

When JTA is enabled for @Inject EntityManager a forwarding EntityManager is injected - this one delegates to the actual request scoped TransactionScopedEntityManager. This is not ideal but it should be fine for POC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants