Search in sources :

Example 6 with SessionFactory

use of org.springframework.data.cassandra.SessionFactory in project spring-data-cassandra by spring-projects.

the class AbstractRoutingSessionFactory method afterPropertiesSet.

// -------------------------------------------------------------------------
// Implementation hooks and helper methods
// -------------------------------------------------------------------------
@Override
public void afterPropertiesSet() {
    Assert.notNull(this.targetSessionFactories, "Property targetSessionFactories is required");
    this.resolvedSessionFactories = new HashMap<>(this.targetSessionFactories.size());
    for (Map.Entry<Object, Object> entry : this.targetSessionFactories.entrySet()) {
        Object lookupKey = resolveSpecifiedLookupKey(entry.getKey());
        SessionFactory sessionFactory = resolveSpecifiedSessionFactory(entry.getValue());
        this.resolvedSessionFactories.put(lookupKey, sessionFactory);
    }
    if (this.defaultTargetSessionFactory != null) {
        this.resolvedDefaultSessionFactory = resolveSpecifiedSessionFactory(this.defaultTargetSessionFactory);
    }
}
Also used : SessionFactory(org.springframework.data.cassandra.SessionFactory) Map(java.util.Map) HashMap(java.util.HashMap)

Example 7 with SessionFactory

use of org.springframework.data.cassandra.SessionFactory in project spring-data-cassandra by spring-projects.

the class MapSessionFactoryLookup method getSessionFactory.

/* (non-Javadoc)
	 * @see org.springframework.data.cassandra.core.cql.session.lookup.SessionFactoryLookup#getSessionFactory(java.lang.String)
	 */
@Override
public SessionFactory getSessionFactory(String sessionFactoryName) throws SessionFactoryLookupFailureException {
    Assert.notNull(sessionFactoryName, "SessionFactory name must not be null");
    SessionFactory sessionFactory = this.sessionFactories.get(sessionFactoryName);
    if (sessionFactory == null) {
        throw new SessionFactoryLookupFailureException(String.format("No SessionFactory with name [%s] registered", sessionFactoryName));
    }
    return sessionFactory;
}
Also used : SessionFactory(org.springframework.data.cassandra.SessionFactory)

Aggregations

SessionFactory (org.springframework.data.cassandra.SessionFactory)7 Test (org.junit.jupiter.api.Test)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BeanFactorySessionFactoryLookup (org.springframework.data.cassandra.core.cql.session.lookup.BeanFactorySessionFactoryLookup)1 SingleSessionFactoryLookup (org.springframework.data.cassandra.core.cql.session.lookup.SingleSessionFactoryLookup)1