---

# (DD07) Business Logic — Example.getURIs() [12 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `io.github.biezhi.java11.http.Example` |
| Layer | Utility |
| Module | `http` (Package: `io.github.biezhi.java11.http`) |

## 1. Role

### Example.getURIs()

This method acts as a lightweight HTTP fan-out utility that takes a collection of target URIs and dispatches asynchronous GET-style requests to each destination. Its business purpose is to execute multiple outbound HTTP calls in parallel, allowing the caller to wait for all remote interactions to finish before continuing. In practical terms, it is a coordination method for batch network access rather than a data-processing or persistence routine.

The method implements a simple routing/delegation pattern: it transforms each incoming `URI` into an `HttpRequest`, submits each request asynchronously through a shared `HttpClient`, and then synchronizes on the entire group of futures. There are no conditional business branches, no CRUD persistence behavior, and no external domain entities are modified. Its role in the larger system is to serve as a reusable example or utility for concurrent HTTP aggregation, demonstrating how to manage multiple outbound requests as a single unit of work.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getURIs(uris)"])
    NEW_CLIENT["Create HttpClient via HttpClient.newHttpClient()"]
    STREAM_URIS["Stream URIs from input list"]
    MAP_BUILDER["Map each URI to HttpRequest.newBuilder(URI)"]
    MAP_BUILD["Build HttpRequest for each URI"]
    COLLECT["Collect requests into List<HttpRequest>"]
    STREAM_REQ["Stream requests list"]
    MAP_SEND["Map each request to client.sendAsync(request, BodyHandlers.ofString())"]
    TO_ARRAY["Convert futures stream to CompletableFuture[]"]
    ALL_OF["Wait for all asynchronous requests with CompletableFuture.allOf(...) then join()"]
    END_NODE(["Complete without returning a value"])

    START --> NEW_CLIENT
    NEW_CLIENT --> STREAM_URIS
    STREAM_URIS --> MAP_BUILDER
    MAP_BUILDER --> MAP_BUILD
    MAP_BUILD --> COLLECT
    COLLECT --> STREAM_REQ
    STREAM_REQ --> MAP_SEND
    MAP_SEND --> TO_ARRAY
    TO_ARRAY --> ALL_OF
    ALL_OF --> END_NODE
```

**CRITICAL — Constant Resolution:**
No application constants are referenced in this method. The implementation relies only on JDK APIs (`HttpClient`, `HttpRequest`, `HttpResponse`, `CompletableFuture`) and the input list of URIs.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `uris` | `List<URI>` | A batch of target endpoint addresses to be called. Each entry represents one outbound HTTP destination that will be converted into a request and executed asynchronously. The list can contain any number of URIs; every item is processed independently and contributes one future to the synchronization barrier. |

External state read by the method: none beyond JDK runtime services. The method creates its own `HttpClient` instance locally and does not read instance fields or shared application state.

## 4. CRUD Operations / Called Services

This method does not perform CRUD against application databases or domain entities. It only performs outbound HTTP request orchestration using JDK client APIs.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|-----------------------|
| R | `HttpClient.newHttpClient()` | N/A | N/A | Creates a reusable HTTP client instance for outbound network access. |
| C | `HttpRequest.newBuilder(...)` | N/A | N/A | Builds one HTTP request object for each input URI. |
| R | `client.sendAsync(...)` | N/A | N/A | Sends each request asynchronously and reads the remote response body as text. |
| R | `CompletableFuture.allOf(...)` | N/A | N/A | Waits for completion of all asynchronous request futures before returning control. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Direct caller not found in scanned Java sources | `UnknownCaller -> Example.getURIs` | `sendAsync [R] outbound HTTP response body` |

The caller search found the method definition only, so no in-repo Java caller could be confirmed from the available source scan. The terminal behavior is the asynchronous outbound HTTP invocation and completion wait; no database or SC endpoint is reached.

## 6. Per-Branch Detail Blocks

**Block 1** — SEQUENCE `(straight-line processing)` (L175-L186)

> The method follows a single, linear execution path with no branching, looping conditions, or exception handling blocks in the shown source range.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HttpClient client = HttpClient.newHttpClient();` |
| 2 | SET | `List<HttpRequest> requests = uris.stream()` |
| 3 | EXEC | `.map(HttpRequest::newBuilder)` |
| 4 | EXEC | `.map(HttpRequest.Builder::build)` |
| 5 | CALL | `.collect(toList());` |
| 6 | SET | `CompletableFuture.allOf(requests.stream()` |
| 7 | EXEC | `.map(request -> client.sendAsync(request, HttpResponse.BodyHandlers.ofString()))` |
| 8 | EXEC | `.toArray(CompletableFuture<?>[]::new))` |
| 9 | EXEC | `.join();` |
| 10 | RETURN | `void` completion |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `uris` | Field | Input collection of endpoint addresses to contact in one batch operation. |
| `URI` | Technical term | Uniform Resource Identifier — standardized address used to locate a remote HTTP endpoint. |
| `HttpClient` | Technical term | JDK HTTP client used to issue outbound network requests. |
| `HttpRequest` | Technical term | JDK object that represents a single outbound HTTP request. |
| `sendAsync` | Technical term | Non-blocking request execution method that returns a future for the remote response. |
| `BodyHandlers.ofString()` | Technical term | Response-body handler that converts the received payload into a text string. |
| `CompletableFuture` | Technical term | JDK abstraction for asynchronous computation and completion coordination. |
| `allOf` | Technical term | Aggregates multiple futures and completes when all of them are finished. |
| `join` | Technical term | Blocks the current thread until the combined asynchronous operations complete. |
| fan-out | Business term | Pattern of distributing one operation across multiple targets in parallel. |
| Utility | Layer | Reusable support code that coordinates technical work without owning business data or persistence. |
