Скачать интернеты бесплатно без регистрации и СМС.
A sitemap builder.
See an example of usage.
- Create the sitemap.
SiteMap map = new SiteMap(new URI("https://host.com/foo/start"));
- Create a filler.
AsynchronousFillerInterface filler = new ThreadPoolFiller(map, 4); // This implementation uses Futures
There are no reasons to use a more generic FillerInterface
, but you can build your implementations for this one.
- Do fill.
filler.fill();
The thread will finish before the futures are completed. So you have to join them.
filler.await(); // or filler.fill().await();
- Get the result, e.g. print it somewhere.
Use implementations of the SerializerInterface
.
SerializerInterface serializer = new TxtSerializer();
There are:
It uses the strategy pattern against site maps.
Sting result = serializer.serialize(map);
Implement the SerializerInterface
and use it.
It is highly recommended implementing the AsynchronousFillerInterface
, e.g. using threads (even only one). Or you can
implement the more generic FillerInterface
.
At the moment the AsynchronousFillerInterface
proposes the onBeforeTaskCreated
callback which is implemented in the ThreadPoolFiller
via the TaskLifecycleHandlerInterface
interface.
More simply, it means that you can pass an implementation of the TaskLifecycleHandlerInterface
interface to the
constructor of ThreadPoolFiller
. This implementation will handle inscribed URIs before launch any task and handle
other URIs.