Upading the pull request after code cleanup.

This commit is contained in:
Abhi Bavishi 2015-06-15 18:38:38 +05:30
parent 8a49637a14
commit e53f998d0d
5 changed files with 49 additions and 80 deletions

View File

@ -2,7 +2,7 @@
@Configuration
@EnableCaching
public class myAppConfig {
public class MyAppConfig {
// Your configuration code goes here.

View File

@ -1,74 +1,42 @@
/**
* The Class Customer.
*/
public class Customer {
/** The id. */
private int id;
/** The name. */
private String name;
/** The address. */
private String customerAddress;
Customer(String name, String address){
this.name = name;
this.address = address;
}
private int id;
/**
* Gets the id.
*
* @return the id
*/
public int getId() {
return id;
}
private String name;
/**
* Sets the id.
*
* @param id the new id
*/
public void setId(int id) {
this.id = id;
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
private String customerAddress;
/**
* Gets the address.
*
* @return the address
*/
public String getCustomerAddress() {
return this.customerAddress;
}
Customer(String name, String address){
this.name = name;
this.customerAddress = address;
}
/**
* Sets the name.
*
* @param name the new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets the address.
*
* @param name the new address
*/
public void setCustomerAddress(String address) {
this.customerAddress = this.name + "," + 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;
}
}

View File

@ -18,7 +18,8 @@ public class CustomerDataService {
CacheManager cacheManager;
/**
* Gets the address.
* 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
@ -32,8 +33,9 @@ public class CustomerDataService {
}
/**
* Gets the address.
*
* 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
*/
@ -46,7 +48,8 @@ public class CustomerDataService {
}
/**
* Gets the address.
* 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
@ -60,7 +63,7 @@ public class CustomerDataService {
}
/**
* Gets the address.
* The method uses the class level cache to look up for entries.
*
* @param customer the customer
* @return the address
@ -74,7 +77,7 @@ public class CustomerDataService {
}
/**
* Gets the address.
* The method selectively caches the results that meet the predefined criteria.
*
* @param customer the customer
* @return the address

View File

@ -6,26 +6,23 @@ 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;
/**
* The Class CustomerDataService.
*/
@Component
public class SpringCachingBehaviorTest {
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
@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");
}
}

View File

@ -7,6 +7,7 @@ import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import org.apache.log4j.Logger;
@ -32,7 +33,7 @@ public class MTConfig {
return sf;
} catch (Throwable ex) {
System.err.println("Failed to load the SessionFactory: " + ex);
logger.error("Failed to load the SessionFactory: " , ex);
throw new ExceptionInInitializerError(ex);
}