1. RichFaces In The Cloud
Jay Balunas Alex Smirnov
RichFaces Project Lead RichFaces Architect
JBoss, by Red Hat Inc. Exadel Inc.
JavaOne
September, 2010
2. What Are We Saying?
• Flavor of "Cloud"
• Google App Engine (GAE)
o Restrictions
o JSF 2 & GAE
• Making it work
• RichFaces/JSF 2 maven archetype
• RichFaces showcase example
4. Google App Engine
• Platform as a Service ( PaaS )
• Operating system agnostic
• Proprietary application engine
o Benefits & problems
• Supports Java & Python
• Built in storage
5. Advantages
• Easy setup
• Fast/easy deployments
• Simple administration
• No need to worry about:
• OS
• Hardware
• Patches
• Backups
• Free to get started
• Fine grained pricing
• Effortless scalability
6. Restrictions
• VERY limited threading
• Restricted class access
• Java2D
• CORBA
• RMI
• No JNI
• Requests limited to 30 sec. by default
• No write access to filesystem
7. From Java Point of View
• Java 6 runtime.
• Servlet 2.4 container.
• JPA and JDO for Google Big Table.
• Additional services:
o Caching
o Task Queues
o Authentication
o Email, XMPP, OAuth.
8. JSF 2.0 and Google App Engine
• Must disable threads for:
• Initialization
• Resource handling
• Should run in "Production" stage.
• Custom classes required for restricted APIs
• Including working around Java2D
• “Push” technologies have problems
9. How RichFaces Makes It Work
Base RichFaces uses restricted API
• Java2D
• dynamically-generated images
• Visual theme backgrounds
• <rich:paint2D> component
• Push
• Architecture doesn't allow serialization of push
listener
• Polling is available
• Cache services (optional)
• Configured to use filesystem
• Require write access
10. How RichFaces Makes It Work
1.Pre-Generate resources at compile time
2.Do not use Push component ( yet )
3.Configure cache to use Google memcache
implementation
11. RichFaces Maven Resources plugin
Resource Plugin:
• Substitute skin parameters to CSS for all skins used by
application
• Compress CSS files
• Provides relative URLs in CSS
• Generates skin images
• Extracts all JavaScript files used by application and
compress them
• Generates descriptor for all processed files.
• RichFaces framework use this descriptor to point to
appropriate resources
12. Resource Plugin usage
• Define plugin in Maven build:
<plugin>
<groupId>org.richfaces.cdk</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>4.0.0-SNAPSHOT</version>
....
• Configure: Full example:
• Skins http://bit.ly/RF_RESOURCE_PLUGIN
• Content types
• Class Mappings
•Update web.xml with resource location init param
org.richfaces.staticResourceLocation
13. RichFaces New GAE Archetype
• Create your own JSF/RF App in minutes
• Standard maven archetype
mvn archetype:generate
-DarchetypeGroupId=org.richfaces.archetypes
-DarchetypeArtifactId=richfaces-archetype-gae
-DarchetypeVersion=4.0.0-SNAPSHOT
-DgroupId=<yourGroupId>
-DartifactId=<yourArtifactId>
-Dversion=<your-version>
• Create your app on GAE server ( <app-name>)
• Update “appengine-web.xml” with <app-name>
• Use “appcfg” from GAE SDK to deploy
14. RichFaces New GAE Archetype
http://<app-name>.appspot.com
Thats it!!!