Search in sources :

Example 1 with Scanner

use of org.eclipse.jetty.util.Scanner in project jetty.project by eclipse.

the class ScanningAppProvider method doStart.

/* ------------------------------------------------------------ */
@Override
protected void doStart() throws Exception {
    if (LOG.isDebugEnabled())
        LOG.debug(this.getClass().getSimpleName() + ".doStart()");
    if (_monitored.size() == 0)
        throw new IllegalStateException("No configuration dir specified");
    LOG.info("Deployment monitor " + _monitored + " at interval " + _scanInterval);
    List<File> files = new ArrayList<>();
    for (Resource resource : _monitored) {
        if (resource.exists() && resource.getFile().canRead())
            files.add(resource.getFile());
        else
            LOG.warn("Does not exist: " + resource);
    }
    _scanner = new Scanner();
    _scanner.setScanDirs(files);
    _scanner.setScanInterval(_scanInterval);
    _scanner.setRecursive(_recursive);
    _scanner.setFilenameFilter(_filenameFilter);
    _scanner.setReportDirs(true);
    _scanner.addListener(_scannerListener);
    _scanner.start();
}
Also used : Scanner(org.eclipse.jetty.util.Scanner) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Resource(org.eclipse.jetty.util.resource.Resource) File(java.io.File)

Example 2 with Scanner

use of org.eclipse.jetty.util.Scanner in project blade by biezhi.

the class EmbedJettyServer method hotSwap.

public void hotSwap(int scanInterval, String resBase) throws Exception {
    Scanner scanner = new Scanner();
    scanner.setScanInterval(scanInterval);
    scanner.addScanDir(new File(resBase));
    scanner.addListener((Scanner.BulkListener) fileNames -> {
        webAppContext.stop();
        webAppContext.setResourceBase(resBase);
        webAppContext.start();
        webAppContext.getHandler().start();
    });
    LOGGER.info("Hot Swap scan interval is {}s.", scanInterval);
    scanner.start();
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet) StringKit(com.blade.kit.StringKit) Config(com.blade.kit.base.Config) AsyncDispatcherServlet(com.blade.mvc.dispatch.AsyncDispatcherServlet) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) BladeInitListener(com.blade.mvc.context.BladeInitListener) Map(java.util.Map) Filter(javax.servlet.Filter) EmbedServerException(com.blade.exception.EmbedServerException) Const(com.blade.Const) EnumSet(java.util.EnumSet) Blade.$(com.blade.Blade.$) Logger(org.slf4j.Logger) HandlerList(org.eclipse.jetty.server.handler.HandlerList) HttpServlet(javax.servlet.http.HttpServlet) Servlet(javax.servlet.Servlet) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) Set(java.util.Set) CollectionKit(com.blade.kit.CollectionKit) DynamicContext(com.blade.mvc.context.DynamicContext) File(java.io.File) org.eclipse.jetty.server(org.eclipse.jetty.server) DispatcherServlet(com.blade.mvc.dispatch.DispatcherServlet) Entry(java.util.Map.Entry) DispatcherType(javax.servlet.DispatcherType) Blade(com.blade.Blade) Scanner(org.eclipse.jetty.util.Scanner) Scanner(org.eclipse.jetty.util.Scanner) File(java.io.File)

Example 3 with Scanner

use of org.eclipse.jetty.util.Scanner in project jetty.project by eclipse.

the class ServerProxyImpl method startScanners.

/**
     * Starts web applications' scanners.
     */
private void startScanners() throws Exception {
    for (AntWebAppContext awc : webApplications) {
        if (scanIntervalSecs <= 0)
            return;
        List<File> scanList = awc.getScanFiles();
        TaskLog.log("Web application '" + awc + "': starting scanner at interval of " + scanIntervalSecs + " seconds.");
        Scanner.Listener changeListener = new WebAppScannerListener(awc);
        Scanner scanner = new Scanner();
        scanner.setScanInterval(scanIntervalSecs);
        scanner.addListener(changeListener);
        scanner.setScanDirs(scanList);
        scanner.setReportExistingFilesOnStartup(false);
        scanner.start();
    }
}
Also used : Scanner(org.eclipse.jetty.util.Scanner) File(java.io.File)

Aggregations

File (java.io.File)3 Scanner (org.eclipse.jetty.util.Scanner)3 Blade (com.blade.Blade)1 Blade.$ (com.blade.Blade.$)1 Const (com.blade.Const)1 EmbedServerException (com.blade.exception.EmbedServerException)1 CollectionKit (com.blade.kit.CollectionKit)1 StringKit (com.blade.kit.StringKit)1 Config (com.blade.kit.base.Config)1 BladeInitListener (com.blade.mvc.context.BladeInitListener)1 DynamicContext (com.blade.mvc.context.DynamicContext)1 AsyncDispatcherServlet (com.blade.mvc.dispatch.AsyncDispatcherServlet)1 DispatcherServlet (com.blade.mvc.dispatch.DispatcherServlet)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1