OpenLiberty/docs

We need documentation on how to implement a CDI extension insdie a user feature.

Closed this issue · 6 comments

Customers have been asking us how to create a CDI Extension inside a user feature. This is a simple process but requires using a SPI unique to OpenLiberty which currently has no documentation other than its javadoc.

This new doc should go under Contexts and Dependency Injection

Draft is at: #7525

Draft publication is at: https://docs-draft-openlibertyio.mqj6zf7jocq.us-south.codeengine.appdomain.cloud/docs/latest/cdi-extension-user-feature.html

HI @benjamin-confino - the draft for this topic is now available for review:

https://docs-draft-openlibertyio.mqj6zf7jocq.us-south.codeengine.appdomain.cloud/docs/latest/cdi-extension-user-feature.html

When you have chance, left me know if any further edits are needed. When you're satisfied with the draft, you can add the technical reviewed label to this issue to sign off. Thanks!

Hello David, thank you for your work on this. I have a few suggestions:

The CDIExtensionMetadata class also enables the two most...
-->
The CDIExtensionMetadata class provides shortcuts for the two most...

(This one is not a technical issue, so feel free to overrule me on the English)


The CDIAnnotation class becomes a bean defining annotation. Any class that is annotated with @Annotation can be injected through CDI.
---->

The CDIAnnotation class becomes a bean defining annotation. Any class that is annotated with @CDIAnnotation can be injected through CDI.


In this example, each of these methods has a default implementation that returns an empty set, so you can implement only the ones that are relevant to your needs.
--->
Each of these methods has a default implementation that returns an empty set, so you can implement only the ones that are relevant to your needs.

The default methods are not specific to this example but apply to any use of CDIExtensionMetadata


@ramkumar-k-9286 - can you peer review this new topic?

Peer Review

The following example shows an implementation of the CDIExtensionMetadata class, with three possible methods that extend the class.
->
Quick question - The example does not immediately follow this sentence, but it is a bit more class description. Should this sentence be moved to after the classes are explained?

Maybe we can put it like

You can implement CDIExtensionMetadata class, with three possible methods that extend the class.
getBeanClasses.....
getBeanDefiningAnnotationClasses....
getExtensions...
...
The following example shows an implementation of the CDIExtensionMetadata class, with these methods that extend the class.
--codeblock--


@Component(service = CDIExtensionMetadata.class, configurationPolicy = IGNORE)

->
Do spaces exist before and after = in both these cases?


 public Set<Class<?>> getBeanClasses() {

-> Are the { meant to be on the next line? ->

 {
    public Set<Class<?>> getBeanClasses() 
    {
        return Set.of(CDIBean.class);
    }

This configuration is all that you need to make your user extension extend CDI.
->
This configuration is all that you need to make your user extension to extend the CDI.


Thanks for reviewing, all changes implemented except:

Java syntax is ok as is
This configuration is all that you need to make your user extension extend CDI.--> ok as is