com.vaadin.base.devserver.

Class AbstractDevServerRunner

    • Constructor Detail

      • AbstractDevServerRunner

        protected AbstractDevServerRunner(Lookup lookup,
                                          int runningPort,
                                          File npmFolder,
                                          CompletableFuture<Void> waitFor)

        Craete an instance that waits for the given task to complete before starting or connecting to the server.

        Parameters:

        lookup - a lookup instance

        runningPort - the port that a dev server is already running on or 0 to start a new server

        npmFolder - the project root

        waitFor - the task to wait for before running the server.

    • Method Detail

      • getServerBinary

        protected abstract File getServerBinary()

        Gets the binary that starts the dev server.

      • getServerConfig

        protected abstract File getServerConfig()

        Gets the main configuration file for the dev server.

      • getServerName

        protected abstract String getServerName()

        Gets the name of the dev server for outputting to the user and statistics.

      • getServerStartupCommand

        protected abstract List<String> getServerStartupCommand(String nodeExec)

        Gets the commands to run to start the dev server.

        Parameters:

        nodeExec - the path to the node binary

      • updateServerStartupEnvironment

        protected void updateServerStartupEnvironment(FrontendTools frontendTools,
                                                      Map<String,String> environment)

        Defines the environment variables to use when starting the dev server.

        Parameters:

        frontendTools - frontend tools metadata

        environment - the environment variables to use

      • getServerSuccessPattern

        protected abstract Pattern getServerSuccessPattern()

        Gets a pattern to match with the output to determine that the server has started successfully.

      • getServerFailurePattern

        protected abstract Pattern getServerFailurePattern()

        Gets a pattern to match with the output to determine that the server has failed to start.

      • doStartDevServer

        protected Process doStartDevServer()

        Starts the dev server and returns the started process.

        Returns:

        the started process or null if no process was started

      • onDevServerCompilation

        protected void onDevServerCompilation(DevServerOutputTracker.Result result)

        Called whenever the dev server output matche the success or failure pattern.

      • getFailedOutput

        public String getFailedOutput()

        Description copied from interface: DevModeHandler

        Return the dev server console output when a compilation error happened.

        Specified by:

        getFailedOutput in interface DevModeHandler

        Returns:

        console output if error or null otherwise.

      • getWatchDog

        protected com.vaadin.base.devserver.DevServerWatchDog getWatchDog()

        Gets the server watch dog.

        Returns:

        the watch dog

      • triggerLiveReload

        protected void triggerLiveReload()

        Triggers live reload.

      • getApplicationConfiguration

        protected ApplicationConfiguration getApplicationConfiguration()

        Gets the application configuration.

        Returns:

        the application configuration

      • checkConnection

        protected boolean checkConnection()

        Check the connection to the dev server.

        Returns:

        true if the dev server is responding correctly, false otherwise

      • getPort

        public int getPort()

        Get the listening port of the dev server.

        Returns:

        the listening port

      • waitForDevServer

        public void waitForDevServer()

        Waits for the dev server to start.

        Suspends the caller's thread until the dev mode server is started (or failed to start).

      • handleRequest

        public boolean handleRequest(VaadinSession session,
                                     VaadinRequest request,
                                     VaadinResponse response)
                              throws IOException

        Description copied from interface: RequestHandler

        Called when a request needs to be handled. If a response is written, this method should return true to indicate that no more request handlers should be invoked for the request.

        Note that request handlers by default do not lock the session. If you are using VaadinSession or anything inside the VaadinSession you must ensure the session is locked. This can be done by extending SynchronizedRequestHandler or by using VaadinSession.accessSynchronously(Command) or UI.accessSynchronously(Command).

        Specified by:

        handleRequest in interface RequestHandler

        Parameters:

        session - The session for the request

        request - The request to handle

        response - The response object to which a response can be written.

        Returns:

        true if a response has been written and no further request handlers should be called, otherwise false

        Throws:

        IOException - If an IO error occurred

      • serveDevModeRequest

        public boolean serveDevModeRequest(javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response)
                                    throws IOException

        Serve a file by proxying to the dev server.

        Note: it considers the HttpServletRequest.getPathInfo() that will be the path passed to the dev server which is running in the context root folder of the application.

        Method returns false immediately if dev server failed on its startup.

        Specified by:

        serveDevModeRequest in interface DevModeHandler

        Parameters:

        request - the servlet request

        response - the servlet response

        Returns:

        false if the dev server returned a not found, true otherwise

        Throws:

        IOException - in the case something went wrong like connection refused