How youseries/ureport works
Project Type and Purpose
• UReport2 is a multi‐module Java project providing a pure‐Java report engine (ureport2-core), a web-based designer console (ureport2-console), a font registration library (ureport2-font), and a JavaScript client (ureport2-js).
• Its purpose is to let developers embed a high-performance, Spring-based report engine into any J2EE/Maven project, design reports in the browser, and export them to PDF/Excel/HTML/Word.
High-Level Components
A. Frontend (ureport2-js)
• Hosts the browser-based designer UI, preview UI, dialogs, tree views, form builder, etc.
• Bundled via Webpack; served as static assets by the console webapp.
• Communicates over HTTP(S) (AJAX/REST) with the backend servlet endpoints.
B. Backend Console (ureport2-console)
• A Java web application (Servlet) running in any servlet container (Tomcat, Jetty).
• Spring Web MVC + custom servlet actions (e.g., DesignerServletAction, RenderPageServletAction, ExportPdfServletAction).
• Manages user sessions, temporary caches (HttpSessionReportCache, TempObjectCache), and serves static resources.
• Delegates report parsing, building, and exporting to ureport2-core.
C. Core Engine (ureport2-core)
• Provides DSL parsing (ANTLR4 grammars), report definition model, builder layers (cell/aggregate/paging), expression evaluation (EL + custom functions), data binding, and export managers.
• Uses a layered architecture:
1. Parser (ReportParser, parser.impl)
2. Definition model (definition/*)
3. Builder/Compute (build/*, compute/*, paging/*)
4. Expression (expression/parse, expression/function)
5. Export (export/excel, export/pdf, export/html, export/word)
6. Caching (cache/*) and resource providers (provider/*)
• Configured via ureport-core-context.xml and ureport.properties; wired by Spring IoC.
D. Font Module (ureport2-font)
• Registers common fonts via Java classes (e.g. ArialFontRegister, YaheiFontRegister).
• Loaded as a bean in Spring context when exporting to formats that embed fonts (PDF, Word).
E. Parent POM (ureport2-parent)
• Defines dependency versions and module aggregation (multi-module Maven project).
External Dependencies & Integrations
• JDBC DataSources or SpringBean data sources (datasource/* in core).
• HTTP/HTTPS image providers for dynamic images.
• Spring Framework, Servlet API, ANTLR4, Jackson/Gson (for JSON), caching (in-memory), and optionally external file storage/classpath for report templates.
Relationships & Data Flow
1. User opens browser → downloads HTML/JS/CSS from ureport2-console.
2. Frontend Designer issues AJAX calls → console servlet endpoints (/ureport/*).
3. Console loads or saves report definition → passes to core DSL parser → builds in-memory ReportDefinition.
4. Core ReportBuilder fetches data via configured DataSource → computes cells, aggregates, paging.
5. Core ExportManager serializes the Report model → chosen format (PDF/Excel/HTML/Word).
6. Console streams the binary or HTML back to the browser → rendered or downloaded by user.
Important Architectural Patterns
• Layered architecture in core (Parser → Definition → Builder → Compute → Export).
• Spring IoC for wiring modules and pluggable providers.
• MVC-style servlet actions in console.
• Client-server separation: a thin JavaScript client vs. a heavyweight Java core.