# 11.b-subsystem-bundled-component-lab

## Overview

This lab demonstrates the explicit subsystem form where the subsystem artifact bundles its component artifact.

This is a secondary variant in the `11` line:

1. `11-subsystem`
   - formal subsystem using generally distributed components
2. `11.a-multi-component-subsystem-lab`
   - formal subsystem hosting multiple independent components without wiring
3. `11.b-subsystem-bundled-component-lab`
   - formal subsystem bundling its component artifact
4. `11.c-subsystem-mixed-component-lab`
   - formal subsystem mixing general and bundled components
5. `11.d-implicit-subsystem-lab`
   - implicit subsystem
6. `11.e-sar-dir-lab`
   - expanded `sar.d`
7. `11.f-subsystem-parameter-lab`
   - descriptor-direct startup

## Intended Use Case

Use this lab when you want to see the closed distribution form:

- the subsystem artifact carries its own component artifact
- startup does not depend on a separately distributed generic component
- the subsystem is distributed as one self-contained SAR

## Current Status

This lab is runnable.

The runtime line is:

- `component.d/explicit-subsystem.sar`
- `--textus.subsystem=testsubsystem`

The important detail is that the active packaged directory (`component.d`) must contain only the bundled SAR for this walkthrough.
If a standalone `base.car` is left in the same directory, the same `testcomp` component is loaded twice:

- once directly from `base.car`
- once from the bundled `explicit-subsystem.sar`

`run.sh` now removes those generated leftovers before recreating the SAR.

## Files

- `component.d/explicit-subsystem.sar`
  - the packaged subsystem artifact generated by `run.sh`
- `subsystem.cml`
  - the bundled subsystem descriptor
- `run.sh`
  - convenience batch runner

## Setup

### Prepare repository tools

```bash
bash ../../bin/setup
```

### Build the sample

```bash
sbt --batch compile
```

## Build The Bundled Subsystem

This lab uses the baseline component implementation from `11-subsystem`:

- build the baseline component jar
- wrap it as `base.car`
- embed `base.car` into `explicit-subsystem.sar`

The generated `*.car` and `*.sar` files are not committed inputs.
They are recreated by `run.sh`.

## Shortcut: Run The Whole Scenario
This is the shortcut verification path, not the teaching path.
For learning, read the explicit command sequence in `Command Walkthrough` first and type those commands by hand.
`run.sh` should be treated as the batch form that replays the documented commands.

This command rebuilds the bundled SAR and runs the walkthrough.

```bash
bash run.sh
```

Expected result:

```yaml
name: testsubsystem
...
```
