private boolean isMyServiceRunning(Class<?> serviceClass) { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClass.getName().equals(service.service.getClassName())) { return true; } } return false; }
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Action action = ActionFactory.getAction(request); String view = action.execute(request, response); if (view.equals(request.getPathInfo().substring(1)) { request.getRequestDispatcher("/WEB-INF/" + view + ".jsp").forward(request, response); } else { response.sendRedirect(view); } } catch (Exception e) { throw new ServletException("Executing action failed.", e); } }
@Override public boolean test(String value) { return "d".equals(value); } };
@Override public boolean test(String t1) { return t1.equals("two"); } });
@Override public boolean test(String t1) { return t1.equals("two"); } });
@Override public String apply(String s) { if (s.equals("x")) { return "xx"; } return s.toUpperCase(); } };
@Override public String apply(String t1) { if ("b".equals(t1)) { throw new RuntimeException("Forced failure"); } return t1 + t1; } };
@Override public String apply(String s) { if (s.equals("x")) { return "xx"; } return s.toUpperCase(); } };
@Override public String apply(String t1) { if ("bb".equals(t1)) { throw new RuntimeException("Forced failure"); } return t1 + t1; } };
@Override public String apply(String t1) { if ("bb".equals(t1)) { throw new RuntimeException("Forced failure"); } return t1 + t1; } };
@Override public void accept(String s) { if ("fail".equals(s)) { throw new RuntimeException("Forced Failure"); } } });
@Override public String apply(String s) { if ("fail".equals(s)) { throw new RuntimeException("Forced Failure"); } System.out.println("BadMapper:" + s); return s; } });
@Override public String apply(String s) { if ("fail".equals(s)) { throw new RuntimeException("Forced Failure"); } System.out.println("BadMapper:" + s); return s; } });
@Override public Integer apply(String t1) { if ("b".equals(t1)) { throw new RuntimeException("Forced Failure"); } return t1.length(); } };
@Override public String apply(String s) { if ("fail".equals(s)) { throw new RuntimeException("Forced Failure"); } System.out.println("BadMapper:" + s); return s; } });
@Override public Integer apply(String t1) { if ("bb".equals(t1)) { throw new RuntimeException("Forced Failure"); } return t1.length(); } };
@Override public Integer apply(String t1) { if ("bb".equals(t1)) { throw new RuntimeException("Forced Failure"); } return t1.length(); } };
@Override public Integer apply(String t1) { if ("b".equals(t1)) { throw new RuntimeException("Forced Failure"); } return t1.length(); } };
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // ... List<Part> fileParts = request.getParts().stream().filter(part -> "file".equals(part.getName())).collect(Collectors.toList()); // Retrieves <input type="file" name="file" multiple="true"> for (Part filePart : fileParts) { String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); // MSIE fix. InputStream fileContent = filePart.getInputStream(); // ... (do your job here) } }
@Override public String apply(Integer t) { assertTrue(Thread.currentThread().getName().equals(currentThreadName)); return "Value_" + t + "_Thread_" + Thread.currentThread().getName(); } });