Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] ServletContextListener defers server start
  • From: Dirk Olmes <dirk.olmes@xxxxxxxxxx>
  • Date: Mon, 7 Oct 2019 09:10:44 +0000
  • Accept-language: de-DE, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=exentra.de; dmarc=pass action=none header.from=exentra.de; dkim=pass header.d=exentra.de; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EihZAGqWlbbXyJvh+ZYR5Pm+6+4yksbeVWqsdZ90DRw=; b=jmm4tgmDvNmq6zTwZ4s9dI7vz/VKiKnLz+0wdZb36n/L9TOm35SNuCi/JnvvaR835BB344p2xzCV8+aZaA3YX97Gvk0kmcE1UOs+WddC5sC0pM/0UtAIZREA2aTjtCxKD7fGPZHUhTYh3pFSQNXXUsF4sAOHTaDMqh8ugXMPG9Fz2/n1XJ2MAxJv4y0dyiN/BniNPyD1sHzOIOSrlZeqdHZvyfKH0U7caMGo9090PwEf7D2QXifEVzCR9i1gAVnYsWpQD7mzTeY5mbffKcam5zd1FZyWTOHHYW0srQkk5VJrbT/fM3hjTDOeLB7Evj6sa35LdL14qFdUEgKHneyFTQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L3MeQdu5s45v5OP+Jp2UGcLgRoKa9OKYP4jRrJgss+9f852uSNJ961l6Lrd03XTVUftu7GhDAU+qi5j8H/sGYWXMbXIXmIWYFf18NBNqXxzQ9duHnNke46yFAeo+TaDdV/L3K3je+F5xYs8I+WkdKS4VXsRj26YXLCKhJPxHtupZhswlsHD36Qii31msOLtDw9KBDK7Xq8pSY2nrEXV+Jbm/eGaJ2OzKpbv5pq2ux+X4GlezTxM5LzEXaH3nGy+C2DgLeFmPrsQG7urtMPjz1K84pnTYEXE+xBLwNYbPeJ86885uTPIbSifGbOVKI8oB63SF2dkPwUyLWZGeu180Jw==
  • Delivered-to: jetty-users@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/jetty-users>
  • List-help: <mailto:jetty-users-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/jetty-users>, <mailto:jetty-users-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/jetty-users>, <mailto:jetty-users-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AQHVerxZgNVPQSBpKkauFvJnVHLIQadKj9iAgACciACAA7xYgA==
  • Thread-topic: [jetty-users] ServletContextListener defers server start

On 10/5/19 2:07 AM, Greg Wilkins wrote:
> Dirk,

Hi Greg,

> Note that you can actually achieve this with just a little bit of work:
> 
> Write a simple context (extend context handler) that all it does is send a
> 503 with whatever message you want.
> Deploy both that context and your context at the same context path.  The
> 503 context will handle all the requests as it is first.
> Once your context is started, stop and/or remove the 503 context.

Thanks for the hint but I'm afraid it is not as simple as you describe -
or I'm still missing bits.

This is what I do for testing:

// this is the handler that just answers 503
ContextHandler duringStartup = new DuringStartupHandler();
// my app
ServletContextHandler theRealContext = ....
HandlerList handlerList = new HandlerList(duringStartup, theRealContext);
server.setHandler(handlerList);

Both handlers participate in the normal server startup, though, which
means that the ServerConnector still does not listen before the real app
context is ready. I'd think that my application context should be
started in a separate thread? Is there anything already present in Jetty
to accomplish this?

The full source of my tests is available here:
https://github.com/dirk-olmes/jetty-delayed-context-startup

-dirk


Back to the top