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

specifications.mddocs/

Archive Specifications

Archive specification implementations provide concrete implementations for standard Java archive formats (JAR, WAR, EAR, RAR) with full compliance to their respective specifications.

JAR Archives

JavaArchiveImpl

Complete implementation of Java Archive (JAR) format with standard JAR functionality.

public class JavaArchiveImpl extends ContainerBase<JavaArchive> implements JavaArchive

Constructors:

public JavaArchiveImpl(String archiveName)

Key Features:

  • Standard JAR file structure
  • Manifest handling (META-INF/MANIFEST.MF)
  • Service provider configuration (META-INF/services/)
  • Class and resource packaging
  • Library dependencies

Usage Example:

JavaArchiveImpl jar = new JavaArchiveImpl("application.jar");
jar.addClass(Application.class)
   .addPackage("com.example.core")
   .addAsResource("config.properties")
   .setManifest("META-INF/MANIFEST.MF");

Web Archives

WebArchiveImpl

Complete implementation of Web Archive (WAR) format for web applications.

public class WebArchiveImpl extends WebContainerBase<WebArchive> implements WebArchive

Constructors:

public WebArchiveImpl(String archiveName)

Web-Specific Structure:

  • /WEB-INF/web.xml - Web application descriptor
  • /WEB-INF/classes/ - Web application classes
  • /WEB-INF/lib/ - Web application libraries
  • Root directory for web resources (HTML, CSS, JS, images)

Usage Example:

WebArchiveImpl war = new WebArchiveImpl("webapp.war");
war.addClass(ServletClass.class)
   .addAsWebResource("index.html")
   .addAsWebResource("css/style.css", "css/style.css")
   .setWebXML("WEB-INF/web.xml")
   .addAsLibrary(dependencyJar);

Enterprise Archives

EnterpriseArchiveImpl

Complete implementation of Enterprise Archive (EAR) format for enterprise applications.

public class EnterpriseArchiveImpl extends EnterpriseContainerBase<EnterpriseArchive> 
    implements EnterpriseArchive

Constructors:

public EnterpriseArchiveImpl(String archiveName)

Enterprise Structure:

  • META-INF/application.xml - Application descriptor
  • /lib/ - Shared libraries
  • Module archives (JAR, WAR, RAR)

Usage Example:

EnterpriseArchiveImpl ear = new EnterpriseArchiveImpl("enterprise.ear");
ear.addAsModule(webModule)
   .addAsModule(ejbModule)
   .addAsLibrary(sharedLibrary)
   .setApplicationXML("META-INF/application.xml");

Resource Adapter Archives

ResourceAdapterArchiveImpl

Complete implementation of Resource Adapter Archive (RAR) format for JCA connectors.

public class ResourceAdapterArchiveImpl extends ResourceAdapterContainerBase<ResourceAdapterArchive> 
    implements ResourceAdapterArchive

Constructors:

public ResourceAdapterArchiveImpl(String archiveName)

RAR Structure:

  • META-INF/ra.xml - Resource adapter descriptor
  • Connector implementation classes
  • Required libraries

Usage Example:

ResourceAdapterArchiveImpl rar = new ResourceAdapterArchiveImpl("connector.rar");
rar.addClass(ResourceAdapterImpl.class)
   .addClass(ConnectionFactoryImpl.class)
   .setResourceAdapterXML("META-INF/ra.xml");

Specification Compliance

JAR Specification Compliance

JavaArchiveImpl follows JAR File Specification:

  • Proper MANIFEST.MF format and location
  • Service provider interface files in META-INF/services/
  • Signature files support (META-INF/*.SF, *.DSA, *.RSA)
  • Index files (META-INF/INDEX.LIST)

WAR Specification Compliance

WebArchiveImpl adheres to Servlet Specification:

  • Required web.xml structure and validation
  • Proper WEB-INF directory layout
  • Class loading hierarchy (WEB-INF/classes before WEB-INF/lib)
  • Tag library descriptor support

EAR Specification Compliance

EnterpriseArchiveImpl follows Java EE Specification:

  • Application.xml descriptor format
  • Module type detection and configuration
  • Library directory handling
  • Alternative deployment descriptors

RAR Specification Compliance

ResourceAdapterArchiveImpl implements JCA Specification:

  • Resource adapter descriptor (ra.xml) format
  • Connector architecture compliance
  • Transaction and security support structures

Archive Type Detection

The specification implementations include automatic type detection:

// Automatic format detection based on extension and content
Archive<?> archive = ArchiveFactory.create("application.war");
// Returns WebArchiveImpl instance

// Explicit type specification
JavaArchive jar = ArchiveFactory.create(JavaArchive.class, "app.jar");
// Returns JavaArchiveImpl instance

Format Validation

Each specification implementation includes validation capabilities:

// Validate archive structure
ValidationResult result = archive.validate();
if (!result.isValid()) {
    for (ValidationError error : result.getErrors()) {
        System.err.println("Validation error: " + error.getMessage());
    }
}

Archive Metadata

Specification implementations provide metadata access:

// JAR-specific metadata
String mainClass = jar.getManifest().getMainAttributes().getValue("Main-Class");

// WAR-specific metadata  
String displayName = war.getWebXml().getDisplayName();

// EAR-specific metadata
List<Module> modules = ear.getApplicationXml().getModules();

Content Organization

JAR Content Layout

META-INF/
  MANIFEST.MF
  services/
    com.example.Service
com/
  example/
    Application.class
config.properties

WAR Content Layout

WEB-INF/
  web.xml
  classes/
    com/example/ServletClass.class
  lib/
    dependency.jar
META-INF/
  MANIFEST.MF
index.html
css/
  style.css

EAR Content Layout

META-INF/
  application.xml
  MANIFEST.MF
lib/
  shared-library.jar
webapp.war
ejb-module.jar
connector.rar

RAR Content Layout

META-INF/
  ra.xml
  MANIFEST.MF
com/
  example/
    ResourceAdapterImpl.class
    ConnectionFactoryImpl.class

Integration with ShrinkWrap API

The specification implementations integrate seamlessly with the broader ShrinkWrap API:

// Create using ShrinkWrap factory
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "app.jar");

// Convert between types
WebArchive war = jar.as(WebArchive.class);

// Export to different formats
File jarFile = jar.as(ZipExporter.class).exportToFile("app.jar");

Custom Specification Extensions

The base classes support creating custom specifications:

public class CustomArchiveImpl extends ContainerBase<CustomArchive> 
    implements CustomArchive {
    
    public CustomArchiveImpl(String archiveName) {
        super(archiveName, CustomArchive.class);
    }
    
    // Custom specification-specific methods
    public CustomArchive setCustomDescriptor(Asset descriptor) {
        return add(descriptor, new BasicPath("/META-INF/custom.xml"));
    }
}

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