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;
}
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);
}
}
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;
}
Aggregations