Posts

Showing posts from October, 2016

Featured Post

ScheduleJob using Qartz

Sample code demonstartes how to schedule job using Quartz jar package com.seo.postman; import org.quartz.JobBuilder; import org.quartz.JobDetail; import org.quartz.Scheduler; import org.quartz.SimpleScheduleBuilder; import org.quartz.Trigger; import org.quartz.TriggerBuilder; import org.quartz.impl.StdSchedulerFactory; /**  *  * @author venkata  */ public class TriggerTest {      public static void main(String[] args) throws Exception { // Quartz 1.6.3 // JobDetail job = new JobDetail(); // job.setName("testJob"); // job.setJobClass(HelloJob.class); JobDetail job = JobBuilder.newJob(HelloJob.class) .withIdentity("testJob", "group1").build();                 //Quartz 1.6.3 // SimpleTrigger trigger = new SimpleTrigger(); // trigger.setStartTime(new Date(System.currentTimeMillis() + 2000)); // trigger.setRepeatCount(SimpleTrigger.REP...

restful web service json response

How can we use Spring to create Restful Web Service returning JSON response? For adding JSON support to your spring application, you will need to  add Jackson dependency  in first step. com.fasterxml.jackson.core jackson-databind 2.4.1 Now you are ready to return JSON response from your MVC controller. All you have to do is return JAXB annotated object from method and use  @ResponseBody  annotation on this return type. @Controller public class EmployeeRESTController { @RequestMapping(value = "/employees") public @ResponseBody EmployeeListVO getAllEmployees() { EmployeeListVO employees = new EmployeeListVO(); //Add employees return employees; } } Alternatively, you can use  @RestController  annotation in place of  @Controller  annotation. This will remove the need to using  @ResponseBody . @RestController = @Controller + @ResponseBody So you can write the above controller as below. @RestController publ...

spring context

What is Spring MVC framework? The Spring web MVC framework provides  model-view-controller  architecture and ready components that can be used to develop flexible and loosely coupled web applications.  The MVC pattern results in separating the different aspects of the application (input logic, business logic, and UI logic), while providing a loose coupling between model, view and controller parts of application. Spring framework provides lots of advantages over other MVC frameworks e.g. Clear separation of roles ? controller, validator, command object, form object, model object, DispatcherServlet, handler mapping, view resolver, etc. Each role can be fulfilled by a specialized object. Powerful and straightforward configuration of both framework and application classes as JavaBeans. Reusable business code ? no need for duplication. You can use existing business objects as command or form objects instead of mirroring them in order to extend a particular framework ...