@Bean public EntityManagerFactory entityManagerFactory() throws NamingException { JndiTemplate jndi = new JndiTemplate(); EntityManagerFactory emf = (EntityManagerFactory) jndi.lookup("java:/emf"); return emf; // Class works with java beans }
/** Resolves the hibernate hibernate.cache.use_second_level_cache */ public String resolveHibernateUseSecondLevelCache() { JndiTemplate jndi = new JndiTemplate(); try { return (String) jndi.lookup(CommonConstants.JNDI_PROP_HIBERNATE_SECOND_LEVEL_CACHE); } catch (NamingException e) { return CommonConstants.HIBERNATE_DEFAULT_SECOND_LEVEL_CACHE; } }
/** Resolves the hibernate hibernate.cache.use_query_cache */ public String resolveHibernateUseQueryCache() { JndiTemplate jndi = new JndiTemplate(); try { return (String) jndi.lookup(CommonConstants.JNDI_PROP_HIBERNATE_QUERY_CACHE); } catch (NamingException e) { return CommonConstants.HIBERNATE_DEFAULT_QUERY_CACHE; } }
/** Resolves the hibernate hibernate.hbm2ddl.auto property */ public String resolveHibernateHbm2ddlAuto() { JndiTemplate jndi = new JndiTemplate(); try { return (String) jndi.lookup(CommonConstants.JNDI_PROP_HIBERNATE_HBM2DDL_AUTO); } catch (NamingException e) { return CommonConstants.HIBERNATE_DEFAULT_HBM2DDL_AUTO; } }
/** Resolves the hibernate hibernate.format_sql property */ public String resolveHibernateFormatSql() { JndiTemplate jndi = new JndiTemplate(); try { return (String) jndi.lookup(CommonConstants.JNDI_PROP_HIBERNATE_FORMAT_SQL); } catch (NamingException e) { return CommonConstants.HIBERNATE_DEFAULT_FORMAT_SQL; } }
/** Resolves the hibernate dialect via JNDI, hibernate property: hibernate.dialect */ public String resolveHibernateDialect() { JndiTemplate jndi = new JndiTemplate(); try { return (String) jndi.lookup(CommonConstants.JNDI_PROP_HIBERNATE_DIALECT); } catch (NamingException e) { return CommonConstants.HIBERNATE_DEFAULT_DIALECT; } }
/** * Resolves the hibernate connection isolation via JNDI, hibernate property: * hibernate.connections.isolation */ public String resolveHibernateConnectionIsolation() { JndiTemplate jndi = new JndiTemplate(); try { return (String) jndi.lookup(CommonConstants.JNDI_PROP_HIBERNATE_CONNECTION_ISOLATION); } catch (NamingException e) { return CommonConstants.HIBERNATE_DEFAULT_CONNECTION_ISOLATION; } }
/** Resolves the email disabled */ public String resolveEmailDisabled() { JndiTemplate jndi = new JndiTemplate(); try { return (String) jndi.lookup(CommonConstants.JNDI_PROP_EMAIL_DISABLED); } catch (NamingException e) { return CommonConstants.EMAIL_DEFAULT_DISABLED; } }
@Bean public NamedParameterJdbcTemplate initializeDataSource1() { DataSource dataSource = null; JndiTemplate jndi = new JndiTemplate(); NamedParameterJdbcTemplate namedParameterJdbcTemplate = null; try { dataSource = (DataSource) jndi.lookup("java:comp/env/jdbc/postgresql/postgres"); namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); } catch (NamingException e) { e.printStackTrace(); } return namedParameterJdbcTemplate; }
/* * Constructor called when a DataSource object to be obtained from Jndi. */ public JdbcProducer(JndiTemplate jndiTemplate, String dataSourceName) throws ClassNotFoundException, JdbcException, NamingException { this((DataSource) jndiTemplate.lookup(dataSourceName)); }