cristof commented on code in PR #321:
URL: https://github.com/apache/openjpa/pull/321#discussion_r4701635494
##########
openjpa-kernel/src/main/java/org/apache/openjpa/cdi/EntityListenerFactoryValue.java:
##########
@@ -29,10 +30,29 @@ public class EntityListenerFactoryValue extends PluginValue
{
public EntityListenerFactoryValue() {
super(KEY, false);
String[] aliases = new String[] {
- DEFAULT_ALIAS,
EntityListenerFactoryImpl.class.getName()
+ DEFAULT_ALIAS,
EntityListenerCachedFactory.class.getName()
};
setAliases(aliases);
setDefault(aliases[0]);
}
+ @Override
+ public Object instantiate(Class<?> type, Configuration c, boolean
fatal) {
+ if (isBeanManagerAPIAvailable()) {
+
setClassName("org.apache.openjpa.cdi.EntityListenerCDIFactory");
+ } else {
+
setClassName(EntityListenerCachedFactory.class.getName());
+ }
+ return super.instantiate(type, c, fatal);
+ }
+
+ private boolean isBeanManagerAPIAvailable() {
+ try {
+ // false avoids running static initializers just to
check existence
+
Class.forName("jakarta.enterprise.inject.spi.BeanManager", false,
EntityListenerCDIFactory.class.getClassLoader());
Review Comment:
Removed the API test, making the default plugin deal with its absence. Added
option to allow users turn CDI injection off. Updated documentation to reflect
it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]