How playframework/play1 works
Project type and purpose
• This repository is the Play Framework version 1 — an open-source, full-stack web application framework for Java (and Groovy), delivered as both a CLI tool (the “play” script) and a Java library.
• It provides an MVC web server, hot-reloading compiler, template engine, ORM and database modules, caching, job scheduling, plugin infrastructure, and extension modules (CRUD, console, documentation, testing, etc.).
File structure
• Top-level:
– .github: CI, issue/pr templates
– README.md: project overview
– play / play.bat / python/: the CLI launcher and Python “pym” toolset for command dispatch
– framework/: the Java core (build.xml, lib dependencies, src, patches, tests)
– modules/: first‐party extension modules (console, crud, docviewer, secure, testrunner, grizzly, etc.)
– documentation/: static site content, cheatsheets, manuals (HTML/Textile)
– samples-and-tests/: sample applications demonstrating features
– resources/: IDE and application skeleton templates
• framework/src/play/*: core Java packages:
– mvc: Controller, Router, Results
– server: HTTP server (Netty-based) pipeline, SSL, handler
– classloading & compilation: hot‐swap, bytecode enhancement
– templates: Groovy template compiler/loader
– db: JDBC, JPA/Hibernate integration, evolutions
– cache: EhCache, Memcached implementations
– jobs: scheduled tasks
– inject: DI container
– utils, i18n, libs: JSON, YAML, HTTP clients, email, OAuth, WebSockets
– exceptions, data binding, validation
README for additional insights
• Play is delivered as an unzippable runtime, exposes a “play” command for scaffolding, running, testing, packaging.
• Emphasizes RESTful, developer productivity, hot code reload, modularity via plugins and modules.
1. CLI layer
– “play” shell script / play.bat
– Python pym backend loading commands (framework/pym/play)
2. Core Java engine
– HTTP Server (framework/src/play/server)
– Request Router & ControllerInvoker (mvc)
– Classloader & Compiler (hot‐reload)
– Template engine (play/templates)
– DI & Plugin Manager (inject & plugins)
– Tasks & Job Scheduler (jobs)
– Data Binding & Validation (data/binding, data/validation)
– Logging, I18N, Utils
3. Data layer
– DB connectors & pools (c3p0, HikariCP)
– ORM: JPA/Hibernate integration, evolutions framework
4. Cache layer
– EhCache, Memcached adapters
5. Extension modules (modules/*)
– Console, CRUD, DocViewer, Secure, TestRunner, Grizzly adapter, etc.
6. Documentation & Samples
– Static docs (documentation/)
– Sample apps (samples-and-tests/)
7. External services
– Databases (MySQL, PostgreSQL, H2)
– Cache servers (Memcached)
– Mail servers (SMTP)
– Third-party REST/OAuth providers
• CLI → launches Java Engine
• Engine boot:
– loads application code & modules via Classloader
– initializes Plugin Manager & DI container
• HTTP Request → Server Pipeline → Router → Controller →
– may invoke Data layer (DAO/JPA) → persists/queries DB
– may invoke Cache layer
– may schedule or invoke Jobs
– may render Template → HTTP Response
• Template compiler hot-reloads on file change
• Plugins and Modules hook into lifecycle events (onStart, onStop)
c. Architectural patterns & principles:
– MVC pattern
– Plugin/Module extensibility (inversion of control)
– Hot-code reloading and bytecode enhancement
– Dependency injection via simple BeanSource/Injector
– Layered architecture: presentation, application, data, integration
– Event‐driven non-blocking IO (Netty)
d. Key technologies/frameworks:
– Java 8+, Groovy templates
– Netty HTTP server
– JPA/Hibernate, Evolutions
– c3p0, HikariCP
– EhCache, Memcached
– Python 3.x (CLI pym scripts)
– Ant/Ivy build and dependency management
– JSON (simplejson), YAML, Mail, OAuth, WebSocket client & server