Changeset 10208 in josm for trunk/src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java
- Timestamp:
- 2016-05-14T02:38:41+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java
r10001 r10208 220 220 } else { 221 221 // create handler object 222 RequestHandler handler = handlerClass. newInstance();222 RequestHandler handler = handlerClass.getConstructor().newInstance(); 223 223 try { 224 224 handler.setCommand(command); … … 243 243 } catch (IOException ioe) { 244 244 Main.debug(Main.getErrorMessage(ioe)); 245 } catch ( Exception e) {245 } catch (ReflectiveOperationException e) { 246 246 Main.error(e); 247 247 try { … … 391 391 public static String getHandlerInfoAsJSON(String cmd) { 392 392 try (StringWriter w = new StringWriter()) { 393 PrintWriter r = new PrintWriter(w);394 393 RequestHandler handler = null; 395 394 try { 396 395 Class<?> c = handlers.get(cmd); 397 396 if (c == null) return null; 398 handler = handlers.get(cmd). newInstance();399 } catch ( InstantiationException | IllegalAccessException ex) {397 handler = handlers.get(cmd).getConstructor().newInstance(); 398 } catch (ReflectiveOperationException ex) { 400 399 Main.error(ex); 401 400 return null; 402 401 } 403 402 403 PrintWriter r = new PrintWriter(w); 404 404 printJsonInfo(cmd, r, handler); 405 405 return w.toString(); … … 459 459 * Reports HTML message with the description of all available commands 460 460 * @return HTML message with the description of all available commands 461 * @throws IllegalAccessException if one handler class or its nullary constructor is not accessible. 462 * @throws InstantiationException if one handler class represents an abstract class, an interface, an array class, 463 * a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason. 464 */ 465 public static String getUsageAsHtml() throws IllegalAccessException, InstantiationException { 461 * @throws ReflectiveOperationException if a reflective operation fails for one handler class 462 */ 463 public static String getUsageAsHtml() throws ReflectiveOperationException { 466 464 StringBuilder usage = new StringBuilder(1024); 467 465 for (Entry<String, Class<? extends RequestHandler>> handler : handlers.entrySet()) { 468 RequestHandler sample = handler.getValue(). newInstance();466 RequestHandler sample = handler.getValue().getConstructor().newInstance(); 469 467 String[] mandatory = sample.getMandatoryParams(); 470 468 String[] optional = sample.getOptionalParams();
Note:
See TracChangeset
for help on using the changeset viewer.