GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - RomanQed/jconv: Flexible and lightweight pipeline implementation for java 11+ in style ASP.NET middleware.

BranchesTags
Open more actions menu

Latest commit

 

History

37 Commits
37 Commits

Folders and files

NameName
Last commit message
Last commit date
gradle/wrapper
gradle/wrapper
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

jconv jconv

Flexible and lightweight pipeline implementation for Java 11+, inspired by ASP.NET middleware design.

Features

  • Fluent API to build conditional and nested middleware pipelines
  • Supports synchronous, asynchronous, and unified task consumers
  • Zero-overhead design suitable for high-performance scenarios
  • Clear separation between middleware (TaskConsumer) and terminal tasks (Task)
  • Conditional branching with addWhen (like ASP.NET UseWhen) and mapWhen (like ASP.NET MapWhen)
  • Easy integration with Java CompletableFuture for async execution

Getting Started

Requirements

  • Java 11 or higher
  • Maven or Gradle build system

Installation

Gradle

dependencies {
    implementation group: 'com.github.romanqed', name: 'jconv', version: '2.0.0'
}

Maven

<dependency>
    <groupId>com.github.romanqed</groupId>
    <artifactId>jconv</artifactId>
    <version>2.0.0</version>
</dependency>

Usage Examples

Basic Middleware Pipeline

import com.github.romanqed.jconv.TaskBuilders;

public class Main {
    public static void main(String[] args) throws Throwable {
        var builder = TaskBuilders.<Integer>linked();
        var pipeline = builder
                .add((c, next) -> {
                    System.out.println("{ - 1");
                    next.run(c);
                    System.out.println("} - 4");
                })
                .add((c, next) -> {
                    System.out.println(c + " - 2");
                    next.run(c - 1);
                })
                .add((c, next) -> {
                    System.out.println(c + " - 3");
                })
                .build();

        pipeline.run(10);
    }
}

Output:

{ - 1
10 - 2
9 - 3
} - 4

Exception Handling in Pipeline

import com.github.romanqed.jconv.TaskBuilders;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws Throwable {
        var builder = TaskBuilders.<Object>linked();
        var pipeline = builder
                .add((ctx, next) -> {
                    try {
                        next.run(ctx);
                    } catch (IOException e) {
                        System.out.println("Caught IOException:");
                        e.printStackTrace();
                    }
                })
                .add((ctx, next) -> {
                    throw new IOException("Simulated I/O error");
                })
                .build();

        pipeline.run(null);
    }
}

Output:

Caught IOException:
java.io.IOException: Simulated I/O error
    at Main.lambda$main$1(Main.java:...)
    ...

Short-Circuiting Execution

import com.github.romanqed.jconv.TaskBuilders;

public class Main {
    public static void main(String[] args) throws Throwable {
        var builder = TaskBuilders.<Integer>linked();
        var pipeline = builder
                .add((c, next) -> {
                    if (c > 0) {
                        next.run(c);
                    } // else short-circuit: do nothing, next tasks won't run
                })
                .add((c, next) -> {
                    System.out.println("Processed: " + c);
                })
                .build();

        pipeline.run(5);  // Prints "Processed: 5"
        pipeline.run(0);  // Prints nothing
    }
}

Conditional Branching with addWhen (like UseWhen)

var pipeline = TaskBuilders.<String>linked()
    .addWhen(s -> s.startsWith("admin"), b -> {
        b.add((s, next) -> {
            System.out.println("Admin branch: " + s);
            next.run(s);
        });
    })
    .add((s, next) -> {
        System.out.println("Common branch: " + s);
    })
    .build();

pipeline.run("adminUser");  // Prints both Admin branch and Common branch messages
pipeline.run("guestUser");  // Prints only Common branch message

Conditional Branching with mapWhen (like MapWhen)

var pipeline = TaskBuilders.<String>linked()
    .mapWhen(s -> s.startsWith("admin"), (s) -> {
        System.out.println("Admin mapped branch: " + s);
    })
    .add((s, next) -> {
        System.out.println("Common branch: " + s);
    })
    .build();

pipeline.run("adminUser");  // Prints only Admin mapped branch message
pipeline.run("guestUser");  // Prints only Common branch message

Note: mapWhen replaces the pipeline if condition is true, short-circuiting subsequent middleware.

API Overview

  • Task — terminal unit of work (sync, async or unified)
  • TaskConsumer — middleware consumer that can delegate downstream
  • TaskConfigurer — fluent interface for building pipeline steps
  • TaskBuilder — interface to assemble and build pipelines
  • TaskBuilders — factory for creating pipeline builders (e.g., linked)

Built With

  • Gradle - Dependency management
  • jfunc - Functional interfaces and utilities
  • jsync - Async functional interfaces and helpers
  • juni - Unified sync/async interfaces

Authors

  • RomanQed - Main author

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache License 2.0 — see the LICENSE file for details

About

Flexible and lightweight pipeline implementation for java 11+ in style ASP.NET middleware.

Topics

actionconveyerconveyorjavajava-11java-17java11java17lightweightmiddlewarepipelinetask

Resources

Readme
Apache-2.0 license
Activity

Stars

2 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.