rmannibucau commented on code in PR #1232:
URL: https://github.com/apache/tomee/pull/1232#discussion_r1665752590


##########
container/openejb-core/src/main/java/org/apache/openejb/threads/impl/ContextServiceImplFactory.java:
##########
@@ -77,6 +86,36 @@ public static ContextServiceImpl 
newPropagateEverythingContextService() {
     }
 
 
+    public static ContextServiceImpl getOrCreateDefaultSingleton() {

Review Comment:
   this can be called concurrently (runtime deployments), code is okish since 
having multiple instances is not critical but it can be worth a comment saying 
"there is not destroy/close callback and multiple instances are fine so no need 
to bother with synchronization" or sthg like that?



##########
container/openejb-core/src/main/java/org/apache/openejb/threads/impl/ContextServiceImplFactory.java:
##########
@@ -29,6 +35,9 @@
 
 public class ContextServiceImplFactory {
 
+    private static final Logger LOGGER = 
Logger.getInstance(LogCategory.OPENEJB, ContextServiceImplFactory.class);

Review Comment:
   this one is normally not needed for nominal case so let's ensure it is not 
static (always created) but created lazily in the catch case only



##########
container/openejb-core/src/main/java/org/apache/openejb/threads/impl/ContextServiceImplFactory.java:
##########
@@ -77,6 +86,36 @@ public static ContextServiceImpl 
newPropagateEverythingContextService() {
     }
 
 
+    public static ContextServiceImpl getOrCreateDefaultSingleton() {
+        if (defaultSingleton == null) {
+            defaultSingleton = newDefaultContextService();
+        }
+
+        return defaultSingleton;
+    }
+
+    public static ContextServiceImpl lookupOrDefault(String name) {
+        if (name == null || name.trim().isEmpty()) {

Review Comment:
   thinking out loud: I guess the default case would be ok to use the default 
singleton without logging so maybe we can have a specific token for that 
("tomeeDefault" - very bad name but it should not be something xbean layer 
handles (`@xxx`, `$...`) nor something too common like `default`, maybe 
`auto!`).
   This way we can get `if (auto) return singleton else if (not set) return 
logAndSingleton() else lookup()` and get a nominal default case.
   
   I'll let you judge on this one, current flavor is fine for me once it gets 
the lazy logger.



##########
container/openejb-core/src/main/java/org/apache/openejb/config/BuiltInEnvironmentEntries.java:
##########
@@ -105,7 +105,6 @@ private void add(final JndiConsumer jndi, final 
DeploymentModule module, final D
             // Jakarta Concurrency ยง3.3.4.3
             add(jndi.getResourceEnvRefMap(), new 
ResourceEnvRef().name("java:comp/DefaultContextService").type(ContextService.class));
 
-

Review Comment:
   unneeded



##########
container/openejb-core/src/test/java/org/apache/openejb/threads/ManagedExecutorServiceNoExplicitContextTest.java:
##########
@@ -0,0 +1,103 @@
+/**
+ * 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.openejb.threads;
+
+import jakarta.annotation.Resource;
+import jakarta.ejb.EJB;
+import jakarta.ejb.Singleton;
+import jakarta.enterprise.concurrent.ManagedExecutorService;
+import org.apache.openejb.jee.EnterpriseBean;
+import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Configuration;
+import org.apache.openejb.testing.Module;
+import org.apache.openejb.testng.PropertiesBuilder;
+import org.apache.openejb.threads.impl.ManagedExecutorServiceImpl;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.naming.NamingException;
+import java.util.Properties;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+@RunWith(ApplicationComposer.class)
+public class ManagedExecutorServiceNoExplicitContextTest {

Review Comment:
   :+1: 



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