Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import org.apache.cxf.endpoint.Server;
  2. import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
  3. import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
  4. import org.apache.cxf.transport.http.HttpDestinationFactory;
  5. import org.apache.cxf.transport.servlet.ServletDestinationFactory;
  6.  
  7. public class RestDemo {
  8.  
  9. public static void main(String[] args) {
  10.  
  11. final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
  12. sf.setAddress("http://0.0.0.0:8080/");
  13. sf.setServiceClass(RestService.class);
  14.  
  15. sf.setResourceProvider(RestService.class, new SingletonResourceProvider(new RestService()));
  16.  
  17. ServletDestinationFactory destinationFactory = new ServletDestinationFactory();
  18. sf.getBus().setExtension(destinationFactory, HttpDestinationFactory.class);
  19.  
  20. Server server = sf.create();
  21. server.start();
  22. System.out.println(server.isStarted());
  23. System.out.println(server.getDestination().getAddress().getAddress().getValue());
  24. System.out.println(server.getEndpoint().getEndpointInfo());
  25.  
  26. try {
  27. Thread.sleep(1000000);
  28. } catch (InterruptedException e) {
  29. e.printStackTrace();
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement