Search in sources :

Example 11 with Package

use of org.expath.pkg.repo.Package in project exist by eXist-db.

the class ExistRepository method resolveJavaModule.

/**
 * Resolve a Java Module.
 *
 * @param namespace the namespace of the module
 * @param ctxt the xquery context
 * @return the Java module, or null
 *
 * @throws XPathException with:
 *      XQST0046 if the namespace URI is invalid
 */
public Module resolveJavaModule(final String namespace, final XQueryContext ctxt) throws XPathException {
    final URI uri;
    try {
        uri = new URI(namespace);
    } catch (final URISyntaxException ex) {
        throw new XPathException(ErrorCodes.XQST0046, "Invalid URI: " + namespace, ex);
    }
    for (final Packages pp : myParent.listPackages()) {
        final Package pkg = pp.latest();
        final ExistPkgInfo info = (ExistPkgInfo) pkg.getInfo("exist");
        if (info != null) {
            final String clazz = info.getJava(uri);
            if (clazz != null) {
                return getModule(clazz, namespace, ctxt);
            }
        }
    }
    return null;
}
Also used : XPathException(org.exist.xquery.XPathException) URISyntaxException(java.net.URISyntaxException) Package(org.expath.pkg.repo.Package) URI(java.net.URI)

Example 12 with Package

use of org.expath.pkg.repo.Package in project exist by eXist-db.

the class ClasspathHelper method scanPackages.

private static void scanPackages(BrokerPool pool, Classpath classpath) {
    try {
        final Optional<ExistRepository> repo = pool.getExpathRepo();
        if (repo.isPresent()) {
            for (final Packages pkgs : repo.get().getParentRepo().listPackages()) {
                final Package pkg = pkgs.latest();
                if (!isCompatible(pkg)) {
                    LOG.warn("Package {} is not compatible with this version of eXist. To avoid conflicts, Java libraries shipping with this package are not loaded.", pkg.getName());
                } else {
                    try {
                        final FileSystemStorage.FileSystemResolver resolver = (FileSystemStorage.FileSystemResolver) pkg.getResolver();
                        final Path packageDir = resolver.resolveResourceAsFile(".");
                        scanPackageDir(classpath, packageDir);
                    } catch (final IOException e) {
                        LOG.warn("An error occurred while updating classpath for package {}", pkg.getName(), e);
                    }
                }
            }
        }
    } catch (final Exception e) {
        LOG.warn("An error occurred while updating classpath for packages", e);
    }
}
Also used : Path(java.nio.file.Path) Packages(org.expath.pkg.repo.Packages) FileSystemStorage(org.expath.pkg.repo.FileSystemStorage) Package(org.expath.pkg.repo.Package) IOException(java.io.IOException) IOException(java.io.IOException) PackageException(org.expath.pkg.repo.PackageException)

Example 13 with Package

use of org.expath.pkg.repo.Package in project exist by eXist-db.

the class ExistRepository method getJavaModules.

public List<URI> getJavaModules() {
    final List<URI> modules = new ArrayList<>();
    for (final Packages pp : myParent.listPackages()) {
        final Package pkg = pp.latest();
        final ExistPkgInfo info = (ExistPkgInfo) pkg.getInfo("exist");
        if (info != null) {
            modules.addAll(info.getJavaModules());
        }
    }
    return modules;
}
Also used : Package(org.expath.pkg.repo.Package) URI(java.net.URI)

Aggregations

Package (org.expath.pkg.repo.Package)13 IOException (java.io.IOException)6 Path (java.nio.file.Path)5 BatchUserInteraction (org.expath.pkg.repo.tui.BatchUserInteraction)5 URI (java.net.URI)4 Txn (org.exist.storage.txn.Txn)4 Either (com.evolvedbinary.j8fu.Either)3 BufferedInputStream (java.io.BufferedInputStream)3 InputStream (java.io.InputStream)3 DirectoryStream (java.nio.file.DirectoryStream)3 Files (java.nio.file.Files)3 java.util (java.util)3 JarEntry (java.util.jar.JarEntry)3 JarInputStream (java.util.jar.JarInputStream)3 Stream (java.util.stream.Stream)3 Nullable (javax.annotation.Nullable)3 LogManager (org.apache.logging.log4j.LogManager)3 Logger (org.apache.logging.log4j.Logger)3 EXistException (org.exist.EXistException)3 SystemProperties (org.exist.SystemProperties)3