0

I have developed a REST server with our app specific APIs. we also have deployed a different rest Job server into another location. Currently the way I am doing is .

@RestController
public class SparkJobController  {

    @Autowired
    private IJobSchedulerService jobService;
...

And the Service Implementation is

@Service(value="jobService")
public class JobSchedulerServiceImpl implements IJobSchedulerService {

    @Override
    public Map triggerJob(String context) {

        Map<String, ?> s = new HashMap<String,Object>();
        RestTemplate restTemplate = new RestTemplate();
//      restTemplate call to other REST API. and returns Map.
    ...     
}

My question is , Is my approach correct ? Or Does Spring framework enables us to use some predefined APIs which can help to use RESTTemplate as a Service

[EDIT] : the deployed REST service is third party application.

chaosguru
  • 1,933
  • 4
  • 30
  • 44

1 Answers1

0

I did some research and havent' seen yet a way to implement RestTemplate as a service.

I have seen RestTemplate defined in the bean config and auto wired in - https://www.informit.com/guides/content.aspx?g=java&seqNum=546

To summarize, most of the examples I have seen use Resttemplate, similar to how you have implemented in your code.

Paul John
  • 1,626
  • 1
  • 13
  • 15