Skip to content

Commit

Permalink
Added extra bean named 'message2' and added private constructor for s…
Browse files Browse the repository at this point in the history
…ingleton. Also, updated the Errata with new corrections.
  • Loading branch information
iuliana committed Mar 18, 2018
1 parent 8eb53c8 commit b666f17
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Binary file modified 9781484228074_Errata.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ public class Singleton {
public static Singleton getInstance() {
return instance;
}

private Singleton(){
// needed so developers cannot instantiate this class directly
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@

<bean id="message" class="java.lang.String"
c:_0="I hope that someone gets my message in a bottle"/>

<bean id="message2" class="java.lang.String"
c:_0="I know I won't be injected :("/>
</beans>


<!-- Java provides a no-arg constructor by default
if it does not extend except Object class and has no any constructors.
In page 105, the class Singleton should have a private constructor
otherwise anybody can get an instance of it by calling new operator,
which breaks the rule single instance in a container. -->

0 comments on commit b666f17

Please sign in to comment.