How idojhirad/generic-iot-infrastructher works
Project type and purpose
• This is a Java-based IoT Gateway Server with a companion WebServer UI module.
• The GatewayServer accepts HTTP requests from IoT devices (and admin UIs), dispatches them via a command pipeline (parse→factory→command), and persists data via an AdminDB. Plugins (GenericIOT.jar variants) extend device support. Separately, the WebServer module offers a JSP/servlet UI for registering companies/products and querying data.
File structure
• Top-level modules:
• WebServer/ – Maven webapp (JSP, servlets, CSS) for user‐facing UI
• src/ – Core GatewayServer code (Main.java, maingatewayserver/, command/, admin_dataBase/, threadpool/, WaitablePQueue)
• resource/ – Plugin jars (GenericIOT.jar variants) and META-INF
• test/ – Unit tests for DB, threadpool, queue, plugins, JSON processing
• Key architectural patterns:
• Plugin architecture (PluginMediator + DirMonitor + plugin jars)
• Command pattern (Command interface + individual command classes)
• Factory pattern (FactoryInterface, Factory)
• Thread pool + waitable priority queue for concurrency
• HTTP service layer (ConnectionService handlers)
• Build/config: WebServer/pom.xml for the servlet container
README for insights
• Shows JSON structure for commands
• Mentions generalized vs. company-specific commands
• Confirms command registration mechanism
a. Main components
• Clients:
– Web Browser (interacts with WebServer UI)
– IoT Devices (HTTP clients sending JSON commands)
• WebServer Module:
– JSP pages & Servlets (RegisterCompany, GetCompany, RegisterProduct, GetProduct(s), Login)
– Talks to GatewayServer or directly to AdminDB for CRUD
• GatewayServer Core:
– HTTP Server (ConnectionService, ChannelHandler, MainHttpHandler)
– Request Processing Service (Parser → Factory → Command)
– PluginMediator (loads GenericIOT plugins via DirMonitor)
– ThreadPool + WaitablePQueue (schedules command execution)
– AdminDB (data persistence layer)
• Plugins Directory (resource/*.jar)
b. Relationships & interactions
1. IoT Device → HTTP → GatewayServer ConnectionService
2. HTTP handler delegates to RequestProcessService
3. Parser parses JSON, Factory creates appropriate Command
4. Command is submitted to ThreadPool (via WaitablePQueue)
5. Worker thread executes Command → interacts with AdminDB or PluginMediator
6. Response flows back through HTTP handler → IoT Device
7. Web Browser → HTTP → WebServer servlets → (GatewayServer or AdminDB) → returns HTML/JSON
c. Architectural patterns & design principles
• Command pattern for decoupling operations
• Factory for command instantiation
• Plugin architecture for dynamic device support
• Producer–consumer model (queue + thread pool) for concurrent request handling
d. Key technologies & libraries
• Java servlets & JSP (WebServer module)
• Custom HTTP server (ConnectionService classes)
• Java concurrency (ThreadPool, synchronized queue)
• Jar plugins (GenericIOT.jar)
Final advice
• Be exhaustive: capture all modules, handlers, and service layers.
• Command pipeline and plugin loading as the project’s unique aspects.