CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-jboss-shrinkwrap--shrinkwrap-impl-base

Common base implementations for the ShrinkWrap project enabling declarative assembly of Java archives (JAR, WAR, EAR, RAR) in code

Pending
Overview
Eval results
Files

archive-bases.mddocs/

Archive Base Classes

The archive base classes provide foundational implementations for all ShrinkWrap archive types. These abstract classes handle core functionality including memory management, content operations, and thread safety.

Core Base Classes

MemoryMapArchiveBase<T>

Thread-safe memory-based archive storage implementation that serves as the foundation for most archive types.

public abstract class MemoryMapArchiveBase<T extends Archive<T>> extends ArchiveBase<T>

Key Features:

  • In-memory content storage using LinkedHashMap
  • Thread-safe operations with synchronized access
  • Support for archive events and handlers
  • Content merging and filtering capabilities

Common Usage:

// Extend for custom archive implementations
public class CustomArchiveImpl extends MemoryMapArchiveBase<CustomArchive> {
    public CustomArchiveImpl(String archiveName) {
        super(archiveName, CustomArchive.class);
    }
}

AssignableBase<T>

Base implementation for archives that support type conversion through the as() method.

public abstract class AssignableBase<T extends Assignable> implements Assignable

Key Methods:

public <TYPE extends Assignable> TYPE as(Class<TYPE> clazz)

Usage Example:

// Convert archive to different exporter type
InputStream stream = archive.as(ZipExporter.class).exportAsInputStream();

ArchiveBase<T>

Root abstract class providing common archive operations and implementing core interfaces.

public abstract class ArchiveBase<T extends Archive<T>> implements Archive<T>, Configurable, ArchiveFormatAssociable, Identifiable

Core Operations:

  • Content addition and retrieval
  • Path-based access to archive nodes
  • Archive merging and filtering
  • Configuration management

Support Classes

ServiceExtensionLoader

Loads ShrinkWrap extensions using the Java ServiceLoader pattern.

public class ServiceExtensionLoader implements ExtensionLoader

Key Methods:

public <T> Collection<T> load(Class<T> serviceClass, ClassLoader classLoader)
public void addOverride(Class<?> serviceClass, Class<?> implementationClass)

Usage:

ServiceExtensionLoader loader = new ServiceExtensionLoader();
Collection<ZipExporter> exporters = loader.load(ZipExporter.class, classLoader);

URLPackageScanner

Scans packages from URLs for class discovery and dynamic loading.

public class URLPackageScanner

Key Methods:

public static Set<Class<?>> scanPackage(String packageName, ClassLoader classLoader)
public static Set<String> getClassNamesFromJar(URL jarUrl, String packageName)

NodeImpl

Implementation of the Archive Node interface representing archive entries.

public class NodeImpl implements Node

Key Methods:

public ArchivePath getPath()
public Asset getAsset()
public Set<Node> getChildren()
public Node getChild(ArchivePath path)

Usage:

Node node = new NodeImpl(new BasicPath("/META-INF"), asset);
Set<Node> children = node.getChildren();

Configuration and Utilities

ExtensionWrapper

Wrapper for extension instances providing lazy loading and caching.

public class ExtensionWrapper<T>

ArchiveFormatStreamBindings

Manages bindings between archive formats and their associated stream handlers.

public class ArchiveFormatStreamBindings

Key Methods:

public static void bind(ArchiveFormat format, Class<? extends StreamExporter> exporterClass)
public static Class<? extends StreamExporter> getExporterClass(ArchiveFormat format)

Exception Handling

ExtensionLoadingException

Runtime exception thrown when extension loading fails.

public class ExtensionLoadingException extends RuntimeException

Constructors:

public ExtensionLoadingException(String message)
public ExtensionLoadingException(String message, Throwable cause)

Common Scenarios:

  • Service loader failures
  • Missing extension classes
  • Configuration errors

Thread Safety

All base classes are designed with thread safety in mind:

  • MemoryMapArchiveBase: Uses synchronized access to internal content map
  • ServiceExtensionLoader: Thread-safe service loading and caching
  • NodeImpl: Immutable node structure with thread-safe operations

Extension Points

The base classes provide several extension points for custom implementations:

  1. Custom Archive Types: Extend MemoryMapArchiveBase for new archive formats
  2. Extension Loading: Override ServiceExtensionLoader for custom loading logic
  3. Node Implementation: Extend NodeImpl for specialized archive entry behavior
  4. Configuration: Implement custom configuration providers through the base interfaces

Install with Tessl CLI

npx tessl i tessl/maven-org-jboss-shrinkwrap--shrinkwrap-impl-base

docs

archive-bases.md

assets.md

containers.md

import-export.md

index.md

specifications.md

utilities.md

tile.json