cristof commented on code in PR #329:
URL: https://github.com/apache/openjpa/pull/329#discussion_r4748567757


##########
openjpa-kernel/src/main/java/org/apache/openjpa/cdi/NonContextualBeanWrapperFactory.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.cdi;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.openjpa.event.BeanWrapper;
+import org.apache.openjpa.event.CachedBeanWrapper;
+import org.apache.openjpa.lib.conf.GenericConfigurable;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
+import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.lib.util.Options;
+import org.apache.openjpa.util.UserException;
+
+/**
+ * Default BeanManager factory, intended to be used in non-CDI environments
+ * and in CDI environments where there is no intention to use CDI injection
+ * on AttributeConverters and EntityListeners.
+ */
+public class NonContextualBeanWrapperFactory implements BeanWrapperFactory, 
GenericConfigurable {
+       
+       private static final Localizer _loc = 
Localizer.forPackage(NonContextualBeanWrapperFactory.class);
+       
+       private Map<Class<?>, BeanWrapper<?>> converterCache = new 
ConcurrentHashMap<>();
+       
+       private Map<Class<?>, BeanWrapper<?>> listenerCache = new 
ConcurrentHashMap<>();
+       
+       @Override
+       public boolean isBeanManagerAvailable() {
+               return false;
+       }
+
+       @Override
+       public Object getBeanManager() {
+               return null;
+       }
+       
+       @SuppressWarnings("unchecked")
+       @Override
+       public <T> BeanWrapper<T> getListenerWrapper(Class<T> listenerClass) {
+               return (BeanWrapper<T>) 
listenerCache.computeIfAbsent(listenerClass, this::createCacheableListener);
+       }
+       
+       @SuppressWarnings("unchecked")
+       @Override
+       public <T> BeanWrapper<T> getConverterWrapper(Class<T> converterClass) {

Review Comment:
   This change would break current basecode. OpenJPA clients may already have 
code to deal with it, so I think that is better to keep current behavior (avoid 
discarding the listener or converter and failing startup).



-- 
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]

Reply via email to