Skip to content

guruperl/java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Genelet Java

Genelet Java is a small Java 8 web framework for JSON-described CRUD-style web applications. A Genelet app keeps its runtime contract in WEB-INF/config.json and per-component component.json files, then supplies generated or hand-written Filter and Model classes for each component.

The framework is intentionally legacy-friendly: it builds with Ant, uses javax.servlet/Java EE 7-era APIs, keeps numeric framework error strings stable, and does not require Maven, Gradle, Spring, or Jakarta.

How It Works

Requests are routed by path:

<Script_name>/<role>/<tag>/<component>
<Script_name>/<role>/<tag>/<component>/<id>

config.json defines the project package, servlet path, roles, chartags, authentication providers, templates, and database connection settings. Each component's component.json defines tables, keys, available actions, validation, aliases, groups, fields, foreign-key helpers, and optional next-page model calls.

For a component named pollsquestion in project package myproject, the application provides:

myproject.pollsquestion.Filter
myproject.pollsquestion.Model

Both classes expose a public Object constructor that receives the parsed component JSON. At request time the servlet creates the filter and model, fills ARGS, optionally attaches a JDBC connection, executes the requested action, and returns JSON/XML or forwards to a JSP-style template depending on the chartag.

The stable runtime contract is documented in docs/contract.md.

Architecture

The framework runtime lives under src/com/genelet/framework:

  • GeneletServlet coordinates request parsing, auth checks, generated class loading, model execution, and response dispatch.
  • RequestContext holds per-request path, action, ARGS, foreign-key extras, and JDBC connection state.
  • ServletOutcome centralizes response decisions: HTTP errors, redirects, legacy bodies, content bodies, JSON, and JSP forwards.
  • GeneratedComponentContract parses and validates generated config/component metadata into descriptors while preserving the legacy map APIs.
  • GeneletFilter and GeneletModel are base classes used by generated application classes.
  • Dbi is the legacy database facade; StatementExecutor owns JDBC statement/result-set lifecycle, generated keys, stored procedures, labels, and output parameters.
  • Crud is the legacy CRUD facade; SqlComposer owns validated SQL table, join, condition, and order construction.
  • Base, Access, Gate, Ticket, Oauth2, and Procedure implement auth/session behavior; AuthSession owns cookie signing/parsing, provider lookup, issuer validation, and challenge formatting.
  • Config, Role, Issuer, Chartag, Table, and GeneletErrors are the runtime configuration and compatibility types.

The helper/generator code lives under src/com/genelet/helper.

Repository Layout

  • src/com/genelet/framework - framework runtime.
  • src/com/genelet/helper - JSON-driven project generator helpers.
  • samples/tutojava - canonical generated web application sample.
  • samples/javahelper - tiny command-line helper wrapper sample.
  • test - framework regression and MySQL-backed tests.
  • lib - stable repo-local third-party jars used by the Ant builds.
  • docs/contract.md - compatibility contract for generated apps.
  • dist - generated framework output, ignored by Git.

Build And Test

Build the framework jar:

ant clean jar

Run the default unit tests:

ant test

Run the MySQL-backed suite in Docker:

ant mysql-test
ant mysql-docker-stop

mysql-test starts a mysql:5.7 container named genelet-mysql-test. Always run mysql-docker-stop afterward to remove it.

Run the full local verification used by this repo:

git diff --check
ant test
ant sample-tutojava-dist
ant mysql-test
ant mysql-docker-stop

Using Genelet

  1. Create a web app with a WEB-INF/config.json defining Script_name, Template, Pubrole, Chartags, Roles, and optional DB/auth settings.
  2. For each component, create a component.json with actions, current_table or current_tables, and current_key or current_keys.
  3. Provide <Project_name>.<component>.Filter and <Project_name>.<component>.Model classes with public Object constructors.
  4. Map a servlet extending GeneletServlet and load parsed config/component JSON into the servlet context.
  5. Build against dist/Genelet.jar and the jars in lib.

Generated apps can use no_db for actions that do not need JDBC and no_method for actions handled entirely by filter/template behavior. JSON/XML chartags return response bodies; HTML-like chartags forward to templates such as:

<Template>/<role>/<component>/<action>.<tag>

Samples

samples/tutojava

tutojava is the canonical generated web application sample. It uses myproject.* generated classes, sample component JSON files, and JSP-style HTML templates.

Build it from the repository root:

ant sample-tutojava-dist

The WAR is written to:

samples/tutojava/dist/Tutojava.war

samples/javahelper

javahelper shows how to call the helper/generator code from a small command-line entry point. The helper implementation itself is maintained in src/com/genelet/helper.

Compatibility Notes

Genelet keeps the legacy generated-app surface stable:

  • Java 8 and Ant remain the supported build shape.
  • Numeric framework error strings are preserved through Error.getMessage().
  • Cookie wire format is preserved.
  • javax.servlet and Java EE 7-era APIs are used.
  • Repo-local jars in lib are the build inputs; generated dist content is not committed.

About

Java Version of the Genelet Web Development Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages