Skip to content

Commit

Permalink
avoid duplicate managed executor definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAure committed Aug 8, 2022
1 parent 32aa6ea commit 7e7ca6e
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static EnterpriseArchive createDeployment() {
.addPackages(false, getFrameworkPackage(), ManagedExecutorDefinitionTests.class.getPackage())
.deleteClasses(
AppBean.class,
ManagedExecutorDefinitionWebBean.class,
ManagedExecutorDefinitionServlet.class,
ManagedExecutorDefinitionOnEJBServlet.class,
ContextServiceDefinitionServlet.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package ee.jakarta.tck.concurrent.spec.ManagedExecutorService.resourcedef;

import jakarta.ejb.Local;
import jakarta.ejb.Stateless;
import jakarta.enterprise.concurrent.ManagedExecutorDefinition;

import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
* ContextServiceDefinitions are defined under
* {@link ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionBean}
*/
@ManagedExecutorDefinition(name = "java:app/concurrent/EJBExecutorA",
context = "java:app/concurrent/EJBContextA",
maxAsync = 2,
hungTaskThreshold = 300000)
@ManagedExecutorDefinition(name = "java:comp/concurrent/EJBExecutorC")
@Local(ManagedExecutorDefinitionInterface.class)
@Stateless
public class ManagedExecutorDefinitionWebBean implements ManagedExecutorDefinitionInterface {

@Override
public Object doLookup(String name) throws NamingException {
return InitialContext.doLookup(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static WebArchive createDeployment() {
ContextServiceDefinitionInterface.class,
ContextServiceDefinitionWebBean.class,
ContextServiceDefinitionServlet.class)
.deleteClasses(ManagedExecutorDefinitionBean.class)
.addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName());

return war;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public static EnterpriseArchive createDeployment() {
.addPackages(false, getFrameworkPackage(), ManagedScheduledExecutorDefinitionTests.class.getPackage())
.deleteClasses(
ReqBean.class,
ManagedScheduledExecutorDefinitionWebBean.class,
ManagedScheduledExecutorDefinitionServlet.class,
ManagedScheduledExecutorDefinitionOnEJBServlet.class)
.addClasses(
ContextServiceDefinitionInterface.class,
ContextServiceDefinitionBean.class)
.addAsManifestResource(ManagedScheduledExecutorDefinitionTests.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml");
// TODO document how users can dynamically inject vendor specific deployment descriptors into this archive

EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ManagedScheduledExecutorDefinitionTests.ear").addAsModules(war, jar);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.resourcedef;

import jakarta.ejb.Local;
import jakarta.ejb.Stateless;
import jakarta.enterprise.concurrent.ManagedScheduledExecutorDefinition;
import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionServlet;
import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionBean;

import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
* @ContextServiceDefinitions are defined under {@link ContextServiceDefinitionServlet} and {@link ContextServiceDefinitionBean}
*/
@ManagedScheduledExecutorDefinition(name = "java:app/concurrent/EJBScheduledExecutorA",
context = "java:app/concurrent/EJBContextA",
maxAsync = 3,
hungTaskThreshold = 360000)
@ManagedScheduledExecutorDefinition(name = "java:comp/concurrent/EJBScheduledExecutorC")
@Local(ManagedScheduleExecutorDefinitionInterface.class)
@Stateless
public class ManagedScheduledExecutorDefinitionWebBean implements ManagedScheduleExecutorDefinitionInterface {

@Override
public Object doLookup(String name) throws NamingException {
return InitialContext.doLookup(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static WebArchive createDeployment() {
ContextServiceDefinitionServlet.class,
ContextServiceDefinitionInterface.class,
ContextServiceDefinitionWebBean.class)
.addAsWebInfResource(ManagedScheduledExecutorDefinitionWebTests.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml")
.deleteClasses(ManagedScheduledExecutorDefinitionBean.class)
.addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName());

return war;
Expand Down

0 comments on commit 7e7ca6e

Please sign in to comment.