Define the Extension Class

In this task, you define the extension class and method stubs to test the custom REST call.

About this task

The REST definition in the previous task referenced a class com.matrixx.rsgateway.purchase.DemoServices that provides a method called queryAndPurchase which does the work of the custom extension.

After testing the extension class with the stubs shown below, you change the DemoServices class to call the Spring object manager to ask for a bean named DemoServices.

Procedure

  1. Go to the projects/purchase/rsgwextension/src/main/java/com/matrixx/rsgateway/configuration directory.
  2. Create a file named DemoServices.java.
  3. Define the class and method stubs.
    package com.matrixx.rsgateway.configuration;
     	
    	import com.matrixx.datacontainer.mdc.DemoRequestSubscriberPurchase;
    	import com.matrixx.datacontainer.mdc.DemoResponseSubscriberPurchase;
    	import com.matrixx.datacontainer.rest.RestQueryTerm;
    
    	import org.springframework.stereotype.Service;
     	
    	@Service(value = "DemoServices")
    	public class DemoServices {
     	
    		public int queryAndPurchase(RestQueryTerm searchTerm, 
    			DemoRequestSubscriberPurchase input, DemoResponseSubscriberPurchase output)	
    			{
    			output.setResult(0L);
    			output.setResultText("Ok -> hello from DemoServices");
    			return 0;
    			}
    	}
  4. Save the file.

What to do next

Test the extension stubs.