# Repository Overview

Welcome! If you're reading this, you're probably getting ready to explore or contribute to this codebase. This repository is a small **Enterprise JavaBean (EJB)** sample project called **EO** — a collection of lightweight Java classes that demonstrate EJB patterns, reflection-based class loading, and basic string utility logic. It uses the standard Java EE EJB annotations (`@Stateless`, `@EJB`) to show how dependency injection and stateless session beans work in a container-managed environment. Whether you're here to understand EJB fundamentals, use the reflection utilities as a reference, or adapt these patterns for your own projects, you'll find the modules organized in a straightforward hierarchy under the `eo.ejb` package.

## Overview

The EO project is an educational reference implementation that demonstrates several common Java and EJB patterns:

- **EJB stateless session beans** — a minimal `@Stateless` bean and an injection-aware client that delegates to an external `MyService` dependency via the `@EJB` annotation.
- **Reflection-based class loading** — utility classes that instantiate arbitrary classes by their fully qualified name at runtime using `Class.forName()` and `newInstance()`.
- **Simple string utilities** — a basic greeting formatter for demonstration purposes.

The project is intentionally small and self-contained, with no external framework dependencies beyond the Java standard library and the `javax.ejb` API. It contains 5 source files spread across 3 subpackages.

## Technology Stack

| Category | Technology | Notes |
|---|---|---|
| Language | Java | Core Java SE classes (`java.lang.Class`, `java.lang.System`, `java.lang.reflect`) |
| EJB | `javax.ejb.Stateless`, `javax.ejb.EJB` | Standard Java EE annotations for stateless beans and dependency injection |
| Frameworks | None detected | The project uses no well-known external frameworks beyond the EJB API |
| Build tool | Not specified | No build configuration files (Maven/Gradle) were found in the indexed files |

## Architecture

The codebase is organized under a single `eo.ejb` root package with three sibling subpackages. Each subpackage serves a distinct purpose — service layer, utility/reflection, and example code.

```mermaid
flowchart TD
    EJB["eo.ejb"] --> service["eo.ejb.service"]
    EJB --> wiki["eo.ejb.wiki"]
    EJB --> example["eo.ejb.example"]
    service --> EJBA["EJBWithArgs"]
    service --> SLSB["StatelessBean"]
    wiki --> PC["PlainClass"]
    wiki --> RC["ReflectiveClass"]
    EJBA --> |injects| SVC["MyService"]
    RC --> |loads via reflection| TC["Target Class"]
```

**Key observations:**

- The `service` and `wiki` packages are peers under `eo.ejb`, with `wiki` having a package-level dependency on `service`.
- The `example` package is independent and serves as a standalone reference pattern.
- The only external dependency injected into the system is `MyService`, resolved via JNDI at deployment time.

## Module Guide

### `eo.ejb.service`

The `service` package contains two EJB components that demonstrate the core enterprise patterns used in this project. **`StatelessBean`** is a minimal `@Stateless` session bean that prints `"stateless execute"` to stdout — essentially a template showing the structure of a stateless EJB. **`EJBWithArgs`** is a container-managed client that injects an external `MyService` dependency via `@EJB(name = "myBean")` and delegates all work to `service.process()`. It contains zero business logic of its own, serving purely as an injection and pass-through point. Together, these classes illustrate the separation between container-managed concerns (injection, pooling) and business logic delegation.

### `eo.ejb.wiki`

The `wiki` package provides two utility classes at the root of the `eo.ejb` hierarchy. **`PlainClass`** is a straightforward string utility that stores a name and returns a greeting (`"Hello, " + name`) — a simple example of an immutable-like data holder. **`ReflectiveClass`** is a reflection-based factory that takes a fully qualified class name, loads the class via `Class.forName()`, instantiates it with `newInstance()`, and can also invoke a static `execute()` method on any provided class via reflection. This module has a package-level dependency on `eo.ejb.service`. The reflection utilities throw `Exception` broadly and do not handle `ClassNotFoundException` or `InstantiationException` internally, so callers must manage error handling.

### `eo.ejb.example`

The `example` package contains a single class, **`PatternOneVar`**, which demonstrates the reflective instantiation pattern in its most concise form. The `load(String clsName)` method takes a fully qualified class name string, resolves it via `Class.forName()`, creates an instance via `newInstance()`, and prints the result to stdout. This module appears to serve as a standalone reference example for understanding how dynamic class loading works in Java. It has no external dependencies beyond `java.lang`. Note that `Class.newInstance()` was deprecated in Java 9 in favor of `getDeclaredConstructor().newInstance()`, so this pattern would need updating for newer Java versions.

## Getting Started

If you are new to this codebase, here is a recommended reading order:

1. **`eo.ejb.example.PatternOneVar`** — Start here to understand the reflection pattern used throughout the project. It's the simplest class with only one method.
2. **`eo.ejb.wiki.PlainClass`** — Next, read this to see the basic data-holding utility. It's a 3-line class that sets up expectations for simple, readable code in this project.
3. **`eo.ejb.wiki.ReflectiveClass`** — Now explore the more sophisticated reflection utilities. This class builds on the pattern from `PatternOneVar` and adds method invocation via reflection.
4. **`eo.ejb.service.StatelessBean`** — Move to the EJB side of the project. This stateless session bean shows the `@Stateless` annotation in its simplest form.
5. **`eo.ejb.service.EJBWithArgs`** — Finally, read this class to understand how `@EJB` dependency injection works in the project.

This order takes you from the simplest concepts (plain Java reflection) to the more complex EJB patterns (container-managed injection), building understanding incrementally.
