BQModuleProvider is made redundant

7 views
Skip to first unread message

Andrus Adamchik

unread,
Dec 5, 2023, 12:08:39 PM12/5/23
to Bootique User Group
A heads up on the latest 3.0 changes... BQModuleProvider was just made redundant and deprecated. The module itself now can (auto)load itself and provide its metadata. I was just going through our standard modules, updating to the new API, and I really love the resulting boilerplate reduction. As the example below shows, it is one class instead of two, with an optional fluent "crate" method in the module supplying the metadata. Much less code, and much easier to make sense of the Module.

This was already pushed to "master". But there are other good things that are about to happen too. We figured out a way to automatically inflate DI-managed objects with external app configuration. So you won't need to interact with ConfigurationFactory anymore (which may be one of the last remaining pieces of boilerplate). Stay tuned!

Andrus


--- before ---
public class MyModule implements BQModule {
...
}

public class MyModuleProvider implements BQModuleProvider {
@Override
public BQModule module() {
return new MyModule();
}

@Override
public Map<String, Type> configs() {
return Collections.singletonMap("my", MyFactory.class);
}

@Override
public BQModuleMetadata.Builder moduleBuilder() {
return BQModuleProvider.super
.moduleBuilder()
.description("Provides a very important function");
}
}


--- after ---
public class MyModule implements BQModule {
...
@Override
public ModuleCrate crate() {
return ModuleCrate.of(this)
.description("Provides a very important function")
.config("my", MyFactory.class)
.build();
}
}
Reply all
Reply to author
Forward
0 new messages