Update of /var/cvs/src/org/mmbase/datatypes
In directory james.mmbase.org:/tmp/cvs-serv8805
Modified Files:
DataTypes.java
Log Message:
Refuse initializing twice. Removed synchronization on methods (not needed any
more because collector is thread safe now
See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/datatypes
Index: DataTypes.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/datatypes/DataTypes.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- DataTypes.java 27 Apr 2009 15:22:19 -0000 1.33
+++ DataTypes.java 27 Apr 2009 15:50:43 -0000 1.34
@@ -39,7 +39,7 @@
*</p>
* @author Pierre van Rooden
* @since MMBase-1.8
- * @version $Id: DataTypes.java,v 1.33 2009/04/27 15:22:19 michiel Exp $
+ * @version $Id: DataTypes.java,v 1.34 2009/04/27 15:50:43 michiel Exp $
*/
public class DataTypes {
@@ -49,14 +49,18 @@
// the datatype collector containing named DataTypes for use throughout
the application
private static final DataTypeCollector dataTypeCollector =
DataTypeCollector.createSystemDataTypeCollector();
+ private static boolean initialized = false;
public static void initialize() {
+ log.trace("" + Constants.class); // make sure its static init is
called, otherwise it goes horribly wrong.
+
+ synchronized(DataTypes.class) {
+ if (! initialized) {
// read the XML
// Watching will probably not work properly,
// as datatypes depend one ach other, and are are referred
// throughout the system.
// For the moment turn watching off.
// Not sure if it is needed anyway - it won't actually happen that
often
- log.trace("" + Constants.class); // make sure its static init is
called, otherwise it goes horribly wrong.
log.debug("Reading datatypes " + dataTypeCollector);
readDataTypes(ResourceLoader.getConfigurationRoot(), "datatypes.xml");
@@ -75,6 +79,11 @@
log.error(t.getClass().getName() + ": " + Logging.stackTrace(t));
}
*/
+ initialized = true;
+ } else {
+ log.warn("Already initalized");
+ }
+ }
}
@@ -224,7 +233,7 @@
* @param name the name of the DataType to look for
* @return A DataType instance or <code>null</code> if none can be found
*/
- public static synchronized BasicDataType getDataType(String name) {
+ public static BasicDataType getDataType(String name) {
return dataTypeCollector.getDataType(name);
}
@@ -239,7 +248,7 @@
* @param baseDataType the dataType to match against. Can be
<code>null</code>.
* @return A DataType instance or <code>null</code> if none can be
instantiated
*/
- public static synchronized BasicDataType getDataTypeInstance(String name,
BasicDataType baseDataType) {
+ public static BasicDataType getDataTypeInstance(String name, BasicDataType
baseDataType) {
return dataTypeCollector.getDataTypeInstance(name, baseDataType);
}
@@ -253,7 +262,7 @@
* @param type the base type to use for a default datatype instance
* @return A DataType instance
*/
- public static synchronized BasicDataType getDataTypeInstance(String name,
int type) {
+ public static BasicDataType getDataTypeInstance(String name, int type) {
return getDataTypeInstance(name, getDataType(type));
}
@@ -268,7 +277,7 @@
* (this type determines the type of the list elements)
* @return A ListDataType instance
*/
- public static synchronized ListDataType getListDataTypeInstance(String
name, int listItemType) {
+ public static ListDataType getListDataTypeInstance(String name, int
listItemType) {
return (ListDataType)getDataTypeInstance(name,
getListDataType(listItemType));
}
@@ -280,7 +289,7 @@
* @param type the base type whose DataType to return
* @return the DataType instance
*/
- public static synchronized BasicDataType getDataType(int type) {
+ public static BasicDataType getDataType(int type) {
String name = Fields.getTypeDescription(type).toLowerCase();
BasicDataType dataType = getDataType(name);
if (dataType == null) {
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs