/**
  * @throws OGCWebServiceException
  * @see org.deegree.ogcwebservices.wpvs.configuration.AbstractDataSource#getOGCWebService()
  */
 @Override
 public OGCWebService getOGCWebService() throws OGCWebServiceException {
   WMSConfigurationType wmsConfig = null;
   synchronized (this) {
     URL url = getOwsCapabilities().getOnlineResource();
     wmsConfig = cache.get(url);
     if (!cache.containsKey(url) || wmsConfig == null) {
       WMSConfigurationDocument wmsDoc = new WMSConfigurationDocument();
       try {
         wmsDoc.load(getOwsCapabilities().getOnlineResource());
         wmsConfig = wmsDoc.parseConfiguration();
         cache.put(url, wmsConfig);
       } catch (IOException e) {
         throw new OGCWebServiceException(
             Messages.getMessage("WPVS_DATASOURCE_CAP_ERROR", toString()) + e.getMessage());
       } catch (SAXException e) {
         throw new OGCWebServiceException(
             Messages.getMessage("WPVS_DATASOURCE_CAP_ERROR", toString()) + e.getMessage());
       } catch (InvalidConfigurationException e) {
         throw new OGCWebServiceException(
             Messages.getMessage("WPVS_DATASOURCE_CAP_ERROR", toString()) + e.getMessage());
       }
     }
   }
   return WMServiceFactory.getWMSInstance(wmsConfig);
 }
  /**
   * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
   */
  public void ctDestroyed() {
    LOG.logInfo("Stopping context: ");

    WMSConfigurationDocument.resetCapabilitiesCache();
    WMSConfigurationDocument_1_3_0.resetCapabilitiesCache();
    WMPSConfigurationDocument.resetCapabilitiesCache();

    ServiceLookup lookup = ServiceLookup.getInstance();
    for (Iterator<?> iter = lookup.getIterator(); iter.hasNext(); ) {
      String serviceName = (String) iter.next();
      LOG.logInfo("Stopping service " + serviceName);

      try {
        String s = SERVICE_FACTORIES_MAPPINGS.get(lookup.getService(serviceName));
        Class<?> clzz = Class.forName(s);
        // TODO stop and reset all service instances
        Method[] methods = clzz.getMethods();
        for (int j = 0; j < methods.length; j++) {
          if (methods[j].getName().equals("reset")) {
            Object[] args = new Object[0];
            methods[j].invoke(clzz.newInstance(), args);
          }
        }
      } catch (Exception e) {
        LOG.logError(e.getMessage(), e);
      }
    }
  }