1 / 28

Web Framework

Circumflex. Web Framework. introduction. Circumflex Software Foundation. Web Framework ORM Framework Markeven Docco tools & integration projects. common goals. focus on code quality make minimal assumptions provide thin abstractions make the life easier. Circumflex. architecture

micah
Download Presentation

Web Framework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Circumflex Web Framework • introduction

  2. CircumflexSoftware Foundation • Web Framework • ORM Framework • Markeven • Docco • tools & integration projects

  3. common goals • focus on code quality • make minimal assumptions • provide thin abstractions • make the life easier

  4. Circumflex architecture Overview Web Framework

  5. Underlying Technologies • HTTP protocol • Java Servlet API 2.5 • Standard Servlet Containers (Jetty, Tomcat, GlassFish, Resin, IBM WebSphere AS, etc...) • Scala 2.8.1 (yet)

  6. Circumflex Application Lifecycle Web Framework

  7. User Request Main Request Router class Main extends RequestRouter { get("/") = <h1>Welcome!</h1> get("/hello") = <h1>Hello world!</h1> get("/hello/:name") = <h1>Hello, {param("name")}!</h1> } GET /hello/world HTTP/1.1 The Routing Paradigm

  8. Handling Complexity Delegation & Prefixes class Main extends RequestRouter { new FooRouter new BarRouter } class FooRouter extends RequestRouter(“/foo”) { get(“/?”) = { ... } // matches `/foo` and `/foo/` ... } class BarRouter extends RequestRouter(“/bar”) { ... }

  9. Handling Complexity Subroutes any(“/users/:id/*”) = User.find(param(“id”)) map { user => subroute(“/users/” + user.id) { get(“/?” = {...} // matches `/users/10` or `/users/10/` get(“/profile”) = {...} // matches `/users/10/profile` ... } } getOrElse sendError(404) // if user does not exist

  10. Request Dispatching • Single thread for request processing • data sharing using ThreadLocal context • reliableJava EE hardware scalability • transaction-per-request pattern • Request router instance per request • thread safety • mutable state • Exception-driven flow • using Scala’s ControlThrowable

  11. Template Engines Integration Template Engine def process(template: String, data: Any): String Data is shared using Context get("/users/:id") = User.get(param("id")) map { user => 'user := user ftl("/users/view.ftl")} getOrElse sendError(404) [#ftl]<h1>Hello, ${user.name}</h1>

  12. Circumflex API Overview Web Framework

  13. Request API • accessing request parameters, headers, cookies, etc. • manipulating with Servlet sessions • parsing multi-part requests with Apache Commons FileUpload • accessing low-level HttpServletRequest

  14. Response API • modifying response state: status code, cookies, content type, etc. • helpers for sending files • low-level HttpServletResponse

  15. Miscellaneous • Matchers API • Routing API • Testing API • Standalone Server using Embedded Jetty

  16. Circumflex HOWTO Web Framework

  17. Before installation Build automation Java 6 SDK Revision control Development environment

  18. Building Circumflex • Clone Circumflex repository: • Build with Maven cd Projectsgit clone git://github.com/inca/circumflex.git cd circumflexmvn clean install

  19. Generating from Archetype • Generate new project: • Compiling: cd Projectsmvn archetype:generate cd wiki-slidesmvn compile jetty:run

  20. Project layout

  21. Sample Application http://github.com/lirio/wiki-slides

  22. References • Circumflex Main Site • Circumflex Sources • FreeMarker Template Engine http://circumflex.ru http://github.com/inca/circumflex http://freemarker.org

  23. Thanks!

More Related