Skip to content

Instantly share code, notes, and snippets.

View CallingSampleRepository
@Autoriwed
SampleRepository sampleRepository;
....
public void useSampleRepository(...) {
....
sampleRepository.save(sample, ttl);
@flnj
flnj / SampleRepository
Created Feb 25, 2016
Sample Repository
View SampleRepository
public interface SampleRepository extends MyRepository<Sample, String> {
}
View Configuration
@Configuration
@EnableCassandraRepositories( repositoryFactoryBeanClass = MyRepositoryFactoryBean.class)
View gist:76a291514f55d1ca3321
public class MyRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable> extends RepositoryFactoryBeanSupport<T, S, ID> {
@Autowired
private CassandraTemplate cassandraTemplate;
@Override
protected RepositoryFactorySupport createRepositoryFactory() {
return new MyRepositoryFactory(cassandraTemplate);
View MyRepositoryImpl
@NoRepositoryBean
public class MyRepositoryImpl<lT, ID extends Serializable> extends SimpleCassandraRepository<T, ID> implements MyRepository<T, ID> {
public MyRepositoryImpl(CassandraEntityInformation<T, ID> metadata, CassandraTemplate template) {
super(metadata, template);
this.entityInformation = metadata;
this.template = template;
}
View MyRepository
@NoRepositoryBean
public interface MyRepository<T, ID extends Serializable> extends TypedIdCassandraRepository<T, ID> {
<S extends T> S save(S s, int ttl);
}
View registerFilter
@Bean
public CustomFilter customFilter(){
return new CustomFilter();
}
@Bean
public FilterRegistrationBean customFilterRegistration(){
FilterRegistrationBean customFilterRegistration=new FilterRegistrationBean(metricsFilter(), dispatcherServletRegistration());
return customFilterRegistration;
}
View gist:76fae9d248a8ee7b69a9
@Bean
public DispatcherServlet dispatcherServlet() {
return new DispatcherServlet();
}
@Bean
public ServletRegistrationBean dispatchcherServletRegistration(){
ServletRegistrationBean registrationBean =new ServletRegistrationBean(dispatcherServlet(), "/rest/v1/*");
registrationBean
.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME );
You can’t perform that action at this time.