---
# (DD09) Business Logic — Example.syncGet() [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.syncGet()

This method performs a synchronous HTTP GET request against the URI supplied by the caller and then writes the HTTP response status code and response body to the standard output stream. In business terms, it acts as a minimal outbound web-access utility used to verify connectivity and retrieve remote content in a blocking manner. The method follows a straightforward routing-and-execution pattern: it converts the input string into a URI, builds a request object, executes the call, and immediately emits the result for inspection.

The method does not branch into multiple business service types; instead, it represents a single transport operation for GET-based retrieval. Its role in the larger system is that of a demonstration or shared sample utility for Java 11 HTTP client usage, showing how a caller can synchronously consume a remote endpoint and observe the returned payload. The processing is strictly sequential and blocking, so any upstream caller must wait until the remote server responds or an exception occurs.

Because the method prints the received status and body directly, it is best understood as a diagnostic or example integration entry point rather than a domain transaction handler. It does not transform, persist, or validate business entities; it simply passes through the external response for immediate visibility.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["syncGet(uri)"])
    CREATE_CLIENT["Create HttpClient with HttpClient.newHttpClient()"]
    BUILD_REQUEST["Build HttpRequest with URI.create(uri)"]
    SEND_REQUEST["Send request with BodyHandlers.ofString()"]
    PRINT_STATUS["Print response.statusCode()"]
    PRINT_BODY["Print response.body()"]
    END_NODE(["Return to caller"])

    START --> CREATE_CLIENT
    CREATE_CLIENT --> BUILD_REQUEST
    BUILD_REQUEST --> SEND_REQUEST
    SEND_REQUEST --> PRINT_STATUS
    PRINT_STATUS --> PRINT_BODY
    PRINT_BODY --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `uri` | `String` | Target endpoint address for the outbound HTTP GET call. This value determines which remote resource is accessed, and it must be a valid URI string because it is parsed directly into a `URI` object. Any malformed or unreachable value affects execution immediately by causing request creation or network I/O failure. |

External state read by the method:
- Standard output stream via `System.out.println(...)`
- Network environment and remote server response returned by the target URI

## 4. CRUD Operations / Called Services

This method does not invoke application CRUD services, database repositories, or entity persistence operations. Its only operations are Java platform HTTP client calls and console output, so no SC/CBS code or database entity can be assigned.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `URI.create` | N/A | N/A | Reads and parses the caller-supplied string into a URI object for outbound request construction. |
| C | `HttpRequest.newBuilder` | N/A | N/A | Creates a new HTTP request definition for the GET invocation. |
| R | `HttpClient.newHttpClient` | N/A | N/A | Obtains a client instance used to execute the outbound request. |
| R | `client.send` | N/A | N/A | Performs a synchronous remote read by sending the request and receiving the response body as text. |
| R | `response.statusCode` | N/A | N/A | Reads the returned HTTP status for operational visibility. |
| R | `response.body` | N/A | N/A | Reads the returned response payload for display. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Internal sample call in `Example` | `Example.main` (commented sample call) -> `Example.syncGet` | `client.send [R] N/A` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SEQUENCE] `(lines 30-39)`

> Creates an HTTP client, builds a GET request, executes the request synchronously, and prints the response metadata and body.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HttpClient client = HttpClient.newHttpClient();` |
| 2 | SET | `HttpRequest request = HttpRequest.newBuilder()` |
| 3 | EXEC | `.uri(URI.create(uri))` |
| 4 | EXEC | `.build();` |
| 5 | SET | `HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());` |
| 6 | CALL | `client.send(request, HttpResponse.BodyHandlers.ofString());` |
| 7 | EXEC | `System.out.println(response.statusCode());` |
| 8 | EXEC | `System.out.println(response.body());` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `uri` | Field | Target resource location for the outbound HTTP GET request. |
| HTTP | Acronym | Hypertext Transfer Protocol — the protocol used for web communication. |
| GET | Business term | Read-only HTTP method used to retrieve data from a remote endpoint. |
| URI | Acronym | Uniform Resource Identifier — a textual identifier for the remote resource. |
| HttpClient | Technical term | Java 11 HTTP client used to send network requests. |
| HttpRequest | Technical term | Java object representing the outbound request configuration. |
| HttpResponse | Technical term | Java object representing the received response from the remote server. |
| status code | Technical term | Numeric HTTP result indicating the outcome of the remote call. |
| body | Technical term | Response payload content returned by the remote server. |
| synchronous | Business term | Blocking execution mode where the caller waits for the response before continuing. |
| standard output | Technical term | Console stream used here to display the result for diagnostics or demonstration. |
