Skip to content
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
13 changes: 0 additions & 13 deletions avaje-jex/src/main/java/io/avaje/jex/DJex.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,13 @@ final class DJex implements Jex {

private final Routing routing = new DefaultRouting();
private final AppLifecycle lifecycle = new DefaultLifecycle();
private final Map<Class<?>, Object> attributes = new HashMap<>();
private final DJexConfig config = new DJexConfig();

@Override
public DJexConfig config() {
return config;
}

@Override
public <T> Jex attribute(Class<T> cls, T instance) {
attributes.put(cls, instance);
return this;
}

@Override
@SuppressWarnings("unchecked")
public <T> T attribute(Class<T> cls) {
return (T) attributes.get(cls);
}

@Override
public Jex routing(Routing.HttpService routes) {
routing.add(routes);
Expand Down
18 changes: 0 additions & 18 deletions avaje-jex/src/main/java/io/avaje/jex/Jex.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,6 @@ static Jex create() {
return new DJex();
}

/**
* Sets a custom attribute that can be accessed later by the Jex instance or its components.
*
* @param <T> The type of the attribute.
* @param cls The class of the attribute.
* @param instance The instance of the attribute.
*/
<T> Jex attribute(Class<T> cls, T instance);

/**
* Returns a custom attribute previously set using {@link #attribute(Class, Object)}.
*
* @param <T> The type of the attribute.
* @param cls The class of the attribute.
* @return The attribute instance, or null if not found.
*/
<T> T attribute(Class<T> cls);

/**
* Adds a new HTTP route and its associated handler to the Jex routing configuration.
*
Expand Down
12 changes: 11 additions & 1 deletion avaje-jex/src/main/java/io/avaje/jex/Routing.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@ public sealed interface Routing permits DefaultRouting {
*/
<T extends Exception> Routing error(Class<T> exceptionClass, ExceptionHandler<T> handler);

/** Add a group of route handlers with a common path prefix. */
/**
* Add a group of route handlers with a common path prefix.
*
* <pre>{@code
* routing.path("api", () -> {
* routing.get("/", ctx -> ctx.text("apiRoot"));
* routing.get("{id}", ctx -> ctx.text("api-" + ctx.pathParam("id")));
* });
*
* }</pre>
*/
Routing path(String path, Group group);

/** Add a HEAD handler. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ JsonService initJsonService() {
if (jsonService != null) {
return jsonService;
}
return CoreServiceLoader.jsonService().orElseGet(this::defaultJsonService);

var json = CoreServiceLoader.jsonService().orElseGet(this::defaultJsonService);

if (json == null) log.log(Level.WARNING, "No Json library configured");

return json;
}

/** Create a reasonable default JsonService if Jackson or avaje-jsonb are present. */
Expand Down
Loading