Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Jakarta EE 11 and Beyond

Reza Rahman
December 06, 2020

Jakarta EE 11 and Beyond

Java EE has been re-branded to Jakarta EE and moved to truly open source governance under the Eclipse Foundation. There have so far been several successful releases under the Eclipse Foundation - Jakarta EE 8, 9, 9.1, 10, and now 11. This session overviews what this means and offers a brief tour of Jakarta EE 11. We will also look at what the future might bring.

We will discuss high level themes, platform level changes, and some detailed features for Jakarta EE 11. Jakarta EE 11 adopts key changes in Java SE including Records and Virtual Threads. It adds a brand new specification called Jakarta Data. Some technologies that have been updated include Persistence, Security, CDI, and Concurrency. Outdated specifications such as SOAP have been removed. Down the line in Jakarta EE 12, there may be further changes afoot for Jakarta Configuration, NoSQL, Messaging, Security, REST, gRPC, and MVC. You can contribute to all this and more.

You should come to this session with your thinking caps on and your sleeves rolled up. There is much to help move forward together that really matters.

Reza Rahman

December 06, 2020
Tweet

More Decks by Reza Rahman

Other Decks in Programming

Transcript

  1. Jakarta EE • Java EE transitioned from JCP to Eclipse

    Foundation as Jakarta EE • Open governance, open source, open compatibility testing • Well-defined specification process, clear IP flow, vendor-neutral open collaboration, level playing field • Key stakeholders maintained if not expanded including Oracle, IBM, Payara, Tomitribe, Red Hat, Microsoft, VMware, Alibaba, London Java Community, OmniFish, SouJava, Apache • Community participation and contribution key https://jakarta.ee
  2. The Importance of Jakarta EE • Jakarta EE is an

    important part of the Java ecosystem • 25-35% of Java applications run on Jakarta EE runtimes • WildFly, Payara, GlassFish, JBoss EAP, WebSphere/Liberty, WebLogic • 70-80% of Java applications depend on at least one or more Jakarta EE APIs • Tomcat, Hibernate, ActiveMQ, Jetty, Jersey, RESTEasy, Quarkus, MicroProfile, Spring Boot 2024 Jakarta EE Developer Survey: https://outreach.eclipse.foundation/jakarta-ee-developer-survey-2024
  3. Jakarta EE Evolution JPE J2EE 1.2 Servlet, JSP, EJB, JMS

    J2EE 1.3 CMP, JCA J2EE 1.4 JAX-WS Java EE 5 EJB 3, JPA, JSF, JAXB, JAX-WS Java EE 7 WebSocket, JSON, Concurrency, Batch, pruning Java EE 8 HTTP/2, SSE, Security, pruning Java EE 6 Profiles, CDI, JAX- RS, Bean Validation Jakarta EE 8 Open-source governance Jakarta EE 9.x Namespace transition Jakarta EE 10 New features, updates Jakarta EE 11 New APIs, features, updates
  4. • CDI Alignment • @Asynchronous, @Schedule, @Lock, @MaxConcurrency in Concurrency,

    @MessageListener in Messaging, @RolesAllowed, @RunAs in Security • Better CDI support in Batch, REST • Java SE Alignment • CompletionStage in Concurrency • Bootstrap APIs for REST, Messaging • Closing standardization gaps • OpenID Connect, JWT, in-memory identity store, batch job definition Java API, @ManagedExecutorDefinition, more SQL support, multipart/form-data • Core/Microservices Profile • Deprecation/removal • EJB Entity Beans, embeddable EJB container, deprecated Servlet/Faces/CDI features • Innovation • Repositories, NoSQL, MVC, Configuration, gRPC Jakarta EE 10 in Context Made it! On the way Gap
  5. Jakarta EE 11 in Context • CDI Alignment • @Schedule,

    @Lock, @MaxConcurrency in Concurrency, @MessageListener in Messaging, @RolesAllowed, @RunAs in Security • Better CDI support in REST, Persistence, Concurrency • Java SE Alignment • Adapting to Records, Virtual Threads • Bootstrap API for Messaging • Modularity, standalone/modernized TCKs • Closing standardization gaps • In-memory identity store, JWT, batch job definition Java API, @Service • Deprecation/removal • JAX-WS (SOAP), JAXB (XML), CORBA, @ManagedBean, EJB • Innovation • Repositories, NoSQL, MVC, Configuration, gRPC Made it! On the way Gap
  6. • Q1 2025 target release date • Java SE 17/21

    baseline, adapting to key changes • Records, Virtual Threads, Security Manager deprecation • Specification updates • Persistence, Concurrency, Security, CDI, Validation • New specifications • Data • Deprecation • JAX-WS (SOAP), JAXB (XML), CORBA, @ManagedBean • Modernized TCK Jakarta EE 11 Themes
  7. Jakarta Persistence • Support for Java SE Records as embeddable

    classes • Support for Instant, Year • Deprecate usage of Date, Time, Timestamp, @Temporal in favor of Date/Time API • More SQL-like features in QL and criteria API • concat (||), union, intersect, except, cast, left, right, replace • Thread-safe entity manager via @Inject • Java configuration as alternative to persistence.xml • Make persistence.xml optional/empty marker • JCache as a second-level cache provider
  8. Embeddable Records @Embeddable public record Address (String street, String city,

    String state, String zipCode) { } @Entity public class Person { @Id private Long id; private String firstName; private String lastName; @Embedded private Address address; ... }
  9. Jakarta Concurrency • Adapting to Virtual Threads • Virtual Threads

    mostly implementation level concern for runtimes • CDI based, modernized equivalent for EJB @Schedule • @Inject support • Support for Flow API • CDI based, modernized equivalent for EJB @Lock • Adding @MaxConcurrency
  10. @Schedule in CDI Beans @ApplicationScoped public class UploadDirectoryScanner { @Asynchronous(runAt

    = { @Schedule(cron = "*/15 * * * * *")}) public CompletableFuture<Integer> processFiles(int mininumSize) { ... if (normal) { return null; // Continue schedule } return Asynchronous.Result.complete(reason); // Stop schedule } }
  11. Jakarta Security • JWT alignment • MicroProfile bridge specification •

    Multiple authentication mechanisms • In-memory identity store • CDI based, modernized equivalent for @RolesAllowed, @RunAs
  12. In-memory Identity Store @InMemoryIdentityStoreDefinition({ @Credentials(callerName = "peter", password = "secret1",

    groups = { "foo", "bar" }), @Credentials(callerName = "john", password = “secret2", groups = { "foo", "kaz" }) })
  13. • CDI based, modernized @MessageListener • Jakarta Messaging Lite for

    cloud native use cases • Standalone bootstrap API • AMQP interoperability Jakarta Messaging
  14. @MessageListener Example @ApplicationScoped @MaxConcurrency(10) public class HandlingEventRegistrationAttemptConsumer { @MessageListener( destinationLookup="jms/HandlingEventRegistrationAttemptQueue",

    selector="source = 'mobile'", batchSize=10, orderBy=TIMESTAMP, retry=5, retryDelay=7000, deadLetterQueue="jms/DeadLetterQueue") public void onEventRegistrationAttempt( HandlingEventRegistrationAttempt... attempts) { ... } }
  15. Bootstrap API for Jakarta Messaging JmsContainer container = JmsContainerFactory.newInstance(); ...

    JMSContext jmsContext = container.getJmsContext(); Destination handlingEventQueue = container.getDestination( “jms/HandlingEventRegistrationAttemptQueue” true); ... jmsContext.createProducer() .setDisableMessageID(true) .setDisableMessageTimestamp(true) .setStringProperty("source", source) .send(handlingEventQueue, attempt); ... container.close();
  16. • Higher level (Repository pattern) data access abstraction like DeltaSpike

    Data, Spring Data • Automatically generated Repository implementations based on annotated interface • Both Jakarta Persistence and NoSQL Jakarta Data
  17. Jakarta Data Example @Entity public class Product { @Id private

    long id; @Column @NotBlank private String name; @Column @PositiveOrZero private float price; @Repository public interface Products extends CrudRepository<Product, Long> { @Asynchronous @OrderBy("price") CompletableFuture<List<Product>> findByNameContains(String searchFor); @Query( "UPDATE Product o SET o.price = o.price - (?2 * o.price) WHERE o.id = ?1") boolean discount(long productId, float discountRate); }
  18. • Standard action-based web framework • Jakarta Faces continues to

    evolve separately • Standalone, “prospective specification” in Jakarta EE 11 • Model • CDI, Validation • View • Facelets, Jakarta Server Pages • Controller • Based on Jakarta REST Jakarta MVC
  19. Jakarta MVC Example @Controller @Path("/") @View("my-index.xhtml") public class Bookstore {

    @Inject private Models model; @Inject private BookService service; ... @GET public void index() { ... model.put(“books”, books); } }
  20. • Specification for accessing NoSQL databases • Mapping/template API akin

    to Jakarta Persistence • API variants by NoSQL taxonomy • Key-value pair, column family, document, and graph • Repositories, validation, externalized configuration Jakarta NoSQL
  21. Jakarta NoSQL Example @Entity public class Order { @Id private

    long id; @Column @NotBlank private String description; @Column @NotEmpty private List<OrderLine> orderLines; @Column @NotNull private Customer customer; @Column @NotNull private Address address; template.insert(order); ... List<Order> results = template.select(Order.class) .where("description").like("^Pinball").result(); logger.info("Found orders for pinball: " + results.size());
  22. Jakarta Configuration • Externalizing application configuration • Built-in stores •

    Property files, Java system properties, environment variables • Extensible stores • Kubernetes Secrets • Secure cloud storage (such as Azure Key Vault) • NoSQL stores (such as Azure Redis) • Relational database • @Inject into code • Reference in EL • Reference in XML • Moving MicroProfile Config to Jakarta EE
  23. Jakarta Configuration Examples @Inject @ConfigProperty(name = “admin.group”, defaultValue=“admin”) private String

    adminGroup; persistence.provider=org.hibernate.ejb.HibernatePersistence persistence.datasource=java:app/jdbc/CargoTrackerDatabase persistence.schema.generation.database.action=create <data-source> <name>java:app/jdbc/CargoTrackerDatabase</name> <class-name>org.apache.derby.jdbc.EmbeddedDriver</class-name> <url>jdbc:derby:${temp.dir}/cargo-tracker-database</url> </data-source>
  24. Other Changes • Java SE Records support in Jakarta Validation,

    CDI, EL • @ManagedBean deprecated • Java SE SecurityManager dependency removed • @Priority on producers • Java SE Records support in JSON Binding • Replace Jakarta REST @Context by CDI/@Inject • Deprecate @Context • Java job definition API as alternative to XML in Jakarta Batch
  25. Validating Records public record Car( @NotBlank String manufacturer, @NotNull @Size(min

    = 2, max = 14) String licensePlate, @Min(2) int seatCount) { }
  26. Job Definition API Example Job job = new JobBuilder(jobName).property("jobk1", "J")

    .listener("jobListener1", new String[]{"jobListenerk1", "#{jobParameters['jobListenerPropVal']}"}, .step(new StepBuilder(stepName) .properties(new String[]{"stepk1", "S"}, new String[]{"stepk2", "S"}) .batchlet(batchlet1Name, new String[]{"batchletk1", "B"}, new String[]{"batchletk2", "B"}) .listener("stepListener1", stepListenerProps) .stopOn("STOP").restartFrom(stepName).exitStatus() .endOn("END").exitStatus("new status for end") .failOn("FAIL").exitStatus() .nextOn("*").to(step2Name) .build()) ... .build();
  27. • More custom websites for key Jakarta EE technologies •

    Like https://beanvalidation.org, http://www.cdi-spec.org • Jakarta EE Examples • Quickly getting working code for most use cases • Jakarta EE Tutorial • The official free resource to learn Jakarta EE • Jakarta Starter • Helping developers getting started quickly • Eclipse Cargo Tracker • End-to-end application demonstrating architectural practices like Domain-Driven Design Beyond Specification Work
  28. Ways of Contributing • Follow Jakarta EE technologies that interest

    you and share opinion • https://jakarta.ee/connect/mailing-lists/ • Advocate for a specific change or feature • https://jakarta.ee/projects/ • Help implement a change in API, specification, TCK or implementation • Sign Eclipse Contributor Agreement • https://www.eclipse.org/legal/ECA.php • Becoming a committer comes much later • Engage an Ambassador if needed • https://jakartaee-ambassadors.io
  29. Summary • Jakarta EE 11 almost here, has important changes

    • One of the key motivations to move Java EE to Jakarta EE is greater community contribution • Jakarta EE work is ongoing - time to get involved is now!
  30. Resources • JakartaOne Livestream recordings • https://jakartaone.org • Jakarta EE

    Community mailing list • https://accounts.eclipse.org/mailing-list/jakarta.ee-community • Jakarta EE X/Twitter handle • @JakartaEE • Jakarta Tech Talks • https://www.meetup.com/jakartatechtalks_