Search in sources :

Example 1 with AnnotationTxAdviceManager

use of jodd.jtx.proxy.AnnotationTxAdviceManager in project jodd by oblac.

the class DefaultAppCore method startDb.

/**
	 * Initializes database. First, creates connection pool.
	 * and transaction manager. Then, Jodds DbOomManager is
	 * configured. It is also configured automagically, by scanning
	 * the class path for entities.
	 */
@SuppressWarnings("unchecked")
protected void startDb() {
    if (!useDatabase) {
        log.info("database is not used");
        return;
    }
    log.info("database initialization");
    // connection pool
    connectionProvider = createConnectionProvider();
    petite.addBean(PETITE_DBPOOL, connectionProvider);
    connectionProvider.init();
    checkConnectionProvider();
    // transactions manager
    jtxManager = createJtxTransactionManager(connectionProvider);
    jtxManager.setValidateExistingTransaction(true);
    AnnotationTxAdviceManager annTxAdviceManager = new AnnotationTxAdviceManager(jtxManager, jtxScopePattern);
    annTxAdviceManager.registerAnnotations(jtxAnnotations);
    AnnotationTxAdviceSupport.manager = annTxAdviceManager;
    DbSessionProvider sessionProvider = new DbJtxSessionProvider(jtxManager);
    // global settings
    DbManager dbManager = DbManager.getInstance();
    dbManager.setConnectionProvider(connectionProvider);
    dbManager.setSessionProvider(sessionProvider);
    petite.addBean(PETITE_DB, dbManager);
    DbOomManager dbOomManager = DbOomManager.getInstance();
    petite.addBean(PETITE_DBOOM, dbOomManager);
    // automatic configuration
    registerDbEntities(dbOomManager);
}
Also used : AnnotationTxAdviceManager(jodd.jtx.proxy.AnnotationTxAdviceManager) DbJtxSessionProvider(jodd.db.jtx.DbJtxSessionProvider) DbSessionProvider(jodd.db.DbSessionProvider) DbOomManager(jodd.db.oom.DbOomManager) DbManager(jodd.db.DbManager)

Aggregations

DbManager (jodd.db.DbManager)1 DbSessionProvider (jodd.db.DbSessionProvider)1 DbJtxSessionProvider (jodd.db.jtx.DbJtxSessionProvider)1 DbOomManager (jodd.db.oom.DbOomManager)1 AnnotationTxAdviceManager (jodd.jtx.proxy.AnnotationTxAdviceManager)1