Search in sources :

Example 1 with Connector

use of org.eclipse.jetty.ant.types.Connector in project jetty.project by eclipse.

the class JettyRunTask method execute.

/**
     * Executes this Ant task. The build flow is being stopped until Jetty
     * server stops.
     *
     * @throws BuildException if unable to build
     */
public void execute() throws BuildException {
    TaskLog.log("Configuring Jetty for project: " + getProject().getName());
    setSystemProperties();
    List<Connector> connectorsList = null;
    if (connectors != null)
        connectorsList = connectors.getConnectors();
    else
        connectorsList = new Connectors(jettyPort, 30000).getDefaultConnectors();
    List<LoginService> loginServicesList = (loginServices != null ? loginServices.getLoginServices() : new ArrayList<LoginService>());
    ServerProxyImpl server = new ServerProxyImpl();
    server.setConnectors(connectorsList);
    server.setLoginServices(loginServicesList);
    server.setRequestLog(requestLog);
    server.setJettyXml(jettyXml);
    server.setDaemon(daemon);
    server.setStopPort(stopPort);
    server.setStopKey(stopKey);
    server.setContextHandlers(contextHandlers);
    server.setTempDirectory(tempDirectory);
    server.setScanIntervalSecs(scanIntervalSeconds);
    try {
        for (WebAppContext webapp : webapps) {
            server.addWebApplication((AntWebAppContext) webapp);
        }
    } catch (Exception e) {
        throw new BuildException(e);
    }
    server.start();
}
Also used : Connectors(org.eclipse.jetty.ant.types.Connectors) Connector(org.eclipse.jetty.ant.types.Connector) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) ArrayList(java.util.ArrayList) BuildException(org.apache.tools.ant.BuildException) LoginService(org.eclipse.jetty.security.LoginService) BuildException(org.apache.tools.ant.BuildException)

Example 2 with Connector

use of org.eclipse.jetty.ant.types.Connector in project jetty.project by eclipse.

the class ServerProxyImpl method configure.

/**
     * Configures Jetty server before adding any web applications to it.
     */
private void configure() {
    if (configured)
        return;
    configured = true;
    if (stopPort > 0 && stopKey != null) {
        ShutdownMonitor monitor = ShutdownMonitor.getInstance();
        monitor.setPort(stopPort);
        monitor.setKey(stopKey);
        monitor.setExitVm(false);
    }
    if (tempDirectory != null && !tempDirectory.exists())
        tempDirectory.mkdirs();
    // Applies external configuration via jetty.xml
    applyJettyXml();
    // Configures connectors for this server instance.
    if (connectors != null) {
        for (Connector c : connectors) {
            ServerConnector jc = new ServerConnector(server);
            jc.setPort(c.getPort());
            jc.setIdleTimeout(c.getMaxIdleTime());
            server.addConnector(jc);
        }
    }
    // Configures login services
    if (loginServices != null) {
        for (LoginService ls : loginServices) {
            server.addBean(ls);
        }
    }
    // Does not cache resources, to prevent Windows from locking files
    Resource.setDefaultUseCaches(false);
    // Set default server handlers
    configureHandlers();
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) ServerConnector(org.eclipse.jetty.server.ServerConnector) Connector(org.eclipse.jetty.ant.types.Connector) ShutdownMonitor(org.eclipse.jetty.server.ShutdownMonitor) LoginService(org.eclipse.jetty.security.LoginService)

Aggregations

Connector (org.eclipse.jetty.ant.types.Connector)2 LoginService (org.eclipse.jetty.security.LoginService)2 ArrayList (java.util.ArrayList)1 BuildException (org.apache.tools.ant.BuildException)1 Connectors (org.eclipse.jetty.ant.types.Connectors)1 ServerConnector (org.eclipse.jetty.server.ServerConnector)1 ShutdownMonitor (org.eclipse.jetty.server.ShutdownMonitor)1 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)1