• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TAKETODAY / today-infrastructure / 18154768944

01 Oct 2025 07:26AM UTC coverage: 81.882% (-0.005%) from 81.887%
18154768944

push

github

web-flow
Merge pull request #290 from TAKETODAY/dev/jspecify

jspecify

59788 of 78013 branches covered (76.64%)

Branch coverage included in aggregate %.

141239 of 167496 relevant lines covered (84.32%)

3.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
today-context/src/main/java/infra/scheduling/concurrent/DefaultManagedTaskExecutor.java
1
/*
2
 * Copyright 2017 - 2025 the original author or authors.
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see [https://www.gnu.org/licenses/]
16
 */
17

18
package infra.scheduling.concurrent;
19

20
import org.jspecify.annotations.Nullable;
21

22
import java.util.Properties;
23
import java.util.concurrent.Executor;
24

25
import javax.naming.NamingException;
26

27
import infra.beans.factory.InitializingBean;
28
import infra.jndi.JndiAccessor;
29
import infra.jndi.JndiLocatorDelegate;
30
import infra.jndi.JndiLocatorSupport;
31
import infra.jndi.JndiTemplate;
32

33
/**
34
 * JNDI-based variant of {@link ConcurrentTaskExecutor}, performing a default lookup for
35
 * JSR-236's "java:comp/DefaultManagedExecutorService" in a Jakarta EE/8 environment.
36
 *
37
 * <p>Note: This class is not strictly JSR-236 based; it can work with any regular
38
 * {@link Executor} that can be found in JNDI.
39
 * The actual adapting to {@link jakarta.enterprise.concurrent.ManagedExecutorService}
40
 * happens in the base class {@link ConcurrentTaskExecutor} itself.
41
 *
42
 * @author Juergen Hoeller
43
 * @see jakarta.enterprise.concurrent.ManagedExecutorService
44
 * @since 4.0
45
 */
46
public class DefaultManagedTaskExecutor extends ConcurrentTaskExecutor implements InitializingBean {
×
47

48
  private final JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
×
49

50
  @Nullable
×
51
  private String jndiName = "java:comp/DefaultManagedExecutorService";
52

53
  /**
54
   * Set the JNDI template to use for JNDI lookups.
55
   *
56
   * @see JndiAccessor#setJndiTemplate
57
   */
58
  public void setJndiTemplate(JndiTemplate jndiTemplate) {
59
    this.jndiLocator.setJndiTemplate(jndiTemplate);
×
60
  }
×
61

62
  /**
63
   * Set the JNDI environment to use for JNDI lookups.
64
   *
65
   * @see JndiAccessor#setJndiEnvironment
66
   */
67
  public void setJndiEnvironment(Properties jndiEnvironment) {
68
    this.jndiLocator.setJndiEnvironment(jndiEnvironment);
×
69
  }
×
70

71
  /**
72
   * Set whether the lookup occurs in a Jakarta EE container, i.e. if the prefix
73
   * "java:comp/env/" needs to be added if the JNDI name doesn't already
74
   * contain it. PersistenceAnnotationBeanPostProcessor's default is "true".
75
   *
76
   * @see JndiLocatorSupport#setResourceRef
77
   */
78
  public void setResourceRef(boolean resourceRef) {
79
    this.jndiLocator.setResourceRef(resourceRef);
×
80
  }
×
81

82
  /**
83
   * Specify a JNDI name of the {@link Executor} to delegate to,
84
   * replacing the default JNDI name "java:comp/DefaultManagedExecutorService".
85
   * <p>This can either be a fully qualified JNDI name, or the JNDI name relative
86
   * to the current environment naming context if "resourceRef" is set to "true".
87
   *
88
   * @see #setConcurrentExecutor
89
   * @see #setResourceRef
90
   */
91
  public void setJndiName(String jndiName) {
92
    this.jndiName = jndiName;
×
93
  }
×
94

95
  @Override
96
  public void afterPropertiesSet() throws NamingException {
97
    if (this.jndiName != null) {
×
98
      setConcurrentExecutor(this.jndiLocator.lookup(this.jndiName, Executor.class));
×
99
    }
100
  }
×
101

102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc