/** * Listener method which waits for a {@link ContextRefreshedEvent} and then * extracts the {@link SessionFactory} from the {@link ApplicationContext} * and pases it to {@link #setSessionFactory(SessionFactory)}. */ @Override public void handleContextRefreshedEvent(ContextRefreshedEvent cre) { ApplicationContext ctx = cre.getApplicationContext(); if (ctx.containsBean("sessionFactory")) { SessionFactory sessionFactory = (SessionFactory) ctx .getBean("sessionFactory"); setSessionFactory(sessionFactory); } else { log.warn("No session factory found. Cannot initialize"); } }