0
# ShrinkWrap Implementation Base
1
2
ShrinkWrap Implementation Base provides common base implementations for the ShrinkWrap project, enabling declarative assembly of Java archives (JAR, WAR, EAR, RAR) in code. This library serves as the foundation for creating, manipulating, and exporting various archive formats without requiring build scripts or external tools.
3
4
## Package Information
5
6
- **Package Name**: shrinkwrap-impl-base
7
- **Package Type**: maven
8
- **Language**: Java
9
- **Group ID**: org.jboss.shrinkwrap
10
- **Artifact ID**: shrinkwrap-impl-base
11
- **Version**: 1.2.6
12
- **Installation**: Add to Maven POM:
13
14
```xml
15
<dependency>
16
<groupId>org.jboss.shrinkwrap</groupId>
17
<artifactId>shrinkwrap-impl-base</artifactId>
18
<version>1.2.6</version>
19
</dependency>
20
```
21
22
## Core Imports
23
24
Primary base classes for archive implementations:
25
26
```java
27
import org.jboss.shrinkwrap.impl.base.MemoryMapArchiveBase;
28
import org.jboss.shrinkwrap.impl.base.container.ContainerBase;
29
import org.jboss.shrinkwrap.impl.base.spec.JavaArchiveImpl;
30
import org.jboss.shrinkwrap.impl.base.spec.WebArchiveImpl;
31
```
32
33
Exporters and importers:
34
35
```java
36
import org.jboss.shrinkwrap.impl.base.exporter.ZipExporterImpl;
37
import org.jboss.shrinkwrap.impl.base.exporter.ExplodedExporterImpl;
38
import org.jboss.shrinkwrap.impl.base.importer.ZipImporterImpl;
39
```
40
41
Utilities and path handling:
42
43
```java
44
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
45
import org.jboss.shrinkwrap.impl.base.ServiceExtensionLoader;
46
```
47
48
## Basic Usage
49
50
Creating and working with archive implementations:
51
52
```java
53
import org.jboss.shrinkwrap.impl.base.spec.JavaArchiveImpl;
54
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
55
import org.jboss.shrinkwrap.api.Archive;
56
57
// Create a JAR archive implementation
58
JavaArchiveImpl archive = new JavaArchiveImpl("myapp.jar");
59
60
// Add content using the container base functionality
61
archive.addClass(MyClass.class);
62
archive.addAsResource("config.properties");
63
64
// Work with archive paths
65
BasicPath path = new BasicPath("/META-INF/MANIFEST.MF");
66
67
// Export to different formats
68
InputStream zipStream = archive.as(ZipExporter.class).exportAsInputStream();
69
```
70
71
## Architecture
72
73
The impl-base module is organized into several key architectural layers:
74
75
- **Base Classes**: Abstract implementations providing core archive functionality
76
- **Container Implementations**: Concrete archive type implementations (JAR, WAR, EAR, RAR)
77
- **Import/Export System**: Pluggable format support for various archive types
78
- **Path Management**: Archive path abstraction and utilities
79
- **Extension System**: Service loader-based extension mechanism
80
81
## Capabilities
82
83
### Archive Base Classes
84
Foundational abstract classes providing core archive functionality including memory management, content operations, and thread safety.
85
86
**Key API interfaces:**
87
```java { .api }
88
public abstract class MemoryMapArchiveBase<T extends Archive<T>> implements Archive<T>
89
public abstract class AssignableBase<T extends Assignable> implements Assignable
90
```
91
92
[Archive Base Classes](./archive-bases.md)
93
94
### Container Implementations
95
Complete implementations for standard Java archive types with specialized container operations.
96
97
**Key API interfaces:**
98
```java { .api }
99
public abstract class ContainerBase<T extends Archive<T>> implements Archive<T>
100
public class JavaArchiveImpl extends ContainerBase<JavaArchive> implements JavaArchive
101
public class WebArchiveImpl extends WebContainerBase<WebArchive> implements WebArchive
102
```
103
104
[Container Implementations](./containers.md)
105
106
### Archive Specifications
107
Concrete archive type implementations for JAR, WAR, EAR, and RAR formats with full specification compliance.
108
109
**Key API interfaces:**
110
```java { .api }
111
public class JavaArchiveImpl implements JavaArchive
112
public class WebArchiveImpl implements WebArchive
113
public class EnterpriseArchiveImpl implements EnterpriseArchive
114
```
115
116
[Archive Specifications](./specifications.md)
117
118
### Import and Export
119
Comprehensive support for importing from and exporting to various archive formats including ZIP, TAR, and exploded directories.
120
121
**Key API interfaces:**
122
```java { .api }
123
public class ZipExporterImpl implements ZipExporter
124
public class ExplodedExporterImpl implements ExplodedExporter
125
public class ZipImporterImpl implements ZipImporter
126
```
127
128
[Import and Export](./import-export.md)
129
130
### Path and Filter Utilities
131
Archive path manipulation and content filtering capabilities for selective archive operations.
132
133
**Key API interfaces:**
134
```java { .api }
135
public class BasicPath implements ArchivePath
136
public class IncludeRegExpPaths implements Filter<ArchivePath>
137
public class ExcludePaths implements Filter<ArchivePath>
138
```
139
140
[Path and Filter Utilities](./utilities.md)
141
142
### Asset Management
143
Asset implementations for various content types including service providers and ZIP entries.
144
145
**Key API interfaces:**
146
```java { .api }
147
public class ServiceProviderAsset implements Asset
148
public class ZipFileEntryAsset implements Asset
149
```
150
151
[Asset Management](./assets.md)
152
153
## Error Handling
154
155
The library defines specific exceptions for common error scenarios:
156
157
```java { .api }
158
public class ExtensionLoadingException extends RuntimeException
159
```
160
161
Common error handling patterns:
162
- Extension loading failures throw `ExtensionLoadingException`
163
- Path-related errors use standard `IllegalArgumentException`
164
- Archive operation failures use ShrinkWrap API exceptions