Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EJB
- private ProxyBeanLocal proxyBean;
- @WebMethod(operationName = "hello")
- public String hello(@WebParam(name = "name") String txt) {
- return proxyBean.businessMethod();
- }
- @Stateless
- public class ProxyBean implements ProxyBeanLocal {
- private final String ADAPTER_1_URL = "";
- private final String ADAPTER_2_URL = "";
- ConcurrentMap<String, String> m;
- @Override
- public String businessMethod() {
- try {
- m = new ConcurrentHashMap<>();
- AdapterWS_Service serviceAdapter = new AdapterWS_Service(new URL(ADAPTER_1_URL));
- AdapterWS adapter = serviceAdapter.getAdapterWSPort();
- adapter.helloAsync("", this);//call async with callback on this
- serviceAdapter = new AdapterWS_Service(new URL(ADAPTER_2_URL));
- adapter = serviceAdapter.getAdapterWSPort();
- adapter.helloAsync("", this);
- } catch (MalformedURLException ex) {
- Logger.getLogger(ProxyBean.class.getName()).log(Level.SEVERE, null, ex);
- }
- return null; //return recordset once all responses arrived (using blocking queue?)
- }
- @Override
- public void handleResponse(Response<HelloResponse> res) {
- try {
- m.put(res.get().getReturn(), res.get().getReturn());
- } catch (InterruptedException ex) {
- Logger.getLogger(ProxyBean.class.getName()).log(Level.SEVERE, null, ex);
- } catch (ExecutionException ex) {
- Logger.getLogger(ProxyBean.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
Add Comment
Please, Sign In to add comment