diff --git a/spring-all/src/main/java/org/baeldung/caching/config/myAppConfig.java b/spring-all/src/main/java/org/baeldung/caching/config/myAppConfig.java deleted file mode 100644 index 042e57bc35..0000000000 --- a/spring-all/src/main/java/org/baeldung/caching/config/myAppConfig.java +++ /dev/null @@ -1,9 +0,0 @@ - -@Configuration -@EnableCaching - -public class MyAppConfig { - - // Your configuration code goes here. - -} diff --git a/spring-all/src/main/java/org/baeldung/caching/example/Customer.java b/spring-all/src/main/java/org/baeldung/caching/example/Customer.java deleted file mode 100644 index c796cc9c60..0000000000 --- a/spring-all/src/main/java/org/baeldung/caching/example/Customer.java +++ /dev/null @@ -1,42 +0,0 @@ - -public class Customer { - - - private int id; - - - private String name; - - - private String customerAddress; - - Customer(String name, String address){ - this.name = name; - this.customerAddress = address; - } - - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public String getCustomerAddress() { - return this.customerAddress; - } - - public void setName(String name) { - this.name = name; - } - - public void setCustomerAddress(String address) { - this.customerAddress = this.name + "," + address; - } -} diff --git a/spring-all/src/main/java/org/baeldung/caching/example/CustomerDataService.java b/spring-all/src/main/java/org/baeldung/caching/example/CustomerDataService.java deleted file mode 100644 index 4c72d83245..0000000000 --- a/spring-all/src/main/java/org/baeldung/caching/example/CustomerDataService.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.baeldung.caching.example; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.CacheManager; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; - -/** - * The Class CustomerDataService. - */ -@Component -@CacheConfig("addressDemo") -public class CustomerDataService { - - /** The cache manager. */ - @Autowired - CacheManager cacheManager; - - /** - * The method returns the customer's address, - only it doesn't find it the cache- addresses and directory. - * - * @param customer the customer - * @return the address - */ - - @Cacheable("addresses", “directory”) - - public String getAddress1(Customer customer) { - - return customer.getAddress(); - } - - /** - * The method returns the customer's address, - but refreshes all the entries in the cache to load new ones. - * - * @param customer the customer - * @return the address - */ - - @CacheEvict(value="addresses", allEntries=true) - - public String getAddress2(Customer customer) { - - return customer.getAddress(); - } - - /** - * The method returns the customer's address, - but not before selectively evicting the cache as per specified paramters. - * - * @param customer the customer - * @return the address - */ - - @Caching(evict = { @CacheEvict("addresses"), @CacheEvict(value="directory", key="customer.name") }) - - public String getAddress3(Customer customer) { - - return customer.getAddress(); - } - - /** - * The method uses the class level cache to look up for entries. - * - * @param customer the customer - * @return the address - */ - - @Cacheable // parameter not required as we have declared it using @CacheConfig - - public String getAddress4(Customer customer) { - - return customer.getAddress(); - } - - /** - * The method selectively caches the results that meet the predefined criteria. - * - * @param customer the customer - * @return the address - */ - - - @CachePut(value="addresses", condition=”#customer.name=’Tom’”) - @CachePut(value="addresses", unless=”#result.length>64”) - - public String getAddress5(Customer customer) { - - return customer.getAddress(); - } - - -} diff --git a/spring-all/src/main/java/org/baeldung/caching/resouces/config.xml b/spring-all/src/main/java/org/baeldung/caching/resouces/config.xml deleted file mode 100644 index 2ca26f4468..0000000000 --- a/spring-all/src/main/java/org/baeldung/caching/resouces/config.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-all/src/main/java/org/baeldung/caching/test/SpringCachingBehaviorTest.java b/spring-all/src/main/java/org/baeldung/caching/test/SpringCachingBehaviorTest.java deleted file mode 100644 index 259f7719eb..0000000000 --- a/spring-all/src/main/java/org/baeldung/caching/test/SpringCachingBehaviorTest.java +++ /dev/null @@ -1,28 +0,0 @@ - - -package org.baeldung.caching.test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.stereotype.Component; -import static org.junit.Assert.*; -import org.junit.Test; - - - -@Component - -public class SpringCachingBehaviorTest { - - @Test - public void testCaching() { - @SuppressWarnings("resource") - ApplicationContext context = new ClassPathXmlApplicationContext("config.xml"); - example = context.getBean(CustomerDataService.class); - Customer cust = new Customer("Tom", "67-2, Downing Street, NY"); - example.getAddress(cust); - fail("Unable to instantiate the CustomerDataService"); - } - -}