Guest User

Untitled

a guest
Aug 14th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. @EJB
  2. private ProxyBeanLocal proxyBean;
  3.  
  4. @WebMethod(operationName = "hello")
  5. public String hello(@WebParam(name = "name") String txt) {
  6. return proxyBean.businessMethod();
  7. }
  8.  
  9. @Stateless
  10. public class ProxyBean implements ProxyBeanLocal {
  11.  
  12. private final String ADAPTER_1_URL = "";
  13. private final String ADAPTER_2_URL = "";
  14. ConcurrentMap<String, String> m;
  15.  
  16. @Override
  17. public String businessMethod() {
  18.  
  19. try {
  20. m = new ConcurrentHashMap<>();
  21.  
  22. AdapterWS_Service serviceAdapter = new AdapterWS_Service(new URL(ADAPTER_1_URL));
  23. AdapterWS adapter = serviceAdapter.getAdapterWSPort();
  24.  
  25. adapter.helloAsync("", this);//call async with callback on this
  26.  
  27. serviceAdapter = new AdapterWS_Service(new URL(ADAPTER_2_URL));
  28. adapter = serviceAdapter.getAdapterWSPort();
  29.  
  30. adapter.helloAsync("", this);
  31.  
  32.  
  33. } catch (MalformedURLException ex) {
  34. Logger.getLogger(ProxyBean.class.getName()).log(Level.SEVERE, null, ex);
  35. }
  36.  
  37. return null; //return recordset once all responses arrived (using blocking queue?)
  38.  
  39. }
  40.  
  41. @Override
  42. public void handleResponse(Response<HelloResponse> res) {
  43. try {
  44. m.put(res.get().getReturn(), res.get().getReturn());
  45. } catch (InterruptedException ex) {
  46. Logger.getLogger(ProxyBean.class.getName()).log(Level.SEVERE, null, ex);
  47. } catch (ExecutionException ex) {
  48. Logger.getLogger(ProxyBean.class.getName()).log(Level.SEVERE, null, ex);
  49. }
  50. }
Add Comment
Please, Sign In to add comment