forked from payara/Payara-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request payara#153 from breakponchito/FISH-5970-reproducer…
…-for-concurrency-upgrade Fish-5970: reproducer for CronTrigger concurrency class
- Loading branch information
Showing
5 changed files
with
428 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
Copyright (c) [2022] Payara Foundation and/or its affiliates. All rights reserved. | ||
The contents of this file are subject to the terms of either the GNU | ||
General Public License Version 2 only ("GPL") or the Common Development | ||
and Distribution License("CDDL") (collectively, the "License"). You | ||
may not use this file except in compliance with the License. You can | ||
obtain a copy of the License at | ||
https://github.com/payara/Payara/blob/master/LICENSE.txt | ||
See the License for the specific | ||
language governing permissions and limitations under the License. | ||
When distributing the software, include this License Header Notice in each | ||
file and include the License file at glassfish/legal/LICENSE.txt. | ||
GPL Classpath Exception: | ||
The Payara Foundation designates this particular file as subject to the "Classpath" | ||
exception as provided by the Payara Foundation in the GPL Version 2 section of the License | ||
file that accompanied this code. | ||
Modifications: | ||
If applicable, add the following below the License Header, with the fields | ||
enclosed by brackets [] replaced by your own identifying information: | ||
"Portions Copyright [year] [name of copyright owner]" | ||
Contributor(s): | ||
If you wish your version of this file to be governed by only the CDDL or | ||
only the GPL Version 2, indicate your decision by adding "[Contributor] | ||
elects to include this software in this distribution under the [CDDL or GPL | ||
Version 2] license." If you don't indicate a single choice of license, a | ||
recipient has the option to distribute your version of this file under | ||
either the CDDL, the GPL Version 2 or to extend the choice of license to | ||
its licensees as provided above. However, if you add GPL Version 2 code | ||
and therefore, elected the GPL Version 2 license, then the option applies | ||
only if the new code is made subject to such option by the copyright | ||
holder. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>fish.payara.examples</groupId> | ||
<artifactId>javaee</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<groupId>fish.payara.examples.javaee</groupId> | ||
<artifactId>concurrency</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>war</packaging> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<failOnMissingWebXml>false</failOnMissingWebXml> | ||
<jakartaee-api.version>9.1.0</jakartaee-api.version> | ||
<arquillian-bom.version>1.7.0.Alpha10</arquillian-bom.version> | ||
<junit-jupiter.version>5.8.2</junit-jupiter.version> | ||
<arquillian-payara.version>3.0.alpha3</arquillian-payara.version> | ||
<jakarta-concurrent.version>3.0.0-SNAPSHOT</jakarta-concurrent.version> | ||
<shrinkwrap.version>3.1.4</shrinkwrap.version> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>jakarta.platform</groupId> | ||
<artifactId>jakarta.jakartaee-api</artifactId> | ||
<version>${jakartaee-api.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian</groupId> | ||
<artifactId>arquillian-bom</artifactId> | ||
<version>${arquillian-bom.version}</version> | ||
<scope>import</scope> | ||
<type>pom</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit</groupId> | ||
<artifactId>junit-bom</artifactId> | ||
<version>${junit-jupiter.version}</version> | ||
<scope>import</scope> | ||
<type>pom</type> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>jakarta.platform</groupId> | ||
<artifactId>jakarta.jakartaee-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.enterprise.concurrent</groupId> | ||
<artifactId>jakarta.enterprise.concurrent-api</artifactId> | ||
<version>${jakarta-concurrent.version}</version> | ||
<scope>provided</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.jboss.arquillian.testng</groupId> | ||
<artifactId>arquillian-testng-container</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.junit5</groupId> | ||
<artifactId>arquillian-junit5-container</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.protocol</groupId> | ||
<artifactId>arquillian-protocol-servlet-jakarta</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shrinkwrap.resolver</groupId> | ||
<artifactId>shrinkwrap-resolver-impl-maven</artifactId> | ||
<version>${shrinkwrap.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shrinkwrap.resolver</groupId> | ||
<artifactId>shrinkwrap-resolver-api-maven</artifactId> | ||
<version>${shrinkwrap.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<finalName>concurrencyApp</finalName> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.9.0</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>3.0.0-M5</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>3.3.2</version> | ||
<configuration> | ||
<attachClasses>true</attachClasses> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<profiles> | ||
<profile> | ||
<id>payara-server-remote</id> | ||
<dependencies> | ||
<dependency> | ||
<groupId>fish.payara.arquillian</groupId> | ||
<artifactId>payara-client-ee9</artifactId> | ||
<version>${arquillian-payara.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>fish.payara.arquillian</groupId> | ||
<artifactId>arquillian-payara-server-remote</artifactId> | ||
<version>${arquillian-payara.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
</project> |
81 changes: 81 additions & 0 deletions
81
...ncurrency/src/main/java/fish/payara/examples/concurrency/crontrigger/CronTriggerRest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
* | ||
* Copyright (c) [2022] Payara Foundation and/or its affiliates. All rights reserved. | ||
* | ||
* The contents of this file are subject to the terms of either the GNU | ||
* General Public License Version 2 only ("GPL") or the Common Development | ||
* and Distribution License("CDDL") (collectively, the "License"). You | ||
* may not use this file except in compliance with the License. You can | ||
* obtain a copy of the License at | ||
* https://github.com/payara/Payara/blob/master/LICENSE.txt | ||
* See the License for the specific | ||
* language governing permissions and limitations under the License. | ||
* | ||
* When distributing the software, include this License Header Notice in each | ||
* file and include the License file at glassfish/legal/LICENSE.txt. | ||
* | ||
* GPL Classpath Exception: | ||
* The Payara Foundation designates this particular file as subject to the "Classpath" | ||
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License | ||
* file that accompanied this code. | ||
* | ||
* Modifications: | ||
* If applicable, add the following below the License Header, with the fields | ||
* enclosed by brackets [] replaced by your own identifying information: | ||
* "Portions Copyright [year] [name of copyright owner]" | ||
* | ||
* Contributor(s): | ||
* If you wish your version of this file to be governed by only the CDDL or | ||
* only the GPL Version 2, indicate your decision by adding "[Contributor] | ||
* elects to include this software in this distribution under the [CDDL or GPL | ||
* Version 2] license." If you don't indicate a single choice of license, a | ||
* recipient has the option to distribute your version of this file under | ||
* either the CDDL, the GPL Version 2 or to extend the choice of license to | ||
* its licensees as provided above. However, if you add GPL Version 2 code | ||
* and therefore, elected the GPL Version 2 license, then the option applies | ||
* only if the new code is made subject to such option by the copyright | ||
* holder. | ||
*/ | ||
package fish.payara.examples.concurrency.crontrigger; | ||
|
||
import jakarta.annotation.Resource; | ||
import jakarta.enterprise.concurrent.CronTrigger; | ||
import jakarta.enterprise.concurrent.ManagedScheduledExecutorService; | ||
import jakarta.enterprise.concurrent.Trigger; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
import java.time.ZoneId; | ||
import java.util.concurrent.ScheduledFuture; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
@Path("concurrency") | ||
public class CronTriggerRest { | ||
|
||
private static final Logger logger = Logger.getLogger(CronTriggerRest.class.getName()); | ||
|
||
@Resource | ||
ManagedScheduledExecutorService managedScheduledExecutorService; | ||
|
||
@GET | ||
@Path("cronTrigger") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String getText() throws InterruptedException { | ||
logger.log(Level.INFO, String.format("Processing schedule executor: %s", managedScheduledExecutorService)); | ||
AtomicInteger numberExecution = new AtomicInteger(); | ||
ZoneId mexico = ZoneId.of("America/Mexico_City"); | ||
Trigger trigger = new CronTrigger("* * * * * *", mexico); | ||
ScheduledFuture feature = managedScheduledExecutorService.schedule(() -> { | ||
numberExecution.getAndIncrement(); | ||
System.out.println("Cron Trigger running"); | ||
}, trigger); | ||
Thread.sleep(1500); | ||
feature.cancel(true); | ||
return "CronTrigger Submitted:"+numberExecution.get(); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...rc/main/java/fish/payara/examples/concurrency/crontrigger/CronTriggerRestApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
* | ||
* Copyright (c) [2022] Payara Foundation and/or its affiliates. All rights reserved. | ||
* | ||
* The contents of this file are subject to the terms of either the GNU | ||
* General Public License Version 2 only ("GPL") or the Common Development | ||
* and Distribution License("CDDL") (collectively, the "License"). You | ||
* may not use this file except in compliance with the License. You can | ||
* obtain a copy of the License at | ||
* https://github.com/payara/Payara/blob/master/LICENSE.txt | ||
* See the License for the specific | ||
* language governing permissions and limitations under the License. | ||
* | ||
* When distributing the software, include this License Header Notice in each | ||
* file and include the License file at glassfish/legal/LICENSE.txt. | ||
* | ||
* GPL Classpath Exception: | ||
* The Payara Foundation designates this particular file as subject to the "Classpath" | ||
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License | ||
* file that accompanied this code. | ||
* | ||
* Modifications: | ||
* If applicable, add the following below the License Header, with the fields | ||
* enclosed by brackets [] replaced by your own identifying information: | ||
* "Portions Copyright [year] [name of copyright owner]" | ||
* | ||
* Contributor(s): | ||
* If you wish your version of this file to be governed by only the CDDL or | ||
* only the GPL Version 2, indicate your decision by adding "[Contributor] | ||
* elects to include this software in this distribution under the [CDDL or GPL | ||
* Version 2] license." If you don't indicate a single choice of license, a | ||
* recipient has the option to distribute your version of this file under | ||
* either the CDDL, the GPL Version 2 or to extend the choice of license to | ||
* its licensees as provided above. However, if you add GPL Version 2 code | ||
* and therefore, elected the GPL Version 2 license, then the option applies | ||
* only if the new code is made subject to such option by the copyright | ||
* holder. | ||
*/ | ||
package fish.payara.examples.concurrency.crontrigger; | ||
|
||
import jakarta.ws.rs.ApplicationPath; | ||
import jakarta.ws.rs.core.Application; | ||
|
||
@ApplicationPath("/") | ||
public class CronTriggerRestApplication extends Application { | ||
} |
Oops, something went wrong.