Richard Allred
2019-05-23 497620c4d1bcb410267c56351432f87fb3aee5a4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.redhat.training.rest;
 
import java.net.InetAddress;
import java.net.UnknownHostException;
 
import javax.ejb.Stateless;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
 
import com.redhat.training.model.Host;
 
@Stateless
@Path("host")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class HostService {
      
    @GET
    public Host getHostInfo() throws UnknownHostException {
        InetAddress address = InetAddress.getLocalHost();
        Host host = new Host(address.getHostAddress(), address.getHostName());
        return host;
    }
}