Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to only use built-in JDK Server #53

Merged
merged 12 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
strategy:
fail-fast: false
matrix:
java_version: [11, 17]
java_version: [21]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java_version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jdk-ea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java_version: [EA,GA] ## valhalla (fails javadoc)
java_version: [EA, GA] ## valhalla (fails javadoc)
os: [ubuntu-latest]

steps:
Expand Down
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ build/
.gradle
.project
*.prefs
avaje-jex-freemarker/.classpath
avaje-jex-jdk/.classpath
avaje-jex-jetty/.classpath
avaje-jex/.classpath
*.classpath
*.prefs
bin/
7 changes: 0 additions & 7 deletions avaje-jex-freemarker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jex-jdk</artifactId>
<version>2.6-SNAPSHOT</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package io.avaje.jex.render.freemarker;

import java.io.IOException;
import java.io.StringWriter;
import java.io.UncheckedIOException;
import java.util.Map;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.Version;
import io.avaje.jex.Context;
import io.avaje.jex.TemplateRender;
import io.avaje.spi.ServiceProvider;

import java.io.IOException;
import java.io.StringWriter;
import java.io.UncheckedIOException;
import java.util.Map;

@ServiceProvider
public class FreeMarkerRender implements TemplateRender {

private final Configuration configuration;
Expand Down
8 changes: 6 additions & 2 deletions avaje-jex-freemarker/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
open module io.avaje.jex.freemarker {
import io.avaje.jex.render.freemarker.FreeMarkerRender;
import io.avaje.jex.spi.JexExtension;

module io.avaje.jex.freemarker {

requires transitive io.avaje.jex;
requires transitive freemarker;
requires java.net.http;

requires static io.avaje.spi;

provides io.avaje.jex.TemplateRender with io.avaje.jex.render.freemarker.FreeMarkerRender;
provides JexExtension with FreeMarkerRender;
}

This file was deleted.

36 changes: 0 additions & 36 deletions avaje-jex-jdk/pom.xml

This file was deleted.

11 changes: 0 additions & 11 deletions avaje-jex-jdk/src/main/java/module-info.java

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions avaje-jex-jdk/src/test/resources/logback-test.xml

This file was deleted.

7 changes: 0 additions & 7 deletions avaje-jex-mustache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jex-jdk</artifactId>
<version>2.6-SNAPSHOT</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import com.github.mustachejava.MustacheFactory;
import io.avaje.jex.Context;
import io.avaje.jex.TemplateRender;
import io.avaje.spi.ServiceProvider;

import java.io.IOException;
import java.io.StringWriter;
import java.io.UncheckedIOException;
import java.util.Map;

@ServiceProvider
public class MustacheRender implements TemplateRender {

private final MustacheFactory mustacheFactory;
Expand Down
6 changes: 4 additions & 2 deletions avaje-jex-mustache/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
open module io.avaje.jex.mustache {
module io.avaje.jex.mustache {

requires transitive io.avaje.jex;
requires transitive com.github.mustachejava;
requires java.net.http;

provides io.avaje.jex.TemplateRender with io.avaje.jex.render.mustache.MustacheRender;
requires static io.avaje.spi;

provides io.avaje.jex.spi.JexExtension with io.avaje.jex.render.mustache.MustacheRender;
}

This file was deleted.

20 changes: 2 additions & 18 deletions avaje-jex/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<artifactId>avaje-jex</artifactId>

<properties>
<jetty.version>11.0.13</jetty.version>
</properties>

<dependencies>
Expand All @@ -31,7 +30,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-inject</artifactId>
<version>9.9</version>
<version>10.6</version>
<optional>true</optional>
</dependency>

Expand All @@ -45,29 +44,14 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb</artifactId>
<version>1.9</version>
<version>2.3</version>
<optional>true</optional>
</dependency>

</dependencies>

<build>
<plugins>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-surefire-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <argLine>-->
<!-- &#45;&#45;add-opens io.avaje.jex/io.avaje.jex.base=com.fasterxml.jackson.databind-->
<!-- &#45;&#45;add-modules com.fasterxml.jackson.databind-->
<!-- &#45;&#45;add-opens io.avaje.jex/io.avaje.jex=ALL-UNNAMED-->
<!-- &#45;&#45;add-opens io.avaje.jex/io.avaje.jex.base=ALL-UNNAMED-->
<!-- &#45;&#45;add-opens io.avaje.jex/io.avaje.jex.core=ALL-UNNAMED-->
<!-- &#45;&#45;add-opens io.avaje.jex/io.avaje.jex.routes=ALL-UNNAMED-->
<!-- &#45;&#45;add-opens io.avaje.jex/io.avaje.jex.jetty=ALL-UNNAMED-->
<!-- </argLine>-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins>
</build>

Expand Down
33 changes: 19 additions & 14 deletions avaje-jex/src/main/java/io/avaje/jex/BootJex.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.avaje.jex;

import io.avaje.inject.BeanScope;

/**
* Start Jex using {@code @Controller} and avaje-inject, avaje-http, avaje-config.
* <p>
Expand All @@ -13,24 +15,27 @@ public interface BootJex {
* Start Jex server using {@code @Controller} with avaje-inject, avaje-http, avaje-config.
*
* <pre>{@code
* public static void main(String[] args) {
* public static void main(String[] args) {
*
* BootJex.start();
* }
* BootJex.start();
* }
* }</pre>
*/
static void start() {
BootJexState.start();
BootJexState.start(BeanScope.builder().build());
}

// /**
// * Stop the Jex server (for CRaC).
// */
// static void stop() {
// BootJexState.stop();
// }
//
// static void restart() {
// BootJexState.restart();
// }
/**
* Start Jex server using {@code @Controller} with avaje-inject, avaje-http, avaje-config.
*
* <pre>{@code
* public static void main(String[] args) {
*
* BootJex.start();
* }
* }</pre>
*/
static void start(BeanScope beanScope) {
BootJexState.start(beanScope);
}
}
19 changes: 6 additions & 13 deletions avaje-jex/src/main/java/io/avaje/jex/BootJexState.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class BootJexState {

private static State state;

static void start() {
state = new BootJexState().create();
static void start(BeanScope beanScope) {
state = new BootJexState().create(beanScope);
}

static void stop() {
Expand All @@ -19,39 +19,32 @@ static void restart() {
state.restart();
}

State create() {
BeanScope beanScope = BeanScope.builder().build();
State create(BeanScope beanScope) {

Jex jex = beanScope.getOptional(Jex.class).orElse(Jex.create());
jex.configureWith(beanScope);

JexConfig config = jex.config();
int port = config.port();
if (port == 7001) {
config.port(Config.getInt("jex.port", port));
}
config.port(Config.getInt("jex.port", port));

jex.lifecycle().onShutdown(beanScope::close);
return new State(jex.start(), beanScope);
return new State(jex.start());
}

private static class State {

private final Jex.Server server;
private final BeanScope beanScope;

State(Jex.Server server, BeanScope beanScope) {
State(Jex.Server server) {
this.server = server;
this.beanScope = beanScope;
}

void stop() {
server.shutdown();
}

public void restart() {
// CRaC based startup ...
//beanScope.restart();
server.restart();
}
}
Expand Down
Loading
Loading