Guest User

Main class in EJB module

a guest
May 29th, 2020
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. package pl.edu.agh.soa;
  2.  
  3. import javax.ejb.Stateless;
  4. import javax.jws.WebResult;
  5. import javax.jws.WebService;
  6. import javax.jws.WebMethod;
  7. import javax.jws.WebParam;
  8.  
  9. //import org.jboss.ejb3.annotation.SecurityDomain;
  10. //import org.jboss.ws.api.annotation.WebContext;
  11. //import javax.annotation.security.DeclareRoles;
  12. //import javax.annotation.security.RolesAllowed;
  13.  
  14. import java.util.ArrayList;
  15.  
  16. @Stateless
  17. @WebService
  18. //@SecurityDomain("domain1")
  19. //@DeclareRoles("user3")
  20. //@WebContext(
  21. //        authMethod="BASIC",
  22. //        transportGuarantee="NONE",
  23. //        secureWSDLAccess=false)
  24. public class Hello {
  25.  
  26.     ArrayList<String> subjects = new ArrayList<>();
  27.     String name;
  28.     String surname;
  29.  
  30.     @WebMethod
  31.     //@RolesAllowed("user3")
  32.     @WebResult(name="returned")
  33.     public String
  34.     listSubjects(@WebParam(name="filter") String filter) {
  35.         ArrayList<String> filtered = new ArrayList<>();
  36.         for(String elem : subjects) {
  37.             if(elem.contains(filter)) {
  38.                 filtered.add(elem);
  39.             }
  40.         }
  41.         return "Filtered out: " + filtered;
  42.     }
  43.  
  44.     @WebMethod
  45.     @WebResult(name="returned")
  46.     public String
  47.     addSubject(@WebParam(name="subj") String subj) {
  48.         subjects.add(subj);
  49.         return "After add: " + subjects;
  50.     }
  51.  
  52.     @WebMethod
  53.     public void
  54.     editName(String name) {
  55.         this.name = name;
  56.     }
  57.  
  58.     @WebMethod
  59.     public void
  60.     editSurname(String surname) {
  61.         this.surname = surname;
  62.     }
  63. }
Add Comment
Please, Sign In to add comment