|
From: <to...@us...> - 2007-02-27 19:11:03
|
Revision: 85
http://techne-dev.svn.sourceforge.net/techne-dev/?rev=85&view=rev
Author: tonit
Date: 2007-02-27 11:10:48 -0800 (Tue, 27 Feb 2007)
Log Message:
-----------
added doublecheck locking
Modified Paths:
--------------
sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/core/ContainerFactory.java
Modified: sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/core/ContainerFactory.java
===================================================================
--- sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/core/ContainerFactory.java 2007-02-27 18:59:06 UTC (rev 84)
+++ sandbox/rickles/org.digivitality.techne.core/src/org/digivitality/techne/core/ContainerFactory.java 2007-02-27 19:10:48 UTC (rev 85)
@@ -1,8 +1,8 @@
package org.digivitality.techne.core;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
-
public class ContainerFactory {
// this will be replaced by techne.properties
@@ -10,42 +10,46 @@
private int quantity;
private List containerInstances = new ArrayList();
private static ContainerFactory instance;
-
+
private ContainerFactory() {
-
+
}
-
- public Object clone() throws CloneNotSupportedException
- {
- throw new CloneNotSupportedException("Cloning a singleton is not allowed.");
- }
-
- static synchronized public ContainerFactory getInstance()
- {
- if (instance==null) {
- instance = new ContainerFactory();
+
+ public Object clone() throws CloneNotSupportedException {
+ throw new CloneNotSupportedException(
+ "Cloning a singleton is not allowed.");
+ }
+
+ static synchronized public ContainerFactory getInstance() {
+ if (instance == null) {
+ synchronized (ContainerFactory.class) {
+ if (instance == null) {
+ instance = new ContainerFactory();
+ }
+ }
}
- return instance;
+
+ return instance;
}
-
+
public void init() {
if (quantity == 0) {
quantity = DEFAULT_QUANTITY;
}
- for (int i = 0; i < quantity; i++ ) {
+ for (int i = 0; i < quantity; i++) {
containerInstances.add(new ContainerIntanceImpl());
}
}
-
+
public void setQuantity(int parm) {
this.quantity = parm;
}
-
+
public int getQuantity() {
return containerInstances.size();
}
-
+
public List getContainerInstances() {
- return containerInstances;
+ return containerInstances;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|