@Override protected void onSubmit() { try { ConnectionPropertiesPatcher.patch(getModelObject()); XmlWebApplicationContext ctx = (XmlWebApplicationContext)getWebApplicationContext(Application.get().getServletContext()); if (ctx == null) { form.error(new StringResourceModel("install.wizard.db.step.error.patch", InstallWizard.this).setParameters("Web context is NULL").getObject()); log.error("Web context is NULL"); return; } LocalEntityManagerFactoryBean emb = ctx.getBeanFactory().getBean(LocalEntityManagerFactoryBean.class); emb.afterPropertiesSet(); dbType = getModelObject().getDbType(); } catch (Exception e) { form.error(new StringResourceModel("install.wizard.db.step.error.patch", InstallWizard.this).setParameters(e.getMessage()).getObject()); log.error("error while patching", e); } }
protected EntityManagerFactory createEntityManagerFactory() { LocalEntityManagerFactoryBean emfBean = new LocalEntityManagerFactoryBean(); emfBean.setPersistenceUnitName(persistenceUnit); emfBean.setJpaPropertyMap(getEntityManagerProperties()); emfBean.afterPropertiesSet(); return emfBean.getObject(); }
private int getBrokerCount() { LocalEntityManagerFactoryBean entityManagerFactory = applicationContext.getBean("&entityManagerFactory", LocalEntityManagerFactoryBean.class); //uses Spring EL so we don't need to reference the classes StandardEvaluationContext context = new StandardEvaluationContext(entityManagerFactory); context.setBeanResolver(new BeanFactoryResolver(applicationContext)); SpelExpressionParser parser = new SpelExpressionParser(); Expression expression = parser.parseExpression("nativeEntityManagerFactory.brokerFactory.openBrokers"); List<?> brokers = expression.getValue(context, List.class); return brokers.size(); }
@Bean public LocalEntityManagerFactoryBean entityManagerFactory() { LocalEntityManagerFactoryBean bean = new LocalEntityManagerFactoryBean(); bean.setPersistenceUnitName(unitName); return bean; }