jodd-joy/src/main/java/jodd/joy/JoyDb.java
@Override
	@SuppressWarnings("unchecked")
	public void start() {
		initLogger();

		if (!databaseEnabled) {
			log.info("DB not enabled.");
			return;
		}

		log.info("DB start ----------");

		final PetiteContainer petiteContainer = joyPetiteSupplier.get().getPetiteContainer();

		// connection pool
		connectionProvider = createConnectionProviderIfNotSupplied();

		petiteContainer.addBean(beanNamePrefix() + "pool", connectionProvider);

		if (connectionProvider instanceof CoreConnectionPool) {
			final CoreConnectionPool pool = (CoreConnectionPool) connectionProvider;
			if (pool.getDriver() == null) {
				databaseEnabled = false;
				log.warn("DB configuration not set (" + beanNamePrefix() + "pool.*). DB will be disabled.");
				return;
			}
		}
		connectionProvider.init();

		checkConnectionProvider();

		// transactions manager
		jtxManager = createJtxTransactionManager(connectionProvider);
		jtxManager.setValidateExistingTransaction(true);

		final AnnotationTxAdviceManager annTxAdviceManager = new AnnotationTxAdviceManager(new LeanJtxWorker(jtxManager), jtxScopePattern);
		AnnotationTxAdviceSupport.manager = annTxAdviceManager;

		// create proxy
		joyProxettaSupplier.get().getProxetta().withAspect(createTxProxyAspects(annTxAdviceManager.getAnnotations()));

		final DbSessionProvider sessionProvider = new DbJtxSessionProvider(jtxManager);

		// querymap
		final long startTime = System.currentTimeMillis();

		final QueryMap queryMap = new DbPropsQueryMap();

		log.debug("Queries loaded in " + (System.currentTimeMillis() - startTime) + "ms.");
		log.debug("Total queries: " + queryMap.size());

		// dboom
		dbOom = DbOom.create()
			.withConnectionProvider(connectionProvider)
			.withSessionProvider(sessionProvider)
			.withQueryMap(queryMap)
			.get();

		dbOom.connect();

		final DbEntityManager dbEntityManager = dbOom.entityManager();
		dbEntityManager.reset();

		petiteContainer.addBean(beanNamePrefix() + "query", dbOom.queryConfig());
		petiteContainer.addBean(beanNamePrefix() + "oom", dbOom.config());

		// automatic configuration
		if (autoConfiguration) {
			final AutomagicDbOomConfigurator automagicDbOomConfigurator =
				new AutomagicDbOomConfigurator(dbEntityManager, true);

			automagicDbOomConfigurator.registerAsConsumer(
				joyScannerSupplier.get().getClassScanner());
		}

		dbEntityManagerConsumers.accept(dbEntityManager);

		log.info("DB OK!");
	}
@Override
	@SuppressWarnings("unchecked")
	public void start() {
		initLogger();

		if (!databaseEnabled) {
			log.info("DB not enabled.");
			return;
		}

		log.info("DB start ----------");

		final PetiteContainer petiteContainer = joyPetiteSupplier.get().getPetiteContainer();

		// connection pool
		connectionProvider = createConnectionProviderIfNotSupplied();

		petiteContainer.addBean(beanNamePrefix() + "pool", connectionProvider);

		if (connectionProvider instanceof CoreConnectionPool) {
			final CoreConnectionPool pool = (CoreConnectionPool) connectionProvider;
			if (pool.getDriver() == null) {
				databaseEnabled = false;
				log.warn("DB configuration not set (" + beanNamePrefix() + "pool.*). DB will be disabled.");
				return;
			}
		}
		connectionProvider.init();

		checkConnectionProvider();

		// transactions manager
		jtxManager = createJtxTransactionManager(connectionProvider);
		jtxManager.setValidateExistingTransaction(true);

		final AnnotationTxAdviceManager annTxAdviceManager = new AnnotationTxAdviceManager(new LeanJtxWorker(jtxManager), jtxScopePattern);
		AnnotationTxAdviceSupport.manager = annTxAdviceManager;

		// create proxy
		joyProxettaSupplier.get().getProxetta().withAspect(createTxProxyAspects(annTxAdviceManager.getAnnotations()));

		final DbSessionProvider sessionProvider = new DbJtxSessionProvider(jtxManager);

		// querymap
		final long startTime = System.currentTimeMillis();

		final QueryMap queryMap = new DbPropsQueryMap();

		log.debug("Queries loaded in " + (System.currentTimeMillis() - startTime) + "ms.");
		log.debug("Total queries: " + queryMap.size());

		// dboom
		dbOom = DbOom.create()
			.withConnectionProvider(connectionProvider)
			.withSessionProvider(sessionProvider)
			.withQueryMap(queryMap)
			.get();

		dbOom.connect();

		final DbEntityManager dbEntityManager = dbOom.entityManager();
		dbEntityManager.reset();

		petiteContainer.addBean(beanNamePrefix() + "query", dbOom.queryConfig());
		petiteContainer.addBean(beanNamePrefix() + "oom", dbOom.config());

		// automatic configuration
		if (autoConfiguration) {
			final AutomagicDbOomConfigurator automagicDbOomConfigurator =
				new AutomagicDbOomConfigurator(dbEntityManager, true);

			automagicDbOomConfigurator.registerAsConsumer(
				joyScannerSupplier.get().getClassScanner());
		}

		dbEntityManagerConsumers.accept(dbEntityManager);

		log.info("DB OK!");
	}
@ Override @ SuppressWarnings ( "unchecked" ) public void start ( ) { initLogger ( ) ; if ( ! databaseEnabled ) { log . info ( "DB not enabled." ) ; return ; } log . info ( "DB start ----------" ) ; final PetiteContainer petiteContainer = joyPetiteSupplier . get ( ) . getPetiteContainer ( ) ; // connection pool connectionProvider = createConnectionProviderIfNotSupplied ( ) ; petiteContainer . addBean ( beanNamePrefix ( ) + "pool" , connectionProvider ) ; if ( connectionProvider instanceof CoreConnectionPool ) { final CoreConnectionPool pool = ( CoreConnectionPool ) connectionProvider ; if ( pool . getDriver ( ) == null ) { databaseEnabled = false ; log . warn ( "DB configuration not set (" + beanNamePrefix ( ) + "pool.*). DB will be disabled." ) ; return ; } } connectionProvider . init ( ) ; checkConnectionProvider ( ) ; // transactions manager jtxManager = createJtxTransactionManager ( connectionProvider ) ; jtxManager . setValidateExistingTransaction ( true ) ; final AnnotationTxAdviceManager annTxAdviceManager = new AnnotationTxAdviceManager ( new LeanJtxWorker ( jtxManager ) , jtxScopePattern ) ; AnnotationTxAdviceSupport . manager = annTxAdviceManager ; // create proxy joyProxettaSupplier . get ( ) . getProxetta ( ) . withAspect ( createTxProxyAspects ( annTxAdviceManager . getAnnotations ( ) ) ) ; final DbSessionProvider sessionProvider = new DbJtxSessionProvider ( jtxManager ) ; // querymap final long startTime = System . currentTimeMillis ( ) ; final QueryMap queryMap = new DbPropsQueryMap ( ) ; log . debug ( "Queries loaded in " + ( System . currentTimeMillis ( ) - startTime ) + "ms." ) ; log . debug ( "Total queries: " + queryMap . size ( ) ) ; // dboom dbOom = DbOom . create ( ) . withConnectionProvider ( connectionProvider ) . withSessionProvider ( sessionProvider ) . withQueryMap ( queryMap ) . get ( ) ; dbOom . connect ( ) ; final DbEntityManager dbEntityManager = dbOom . entityManager ( ) ; dbEntityManager . reset ( ) ; petiteContainer . addBean ( beanNamePrefix ( ) + "query" , dbOom . queryConfig ( ) ) ; petiteContainer . addBean ( beanNamePrefix ( ) + "oom" , dbOom . config ( ) ) ; // automatic configuration if ( autoConfiguration ) { final AutomagicDbOomConfigurator automagicDbOomConfigurator = new AutomagicDbOomConfigurator ( dbEntityManager , true ) ; automagicDbOomConfigurator . registerAsConsumer ( joyScannerSupplier . get ( ) . getClassScanner ( ) ) ; } dbEntityManagerConsumers . accept ( dbEntityManager ) ; log . info ( "DB OK!" ) ; }
Initializes database. First, creates connection pool.
and transaction manager. Then, Jodds DbEntityManager is
configured. It is also configured automagically, by scanning
the class path for entities.
Initializes database . First creates connection pool . and transaction manager . Then Jodds DbEntityManager is configured . It is also configured automagically by scanning the class path for entities .