views:

60

answers:

1

I have embedded Jetty in a java application and am calling the start() method on an instance of the Jetty server object (after setting a handler list which describes the location of the static and dynamic web content). Does the start() call block until initialization is complete? If not, how do I determine when the server is fully started and ready to receive requests?

A: 

Here's an example of how I've down this within ANT, launching firefox once the jetty application was ready

<parallel>
    <jetty tempDirectory="${work.dir}">
        <connectors>
            <selectChannelConnector port="${jetty.port}"/>
        </connectors>
        <webApp name="ex1" warfile="ex1.war" contextpath="/ex1"/>
    </jetty>

    <sequential>
        <waitfor maxwait="10" maxwaitunit="second">
            <http url="http://localhost:${jetty.port}/ex1"/&gt;
        </waitfor>

        <exec executable="firefox" spawn="yes">
            <arg line="http://localhost:${jetty.port}/ex1"/&gt;
        </exec>
    </sequential>
</parallel>
Mark O'Connor