https://github.com/chamikathereal/j2ee-timer
A simple Java EE project demonstrating EJB Timer Service for scheduling and managing automated tasks. Ideal for learning timer-based automation in enterprise applications.
https://github.com/chamikathereal/j2ee-timer
ejb jakartaee java javaee timer timer-app timer-service
Last synced: 28 days ago
JSON representation
A simple Java EE project demonstrating EJB Timer Service for scheduling and managing automated tasks. Ideal for learning timer-based automation in enterprise applications.
- Host: GitHub
- URL: https://github.com/chamikathereal/j2ee-timer
- Owner: chamikathereal
- Created: 2025-06-15T13:58:36.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-06-21T18:35:39.000Z (9 months ago)
- Last Synced: 2025-10-31T05:49:01.390Z (5 months ago)
- Topics: ejb, jakartaee, java, javaee, timer, timer-app, timer-service
- Language: Java
- Homepage:
- Size: 3.88 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π J2EE-Timer
## π Project Overview
**J2EE-Timer** is a simple Java EE project that demonstrates how to schedule and manage timed tasks using EJB Timer Service. This project showcases both programmatic and automatic timer creation, making it a practical reference for understanding scheduled background processing in enterprise Java applications. The implementation covers stateless session beans, timer callbacks, and integration with servlets for task managementβall following best practices for reliability and scalability.
---
## π½οΈ Demo Video
[](https://youtu.be/kAnNUfUK1kY)
---
## ποΈ Project Structure
```
J2EE-Timer/
βββ src/
β βββ main/
β βββ java/
β β βββ lk.jlat.web.eetimer/
β β βββ ejb/
β β β βββ remote/
β β β βββ AutoTimerSessionBean
β β β βββ TaskSessionBean
β β β βββ TimerSessionBean
β β βββ servlet/
β β β βββ Task2
β β β βββ Test
β β βββ timer/
β β βββ Task
β βββ resources/
β βββ webapp/
β βββ index.jsp
βββ pom.xml
```
## **Modules & Key Files**
#### π¦ ejb
- **AutoTimerSessionBean**
Handles automatic scheduling using `@Schedule` annotation for recurring tasks.
- **TaskSessionBean**
Demonstrates asynchronous task execution using a managed executor service.
- **TimerSessionBean**
Manages programmatic timers, calendar-based scheduling, timer callbacks (`@Timeout`), and timer cancellation.
##
#### π¦ servlet
- **Test**
Servlet to trigger and schedule a new timer task via `TimerSessionBean`.
- **Task2**
Servlet to cancel an existing timer by referencing the scheduled task.
##
#### π¦ timer
- **Task**
Serializable class representing a scheduled task's identity and metadata.
---
## βοΈ How It Works
- β
**Automatic Timers:**
Use `@Schedule` in `AutoTimerSessionBean` to run methods at fixed intervals without manual intervention.
- β
**Programmatic Timers:**
`TimerSessionBean` creates timers dynamically using `TimerService`, schedules tasks, and handles timeout events with `@Timeout` methods.
- β
**Task Execution:**
`TaskSessionBean` leverages Java EE's managed executor service for asynchronous operations.
- β
**Servlet Integration:**
The `Test` servlet triggers new timers and stores task info in the session, while `Task2` cancels the timer based on task ID.
- β
**Persistence & Configuration:**
Maven-based project setup with Java 11 and Jakarta EE 10 dependencies for modern, portable deployment.
---
## β¨ Key Features
- β
Demonstrates both annotation-based and programmatic EJB timers
- β
Showcases timer callbacks and cancellation
- β
Integrates servlets for web-based task management
- β
Clean, modular code for easy learning and extension
---
## π οΈ Technologies Used
- Java 11
- Jakarta EE 10 (EJB, Servlet)
- Maven
---
## π Learning Outcomes
- β
Understand EJB Timer Service for scheduled and recurring tasks
- β
Learn to implement both automatic and programmatic timers
- β
Explore asynchronous processing in Java EE
- β
Gain hands-on experience with modular enterprise Java applications
---
## π§βπ» Author
Chamika Gayashan
Undergraduate Software Engineer | Sri Lanka
Linkedin: @chamikathereal
Current date: Saturday, June 21, 2025, 11:47 PM +0530