Commits

tbrugz committed 134cab8

refactoring: removing dependency 'util->def'

  • Participants
  • Parent commits cf1596d

Comments (0)

Files changed (2)

File src/tbrugz/sqldump/def/DBMSResources.java

 import java.sql.SQLException;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
 import tbrugz.sqldump.dbmodel.Column;
 import tbrugz.sqldump.util.ParametrizedProperties;
 import tbrugz.sqldump.util.SQLIdentifierDecorator;
+import tbrugz.sqldump.util.SQLUtils;
 import tbrugz.sqldump.util.Utils;
 
 //TODOne: add addUpdateListener() ? so DBMSResources may notify others that need its info
 			updateIdentifierQuoteString();
 			updateSpecificFeaturesClass();
 			fireUpdateToListeners();
-			Column.ColTypeUtil.setDbId(newid);
 		}
 		else {
 			log.warn("unknown dbid: '"+newid+"' ; keeping '"+dbId+"' as dbid");
 		for(DBMSUpdateListener listener: updateListeners) {
 			listener.dbmsUpdated();
 		}
+		
+		//instead of firing update to listeners...
+		Column.ColTypeUtil.setDbId(DBMSResources.instance().dbid());
+		Map<Class<?>, Class<?>> mapper = DBMSResources.instance().databaseSpecificFeaturesClass().getColumnTypeMapper();
+		SQLUtils.setupColumnTypeMapper(mapper);
 	}
 	
 }

File src/tbrugz/sqldump/util/SQLUtils.java

 import java.util.Set;
 import java.util.regex.Matcher;
 
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import tbrugz.sqldump.def.DBMSResources;
-import tbrugz.sqldump.def.DBMSUpdateListener;
-
 public class SQLUtils {
 	
 	static final Log log = LogFactory.getLog(SQLUtils.class);
 	
-	//XXX: move updateListener to another class/package (cyclic dependency: util <-> def)? 
-	final static DBMSUpdateListener updateListener = new DBMSUpdateListener() {
-		@Override
-		public void dbmsUpdated() {
-			Map<Class<?>, Class<?>> mapper = DBMSResources.instance().databaseSpecificFeaturesClass().getColumnTypeMapper();
-			setupColumnTypeMapper(mapper);
-		}
-	};
-	
-	static {
-		DBMSResources.instance().addUpdateListener(updateListener);
-	}
-
 	public static String getRowFromRS(ResultSet rs, int numCol, String table) throws SQLException {
 		return getRowFromRS(rs, numCol, table, ";");
 	}