use of com.ctrip.platform.dal.dao.datasource.DefaultDalConnectionLocator in project dal by ctripcorp.
the class DalConfigureFactory method getFromDocument.
public DalConfigure getFromDocument(Document doc) throws Exception {
Element root = doc.getDocumentElement();
String name = getAttribute(root, NAME);
DalLogger logger = readComponent(root, LOG_LISTENER, new DefaultLogger(), LOGGER);
// To wrap with a sandbox logger
// logger = new DalSafeLogger(logger);
DalTaskFactory factory = readComponent(root, TASK_FACTORY, new DefaultTaskFactory(), FACTORY);
DalConnectionLocator locator = readComponent(root, CONNECTION_LOCATOR, new DefaultDalConnectionLocator(), LOCATOR, false);
// read config of ''
DalConfigCustomizedOption defaultOption = readOverridableProperty(root);
Map<String, DatabaseSet> databaseSets = readDatabaseSets(getChildNode(root, DATABASE_SETS));
if (locator instanceof InjectableComponentSupport) {
((InjectableComponentSupport) locator).inject(new DatabaseSetsImpl(databaseSets.values()));
}
locator.initialize(getSettings(getChildNode(root, CONNECTION_LOCATOR)));
Map<String, DatabaseSet> clusters = readClusters(getChildNode(root, DATABASE_SETS), locator, defaultOption);
clusters.putAll(databaseSets);
locator.setup(clusters.values());
DatabaseSetAdapter adapter = new ClusterDatabaseSetAdapter(locator);
tryAdaptDatabaseSets(clusters, adapter);
Map<String, DalConnectionString> connectionStrings = DataSourceConfigureLocatorManager.getInstance().getAllConnectionStrings();
adapter = new LocalDatabaseSetAdapter(connectionStrings);
tryAdaptDatabaseSets(clusters, adapter);
DatabaseSelector selector = readComponent(root, DATABASE_SELECTOR, new DefaultDatabaseSelector(), SELECTOR);
return new DalConfigure(name, clusters, logger, locator, factory, selector);
}
Aggregations