About Me ~ Shekhar Gulati
• OpenShift Evangelist at Red Hat• Hands on developer• Speaker• Writer and Blogger• Twitter @ shekhargulati
PaaS == Platform as a Service
A Cloud Application Platform
Code Deploy Enjoy
Save Time and MoneyCode your app
Push-button Deploy, and your App is
running in the Cloud!
Why PaaS?
• Lets developer focus on his job i.e. to write code.
• Improves developer productivity.
• Brings agility to product development.
• Gives developers the power to prototype their ideas quickly and rapidly.
OpenShift – Open PaaS
• Polyglot – supports multiple programming languages
• Support multiple databases• Auto scales• Developer friendly
• Flexible• Open source – OpenShift Origin
Why OpenShift?• Strength. OpenShift is built on proven Red Hat
technologies.
• Freedom. In OpenShift, work the way you want.– Choice of Interface: Web Console, Command-line, or IDE
– Choice of Middleware: Java(EE6), Ruby, Node.js, PHP, Python, and Perl
– Choice of Cloud: Public, Private, or Hybrid Cloud
– Choice of Elasticity: Automatic application scaling when needed
• Openness. OpenShift’s open source software stack ensures application portability and No Lock-In.
Why I think OpenShift is Best?• Can run any thing that's Java – Java EE or
Spring does not matter.
• Supports both Java 6 and Java 7
• Supports JBoss AS7, JBoss EAP 6.0, and Tomcat
• Ability to write to persistent file system
• Debugging support
• Hot deployment
• Eclipse support
Getting Started with OpenShift
1) Sign up with Promo Code
JUDCON.IN
2) Verify Email
https://openshift.redhat.com/app/account/new
What I get after sign up?
• OpenShift is free-as-in-beer & free-as-in-freedom
• You get three free gears, each with 512MB memory and 1GB of disk space.
• Need more resources, just ask!
• The catch is we are in developer preview right now
How To Work with OpenShift
Developer IDEIntegrations
Web BrowserConsole
Command LineTooling
REST APIs
Demo 1 – Web Console
• Log in to OpenShift Web console• Walkthrough various application types• Creating Domain Name• Wordpress Blog in less than 2 minutes• Credentials admin/OpenShiftAdmin
Install Client Tools and Setup Account
• Install the client tools – Install Ruby 1.8.7 or above
– sudo gem install rhc
• Install Git
• rhc setup -l <openshift_login>– Upload ssh keys– Check if git is installed
– Create domain if not exists
Look at Java EE 6• Java EE 6 provides a platform to write enterprise
applications in Java
• Consists of 28 specifications (Thousands of pages)
• Convention over configuration
• Less boilerplate code
• Promotes POJO programming model
• Annotations and types over XML
• Introduced EJB Lite
• Simplified Packaging
• Introduced concept of Profiles
Java EE 6 Specifications
• JSF 2.0
• Servlet 3.0
• JSP 2.2
• EL, JSTL 2.0, etc.
• EJB 3.1
• JPA 2.0
• JTA 1.1
• JavaMail etc.
• JAX-RS 2.0
• JAX-WS 2.2
• etc...
• JAX-WS 2.2
• JAXB 2.2
• JDBC 4.0
• JNDI 1.5
• SAAJ 1.3
• Common 1.1
• CDI (JSR 299)1.0
• @Inject 1.0
• Bean Validation 1.0
• Interceptor 1.1
• Managed Bean 1.0
• JACC 1.0
Java SE 6
Note : This is not a full list
Servlet 3.0
• Ease of development via annotations• Pluggability• Async support• File upload support• And many more..
JPA 2.0
• Evolved separately from EJB now– JSR 317
• Richer mappings• Richer JPQL
• Standard config options• Criteria API• And many more..
EJB 3.1• Optional local interface
– Use @Local and @Remote
• Packaged in war• Asynchronous calls using
@Asynchronous annotation• Timer Service supports cron like syntax• And many more @Singleton,
Embeddable container,etc.
Demo 2 Servlet 3.0, JPA 2.0, EJB 3.1
• Todo Application– JPA 2.0 for persistence– Servlet 3.0 as controller– EJB 3.1 as business service
Github repo of demo applicationhttps://github.com/shekhargulati/judcon-todo-servlet3-jpa2-ejb31-demo
Demo 2 Steps• Create JBoss EAP 6.0 OpenShift Application
• Add PostgreSQL support
• Create domain model – TodoList 1->n Todo
• Add persistence.xml
• Create EJB service TodoService
• Create TodoServlet to create and find TodoList
• Create FileUploadServlet
• Add page.jsp to WEB-INF/pages folder
• git add .
• git commit -am “Todo Application created”
• git push
Bean Validation 1.0
• Enable declarative validation in your applications
• Constrain Once and Validate Anywhere– restriction on a bean, field or property– not null, size between 1 and 7, valid
email...
• Standard way to validate constraints
• Integration with JPA 2.0 & JSF 2.0
CDI
• Stands for Context and Dependency Injection
• Glues the platform in a way never done before
• Provide two main things– Dependency Injection– Manages components in scope
• Leads to loose coupling and strong typing using annotations
Interceptors 1.1
• Address cross-cutting concerns in Java EE
• Separate spec shipped with EJB 3.1
• Can be used with EJBs as well as ManagedBeans
• @AroundInvoke
• @AroundTimeout for EJB timers
Demo 3 JSF 2.0, CDI, Bean Validation, Events, Interceptors
git rm -rf src/ pom.xml
git commit -am "removed demo 2"
git remote add demo2 -m master git://github.com/shekhargulati/judcon-todo-jsf2-cdi-jsr303-events-interceptor-demo.git
git pull -s recursive -X theirs demo2 master
Demo 3
• Extending Todo application– CDI for dependency injection– JPA 2.0 Criteria API for querying– EJB 3.1 for writing business service– Interceptor for logging– JAX RS for Restful web services
3 More Sessions ~ All Different• Polyglot Persistence Apps on OpenShift - Today
• Building Java MongoDB application using Hibernate OGM - Tomorrow
• JBoss Forge + OpenShift = Rapid Enterprise Application Development for Cloud – Tomorrow