The Next Generation - Austin Java Users Group

Post on 03-Feb-2022

4 views 0 download

Transcript of The Next Generation - Austin Java Users Group

The Next Generation

Prabhat JhaPrincipal Engineer

What do you wish you had in an Open Source JEE Application Server?

Faster Startup Time?

Lighter Memory Footprint?

Easier Administration?

7 Reasons To Love AS7...

7 Reasons To Love AS7...

• Blazing fast startup time

7 Reasons To Love AS7...

• Blazing fast startup time

• Lightweight

7 Reasons To Love AS7...

• Blazing fast startup time

• Lightweight

• Modular core

7 Reasons To Love AS7...

• Blazing fast startup time

• Lightweight

• Modular core• Hot, parallel deployment

7 Reasons To Love AS7...

• Blazing fast startup time

• Lightweight

• Modular core• Hot, parallel deployment

• Elegant administration

7 Reasons To Love AS7...

• Blazing fast startup time

• Lightweight

• Modular core• Hot, parallel deployment

• Elegant administration• Domain management

7 Reasons To Love AS7...

• Blazing fast startup time

• Lightweight

• Modular core• Hot, parallel deployment

• Elegant administration• Domain management

• First class components

Bonus for Austin JUG

• Testable by design :-)

Details

Blazing Fast Startup Time

Lightweight Footprint

New Possibilities

• Execute an entire Java EE container in a unit test !

• Use an appserver VM per application

• Run in constrained environments (light cloud, plug computers, mobile devices)

• Develop faster than you ever have before.

• Run multiple staging servers on your laptop.

JBoss AS7 Architecture

Modular Core

Isolated Classes vs.One Size Fits All!

JBoss Modules• Provides extremely fast modular class loading

– O(1) Dependency resolution

– Concurrent CL (lockless in most VMs)

• “Pure” modular class loading– Modules only see what they import (includes JDK classes!)

• External module definitions– Don’t have to break open the JAR

• Dynamic– Modules can be redefined

• Extensible– JBoss OSGi implemented on modules

OLD: HierarchicalClassloading

NEW:Modular

Classloading

User Deployments

• User deployments are modules too

• Sets up dependencies on some modules automatically (e.g. JPA, Hibernate, WebServices)

• The user can also set up their own dependencies on app server modules

Hot, Parallel Deployment

Services Load Concurrently!

Services

• In AS7 almost everything is a service

• Services are objects that can be started and stopped

• Services can have dependencies on other services

• When all a services dependencies are satisfied it will attempt to start

• If a dependency going to be stopped, then MSC will stop all dependent services first

• Services can inject dependent services

Elegant Administration

First Class Components

• Infinispan

• CDI/Weld

• HornetQ• Hibernate

• JSF

• OSGI

• PicketBox

EAP 6 – Test Drive Now!

• Fast and Lightweight

• Supports domain (multi-node) management

• Multiple consistent management interfaces

• CLI, Java API, HTTP API, Console

• Unified, user-focused configuration

• Modular

• Only APIs, no AS implementation exposure

• True isolation

Key Features

Two Operational Models

Standalone• Traditional JBoss single JVM server

• Management facilities IN-VM

Domain• Multi-JVM, multi-server model

• Management coordinated by Domain Controller Process

• Multiple server instances (JVMs) per Host

• Full lifecycle managed by Process Controller

Standalone Mode

• Standalone is a single AS process for use in development, where the additional management functionality is not required

• Provides a similar development experience to previous versions of the AS, allowing for a deployment to be dropped in the deployments folder and automatically deployed

• Can still be managed by the same tools and API's as domain mode

Standalone Mode

Demo

Domain Mode

• Easy management of multiple AS instances

• Managed from a single point, all have access to the same domain configuration

• Allows for management and configuration updates to be pushed out to all servers

• Domain Mode has three separate processes:– Process Controller

– Host Controller

– Server Instance

Domain Mode Architecture

Domain Mode ..

• Multi-server management as a core part of AS 7 /EAP 6 itself– Start/quiesce/stop servers– Rolling deployment to a set of servers– Roll a config change out of a set of servers– Roll back changes

Domain Model Concepts

• Subsystem : a particular set of capabilities that extend the app server core

– WebServer, Transaction Manager, EJB3

• Profile: the set of subsystem a server or a group of server runs

– Change your profile to expand or narrow the capabilities of your servers

Management

• ONE configuration file – standalone.xml / domain.xml

• Management API that allows for persistent changes to the configuration

• Management API can manage all servers in the domain

• Management console to provide user friendly management in a web browser

• Command line tool for use in scripts

Management via Configuration

Management via API

Management via CLI

• Scriptable command line management tool

• Uses the management API internally

• Allows access to high level user friendly commands:

create-jms-queue –-name testQueue

• Also allows direct access to the domain model, giving access to the full functionality of the management API

Testing with Arquillian

• AS7 supports easy testing with ArquillIan

• Arquillian is used both in the internal test suite and by end users to test their applications

• Combined with the fast startup speed of AS7 testing in the container is just as easy as running normal JUnit tests.

High Octane Development | Automated Testing for Java EE6 | Andrew Lee Rubinger

A simple API for constructing archives as Java objects:

WebArchive archive = ShrinkWrap.create(WebArchive.class,”archive.war”) .addClasses(MyClass.class,MyOtherClass.class, WecomeServlet.class) .addAsResource("mystuff.properties");myServer.deploy(archive); // And done.

Java EE 6 Intro

• Extensibility

• Profiles

– Subsets of “full” EE platform

– Web Profile

• Pruning

– CMP, JAX-RPC, JAXR, JSR-88 are “pruned” in EE6

• New Technology & Improvements to Existing

– Dependency Injection, CDI, Servlet 3, JPA 2, JSF 2, JAX-RS, Bean Validation

Servlet 3

• Ease of Development

– Annotations

– Zero configuration in XML for the most part.

• Web framework pluggability

– Programmatic access to web.xml

– Dynamic changes to configuration of webapp

• Async and Commet support

– Non blocking input and output

– Delay request handing

– Delay response close

Servlet 3

@WebServlet@WebServlet

@WebServlet("/report")

public class ReportServlet extends HttpServlet

@WebFilter@WebFilter

@WebFilter(filterName = "TimeOfDayFilter",

urlPatterns = {"/*"},

initParams = {

@WebInitParam(name = "report", value = "dev")})

public class TimeOfDayFilter implements Filter {

@HttpConstraint @HttpMethodConstraint @MultipartConfig@HttpConstraint @HttpMethodConstraint @MultipartConfig

@ServletSecurity @WebInitParam @WebListener@ServletSecurity @WebInitParam @WebListener

JSF 2

• Ajax

• Easy component creation

• Bookmarkable URLs

• Templating (think Facelets)

JPA 2

• O/R mapping enhancements

– Embedded objects, collections, ordered lists

• Query and Entity Manager Enhancements

– First result, max results, typed results

• Criteria API

• 2nd Level Caching

• Pessimistic Locking

JPA 2 ...

JAX-RS

• Web services through REST instead of SOAP

• REST counterpart of JAX-WS

• Annotations from ground up

• Integration with CDI and EJB@Path("users/{username: [a-zA-Z][a-zA-Z_0-9]}")

public class HelloWorldResource {

@GET

@Produces("text/xml")

public String getMessage(@PathParam("username") String userName) {

return "Hi” + userName + “!! Howz JBoss AS 7 ??";

}

EJB 3.1 ( Lite)

• Removal of the requirement for a separate local business interface.

• Support for direct use of EJBs in the servlet container, including simplified packaging options.

• Singleton beans with different locking options.

• Support for asynchronous session bean invocation.

• Application-level callback notifications, including for container initialization and shutdown.

• EJB Timer Service enhancements to support cron-like scheduling, deployment-time timer creation, and stateful session bean timed objects.

• Lite:

– Local Session Bean, Annotation, Security, Interceptors.

– MDB, Timer, Web Services End Point, RMI-IIOP

EJB 3.1 ( Lite) ...

@javax.ejb.Stateless

public class CarHotelAndAirLineBookingServiceBean {

@javax.ejb.Asynchronous

public Future<BookingConfirmation> bookCarHotelAndAirLine( Car rental, Hotel hotel, AirLine airLine) { ...}

}//end async service

//-------------------------In your JSF bean, you can then do------------------------------

public String makeRequest() {

confirmation = bookingService.bookCarHotelAndAirLine(...);

return "showConfirmationPending";

}

public Future<BookingConfirmation> getConfirmation(){ /* ... */ }

EJB 3.1 ( Lite)

• Removal of the requirement for a separate local business interface.

• Support for direct use of EJBs in the servlet container, including simplified packaging options.

• Singleton beans with different locking options.

• Support for asynchronous session bean invocation.

• Application-level callback notifications, including for container initialization and shutdown.

• EJB Timer Service enhancements to support cron-like scheduling, deployment-time timer creation, and stateful session bean timed objects.

• Lite:

– Local Session Bean, Annotation, Security, Interceptors.

– MDB, Timer, Web Services End Point, RMI-IIOP

Bean Validation

• Specify constraints only once across application layers @NotNull

@Size(min = 1, max = 25)

@Pattern(regexp = "[A-Za-z ]*", message = "must contain only letters and spaces")

private String name;

@NotNull

@Size(min = 10, max = 12)

@Digits(fraction = 0, integer = 12)

private String phoneNumber;

CDI

• Makes Java EE development more productive. !!

• Provides a declarative way to manage the scope, state and life-cycle of components bound to contexts.

• Provides a standardised, annotation-driven, type-safe dependency injection framework for the platform .

• Provides a Service Provider Interface (SPI) for developing portable extensions for the Java EE platform

• What is CDI aka JSR-299's relationship with respect to JSR-330, Dependency Injection?

Community or Enterprise?

Community or Enterprise?

Demo

• Administration Console

• Domain Model

• Quickstart with maven archetype• Deployments

• OpenShift mvn archetype:generate \-DarchetypeArtifactId=jboss-javaee6-webapp \-DarchetypeGroupId=org.jboss.spec.archetypes \-DarchetypeVersion=7.0.0.CR1 \-DarchetypeRepository=repository.jboss.org/ nexus/content/groups/public

mvn archetype:generate \-DarchetypeArtifactId=jboss-javaee6-webapp \-DarchetypeGroupId=org.jboss.spec.archetypes \-DarchetypeVersion=7.0.0.CR1 \-DarchetypeRepository=repository.jboss.org/ nexus/content/groups/public

OpenShift – EE6 In the Cloud!