An open API service indexing awesome lists of open source software.

https://github.com/krkarma777/javelin

A high-performance, lightweight Java Web Application Server powered by Virtual Threads. ๐Ÿš€
https://github.com/krkarma777/javelin

concurrency high-performance http-server java java21 javelin lightweight modern-java virtual-threads was web-server

Last synced: about 1 month ago
JSON representation

A high-performance, lightweight Java Web Application Server powered by Virtual Threads. ๐Ÿš€

Awesome Lists containing this project

README

          


logo

# Javelin WAS - A High-Performance Virtual Thread-Based Web Application Server ๐Ÿš€

Javelin WAS is a lightweight, high-performance web application server built on Java Virtual Threads.
It aims to provide a modern alternative to traditional Java-based WAS solutions like Tomcat and Jetty, leveraging Virtual Threads for maximum concurrency and efficiency.

---

## ๐Ÿ”ฅ Features
- **Virtual Thread-Based Concurrency** โ€“ Handles thousands of concurrent requests efficiently without blocking OS threads.
- **Lightweight & Fast** โ€“ Designed to be minimal and optimized for high performance.
- **Easy Routing** โ€“ Supports simple and flexible request handling.
- **Middleware System** โ€“ Easily extendable with logging, authentication, and security middleware.
- **JSON Support** โ€“ Built-in JSON serialization and deserialization.
- **Static File Serving** โ€“ Serves static files efficiently without external dependencies.
- **Designed for Modern Java Applications** โ€“ No heavy frameworks required.

---

## โ˜• Requirements
- Java **21** or higher (required for Virtual Threads)
- Gradle **7+**

---

## ๐Ÿ› ๏ธ Installation & Running

### 1. Clone the repository
```sh
git clone https://github.com/your-repo/Javelin.git
cd javelin-was
```

### 2. Build & Run (Using Gradle)
```sh
./gradlew run
```

---

## ๐Ÿš€ Test the Server

Once the server is running, open your browser or use `curl`:

```sh
curl http://localhost:8080
```

โœ… **Expected Response:**
```
Hello from Javelin Virtual Thread WAS!
```

#### โœ… Example Code (Minimal)
```java
public class Main {
public static void main(String[] args) {
VirtualThreadServer server = new VirtualThreadServer(8080);

server.get("/", ctx -> ctx.send("Hello from Javelin Virtual Thread WAS!"));

server.start();
}
}
```

---

## ๐Ÿงช Example Usage

### ๐Ÿงฉ Middleware
```java
server.use(ctx -> {
System.out.println("Request Path: " + ctx.path());
ctx.next();
});
```

### ๐Ÿ“ฆ JSON Handling
```java
server.post("/echo", ctx -> {
Map data = ctx.body(Map.class);
ctx.json(Map.of("you_sent", data));
});
```

---

## ๐Ÿ“ Serving Static Files
To serve files from a `public/` directory under `/static`:

```java
server.use(new StaticFileHandler("/static", "public"));
```

Then access:
```
http://localhost:8080/static/index.html
```

---

## ๐Ÿง  How It Works

Javelin WAS uses **Java 21+ Virtual Threads** to efficiently handle HTTP requests without the overhead of traditional thread pools.
Each request is processed in a lightweight Virtual Thread, allowing **massive concurrency with minimal resource usage**.

---

## ๐Ÿ“œ License
This project is licensed under the **Apache License 2.0**.
See the [`LICENSE`](LICENSE) file for more details.

---

## ๐Ÿ‘ฅ Contributing
We welcome contributions!
Feel free to submit issues, feature requests, or pull requests.

---

## ๐Ÿ“ง Contact
For inquiries or collaboration:
**๐Ÿ“ฉ krkarma777@gmail.com**

---