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

Upgrade Jooby #40

Open
pierre opened this issue Sep 3, 2020 · 1 comment
Open

Upgrade Jooby #40

pierre opened this issue Sep 3, 2020 · 1 comment

Comments

@pierre
Copy link
Member

pierre commented Sep 3, 2020

Jooby 2.x is a significant rewrite. The major breaking change is that there is no more Servlet support, which is a blocker for us.

Here are my notes from a quick investigation.

  1. org.jooby.Result and org.jooby.Results are gone, the new io.jooby.Context should be used instead.
@Singleton
@Path("/something")
public class SomethingResource {
    @GET
    public Result getSomething(final Optional<String> maybeSomething) {
        return Results.ok(...);
    }
}

becomes

@Singleton
@Path("/something")
public class SomethingResource {
    @GET
    public void getSomething(final Optional<String> maybeSomething, final Context context) {
        context.setResponseCode(StatusCode.OK);
    }
}
  1. Jooby#use(config) has been removed: instead, we need to create a new environment (https://jooby.io/#configuration-custom-environment). Maybe something like that (untested):
    public PluginApp build() {
        final PluginApp app = new PluginApp(jackson, services, routeClasses);
        final Environment origEnv = app.getEnvironment();
        final Environment newEnv = new Environment(origEnv.getClassLoader(),
                                                   this.config.withFallback(origEnv.getConfig()),
                                                   origEnv.getActiveNames());
        app.setEnvironment(newEnv);
        return app;
    }
  1. org.jooby.Sse has become io.jooby.ServerSentEmitter
  2. org.jooby.mvc.Local has become io.jooby.annotations.ContextParam
  3. There is no injection framework in 2.x. Guice has been replaced with a simple hash map service registry. Extra work is needed to integrate Guice again: https://jooby.io/#dependency-injection-guice

As part of the upgrade, we should add a few tests (https://jooby.io/#testing) in our base framework, to help with such upgrades in the future.

@pierre pierre mentioned this issue Sep 3, 2020
18 tasks
@sbrossie
Copy link
Member

Also, it seems that Jooby's major version is now 3.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants