Class JpaBeans


  • public class JpaBeans
    extends java.lang.Object
    This is JpaBeans.
    Since:
    5.2.0
    • Constructor Summary

      Constructors 
      Constructor Description
      JpaBeans()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isValidDataSourceConnection​(CloseableDataSource ds, int timeout)
      Is valid data source connection.
      javax.sql.DataSource newDataSource​(java.lang.String driverClass, java.lang.String username, java.lang.String password, java.lang.String url)
      New simple data source.
      CloseableDataSource newDataSource​(org.apereo.cas.configuration.model.support.jpa.AbstractJpaProperties jpaProperties)
      Get new data source, from JNDI lookup or created via direct configuration of Hikari pool.
      org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean newEntityManagerFactoryBean​(org.apereo.cas.configuration.model.support.jpa.JpaConfigurationContext config)
      New entity manager factory bean.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JpaBeans

        public JpaBeans()
    • Method Detail

      • newDataSource

        public javax.sql.DataSource newDataSource​(java.lang.String driverClass,
                                                  java.lang.String username,
                                                  java.lang.String password,
                                                  java.lang.String url)
        New simple data source.
        Parameters:
        driverClass - the driver class
        username - the username
        password - the password
        url - the url
        Returns:
        the data source
      • newDataSource

        public CloseableDataSource newDataSource​(org.apereo.cas.configuration.model.support.jpa.AbstractJpaProperties jpaProperties)
        Get new data source, from JNDI lookup or created via direct configuration of Hikari pool.

        If properties specify a data source name, a lookup will be attempted. If the DataSource is not found via JNDI then CAS will attempt to configure a Hikari connection pool.

        Since the datasource beans are RefreshScope, they will be a proxied by Spring and on some application servers there have been classloading issues. A workaround for this is to use activate data source proxying via settings and then the dataSource will be wrapped in an application level class. If that is an issue, don't do it.

        If user wants to do lookup as resource, they may include java:/comp/env in dataSourceName and put resource reference in web.xml otherwise dataSourceName is used as JNDI name.

        Parameters:
        jpaProperties - the jpa properties
        Returns:
        the data source
      • newEntityManagerFactoryBean

        public org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean newEntityManagerFactoryBean​(org.apereo.cas.configuration.model.support.jpa.JpaConfigurationContext config)
        New entity manager factory bean.
        Parameters:
        config - the config
        Returns:
        the local container entity manager factory bean
      • isValidDataSourceConnection

        public boolean isValidDataSourceConnection​(CloseableDataSource ds,
                                                   int timeout)
        Is valid data source connection.
        Parameters:
        ds - the ds
        timeout - the timeout
        Returns:
        the boolean