Class Factory

java.lang.Object
com.framed.orchestrator.Factory

public class Factory extends Object
The Factory class provides dynamic instantiation of Service implementations based on JSON configuration. It uses Java reflection to match constructor parameters with configuration keys and injects an EventBus where required.

Features:

  • Dynamically loads classes by name using Class.forName(String).
  • Matches constructor parameters with JSON configuration keys.
  • Automatically injects an EventBus into constructors.

Matching Logic:

  • If a constructor parameter name matches a key in the JSON config, its value is used.
  • If a parameter type is EventBus, the provided event bus is injected.
  • If no matching constructor is found, a ClassNotFoundException is thrown.