<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Dependency Injection on ilikeorangutans</title><link>https://kuelzer.ca/tags/dependency-injection/</link><description>Recent content in Dependency Injection on ilikeorangutans</description><generator>Hugo</generator><language>en</language><copyright>© 2026 Jakob Külzer</copyright><lastBuildDate>Sun, 12 Apr 2026 14:27:24 -0400</lastBuildDate><atom:link href="https://kuelzer.ca/tags/dependency-injection/index.xml" rel="self" type="application/rss+xml"/><item><title>Google Guice and Scope Mixing</title><link>https://kuelzer.ca/posts/2012/12/11/google-guice-and-scope-mixing/</link><pubDate>Tue, 11 Dec 2012 13:59:40 -0400</pubDate><guid>https://kuelzer.ca/posts/2012/12/11/google-guice-and-scope-mixing/</guid><description>&lt;p&gt;I&amp;rsquo;ve been working on a small Java application I wrote a few years ago for some bug fixes and in the process of making it better, I introduced &lt;a href="https://code.google.com/p/google-guice/"&gt;Google Guice&lt;/a&gt;, my favourite dependency injection framework. On of the great features of Guice is that it supports different &lt;a href="https://code.google.com/p/google-guice/wiki/Scopes"&gt;scopes for injection&lt;/a&gt;. Per default, Guice will return a new object for every request. But sometimes you want to objects to be created a bit less liberally, for example, you want a certain object to be created only once. Guice has a &lt;code&gt;@Singleton&lt;/code&gt; scope for that. Want an object to be created once for a request? Guice and &lt;a href="https://code.google.com/p/google-guice/wiki/Servlets"&gt;guice-servlet&lt;/a&gt; offers &lt;code&gt;@RequestScoped&lt;/code&gt; and &lt;code&gt;SessionScoped&lt;/code&gt;. But there&amp;rsquo;s more, need JUnit per test scope? &lt;a href="https://code.google.com/p/guiceberry/"&gt;Guiceberry&lt;/a&gt; has exactly that: &lt;code&gt;@TestScoped&lt;/code&gt; that will make sure every test gets exactly one object.&lt;/p&gt;</description></item></channel></rss>