Пример #1
0
 /**
  * Doing the start, stop, reload and lazy unload of webapps inside all hosts respectively when
  * getting request.
  *
  * @param nameOfOperation the operation to be performed in oder to hot update the host
  * @throws CarbonException if errors occurs when hot update the host
  */
 private void handleHotUpdateToHost(String nameOfOperation) throws CarbonException {
   if (DataHolder.getHotUpdateService() != null) {
     List<String> mappings =
         URLMappingHolder.getInstance().getUrlMappingsPerApplication(this.context.getName());
     Engine engine = DataHolder.getCarbonTomcatService().getTomcat().getEngine();
     Context hostContext;
     Host host;
     for (String hostName : mappings) {
       host = (Host) engine.findChild(hostName);
       if (host != null) {
         hostContext = (Context) host.findChild("/");
         if (hostContext != null) {
           if (nameOfOperation.equalsIgnoreCase("start")) {
             start(hostContext);
           } else if (nameOfOperation.equalsIgnoreCase("stop")) {
             stop(hostContext);
           } else if (nameOfOperation.equalsIgnoreCase("reload")) {
             reload(hostContext);
           } else if (nameOfOperation.equalsIgnoreCase("lazyunload")) {
             lazyUnload(hostContext);
             DataHolder.getHotUpdateService().removeHost(hostName);
           } else if (nameOfOperation.equalsIgnoreCase("delete")) {
             DataHolder.getHotUpdateService().deleteHost(hostName);
           }
         }
       }
     }
   }
 }
Пример #2
0
  protected Realm getRealm(HttpServletRequest request) {
    String serverName = request.getServerName();
    String contextPath = request.getContextPath();

    Host host = (Host) engine.findChild(serverName);
    if (host == null) {
      // if it cannot find host, then use the default host.
      host = (Host) engine.findChild(engine.getDefaultHost());
      if (host == null)
        throw new NullPointerException(
            "Could not find Tomcat host for: " + serverName + " or: " + engine.getDefaultHost());
    }
    Context context = (Context) host.findChild(contextPath);
    if (context == null)
      throw new NullPointerException("Could not find Tomcat context for: " + contextPath);
    Realm realm = context.getRealm();
    if (realm == null)
      throw new NullPointerException(
          "Could not find Tomcat realm for: " + serverName + "" + contextPath);

    return realm;
  }