本文整理汇总了Java中org.springframework.data.cassandra.core.CassandraTemplate类的典型用法代码示例。如果您正苦于以下问题:Java CassandraTemplate类的具体用法?Java CassandraTemplate怎么用?Java CassandraTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CassandraTemplate类属于org.springframework.data.cassandra.core包,在下文中一共展示了CassandraTemplate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: removeAccessTokenUsingRefreshToken
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
@Override
public void removeAccessTokenUsingRefreshToken(OAuth2RefreshToken refreshToken) {
String tokenValue = refreshToken.getValue();
// Lookup RefreshTokenToAccessToken table for locating access token
RefreshTokenToAccessToken refreshTokenToAccessToken = refreshTokenToAccessTokenRepository.findOne(tokenValue);
if (refreshTokenToAccessToken != null) {
String accessTokenKey = refreshTokenToAccessToken.getAccessTokenKey();
AccessToken accessToken = accessTokenRepository.findOne(accessTokenKey);
String jsonOAuth2AccessToken = accessToken.getoAuth2AccessToken();
OAuth2AccessToken oAuth2AccessToken = OAuthUtil.deserializeOAuth2AccessToken(jsonOAuth2AccessToken);
// Delete access token from all related tables
List<RegularStatement> statementList = prepareRemoveAccessTokenStatements(oAuth2AccessToken);
// Delete from RefreshTokenToAccessToken table
Delete refreshTokenToAccessTokenDelete = CassandraTemplate.createDeleteQuery(RefreshTokenToAccessToken.TABLE, refreshTokenToAccessToken, null, cassandraTemplate.getConverter());
statementList.add(refreshTokenToAccessTokenDelete);
Batch batch = QueryBuilder.batch(statementList.toArray(new RegularStatement[statementList.size()]));
cassandraTemplate.execute(batch);
}
}
开发者ID:Mert-Z,项目名称:spring-oauth2-cassandra-token-store,代码行数:20,代码来源:CassandraTokenStore.java
示例2: storeRefreshToken
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
@Override
public void storeRefreshToken(OAuth2RefreshToken refreshToken, OAuth2Authentication authentication) {
List<RegularStatement> statementList = new ArrayList<RegularStatement>();
byte[] serializedRefreshToken = SerializationUtils.serialize(refreshToken);
ByteBuffer bufferedRefreshToken = ByteBuffer.wrap(serializedRefreshToken);
byte[] serializedAuthentication = SerializationUtils.serialize(authentication);
ByteBuffer bufferedAuthentication = ByteBuffer.wrap(serializedAuthentication);
WriteOptions refreshWriteOptions = new WriteOptions();
if (refreshToken instanceof ExpiringOAuth2RefreshToken) {
ExpiringOAuth2RefreshToken expiringRefreshToken = (ExpiringOAuth2RefreshToken) refreshToken;
Date expiration = expiringRefreshToken.getExpiration();
if (expiration != null) {
int seconds = Long.valueOf((expiration.getTime() - System.currentTimeMillis()) / 1000L).intValue();
refreshWriteOptions.setTtl(seconds);
}
}
// Insert into RefreshToken table
Insert accessInsert = CassandraTemplate.createInsertQuery(RefreshToken.TABLE, new RefreshToken(refreshToken.getValue(), bufferedRefreshToken), refreshWriteOptions, cassandraTemplate.getConverter());
statementList.add(accessInsert);
// Insert into RefreshTokenAuthentication table
Insert authInsert = CassandraTemplate.createInsertQuery(RefreshTokenAuthentication.TABLE, new RefreshTokenAuthentication(refreshToken.getValue(), bufferedAuthentication), refreshWriteOptions, cassandraTemplate.getConverter());
statementList.add(authInsert);
Batch batch = QueryBuilder.batch(statementList.toArray(new RegularStatement[statementList.size()]));
cassandraTemplate.execute(batch);
}
开发者ID:Mert-Z,项目名称:spring-oauth2-cassandra-token-store,代码行数:32,代码来源:CassandraTokenStore.java
示例3: templateExists
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
@Test
public void templateExists() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestExcludeConfiguration.class, TestConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBeanNamesForType(CassandraTemplate.class).length)
.isEqualTo(1);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:CassandraDataAutoConfigurationTests.java
示例4: create
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
/**
* Create an {@link EventStore} that persists and retrieves {@link Event}s using Cassandra.
* @param cassandraTemplate The {@link CassandraTemplate} to use to perform queries against Cassandra.
* @param objectMapper the {@link ObjectMapper} to use to serialise and deserialise event data.
* @return The constructed {@link EventStore}
*/
public static EventStore create(CassandraTemplate cassandraTemplate, ObjectMapper objectMapper) {
return ComposedEventStore.create(
CassandraEventPersister.create(cassandraTemplate, objectMapper),
CassandraEventRetriever.create(cassandraTemplate, objectMapper)
);
}
开发者ID:opencredo,项目名称:concursus,代码行数:13,代码来源:CassandraEventStore.java
示例5: create
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
/**
* Create a new {@link AggregateCatalogue} that uses Cassandra for persistence.
* @param cassandraTemplate The {@link CassandraTemplate} to use to execute Cassandra queries.
* @param bucketCount The number of buckets to use to distribute the catalogue data over multiple rows.
* @return The constructed {@link AggregateCatalogue}.
*/
public static AggregateCatalogue create(CassandraTemplate cassandraTemplate, int bucketCount) {
PreparedStatement insertStatement = cassandraTemplate.getSession().prepare(
"INSERT INTO Catalogue (aggregateType, bucket, aggregateId) VALUES (?, ?, ?)");
PreparedStatement deleteStatement = cassandraTemplate.getSession().prepare(
"DELETE FROM Catalogue WHERE aggregateType = ? AND bucket = ? AND aggregateId = ?");
return new CassandraAggregateCatalogue(bucketCount, cassandraTemplate, insertStatement, deleteStatement);
}
开发者ID:opencredo,项目名称:concursus,代码行数:14,代码来源:CassandraAggregateCatalogue.java
示例6: aggregateCatalogue
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
@Bean
@Primary
public AggregateCatalogue aggregateCatalogue(Cluster cluster) {
return CassandraAggregateCatalogue.create(
new CassandraTemplate(cluster.connect(configuration.getKeyspace())),
configuration.getCatalogueBucketCount());
}
开发者ID:opencredo,项目名称:concursus,代码行数:8,代码来源:CassandraCatalogueBeans.java
示例7: templateExists
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
@Test
public void templateExists() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestExcludeConfiguration.class, TestConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class);
this.context.refresh();
assertEquals(1, this.context.getBeanNamesForType(CassandraTemplate.class).length);
}
开发者ID:Nephilim84,项目名称:contestparser,代码行数:10,代码来源:CassandraDataAutoConfigurationTests.java
示例8: setUp
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
final Cluster cluster = Cluster.builder()
.addContactPoints(InetAddress.getLoopbackAddress())
.withPort(9142)
.build();
cassandraTemplate = new CassandraTemplate(cluster.connect("zuul"));
instance = new CassandraZuulRouteStore(cassandraTemplate);
}
开发者ID:jmnarloch,项目名称:zuul-route-cassandra-spring-cloud-starter,代码行数:12,代码来源:CassandraZuulRouteStoreTest.java
示例9: cassandraTemplate
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
@Bean
public CassandraTemplate cassandraTemplate(Session session) {
return new CassandraTemplate(session);
}
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:5,代码来源:BasicConfiguration.java
示例10: prepareRemoveAccessTokenStatements
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
private List<RegularStatement> prepareRemoveAccessTokenStatements(OAuth2AccessToken token) {
//String tokenId = token.getValue();
String tokenValue = token.getValue();
String jsonOAuth2AccessToken = OAuthUtil.serializeOAuth2AccessToken(token);
List<RegularStatement> statementList = new ArrayList<RegularStatement>();
// Delete from AccessToken table
RegularStatement accessTokenDelete = prepareDeleteByPrimaryKeyRegularStatement(AccessToken.class, tokenValue);
statementList.add(accessTokenDelete);
// Lookup Authentication table for further deleting from AuthenticationToAccessToken table
Authentication authentication = authenticationRepository.findOne(tokenValue);
if (authentication != null) {
ByteBuffer bufferedOAuth2Authentication = authentication.getoAuth2Authentication();
byte[] serializedOAuth2Authentication = new byte[bufferedOAuth2Authentication.remaining()];
bufferedOAuth2Authentication.get(serializedOAuth2Authentication);
OAuth2Authentication oAuth2Authentication = SerializationUtils.deserialize(serializedOAuth2Authentication);
String clientId = oAuth2Authentication.getOAuth2Request().getClientId();
// Delete from Authentication table
RegularStatement authenticationDelete = prepareDeleteByPrimaryKeyRegularStatement(Authentication.class, tokenValue);
statementList.add(authenticationDelete);
// Delete from AuthenticationToAccessToken table
RegularStatement authToAccessDelete = prepareDeleteByPrimaryKeyRegularStatement(AuthenticationToAccessToken.class, authenticationKeyGenerator.extractKey(oAuth2Authentication));
statementList.add(authToAccessDelete);
// Delete from UsernameToAccessToken table
Optional<UsernameToAccessToken> optionalUsernameToAccessToken = usernameToAccessTokenRepository.findByKeyAndOAuth2AccessToken(OAuthUtil.getApprovalKey(clientId, oAuth2Authentication.getName()), jsonOAuth2AccessToken);
optionalUsernameToAccessToken.ifPresent(usernameToAccessToken -> {
Delete usernameToAccessDelete = CassandraTemplate.createDeleteQuery(UsernameToAccessToken.TABLE, usernameToAccessToken, null, cassandraTemplate.getConverter());
statementList.add(usernameToAccessDelete);
});
// Delete from ClientIdToAccessToken table
Optional<ClientIdToAccessToken> optionalClientIdToAccessToken = clientIdToAccessTokenRepository.findByKeyAndOAuth2AccessToken(clientId, jsonOAuth2AccessToken);
optionalClientIdToAccessToken.ifPresent(clientIdToAccessToken -> {
Delete clientIdToAccessDelete = CassandraTemplate.createDeleteQuery(ClientIdToAccessToken.TABLE, clientIdToAccessToken, null, cassandraTemplate.getConverter());
statementList.add(clientIdToAccessDelete);
});
}
return statementList;
}
开发者ID:Mert-Z,项目名称:spring-oauth2-cassandra-token-store,代码行数:45,代码来源:CassandraTokenStore.java
示例11: cassandraTemplate
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
@Bean
public CassandraTemplate cassandraTemplate() throws Exception {
return new CassandraTemplate(session().getObject());
}
开发者ID:adarshkumarsingh83,项目名称:spring_boot,代码行数:5,代码来源:CassandraConfiguration.java
示例12: cassandraTemplate
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public CassandraTemplate cassandraTemplate(Session session,
CassandraConverter converter) throws Exception {
return new CassandraTemplate(session, converter);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:CassandraDataAutoConfiguration.java
示例13: CassandraEventRetriever
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
private CassandraEventRetriever(CassandraTemplate cassandraTemplate, BiFunction<String, Type, Object> deserialiser) {
this.cassandraTemplate = cassandraTemplate;
this.deserialiser = deserialiser;
}
开发者ID:opencredo,项目名称:concursus,代码行数:5,代码来源:CassandraEventRetriever.java
示例14: CassandraAggregateCatalogue
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
private CassandraAggregateCatalogue(int bucketCount, CassandraTemplate cassandraTemplate, PreparedStatement insertStatement, PreparedStatement deleteStatement) {
this.bucketCount = bucketCount;
this.cassandraTemplate = cassandraTemplate;
this.insertStatement = insertStatement;
this.deleteStatement = deleteStatement;
}
开发者ID:opencredo,项目名称:concursus,代码行数:7,代码来源:CassandraAggregateCatalogue.java
示例15: CassandraEventPersister
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
private CassandraEventPersister(CassandraTemplate cassandraTemplate, PreparedStatement preparedStatement, Function<Object, String> serialiser) {
this.cassandraTemplate = cassandraTemplate;
this.preparedStatement = preparedStatement;
this.serialiser = serialiser;
}
开发者ID:opencredo,项目名称:concursus,代码行数:6,代码来源:CassandraEventPersister.java
示例16: eventStore
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
@Bean
@Primary
public EventStore eventStore(Cluster cluster, ObjectMapper objectMapper) {
return CassandraEventStore.create(new CassandraTemplate(cluster.connect(configuration.getKeyspace())), objectMapper);
}
开发者ID:opencredo,项目名称:concursus,代码行数:6,代码来源:CassandraEventStoreBeans.java
示例17: cassandraTemplate
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
@Bean
public CassandraOperations cassandraTemplate(Cluster cluster) {
return new CassandraTemplate(cluster.connect("zuul"));
}
开发者ID:jmnarloch,项目名称:zuul-route-cassandra-spring-cloud-starter,代码行数:5,代码来源:CassandraZuulProxyStoreTest.java
示例18: ops
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
private CassandraOperations ops() {
return new CassandraTemplate(session);
}
开发者ID:Excelian,项目名称:Mache,代码行数:4,代码来源:CassandraCacheLoader.java
示例19: operations
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
@Bean
public CassandraOperations operations() throws Exception {
return new CassandraTemplate(session().getObject(), new MappingCassandraConverter(new BasicCassandraMappingContext()));
}
开发者ID:pivotal-cf,项目名称:cf-cassandra-spring-example-app,代码行数:5,代码来源:ApplicationConfiguration.java
示例20: create
import org.springframework.data.cassandra.core.CassandraTemplate; //导入依赖的package包/类
/**
* Construct an {@link EventRetriever} that retrieves events from Cassandra using the supplied
* {@link CassandraTemplate} and {@link ObjectMapper}
* @param cassandraTemplate The {@link CassandraTemplate} to use to execute Cassandra queries.
* @param objectMapper The {@link ObjectMapper} to use to deserialise Event data.
* @return The constructed {@link EventRetriever}.
*/
public static EventRetriever create(CassandraTemplate cassandraTemplate, ObjectMapper objectMapper) {
return create(cassandraTemplate, JsonDeserialiser.using(objectMapper));
}
开发者ID:opencredo,项目名称:concursus,代码行数:11,代码来源:CassandraEventRetriever.java
注:本文中的org.springframework.data.cassandra.core.CassandraTemplate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论