eclipse plugin: Remove the need of syncronization by correctly...
...creating the singleton. This uses the IODH idiom More info at: http://www.ibm.com/developerworks/java/library/j-dcl/index.html Issue found by "FindBugs"
This commit is contained in:
parent
7a593813e0
commit
62460f6828
1 changed files with 14 additions and 8 deletions
|
@ -28,17 +28,23 @@ import org.wesnoth.utils.StringUtils;
|
|||
|
||||
public class TemplateProvider
|
||||
{
|
||||
private static TemplateProvider instance_;
|
||||
/**
|
||||
* Holds the instance of the TemplateProvider.
|
||||
* This is based on the Initialization on demand holder idiom
|
||||
*/
|
||||
private static class TemplateProviderInstance{
|
||||
private static final TemplateProvider instance_ = new TemplateProvider();
|
||||
}
|
||||
|
||||
private final Map<String, String> templates_ = new HashMap<String, String>();
|
||||
|
||||
public static TemplateProvider getInstance()
|
||||
private TemplateProvider(){
|
||||
loadTemplates();
|
||||
}
|
||||
|
||||
public static TemplateProvider getInstance()
|
||||
{
|
||||
if (instance_ == null)
|
||||
{
|
||||
instance_ = new TemplateProvider();
|
||||
instance_.loadTemplates();
|
||||
}
|
||||
return instance_;
|
||||
return TemplateProviderInstance.instance_;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue