1
votes

OpenLiberty offers the wonderful feature of shared libraries that can be deployed in the server once and then (very skinny and fast-redeploying) WARs can access them at run-time. On the other hand, CDI provides a mechanism to reduce the bean scanning, for example:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee">
    <scan>
        <exclude name="com.mycompany.nonecdi.**"/>    
    </scan>
</beans>

My questions are - how do the two interact:

  1. Is Openliberty CDI scanner going to inspect the shared libs for beans upon WAR deployment, in the complete absence of CDI scanner restricition?
  2. Can the CDI scanner reference packages from the shared libs?
1
I am not familiar with Liberty, but can share CDI point of view on this. 1) if you deploy your WAR, you also have beans.xml there, so you have the restrictions when you start scanning. That being said, 2) should be able to reference it as when it is checked, shared lib should already be on classpath hence FQCN should be resolvable. - Siliarus
Thanks, I am thinking the same, just wanted someone from OpenLiberty to confirm it. - Hristo Stoyanov

1 Answers

1
votes

Shared libraries are supported in Open Liberty. If there are beans.xml or bean defining annotations specified (e.g. @ApplicationScoped,etc) in the shared libraries, the beans would be found by CDI runtime. Therefore, shared libs can use CDI in Open Liberty and WebSphere Liberty.