Advertisement
Guest User

Untitled

a guest
May 18th, 2017
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package org.too.webservice;
  2.  
  3. import javax.ws.rs.ApplicationPath;
  4. import org.glassfish.jersey.server.ResourceConfig;
  5.  
  6. @ApplicationPath("")
  7. public class ApplicationConfig extends ResourceConfig {
  8.  
  9.  
  10.     public ApplicationConfig() {
  11.         super(ApplicationConfig.class);
  12.         packages("org.too.webservice");
  13.     }
  14. }
  15.  
  16. /////////////////////////////////////////////////////////////////////////
  17. package org.too.webservice;
  18.  
  19. import javax.inject.Inject;
  20. import javax.ws.rs.GET;
  21. import javax.ws.rs.Path;
  22. import javax.ws.rs.QueryParam;
  23.  
  24. @Path("service")
  25. public class ServiceResource {
  26.  
  27.     @Inject
  28.     private AccountService accountService;
  29.  
  30.     @GET
  31.     @Path("/account/get")
  32.     public String getAccount(@QueryParam("id") String id) {
  33.         return accountService.get(id).toString();
  34.     }
  35. }
  36.  
  37. /////////////////////////////////////////////////////////////////////////
  38. package org.too.webservice;
  39.  
  40. import javax.inject.Singleton;
  41.  
  42. @Singleton
  43. public class AccountService {
  44.  
  45.     public String get(String id) {
  46.         return "New Account with Id = " + id;
  47.     }
  48. }
  49.  
  50. /////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement