That’s a good question, and probably one deserving a separate blog with code examples.

One possibility is to use proxies (see for example https://github.com/adamw/macwire#scopes) — there’s nothing in the proxy usage that would require using a IoC container.

Another is to make the per-session or per-request “scoping” explicit by passing e.g. a SessionId => MyBean function instead of a MyBean instance. It’s less “magical” than what we know from web frameworks, but also much less surprising in usage. It‘s also crystal clear then which code actually touches sessions (even indirectly).

--

--

Software engineer, Functional Programming and Scala enthusiast, SoftwareMill co-founder

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adam Warski

Adam Warski

Software engineer, Functional Programming and Scala enthusiast, SoftwareMill co-founder

More from Medium

When You’re Looking For The Exit Sign

Heroes & Romantics

How should we trade-off different morally relevant factors?