below is a URL configured as an autosys job. This invokes the servlet listed below. Can anyone suggest me how to protect this method? psServiceWrapper.processHRFeed (); "called constantly with incorrect data modification every time this URL is clicked, they say it all the time 10 times. I want it to be accessed only one stream at a time.
I know that I need to use a synchronized method or block .. not sure how to do it .. since I am not familiar with threads.
http://mydomain:11000/dorf/HRDORFScriptServlet?script=hrFeed public class HRDORFScriptServlet extends HttpServlet { private static final long serialVersionUID = 1L; private static final Logger log = Logger.getLogger(HRDORFScriptServlet.class); private final String script = "script"; @Override protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException { // TODO Auto-generated method stub performTask(arg0, arg1); } @Override protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException { // TODO Auto-generated method stub performTask(arg0, arg1); } /** Execute the servlet. * * @param request * @param response * @throws ServletException * @throws IOException */ public void performTask(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException { DorfUser dorfUser = DorfSessionUtils.getDorfUser(request.getSession()); HRDorfFeedServiceWrapper psServiceWrapper = new HRDorfFeedServiceWrapper(dorfUser); String reqParam = request.getParameter(script); if(reqParam.equals("hrFeed")){ try{ psServiceWrapper.processHRFeed(); } catch(ServiceException se){ log.error("Error While calling HRFeed Service : "+se.getMessage()); } catch(Exception e){ log.error("Error While calling HRFeed Service : "+e.getMessage()); } } }
}
source share