org.apache.catalina.Context.getState()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.apache.catalina.Context.getState()方法的一些代码示例,展示了Context.getState()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getState()方法的具体详情如下:
包路径:org.apache.catalina.Context
类名称:Context
方法名:getState

Context.getState介绍

暂无

代码示例

代码示例来源:origin: psi-probe/psi-probe

@Override
public boolean getAvailable(Context context) {
 return context.getState().isAvailable();
}

代码示例来源:origin: psi-probe/psi-probe

@Override
protected ModelAndView handleContext(String contextName, Context context,
  HttpServletRequest request, HttpServletResponse response) throws Exception {
 if (context != null && !request.getContextPath().equals(contextName)) {
  try {
   // Logging action
   Authentication auth = SecurityContextHolder.getContext().getAuthentication();
   // get username logger
   String name = auth.getName();
   if (context.getState().isAvailable()) {
    logger.info("{} requested STOP of {}", request.getRemoteAddr(), contextName);
    getContainerWrapper().getTomcatContainer().stop(contextName);
    logger.info(getMessageSourceAccessor().getMessage("probe.src.log.stop"), name,
      contextName);
   } else {
    logger.info("{} requested START of {}", request.getRemoteAddr(), contextName);
    getContainerWrapper().getTomcatContainer().start(contextName);
    logger.info(getMessageSourceAccessor().getMessage("probe.src.log.start"), name,
      contextName);
   }
  } catch (Exception e) {
   logger.error("Error during ajax request to START/STOP of '{}'", contextName, e);
  }
 }
 return new ModelAndView(getViewName(), "available",
   context != null && getContainerWrapper().getTomcatContainer().getAvailable(context));
}

代码示例来源:origin: modcluster/mod_cluster

@Override
public boolean isStarted() {
  return LifecycleState.STARTED.equals(this.context.getState());
}

代码示例来源:origin: com.github.skjolber.mockito-rest-spring/tomcat

private void destroy(Context context) throws LifecycleException, InterruptedException {
    context.destroy();

    long deadline = System.currentTimeMillis() + 10000;
    do {
      switch(context.getState()) {
      case DESTROYED:
      case FAILED:
        return;
      default : {
      }
      }
      Thread.sleep(10);
    } while(deadline > System.currentTimeMillis());		
  }    
}

代码示例来源:origin: com.github.skjolber.mockito-rest-spring/tomcat

private void stop(Context context) throws LifecycleException, InterruptedException {
  context.stop();
  long deadline = System.currentTimeMillis() + 10000;
  do {
    switch(context.getState()) {
    case STOPPED:
    case DESTROYING:
    case DESTROYED:
    case FAILED:
      return;
    default : {
    }
    }
    Thread.sleep(10);
  } while(deadline > System.currentTimeMillis());		
}

代码示例来源:origin: org.apache.meecrowave/meecrowave-core

private Stream<Context> findContexts(final Host host) {
  return Stream.of(host.findChildren())
      .filter(Context.class::isInstance)
      .map(Context.class::cast)
      .filter(ctx -> ctx.getState().isAvailable());
}

代码示例来源:origin: apache/meecrowave

private Stream<Context> findContexts(final Host host) {
  return Stream.of(host.findChildren())
      .filter(Context.class::isInstance)
      .map(Context.class::cast)
      .filter(ctx -> ctx.getState().isAvailable());
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

private void writeDeployResult(PrintWriter writer, StringManager smClient,
    String name, String displayPath) {
  Context deployed = (Context) host.findChild(name);
  if (deployed != null && deployed.getConfigured() &&
      deployed.getState().isAvailable()) {
    writer.println(smClient.getString(
        "managerServlet.deployed", displayPath));
  } else if (deployed!=null && !deployed.getState().isAvailable()) {
    writer.println(smClient.getString(
        "managerServlet.deployedButNotStarted", displayPath));
  } else {
    // Something failed
    writer.println(smClient.getString(
        "managerServlet.deployFailed", displayPath));
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

private void writeDeployResult(PrintWriter writer, StringManager smClient,
    String name, String displayPath) {
  Context deployed = (Context) host.findChild(name);
  if (deployed != null && deployed.getConfigured() &&
      deployed.getState().isAvailable()) {
    writer.println(smClient.getString(
        "managerServlet.deployed", displayPath));
  } else if (deployed!=null && !deployed.getState().isAvailable()) {
    writer.println(smClient.getString(
        "managerServlet.deployedButNotStarted", displayPath));
  } else {
    // Something failed
    writer.println(smClient.getString(
        "managerServlet.deployFailed", displayPath));
  }
}

代码示例来源:origin: modcluster/mod_cluster

@Test
public void isStarted() {
  when(this.context.getState()).thenReturn(LifecycleState.STOPPED);
  boolean result = this.catalinaContext.isStarted();
  assertFalse(result);
  when(this.context.getState()).thenReturn(LifecycleState.STARTED);
  result = this.catalinaContext.isStarted();
  assertTrue(result);
}

代码示例来源:origin: codefollower/Tomcat-Research

@Override
public Set<String> setServletSecurity(ServletSecurityElement constraint) {
  if (constraint == null) {
    throw new IllegalArgumentException(sm.getString(
        "applicationServletRegistration.setServletSecurity.iae",
        getName(), context.getName()));
  }
  if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
    throw new IllegalStateException(sm.getString(
        "applicationServletRegistration.setServletSecurity.ise",
        getName(), context.getName()));
  }
  return context.addServletSecurity(this, constraint);
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

@Override
public Set<String> setServletSecurity(ServletSecurityElement constraint) {
  if (constraint == null) {
    throw new IllegalArgumentException(sm.getString(
        "applicationServletRegistration.setServletSecurity.iae",
        getName(), context.getName()));
  }
  
  if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
    throw new IllegalStateException(sm.getString(
        "applicationServletRegistration.setServletSecurity.ise",
        getName(), context.getName()));
  }
  return context.addServletSecurity(this, constraint);
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

@Override
public Set<String> setServletSecurity(ServletSecurityElement constraint) {
  if (constraint == null) {
    throw new IllegalArgumentException(sm.getString(
        "applicationServletRegistration.setServletSecurity.iae",
        getName(), context.getName()));
  }
  if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
    throw new IllegalStateException(sm.getString(
        "applicationServletRegistration.setServletSecurity.ise",
        getName(), context.getName()));
  }
  this.constraint = constraint;
  return context.addServletSecurity(this, constraint);
}

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

@Override
public Set<String> setServletSecurity(ServletSecurityElement constraint) {
  if (constraint == null) {
    throw new IllegalArgumentException(sm.getString(
        "applicationServletRegistration.setServletSecurity.iae",
        getName(), context.getName()));
  }
  
  if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
    throw new IllegalStateException(sm.getString(
        "applicationServletRegistration.setServletSecurity.ise",
        getName(), context.getName()));
  }
  return context.addServletSecurity(this, constraint);
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

@Override
public Set<String> setServletSecurity(ServletSecurityElement constraint) {
  if (constraint == null) {
    throw new IllegalArgumentException(sm.getString(
        "applicationServletRegistration.setServletSecurity.iae",
        getName(), context.getName()));
  }
  
  if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
    throw new IllegalStateException(sm.getString(
        "applicationServletRegistration.setServletSecurity.ise",
        getName(), context.getName()));
  }
  return context.addServletSecurity(this, constraint);
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

@Override
public Set<String> setServletSecurity(ServletSecurityElement constraint) {
  if (constraint == null) {
    throw new IllegalArgumentException(sm.getString(
        "applicationServletRegistration.setServletSecurity.iae",
        getName(), context.getName()));
  }
  
  if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
    throw new IllegalStateException(sm.getString(
        "applicationServletRegistration.setServletSecurity.ise",
        getName(), context.getName()));
  }
  return context.addServletSecurity(this, constraint);
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

@Override
public Set<String> setServletSecurity(ServletSecurityElement constraint) {
  if (constraint == null) {
    throw new IllegalArgumentException(sm.getString(
        "applicationServletRegistration.setServletSecurity.iae",
        getName(), context.getName()));
  }
  
  if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
    throw new IllegalStateException(sm.getString(
        "applicationServletRegistration.setServletSecurity.ise",
        getName(), context.getName()));
  }
  return context.addServletSecurity(this, constraint);
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

@Override
public Set<String> setServletSecurity(ServletSecurityElement constraint) {
  if (constraint == null) {
    throw new IllegalArgumentException(sm.getString(
        "applicationServletRegistration.setServletSecurity.iae",
        getName(), context.getName()));
  }
  if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
    throw new IllegalStateException(sm.getString(
        "applicationServletRegistration.setServletSecurity.ise",
        getName(), context.getName()));
  }
  this.constraint = constraint;
  return context.addServletSecurity(this, constraint);
}

代码示例来源:origin: codefollower/Tomcat-Research

private void reload(DeployedApplication app) {
  if(log.isInfoEnabled())
    log.info(sm.getString("hostConfig.reload", app.name));
  Context context = (Context) host.findChild(app.name);
  if (context.getState().isAvailable()) {
    // Reload catches and logs exceptions
    context.reload();
  } else {
    // If the context was not started (for example an error
    // in web.xml) we'll still get to try to start
    try {
      context.start();
    } catch (Exception e) {
      log.warn(sm.getString
           ("hostConfig.context.restart", app.name), e);
    }
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

private void reload(DeployedApplication app, File fileToRemove, String newDocBase) {
  if(log.isInfoEnabled())
    log.info(sm.getString("hostConfig.reload", app.name));
  Context context = (Context) host.findChild(app.name);
  if (context.getState().isAvailable()) {
    if (fileToRemove != null && newDocBase != null) {
      context.addLifecycleListener(
          new ExpandedDirectoryRemovalListener(fileToRemove, newDocBase));
    }
    // Reload catches and logs exceptions
    context.reload();
  } else {
    // If the context was not started (for example an error
    // in web.xml) we'll still get to try to start
    if (fileToRemove != null && newDocBase != null) {
      ExpandWar.delete(fileToRemove);
      context.setDocBase(newDocBase);
    }
    try {
      context.start();
    } catch (Exception e) {
      log.warn(sm.getString
           ("hostConfig.context.restart", app.name), e);
    }
  }
}

相关文章

微信公众号

最新文章

更多

Context类方法