Skip to content

Instantly share code, notes, and snippets.

View aziz781's full-sized avatar

Abdul Aziz (A575072) aziz781

View GitHub Profile
@aziz781
aziz781 / gist:1336651
Created November 3, 2011 14:38
Spring application with annotation based bean configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
@aziz781
aziz781 / gist:1336642
Created November 3, 2011 14:36
Spring iBatis sample sqlmap configuration file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL MAP 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<!-- Abdul Aziz -->
<sqlMap namespace="ObsClaim">
<resultMap id="claim-map" class="uk.gov.nhsbsa.dcss.obs.domain.ObsClaim">
<result property="obsId" column="OBS_ID" />
<result property="formId" column="FORM_ID" />
<result property="correlationId" column="CORRELATION_ID" />
@aziz781
aziz781 / gist:1336634
Created November 3, 2011 14:33
Spring iBatis ORM Configuration data-access-config-ibatis.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
@aziz781
aziz781 / gist:1336630
Created November 3, 2011 14:32
Spring JMS: smaple JMS Configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- @author Abdul Aziz -->
<!-- SOA : JMS-Queue JNDI provider URL -->
@aziz781
aziz781 / gist:1336551
Created November 3, 2011 14:02
Java Spring Controller
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class StatusController {
@RequestMapping(value = "/", method = RequestMethod.GET)
@aziz781
aziz781 / gist:1336542
Created November 3, 2011 13:56
Spring JDBC: simple way to excute a query
// first get 'dataSource'
// @Autowired
// private DataSource dataSource;
private Object[] geStatus() {
try {
JdbcTemplate template = new JdbcTemplate(dataSource);
Object[] result = (Object[]) template.queryForObject(SQL, new RowMapper() {
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
return new Object[]{rs.getString(1), sdf.format(rs.getDate(2))};
}
@aziz781
aziz781 / gist:1336525
Created November 3, 2011 13:48
java get current date
public static Date getCurrentDate()
{
Calendar calendar = Calendar.getInstance();
Date currentDate = calendar.getTime();
String dateStr= new SimpleDateFormat("dd/MM/yyyy").format(currentDate);
return getDate(dateStr);
}
@aziz781
aziz781 / gist:1336521
Created November 3, 2011 13:47
Java: is Current date
public static boolean isCurrentDate(Date givenDate)
{
// current date
Calendar currentCal = Calendar.getInstance();
currentCal.setTime(getCurrentDate());
// given date
Calendar givenCal = Calendar.getInstance();
givenCal.setTime(givenDate);
if(currentCal.equals(givenCal))
return true;
@aziz781
aziz781 / gist:1336519
Created November 3, 2011 13:47
Java: is Future Date
public static boolean isFutureDate(Date givenDate)
{
// current date
Calendar currentCal = Calendar.getInstance();
currentCal.setTime(getCurrentDate());
// given date
Calendar givenCal = Calendar.getInstance();
givenCal.setTime(givenDate);
if(currentCal.equals(givenCal) || currentCal.after(givenCal))
return false;
@aziz781
aziz781 / gist:1336511
Created November 3, 2011 13:44
Spring Batch sample configuration applicationContext-batch.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:amq="http://activemq.apache.org/schema/core"