// Suppressing the warning as the new exception is using the jaxbe error code and message to pass // on to the ResourceContextExcepiton @SuppressWarnings("PMD.PreserveStackTrace") @Override public Object perform(UnmarshallerValidator resource) { try { return resource.validateUnmarshal(cfgResource.newInputStream()); } catch (JAXBException jaxbe) { throw new ResourceContextException( "Failed to unmarshall resource " + cfgResource.name() + " - " + jaxbe.getCause() + " - Error code: " + jaxbe.getErrorCode() + " - Reason: " + jaxbe.getMessage(), jaxbe.getLinkedException()); } catch (IOException ioe) { throw new ResourceContextException( "An I/O error has occured while trying to read resource " + cfgResource.name() + " - Reason: " + ioe.getMessage(), ioe); } catch (SAXException se) { throw new ResourceContextException( "Validation error on resource " + cfgResource.name() + " - " + se.getMessage(), se); } catch (Exception ex) { throw new ResourceContextException( "Failed to unmarshall resource " + cfgResource.name() + " - Reason: " + ex.getMessage(), ex); } }
@Override public void configurationUpdated(ConfigurationResource config) { LOG.info("WADL file changed: " + config.name()); synchronized (lock) { if (validators == null) { return; } boolean found = false; for (ValidatorInfo info : validators) { if (info.getUri() != null && getNormalizedPath(info.getUri()).equals(config.name())) { info.reinitValidator(); found = true; } } if (!found) { // If we couldn't match the particular config... be safe and clear // all fo the validators for (ValidatorInfo info : validators) { info.reinitValidator(); } } } isInitialized = true; }
@Override public synchronized void run() { for (ConfigurationResource resource : watchMap.values()) { try { if (resource.updated()) { eventManager.newEvent(ConfigurationEvent.UPDATE, resource); LOG.info("Updated " + resource.name()); } } catch (Exception e) { // TODO:Log - Create a logger that is smart enough not to print out errors we don't care // about more than once } } }
public synchronized void watch(ConfigurationResource resource) { watchMap.put(resource.name(), resource); }