Example usage for org.hibernate.boot.archive.scan.spi ScanEnvironment getRootUrl

List of usage examples for org.hibernate.boot.archive.scan.spi ScanEnvironment getRootUrl

Introduction

In this page you can find the example usage for org.hibernate.boot.archive.scan.spi ScanEnvironment getRootUrl.

Prototype

public URL getRootUrl();

Source Link

Document

Returns the root URL for scanning.

Usage

From source file:de.micromata.genome.jpa.impl.JpaWithExtLibrariesScanner.java

License:Apache License

@Override
public ScanResult scan(ScanEnvironment environment, ScanOptions options, ScanParameters parameters) {
    ScanResultCollector collector = new ScanResultCollector(environment, options, parameters);

    if (environment.getNonRootUrls() != null) {
        ArchiveContext context = new ArchiveContextImpl(false, collector);
        for (URL url : environment.getNonRootUrls()) {
            ArchiveDescriptor descriptor = buildArchiveDescriptor(url, false);
            descriptor.visitArchive(context);
        }/*from w  ww  . j  av a  2  s .  c o m*/
    }
    Set<URL> loadedUrls = new HashSet<>();
    if (environment.getRootUrl() != null) {
        URL rootUrl = environment.getRootUrl();
        visitUrl(rootUrl, collector, CommonMatchers.always());
    }
    visitExternUrls(environment, collector, loadedUrls);
    return collector.toScanResult();
}

From source file:org.ligoj.bootstrap.core.dao.ResourceScanner.java

License:MIT License

/**
 * Perform the scanning against the described persistence unit using the defined options, and return the scan
 * results.//from w  ww  .  ja  va2s . c  o m
 * 
 * @param scanOptions
 *            The scan options
 * @return The scan results.
 */
@Override
public ScanResult scan(final ScanEnvironment environment, final ScanOptions scanOptions,
        final ScanParameters parameters) {

    try {
        final Set<URL> urls = new LinkedHashSet<>(environment.getNonRootUrls()); // NOSONAR - Requested by Hibernate
        urls.addAll(
                Collections.list(getOrmUrls()).stream().map(this::getJarUrlSafe).collect(Collectors.toList()));

        // Remove the root URL from the non root list
        urls.remove(environment.getRootUrl());

        // Replace the URL with the new set
        environment.getNonRootUrls().clear();
        environment.getNonRootUrls().addAll(urls);
        return super.scan(environment, scanOptions, parameters);
    } catch (final IOException e) {
        throw new IllegalStateException("Unable to read ORM Jars", e);
    }
}