Spring Task Example

pom.xml [code] <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.tugrulaslan</groupId> <artifactId>SpringScheduledTaskExample</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>SpringScheduledTaskExample</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>3.1.2.RELEASE</spring.version> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project> [/code] batch.xml in src>java>resources [code] <?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" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task

Enabling auto reconnect in mysql hibernate spring

in your spring config file append the url entry with the below sample   <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${database.driverClassName}" /> <property name="url" value="${database.url}?characterEncoding=UTF-8&amp;autoReconnect=true"/> <property name="username" value="${database.user}" /> <property name="password" value="${database.password}" /> </bean>

Spring + ZKoss Customized Login, Logout, Authorization and Authentication

CustomAuthenticationFilter.java public class CustomAuthenticationFilter extends UsernamePasswordAuthenticationFilter { @Autowired private xxService xService; static final Logger logger = Logger.getLogger(CustomAuthenticationFilter.class); @Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { String username = request.getParameter(getUsernameParameter()); String password = request.getParameter(getPasswordParameter()); String server = request.getParameter("server"); if(username.trim().length() == 0 || password.trim().length() == 0){ logger.error("Error empty credentials entered " + username + password

Switching Between Hibernate’s and Spring’s Transaction

Uncomment the below lines to hand the activation down to Spring pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.tugrulaslan</groupId> <artifactId>WebApp</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>BlogWebApp Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <project-java.version>1.7</project-java.version> <maven-compiler-plugin.version>3.1</maven-compiler-plugin.version> <junit.version>4.11</junit.version> <mysql-connector.version>5.1.34</mysql-connector.version> <hibernate.version>4.3.8.Final</hibernate.version> <javax-persistance-api.version>1.0.2</javax-persistance-api.version> <spring.version>4.0.6.RELEASE</spring.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql-connector.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version>