Otavio,
On your Easy-Cassandra example with Spring you create an XML file to load the beans as follows:
<bean id = "clusterInformation" class="org.easycassandra.persistence.cassandra.ClusterInformation">
<property name="keySpace" value="campus" />
<property name="hosts">
<list>
<value>localhost</value>
</list>
</property>
</bean>
<bean id="cassandraFactory" class="org.easycassandra.persistence.cassandra.spring.CassandraFactoryAnnotation">
<constructor-arg name="clusterInformation" ref="clusterInformation" />
<property name="annotatedClasses">
<list>
<value>org.easycassandra.persistence.cassandra.spring.entity.Contact</value>
<value>org.easycassandra.bean.model.Step</value>
<value>org.easycassandra.bean.model.Weight</value>
</list>
</property>
</bean>
<bean id="cassandraTemplate" class="org.easycassandra.persistence.cassandra.spring.SimpleCassandraTemplateImpl" >
<constructor-arg name="factory" ref="cassandraFactory" />
</bean>
I would like to use Spring 4 and have those beans inside my RootContextConfiguration class.
From the book, Java Wev Aplications, you have the following example of the 3 beans while using MySQL:
@Bean
public DataSource customerSupportDataSource()
{
JndiDataSourceLookup lookup = new JndiDataSourceLookup();
return lookup.getDataSource("jdbc/CustomerSupport");
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean()
{
Map<String, Object> properties = new Hashtable<>();
properties.put("javax.persistence.schema-generation.database.action",
"none");
properties.put("hibernate.ejb.use_class_enhancer", "true");
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
adapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");
LocalContainerEntityManagerFactoryBean factory =
new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(adapter);
factory.setDataSource(this.customerSupportDataSource());
factory.setPackagesToScan("com.wrox.site.entities",
"com.wrox.site.converters");
factory.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
factory.setValidationMode(ValidationMode.NONE);
factory.setLoadTimeWeaver(this.loadTimeWeaver); // TODO: remove when SPR-10856 fixed
factory.setJpaPropertyMap(properties);
return factory;
}
@Bean
public PlatformTransactionManager jpaTransactionManager()
{
return new JpaTransactionManager(
this.entityManagerFactoryBean().getObject()
);
}
So I imagine that I need a ClusterInformation bean that initializes org.easycassandra.persistence.cassandra.ClusterInformation object
A cassandraFactory bean that initiazlies a org.easycassandra.persistence.cassandra.spring.CassandraFactoryAnnotation
A cassandraTemplate bean that initializes a org.easycassandra.persistence.cassandra.spring.SimpleCassandraTemplateImpl
Have you ever tried Easy-Cassandra with Spring 4?
Thank you,
Carlos.