Package com.vaadin.copilot.rewriter
Class SourceSyncChecker
java.lang.Object
com.vaadin.copilot.rewriter.SourceSyncChecker
The
SourceSyncChecker is responsible for monitoring changes to Java
source files during development to identify scenarios where source files may
be out of sync with the running application or route view is deleted by the
user.-
Constructor Summary
ConstructorsConstructorDescriptionSourceSyncChecker(com.vaadin.flow.internal.DevModeHandlerManager devModeHandler, Executor startupExecutor) Starts the source file watcher with the given application configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDeletedView(com.vaadin.flow.component.Component component) Stores component class into the deleted views list so thatSuggestRestartExceptioncan be thrown when it is requestedvoidaddDeletedView(String qualifiedClassName) Stores the given class name as the view is removedbooleanisViewDeleted(String qualifiedClassName) booleanmaybeOutOfSync(ComponentInfoNotFoundException exception) Looks for file has been updated since the startup.voidthrowIfViewDeleted(ComponentTypeAndSourceLocation componentTypeAndSourceLocation) Throws an exception if class from the givencomponentTypeAndSourceLocationis deleted during the lifetime of the application.
-
Constructor Details
-
SourceSyncChecker
public SourceSyncChecker(com.vaadin.flow.internal.DevModeHandlerManager devModeHandler, Executor startupExecutor) Starts the source file watcher with the given application configuration.Starting the watchers walks and hashes the whole source tree, which can be slow on large trees, network/virtualized drives, or when antivirus software scans every file open. That work is therefore performed asynchronously on a background thread so it does not block the Copilot connect thread (which would otherwise stall
Copilot.handleConnect, leaving the browser UI loaded but empty and blocking other sessions on the shared session map lock). Callers that need the watchers to be running can wait viaawaitWatchersStarted(long, TimeUnit).- Parameters:
devModeHandler- flow dev mode handler for registering file watcher shut downstartupExecutor- executor used to run the source-tree walk off the calling thread (typicallyVaadinService.getExecutor())
-
-
Method Details
-
maybeOutOfSync
Looks for file has been updated since the startup. Additionally, caches exceptions that happens without any files changes.- Parameters:
exception- Exception that happens when finding component info fails.- Returns:
- true if file may be out of sync, false otherwise
-
addDeletedView
Stores the given class name as the view is removed- Parameters:
qualifiedClassName- fully qualified class name of a view
-
addDeletedView
public void addDeletedView(com.vaadin.flow.component.Component component) Stores component class into the deleted views list so thatSuggestRestartExceptioncan be thrown when it is requested- Parameters:
component- Flow node
-
throwIfViewDeleted
public void throwIfViewDeleted(ComponentTypeAndSourceLocation componentTypeAndSourceLocation) throws SuggestRestartException Throws an exception if class from the givencomponentTypeAndSourceLocationis deleted during the lifetime of the application.- Parameters:
componentTypeAndSourceLocation-- Throws:
SuggestRestartException- is thrown when file is not present
-
isViewDeleted
-