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).

Scala software engineer, Functional Programming enthusiast, SoftwareMill co-founder

Scala software engineer, Functional Programming enthusiast, SoftwareMill co-founder