Package com.google.opengse.configuration

Examples of com.google.opengse.configuration.WebAppConfigurationException


    checkTempDirProperty();
  }

  private void checkTempDirProperty() throws WebAppConfigurationException {
    if (tmpdir == null) {
      throw new WebAppConfigurationException(
          "No '" + CONTEXTKEY_TMP_DIR + "' property defined");
    }
    if (tmpdir.isFile()) {
      throw new WebAppConfigurationException(
          "'" + CONTEXTKEY_TMP_DIR + "' property points to a file");
    }
    if (!tmpdir.exists()) {
      tmpdir.mkdirs();
    }
    if (!tmpdir.exists()) {
      throw new WebAppConfigurationException(
          "Directory ${" + CONTEXTKEY_TMP_DIR + "}=" + tmpdir
              + " does not exist");
    }
  }
View Full Code Here


   * @return a new WebApplications object.
   */
  static WebAppCollection create(Properties props, WebApp rootWebApp)
      throws WebAppConfigurationException, IOException {
    if (!ROOT_CONTEXT_URI_PREFIX.equals(rootWebApp.getUriPrefix())) {
      throw new WebAppConfigurationException("Not a root WebApp");
    }
    WebAppCollectionImpl webApps = new WebAppCollectionImpl(props);
    webApps.addWebApp(rootWebApp);
    return webApps;
  }
View Full Code Here

   * throw an exception.
   */
  public void addWebApp(WebApp webapp) throws WebAppConfigurationException {
    String uriPrefix = webapp.getUriPrefix();
    if (getWebApp(uriPrefix) != null) {
      throw new WebAppConfigurationException(
          "A WebApp with URI prefix '" + uriPrefix + "' already exists");
    }
    uriPrefixToWebApp.put(webapp.getUriPrefix(), webapp);
  }
View Full Code Here

          regexHandler.replaceDefaultHandler(handler);
        } else {
          String regex = uriPattern.toRegex();
          if (!regexHandler.setHandler(regex, handler)) {
            // throw an exception if we are replacing a non-global pattern
            throw new WebAppConfigurationException(
                "Pattern '" + uriPattern + "' already registered");
          }
        }
      }
    }
View Full Code Here

  void addServletMapping(WebAppServletMapping mapping)
      throws WebAppConfigurationException {
    String servletName = mapping.getServletName();
    if (servletName == null) {
      throw new WebAppConfigurationException(
          "No servlet-name in servlet-mapping");
    }
    RequestHandlerFactory info = servletNameToInfo.get(servletName);
    if (info == null) {
      LOGGER.info("Could not find servlet-name '" + servletName + "'");
View Full Code Here

  void addFilterMapping(WebAppFilterMapping mapping)
      throws WebAppConfigurationException {
    String filterName = mapping.getFilterName();
    if (filterName == null) {
      throw new WebAppConfigurationException(
          "No filter-name in filter-mapping");
    }
    if (mapping.getServletNames() == null && mapping.getUrlPatterns() == null) {
      throw new WebAppConfigurationException(
          "No servlet-name or url-pattern element");
    }
    FilterInfo info = filterNameToInfo.get(filterName);
    if (info == null) {
      LOGGER.severe("Error: Could not find filter-name '" + filterName + "'");
      return;
    }
    if (!info.initialized) {      // should never happen
      LOGGER.severe("Error: Filter not initialized '" + filterName + "'");
      return;
    }

    if (mapping.getServletNames() != null) {
      for (String servletName : mapping.getServletNames()) {
        if (servletName.equals("*")) {
          addFilterMappingForAllServlets(info, mapping);
        } else if (!servletNameToInfo.containsKey(servletName)) {
          throw new WebAppConfigurationException(
              "Unknown servlet-name '" + servletName + "'");
        } else {
          addFilterMappingForOneServlet(info, servletName, mapping);
        }
      }
View Full Code Here

            }
          }
        }
      }
    } catch (MalformedURLException e) {
      throw new WebAppConfigurationException(e);
    }

      URL[] urls = urlList.toArray(new URL[0]);
      URLClassLoader urlcl = new URLClassLoader(urls, WebAppFactory.class.getClassLoader());
      return WebAppImpl.create(uriPrefix, contextBase,
View Full Code Here

   *                                      not a directory
   */
  private static void checkDirectory(File dir)
      throws WebAppConfigurationException {
    if (!dir.exists()) {
      throw new WebAppConfigurationException(
          "Directory '" + dir + "' does not exist");
    }
    if (!dir.isDirectory()) {
      throw new WebAppConfigurationException(
          "'" + dir + "' is not a directory");
    }
  }
View Full Code Here

      throws IOException, WebAppConfigurationException {
    Enumeration<URL> webxmls = classLoader.getResources(globalConfiguration);
    URL webxmlUrl = null;
    while (webxmls.hasMoreElements()) {
      if (webxmlUrl != null) {
        throw new WebAppConfigurationException(
            "More than one " + globalConfiguration + " found in the classpath");
      }
      webxmlUrl = webxmls.nextElement();
    }
//System.out.println("Classloaders: " + getClassloaderChain(classLoader));
    if (webxmlUrl == null) {
      String me = GlobalConfigurationFactory.class.getName().replace('.', '/') + ".class";
      InputStream istr = classLoader.getResourceAsStream(me);
      if (istr == null) {
        throw new RuntimeException("Cannot load " + me + " something is seriously wrong with the classloader(s): " + getClassloaderChain(classLoader));
      }
      throw new WebAppConfigurationException(
          "Could not find global configuration resource '" + globalConfiguration
              + "'");
    }
    Reader reader = new InputStreamReader(webxmlUrl.openStream());
    try {
      WebXmlParser parser = new WebXmlParserImpl2();
      return parser.parse(reader);
    } catch (SAXException e) {
      throw new WebAppConfigurationException(e);
    } finally {
      reader.close();
    }
  }
View Full Code Here

      InstantiationException, IllegalAccessException {
    if (ROOT.equals(contextname)) {
      return createWithRootWebapp(props, contextdir);
    }
    if (contextname.indexOf('/') >= 0) {
      throw new WebAppConfigurationException(
              "Found / in contextname '" + contextname + "'");
    }
    String uriPrefix = "/" + contextname;
    WebAppCollection webAppCollection = WebAppCollectionFactory.create(props);
    ServletContainerContext containerContext
View Full Code Here

TOP

Related Classes of com.google.opengse.configuration.WebAppConfigurationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.