Search in sources :

Example 1 with DalTaskFactory

use of com.ctrip.platform.dal.dao.task.DalTaskFactory 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);
}
Also used : DalLogger(com.ctrip.platform.dal.dao.client.DalLogger) DefaultTaskFactory(com.ctrip.platform.dal.dao.task.DefaultTaskFactory) DalTaskFactory(com.ctrip.platform.dal.dao.task.DalTaskFactory) DalConfigCustomizedOption(com.ctrip.framework.dal.cluster.client.config.DalConfigCustomizedOption) DefaultLogger(com.ctrip.platform.dal.dao.client.DefaultLogger) DefaultDalConnectionLocator(com.ctrip.platform.dal.dao.datasource.DefaultDalConnectionLocator) DefaultDalConnectionLocator(com.ctrip.platform.dal.dao.datasource.DefaultDalConnectionLocator) DalConnectionLocator(com.ctrip.platform.dal.dao.client.DalConnectionLocator)

Aggregations

DalConfigCustomizedOption (com.ctrip.framework.dal.cluster.client.config.DalConfigCustomizedOption)1 DalConnectionLocator (com.ctrip.platform.dal.dao.client.DalConnectionLocator)1 DalLogger (com.ctrip.platform.dal.dao.client.DalLogger)1 DefaultLogger (com.ctrip.platform.dal.dao.client.DefaultLogger)1 DefaultDalConnectionLocator (com.ctrip.platform.dal.dao.datasource.DefaultDalConnectionLocator)1 DalTaskFactory (com.ctrip.platform.dal.dao.task.DalTaskFactory)1 DefaultTaskFactory (com.ctrip.platform.dal.dao.task.DefaultTaskFactory)1