Improved DI

30 views
Skip to first unread message

Claude

unread,
Jul 30, 2020, 11:51:55 AM7/30/20
to Smooks Development
Hi Tom,

I've opened a draft PR which improves, from my perspective, the DI in Smooks: https://github.com/smooks/smooks/pull/320. Essentially, I've generalised many concepts like DataDecoder, Parameter, and SmooksResourceConfigurationStore. The goals are to simplify the code, make the DI more flexible and, hopefully, more intuitive with the use of JSR annotations and interfaces. I need to have another pass at the code before moving the PR to the review stage but I thought I should give you a head start.

Claude

Claude

unread,
Aug 4, 2020, 3:05:43 PM8/4/20
to Smooks Development
I've opened another draft PR in the smooks-javabean-cartridge repo: https://github.com/smooks/smooks-javabean-cartridge/pull/9. It shows an example of a cartridge migrated with the changes in https://github.com/smooks/smooks/pull/320. Some of the migrations include:
  • @AppContext, @ConfigParam, and @Config replaced with @javax.inject.Inject
  • @Initialize replaced with @javax.annotation.PostConstruct
  • "name" attribute in @ConfigParam replaced with @javax.inject.Named
  • "default" attribute in @ConfigParam replicated by initialising the field to the default value
  • Wrapped optional fields with java.util.Optional which tells org.smooks.cdr.annotation.Configurator that the value may be absent
  • References to SmooksResourceConfigurationStore replaced with Registry
  • References to decoder/encoder replaced with TypeConverterFactory
  • SmooksResourceConfiguration.getStringParameter(...) replaced with SmooksResourceConfiguration.getParameterValue(..., String.class)
  • applicationContext.setAttribute(..., ...) and applicationContext.getAttribute(..., ...) replaced with applicationContext.getRegistry().registerObject(..., ...) and applicationContext.getRegistry().lookup(...), respectively
Claude

Tom Fennelly

unread,
Aug 5, 2020, 2:47:47 PM8/5/20
to smook...@googlegroups.com
Hi Claude.

Sorry for the slow reply. I'm on PTO myself atm, so not keeping up with emails. I'll try to have a look at these in the coming days.

Regards,

Tom.

--
You received this message because you are subscribed to the Google Groups "Smooks Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smooks-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smooks-dev/20316f94-05d0-435c-9854-0ddda4c73aa1n%40googlegroups.com.

Claude

unread,
Aug 11, 2020, 4:15:42 AM8/11/20
to Smooks Development
One final note. I'm proposing in the PR a change to turn Configurator into a composable and extensible class named LifecycleManager. Previously, one would inject values and trigger lifecycle methods with something alone the lines of:

Configurator.configure(beanWriter, config, appContext);

Following the refactoring, the above would become:

appContext.getRegistry().lookup(new LifecycleManagerLookup()).applyPhase(beanWriter, new PostConstructLifecyclePhase(new Scope(appContext.getRegistry(), config, beanWriter)));

Claude
Reply all
Reply to author
Forward
0 new messages