T2 Web Framework

36
T2 framework T2 project http://t- 2.googlecode.com/ Shinpei Ohtani(shot6)

description

T2 webframework is simple and modernized java webframework for web2.0 environment.This presentaion tells you the new web development situation is coming to us and how we solve by T2 webframework.

Transcript of T2 Web Framework

Page 1: T2 Web Framework

T2 frameworkT2 project

http://t-2.googlecode.com/Shinpei Ohtani(shot6)

Page 2: T2 Web Framework

Agenda

Introduce myself and the teamAn overview of T2 frameworkCurrent web development situationT2 architecture and mechanismDemosConclusion

Page 3: T2 Web Framework

Introduce myself

Shinpei OhtaniOpen source programmer

Java/ActionScript/JavaScript/C#...

Works at ISI Dentsu, LtdBlog

http://d.hatena.ne.jp/shot6/ (Japanese)

Twitterhttp://twitter.com/shot6/

Page 4: T2 Web Framework

Introduce the T2 team

The team are:5 committersAll professional programmer, especially

JavaEach of us create both applications and

frameworksThe experiences are the core of creating

T2

Page 5: T2 Web Framework

Web development situation

The time for web application re-inventedRIA is no more new thing, it is just choice!

Ajax, Flex, Silverlight, there are just choices.

Cloud environment is the matterWeb application needs to deploy to multiple

clouds

HTTP based protocol and format rises upAMF, XMPP, reversehttp, pubsubhubbubOr, legacy SOAP:P

Page 6: T2 Web Framework

RIP –Rich Internet Platform-

RIA to RIP(Rich Internet Platform)RIP is the platform to support multiple RIA

environment(HTML5, Ajax, Flex, Silverlight…).

HTML5 is the flagship of RIPUnlike HTML4, HTML5 is the platform for RIA.Runtime is the key such as

• WebSockets• WebStorage• WebWorker• CacheManifest• Geolocation API

Page 7: T2 Web Framework

Cloudability

CloudabilityAbility to work well at cloud environmentWork well means:

Deploy easilyScale easily so be statelessInteroperable to multiple cloud environment

• Not only for GAE, Amazon, or other, do work with all these.

Page 8: T2 Web Framework

HTTP matters

HTTP/HTTPS it the protocolThe unified protocol for next generation

appsThe format also matters

AMF for Flex, XMPP for jabber, pubsubhubbub for WebHook, so many format rises up!

These formats and mechanism is the key for new interactive web apps

Page 9: T2 Web Framework

To the next level web apps

Choose good/simple framework that has some features for:RIPCloudabilityHTTP based multiple format

is one of the choice for you.

Page 10: T2 Web Framework

What is T2 framework

Simple and modernized java web framework for real developerEasy to use and maintain by annotationCurrent version is T2 0.6.1-ga. ASL2

License.http://code.google.com/p/t-2/

The framework for RIP appsOfcourse support classic web application!Extensible and embeddable framework

Page 11: T2 Web Framework

The big picture

BrowserBrowserHTTPPOST

JavaScript

Client

JavaScript

Client

XmlHttpRequest

Flex/AIRFlex/AIR

AMF

REST-likeClient

REST-likeClient PUT /hoge/foo

POJOPOJO

POJOPOJO

POJOPOJO

Serverside javaapplications

……

……

……

Request format doesn’t effect server side POJO-based model. Request format doesn’t effect server side POJO-based model.

Page 12: T2 Web Framework

The motivation

The motivationAll of Java webframework is too difficult to

use and maintainAlso mention none of these follow

modernized web clients with one unified modelDoes your framework handle Ajax, AMF, REST

request using one unified programming model? No clean url, no life.No choice of template engine, no life.Less configuration without difficult CoC!

Page 13: T2 Web Framework

The motivation(cont’d)

Web framework:should be much more simple.should give developer loosely-coupled unified

model.Request type and format doesn’t effect server side.

should handle modernized web request wellAjax, AMF from Flex, REST, POX from Silverlight…

should give you clean beatiful urlshould give you free to choose template engine

Page 14: T2 Web Framework

The concept

ConceptDo one thing well

T2 just connects between multiple HTTP clients to POJO using url pattern gracefully.Doesn’t do things at all.

Accepts WEB diversity100 ways to make web application with

technology (browser/RIA/CUI…), and we can’t push developer to one way.Do it freely using T2.

Only things for sure is using HTTP and URL.

Page 15: T2 Web Framework

The target user

Who should use T2?Developers who’d like to:

Develop and control web application easily.Separate clients and server side application

gracefullyDevelop his/her framework based on simple and

extensible framework and control perfectly Develop RIA application quickly using REST like

request, Ajax request, or Flex AMF requestDevelop cloud based application

Page 16: T2 Web Framework

Programming model

Page modelAll of T2 application uses page modelBasically POJO but annotations enhanced

for class, method, parameterVery unobtrusive model, no one harms for

thisPage is a class to map an url for a pojo.Page has action methods for executing

user request.Action parameter is injected by T2

Page 17: T2 Web Framework

Programming model(cont’d)

Example: @Page("employee") public class EmployeePage { @Default public Navigation index(WebContext context) { …... } @GET @ActionPath("list/detail") public Navigation detail(WebContext context) { …… } }

Page 18: T2 Web Framework

Action method design

Funnel-like designPage class is created as you put url and

its parameter from whole to detailSet url for a page Set url for an action method Set parameter whichever you would like to

receive

Page 19: T2 Web Framework

Action method design(cont’d)

Example: HTTP GET /hoge/foo?bar=2Page class takes /hoge as urlAction method tales /foo as urlMethod args takes bar as String

So it is like:@Page("/hoge”)public YourPage { @GET @ActionPath(“hoge”) public Navigation hoge(@RequestParam("bar") String bar) {

Page 20: T2 Web Framework

Action parameter design

Action parameter is injected by T2T2 prepared contexts

WebContext/Request/Response…

Servlet spec contextsHttpServletRequest/HttpServletResponse…

Converted POJO from form dataFrom HTTP POST, or from Flex AMF

Useful parametersREST-like some url, or foreach index, upload

file…

Page 21: T2 Web Framework

Take a look code!

@Page(”sample") public class SamplePage { @Default public Navigation index(WebContext context) {… @Amf public Navigation execute(HogeDto hoge) {… @ActionParam public Navigation submit(@Form FooDto foo) {… @ActionPath(“fuga/{moge}”) public Navigation submit(@Var(“moge”) String s)

{…

Page 22: T2 Web Framework

Core components

@PageHTTP handling using @GET/@POSTURL pattern matching by @ActionPathRequest data matching by

@ActionParamRequest type matching by @Ajax/@AmfReturn type, NavigationContainerAdapter for integrate with DI

container

Page 23: T2 Web Framework

@Page

The root annotation for T2 PagePage must have @Page.T2 does not have any configuration

except web.xml and @PageTraverse by class path and finds page

classes

Page 24: T2 Web Framework

HTTP matching

HTTP matching is the first thing T2 does for action methodsGET, POST, PUT, DELETE, even HEAD.These are distinguished by annotation

like @GET or @POST

Page 25: T2 Web Framework

URL matching for action method

URL matching for action method@ActionPath is the main role to do@Page(“hoge”) + @ActionPath(“foo”) -

> /hoge/foo is the url to access to the method

Page 26: T2 Web Framework

Data matching for action method

Data matching for action method@ActionParam is the main role to doMatch submitted request parameter

name.If it’s @ActionParam(“execute”), execute the

action method if request paramete name “execute” exist

Usually it is used to separate user submit action.

• Data update button, cancel button, things like that.

Page 27: T2 Web Framework

Request type matching

T2 can separate methods for request type.@Ajax

Accept only XmlHttpRequest, not othersDone by “X-Requested-With” header

@AmfAccept only Flex/AIR AMF request, not othersDone by content-type header

Request type is importantThe logic must be different with sync/async.

Page 28: T2 Web Framework

Default method for a page

Default method is always good to have.At least some odd error does not happenDefault behavior takes over and user

doesn’t feel uncomfortable

@Default is for default methodUsually returns default page transition.Sometimes clear states if application

contains.

Page 29: T2 Web Framework

Navigation

Navigation is the user interface for:Telling T2 where the transition goesTelling T2 how view will be rendered

Navigation is:Very simple to use.Extensible.Developer can implement

easily.

Page 30: T2 Web Framework

Default prepared navigations

Default navigationsForward/Redirect/Proceed(Psuedo

redirect)Json(or SecureJson using json-prefixing)Direct(Stream response)AmfResponse(Flex AMF)CacheManifest(Generate HTML5 manifest)In the future:

CVS, PDF, GoogleMaps, or Charts.

Page 31: T2 Web Framework

ContainerAdapter

Dependency Injection is the defacto technology for easy and maintainable developmentT2 provides adapters for these

containers:Spring/Guice/Seasar2 or our Lucy

It can use by settings using web.xml<init-param> <param-name>t2.container.adapter</param-name> <param-value>org.t2framework.t2.adapter.SpringAdapter</param-value></init-param>

Page 32: T2 Web Framework

Demos

RIA type demoPureMVC + T2 + Spring + iBatisComplete sample for CRUD

Cloud type demoFlex + GAEJ + T2Using T2 AMF3 implementation

Where is my lovely iPhone? Mushup DemoGeolocation(ajax) + T2 + Yahoo local search

+ iPhone serversman web server

Page 33: T2 Web Framework

Conclusion

Web development will be re-invented by:RIP, mostly HTML5Cloud environmentMultiple HTTP based formats

T2 framework is the simple framework for working well with these environments.

Page 34: T2 Web Framework

Resources

Sitehttp://code.google.com/p/t-2/

Downloadhttp://code.google.com/p/t-2/downloads/

list

Maven sitehttp://maven.t2framework.org/maven2/

Page 35: T2 Web Framework

Resources(cont’d)

Documentshttp://code.google.com/p/t-2/wiki/Index

Mailing listhttp://groups.google.com/group/t2-users-

en

Sourcehttp://code.google.com/p/t-2/source/

checkout

Page 36: T2 Web Framework

Thanks!!