Java Code Examples for org.eclipse.jetty.server.Server#getChildHandlerByClass()

The following examples show how to use org.eclipse.jetty.server.Server#getChildHandlerByClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeploymentCheck.java    From jetty-runtime with Apache License 2.0 6 votes vote down vote up
@Override
public void lifeCycleStarted(LifeCycle bean) {
  if (bean instanceof Server) {
    Server server = (Server)bean;
    Connector[] connectors = server.getConnectors();
    if (connectors == null || connectors.length == 0) {
      server.dumpStdErr();
      throw new IllegalStateException("No Connector");
    } else if (!Arrays.stream(connectors).allMatch(Connector::isStarted)) {
      server.dumpStdErr();
      throw new IllegalStateException("Connector not started");
    }
    ContextHandler context = server.getChildHandlerByClass(ContextHandler.class);
    if (context == null || !context.isAvailable()) {
      server.dumpStdErr();
      throw new IllegalStateException("No Available Context");
    }
  }
}
 
Example 2
Source File: JettyServer.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
private static void logStartupBanner(Server server) {
  Object banner = null;

  ContextHandler contextHandler = server.getChildHandlerByClass(ContextHandler.class);
  if (contextHandler != null) {
    Context context = contextHandler.getServletContext();
    if (context != null) {
      banner = context.getAttribute("nexus-banner");
    }
  }

  StringBuilder buf = new StringBuilder();
  buf.append("\n-------------------------------------------------\n\n");
  buf.append("Started ").append(banner instanceof String ? banner : "Nexus Repository Manager");
  buf.append("\n\n-------------------------------------------------");
  log.info(buf.toString());
}
 
Example 3
Source File: NanoSparqlServer.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the {@link WebAppContext} for the {@link Server}.
 * 
 * @param server
 *            The {@link Server}.
 *            
 * @return The {@link WebAppContext} associated with the bigdata webapp.
 */
public static WebAppContext getWebApp(final Server server) {

    final WebAppContext wac = server
            .getChildHandlerByClass(WebAppContext.class);

    /*
     * Note: This assumes that this is the webapp for bigdata. If there are
     * multiple webapps then this assumption is no longer valid and things
     * will break.
     */
 
    return wac;

}