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();
}
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.");
}
Aggregations