@Test public void testPersistKeyValue() { metadataStore.put("GemfireMetadataStoreTests-Spring", "Integration"); GemfireTemplate gemfireTemplate = new GemfireTemplate(region); assertEquals("Integration", gemfireTemplate.get("GemfireMetadataStoreTests-Spring")); }
@Test public void testPersistKeyValueIfAbsent() { metadataStore.putIfAbsent("GemfireMetadataStoreTests-Spring", "Integration"); GemfireTemplate gemfireTemplate = new GemfireTemplate(region); assertEquals("Integration", gemfireTemplate.get("GemfireMetadataStoreTests-Spring")); }
/** * Creates an instance of the GemfireTemplate for the given Pivotal GemFire Cache Region. * <p>Can be overridden in subclasses to provide a GemfireTemplate instance with different configuration, * or even a custom GemfireTemplate subclass. * * @param region the Pivotal GemFire Cache Region for which the GemfireTemplate is created. * @return a new GemfireTemplate instance configured with the given Pivotal GemFire Cache Region. * @see org.apache.geode.cache.Region * @see #setRegion */ protected GemfireTemplate createGemfireTemplate(Region<?, ?> region) { return new GemfireTemplate(region); }
/** * Creates an instance of the GemfireTemplate for the given GemFire Cache Region. * <p>Can be overridden in subclasses to provide a GemfireTemplate instance with different configuration, * or even a custom GemfireTemplate subclass. * * @param region the GemFire Cache Region for which the GemfireTemplate is created. * @return a new GemfireTemplate instance configured with the given GemFire Cache Region. * @see org.apache.geode.cache.Region * @see #setRegion */ protected GemfireTemplate createGemfireTemplate(Region<?, ?> region) { return new GemfireTemplate(region); }
@Autowired public GemfireResourceDAO(Cache cache) { Region r = cache.getRegion("Resource"); this.gemfire = new GemfireTemplate(r); }
@Autowired public GemfireTraceDAO(Cache cache) { Region r = cache.getRegion("Trace"); this.gemfire = new GemfireTemplate(r); this.sizer = new GemfireTraceRegionSizer(); }
/** * Defines a {@link GemfireTemplate} bean used to interact with the (Client)Cache {@link Region} * used to store {@link Session} state. * * @param gemfireCache reference to the single {@link GemFireCache} instance used by the {@link GemfireTemplate} * to perform cache {@link Region} data access operations. * @return a {@link GemfireTemplate} used to interact with the (Client)Cache {@link Region} * used to store {@link Session} state. * @see org.springframework.data.gemfire.GemfireTemplate * @see org.apache.geode.cache.GemFireCache * @see org.apache.geode.cache.Region * @see #getSessionRegionName() */ @Bean @DependsOn(DEFAULT_SESSION_REGION_NAME) public GemfireTemplate sessionRegionTemplate(GemFireCache gemfireCache) { return new GemfireTemplate(gemfireCache.getRegion(getSessionRegionName())); }
/** * Constructs a new instance of {@link GemfireTemplate} initialized with the identified {@link Region} * used to back all persistent, data access operations defined by the {@link Repository}. * * @param repositoryMetadata {@link RepositoryMetadata} containing meta-data about the {@link Repository}. * @return a new instance of {@link GemfireTemplate} initialized with the identified {@link Region}. * @see #resolvePersistentEntity(Class) * @see #resolveRegion(RepositoryMetadata, GemfirePersistentEntity) * @see #validate(RepositoryMetadata, GemfirePersistentEntity, Region) * @see org.springframework.data.repository.core.RepositoryMetadata * @see org.springframework.data.gemfire.GemfireTemplate * @see org.apache.geode.cache.Region */ protected GemfireTemplate newTemplate(RepositoryMetadata repositoryMetadata) { GemfirePersistentEntity<?> entity = resolvePersistentEntity(repositoryMetadata.getDomainType()); return new GemfireTemplate(validate(repositoryMetadata, entity, resolveRegion(repositoryMetadata, entity))); }
/** * Constructs a new instance of {@link GemfireTemplate} initialized with the identified {@link Region} * used to back all persistent, data access operations defined by the {@link Repository}. * * @param repositoryMetadata {@link RepositoryMetadata} containing meta-data about the {@link Repository}. * @return a new instance of {@link GemfireTemplate} initialized with the identified {@link Region}. * @see #resolvePersistentEntity(Class) * @see #resolveRegion(RepositoryMetadata, GemfirePersistentEntity) * @see #validate(RepositoryMetadata, GemfirePersistentEntity, Region) * @see org.springframework.data.repository.core.RepositoryMetadata * @see org.springframework.data.gemfire.GemfireTemplate * @see org.apache.geode.cache.Region */ protected GemfireTemplate newTemplate(RepositoryMetadata repositoryMetadata) { GemfirePersistentEntity<?> entity = resolvePersistentEntity(repositoryMetadata.getDomainType()); return new GemfireTemplate(validate(repositoryMetadata, entity, resolveRegion(repositoryMetadata, entity))); }