Interface PackageRegistry
-
@ProviderType public interface PackageRegistry
The package registry is the next generationPackageManager
andJcrPackageManager
. It defines storage independent methods to register (upload), enumerate and remove packages. The installation lifecycle of the packages is provided viaExecutionPlan
s.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DependencyReport
analyzeDependencies(PackageId id, boolean onlyInstalled)
Creates a dependency report that lists the resolved and unresolved dependencies.boolean
contains(PackageId id)
Checks if this registry contains the package with the given id.ExecutionPlanBuilder
createExecutionPlan()
Creates a new execution plan builder.RegisteredPackage
open(PackageId id)
Opens the package with the given id.java.util.Set<PackageId>
packages()
Returns as set of all packages registered in this registry.PackageId
register(java.io.File file, boolean replace)
Registers a package provided via a file.PackageId
register(java.io.InputStream in, boolean replace)
Registers a package provided via an input stream.PackageId
registerExternal(java.io.File file, boolean replace)
Registers a package provided via an external file.void
remove(PackageId id)
Removes the package from this registry.PackageId
resolve(Dependency dependency, boolean onlyInstalled)
Tries to resolve the given dependency and returns the id of the package that matches the dependency filter best.PackageId[]
usage(PackageId id)
Returns the package ids of installed packages that depend on the given package.
-
-
-
Method Detail
-
contains
boolean contains(@Nonnull PackageId id) throws java.io.IOException
Checks if this registry contains the package with the given id.- Parameters:
id
- the package id.- Returns:
true
if the package is registered.- Throws:
java.io.IOException
- if an I/O error occurrs.
-
packages
@Nonnull java.util.Set<PackageId> packages() throws java.io.IOException
Returns as set of all packages registered in this registry.- Returns:
- a set of package ids.
- Throws:
java.io.IOException
- if an I/O error occurrs.
-
open
@Nullable RegisteredPackage open(@Nonnull PackageId id) throws java.io.IOException
Opens the package with the given id.- Parameters:
id
- the package id- Returns:
- the package or
null
if it does not exists. - Throws:
java.io.IOException
- if an I/O error occurrs.
-
register
@Nonnull PackageId register(@Nonnull java.io.InputStream in, boolean replace) throws java.io.IOException, PackageExistsException
Registers a package provided via an input stream. The method fails, if a package with the same id already exists, andreplace
is set tofalse
. otherwise the existing package is replaced.- Parameters:
in
- the input stream to the package datareplace
-true
if existing package should be replaced.- Returns:
- the new package id.
- Throws:
java.io.IOException
- if an I/O error occurrs.PackageExistsException
- if the package exists andreplace
isfalse
.
-
register
@Nonnull PackageId register(@Nonnull java.io.File file, boolean replace) throws java.io.IOException, PackageExistsException
Registers a package provided via a file. The method fails, if a package with the same id already exists, andreplace
is set tofalse
; otherwise the existing package is replaced.- Parameters:
file
- the file to the package datareplace
-true
if existing package should be replaced.- Returns:
- the new package id.
- Throws:
java.io.IOException
- if an I/O error occurrs.PackageExistsException
- if the package exists andreplace
isfalse
.
-
registerExternal
@Nonnull PackageId registerExternal(@Nonnull java.io.File file, boolean replace) throws java.io.IOException, PackageExistsException
Registers a package provided via an external file. The binary data of the package will not be copied into the underlying persistence but only be referenced. Removing such a linked package afterwards will not delete the original file. The method fails, if a package with the same id already exists, andreplace
is set tofalse
; otherwise the existing package is replaced.- Parameters:
file
- the file to the package data.replace
-true
if existing package should be replaced.- Returns:
- the new package id.
- Throws:
java.io.IOException
- if an I/O error occurrs.PackageExistsException
- if the package exists andreplace
isfalse
.
-
remove
void remove(@Nonnull PackageId id) throws java.io.IOException, NoSuchPackageException
Removes the package from this registry.- Parameters:
id
- the id of the package to remove- Throws:
java.io.IOException
- if an I/O error occurrs.NoSuchPackageException
- if the package does not exist
-
analyzeDependencies
@Nonnull DependencyReport analyzeDependencies(@Nonnull PackageId id, boolean onlyInstalled) throws java.io.IOException, NoSuchPackageException
Creates a dependency report that lists the resolved and unresolved dependencies.- Parameters:
id
- the package id.onlyInstalled
- iftrue
only installed packages are used for resolution- Returns:
- the report
- Throws:
java.io.IOException
- if an error accessing the repository occurrsNoSuchPackageException
- if the package with the givenid
does not exist.
-
resolve
@Nullable PackageId resolve(@Nonnull Dependency dependency, boolean onlyInstalled) throws java.io.IOException
Tries to resolve the given dependency and returns the id of the package that matches the dependency filter best.- Parameters:
dependency
- the dependency to resolve against.onlyInstalled
- iftrue
only installed packages are respected.- Returns:
- the package id or
null
- Throws:
java.io.IOException
- if an I/O error occurrs.
-
usage
@Nonnull PackageId[] usage(@Nonnull PackageId id) throws java.io.IOException
Returns the package ids of installed packages that depend on the given package.- Parameters:
id
- the package id to search for- Returns:
- the array of package ids.
- Throws:
java.io.IOException
- if an I/O error occurs.
-
createExecutionPlan
@Nonnull ExecutionPlanBuilder createExecutionPlan()
Creates a new execution plan builder. The builder allows to create an execution plan for package installation related tasks.- Returns:
- a new builder
-
-