Search in sources :

Example 1 with SessionType

use of com.oracle.coherence.hibernate.cache.v53.configuration.session.SessionType in project coherence-hibernate by coherence-community.

the class CoherenceRegionFactory method prepareCoherenceSessionIfNeeded.

private void prepareCoherenceSessionIfNeeded(CoherenceHibernateProperties coherenceHibernateProperties) {
    if (this.coherenceSession == null) {
        final SessionConfiguration.Builder sessionConfigurationBuilder = SessionConfiguration.builder();
        if (coherenceHibernateProperties.getSessionName() != null) {
            sessionConfigurationBuilder.named(coherenceHibernateProperties.getSessionName());
        }
        sessionConfigurationBuilder.withConfigUri(coherenceHibernateProperties.getCacheConfigFilePath());
        final SessionConfiguration sessionConfiguration = sessionConfigurationBuilder.build();
        // GrpcSessionConfiguration.Builder
        final CoherenceConfiguration coherenceConfiguration = CoherenceConfiguration.builder().withSession(sessionConfiguration).build();
        final SessionType sessionType = coherenceHibernateProperties.getSessionType();
        this.coherence = this.createCoherenceInstance(sessionType, coherenceConfiguration);
        try {
            coherence.start().get();
        } catch (InterruptedException | ExecutionException ex) {
            throw new IllegalStateException("Unable to start Coherence instance.", ex);
        }
        if (coherenceHibernateProperties.getSessionName() != null) {
            this.setCoherenceSession(coherence.getSession(coherenceHibernateProperties.getSessionName()));
        } else {
            this.setCoherenceSession(coherence.getSession());
        }
    }
    this.coherenceSession.activate();
}
Also used : SessionType(com.oracle.coherence.hibernate.cache.v53.configuration.session.SessionType) ExecutionException(java.util.concurrent.ExecutionException) CoherenceConfiguration(com.tangosol.net.CoherenceConfiguration) SessionConfiguration(com.tangosol.net.SessionConfiguration)

Example 2 with SessionType

use of com.oracle.coherence.hibernate.cache.v53.configuration.session.SessionType in project coherence-hibernate by coherence-community.

the class CoherenceHibernatePropertiesTests method retrieveLowerCaseSessionTypeOfCoherenceProperties.

@Test
public void retrieveLowerCaseSessionTypeOfCoherenceProperties() {
    final Map rawHibernateProperties = new HashMap();
    rawHibernateProperties.put("com.oracle.coherence.hibernate.cache.session_type", "");
    try {
        new CoherenceHibernateProperties(rawHibernateProperties);
    } catch (IllegalArgumentException ex) {
        assertThat(ex.getMessage()).isEqualTo("The sessionType cannot be an empty String.");
        return;
    }
    fail("Was expecting an IllegalArgumentException to be thrown.");
}
Also used : CoherenceHibernateProperties(com.oracle.coherence.hibernate.cache.v53.configuration.support.CoherenceHibernateProperties) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Aggregations

SessionType (com.oracle.coherence.hibernate.cache.v53.configuration.session.SessionType)1 CoherenceHibernateProperties (com.oracle.coherence.hibernate.cache.v53.configuration.support.CoherenceHibernateProperties)1 CoherenceConfiguration (com.tangosol.net.CoherenceConfiguration)1 SessionConfiguration (com.tangosol.net.SessionConfiguration)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ExecutionException (java.util.concurrent.ExecutionException)1 Test (org.junit.jupiter.api.Test)1