Slides of the talk we made with David Delabasee (@delabassee) at Devoxx 2015. A list of Java SE 8 patterns that you can use in Java EE 7 applications, thanks to the support of the major app servers.
Asynchronous API in Java8, how to use CompletableFutureJosé Paumard
Slides of my talk as Devoxx 2015. How to set up asynchronous data processing pipelines using the CompletionStage / CompletableFuture API, including how to control threads and how to handle exceptions.
The slides of my JavaOne 2017 talk. It describes how you can create API using functional interfaces, default and static methods starting with Java 8. You can watch the video here: https://www.youtube.com/watch?v=64UO1YjVcZ0
The slides of my university talk at Devoxx BE 2015. Presentation of the Java 8 Stream API and RxJava, pattern and performance comparisons. Presentation of the upcoming reactive API in Java 9: the Flow API.
The spliterators patterns can be found here: https://github.com/JosePaumard/jdk8-spliterators.
Lambda and Stream Master class - part 1José Paumard
These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This first part covers Lambda Expressions and API design with functional interfaces.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
Lambdas and Streams Master Class Part 2José Paumard
These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This second part covers the Stream API, reduction and the Collector API.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
Asynchronous API in Java8, how to use CompletableFutureJosé Paumard
Slides of my talk as Devoxx 2015. How to set up asynchronous data processing pipelines using the CompletionStage / CompletableFuture API, including how to control threads and how to handle exceptions.
The slides of my JavaOne 2017 talk. It describes how you can create API using functional interfaces, default and static methods starting with Java 8. You can watch the video here: https://www.youtube.com/watch?v=64UO1YjVcZ0
The slides of my university talk at Devoxx BE 2015. Presentation of the Java 8 Stream API and RxJava, pattern and performance comparisons. Presentation of the upcoming reactive API in Java 9: the Flow API.
The spliterators patterns can be found here: https://github.com/JosePaumard/jdk8-spliterators.
Lambda and Stream Master class - part 1José Paumard
These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This first part covers Lambda Expressions and API design with functional interfaces.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
Lambdas and Streams Master Class Part 2José Paumard
These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This second part covers the Stream API, reduction and the Collector API.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
The slides of my JavaOne 2016 talk. This talk is a tutorial on how to write lambda expressions, how to compose them using default methods in functional interfaces, and how to create factory methods in those interfaces. Many examples and patterns are provided.
Slides from the talk we did with Maurice Naftalin for Devoxx Belgium 2019.
Functional programmers have been saying for decades that they know the way to the future.
Clearly they have been wrong, since imperative languages are still far more popular.
Clearly they have also been right, as the advantages of functional programming have become increasingly obvious. Is it possible to face both ways, and combine the two models?
Scala is one language that does this, and Java too has been on a journey, which still continues, of learning from functional languages and carefully adding features from them.
In this talk, we will review what Java has learned from functional languages, what it can still learn, and how its added features compare to Scala's original ones.
Java 8 Stream API and RxJava ComparisonJosé Paumard
The slides of my JavaOne talk: Java 8 Stream API and RxJava Comparison: Patterns and Performances.
The spliterators patterns can be found here: https://github.com/JosePaumard/jdk8-spliterators.
A brief introduction to using Apache Solr for implementing search for your website.
Download the ppt to see comments which add more detail.
Presented at eBig Java SIG, Oakland, CA. June 2008
The slides of my talk at Devoxx BE 2017. This in depth talk is all about collectors: those available, because we need to know them, those that we can create, those we had no idea they could be created, and the others, as there is in fact no limit to what can be done with this API. The concept of downstream collector will be used to show how we can write entire data processing pipelines using collectors only, and pass them as parameters to other pipelines.
Currying and Partial Function Application (PFA)Dhaval Dalal
We look at Currying and Partial Function Application (PFA) in Functional Programming. Languages like Clojure don't have currying, but PFA, where has Haskell currying and not PFA, whereas Scala has both, Groovy wants you to call methods like curry() and rcurry(). In OO paradigm, we use DI (dependency Injection) and we will see how this is automatically subsumed using Currying and PFA.
If you thought Monads are a mystery, then this demonstration would show you how to evolve your code towards a Monad without knowing about it. This demo will neither go into any Category Theory nor begin with monadic laws. Instead, we will start with typical code that you see in your daily life as a developer, attempt to DRY (Don't Repeat Yourself) it up and eventually use Monad to remove duplication and verbosity. You'll also see how Monads make your code more declarative and succinct by sequencing the steps in your domain logic.
Also, we know in Java8 Checked Exceptions + λ == Pain! To be more precise, we will evolve a Try<t> (exception handling monad) which is missing in Java8, similar to one found in Scala.
React mit TypeScript – eine glückliche Eheinovex GmbH
In seiner Brownbag sprach inovexler Johann über die Verwendung von TypeScript in einer React-Anwendung.
Als Java-Land Immigrant mit Typisierungshintergrund, fällt es einem in der neuen JavaScript-Welt erstmal schwer auf etablierte Refactoring-Traditionen und die gute, alte Code-Literatur zu verzichten. TypeScript bringt verloren geglaubte Möglichkeiten zurück und ist auch zu React eine willkommene Bereicherung.
In diesem Vortrag wird gezeigt, wie man möglichst einfach ein React-Projekt mit TypeScript aufsetzt, einfache Typisierungsregeln etabliert und bekannte Bibliotheken integriert.
Event: Brownbag bei inovex
Speaker: Johann Böhler, inovex
Datum: 25.06.2018
Weitere Tech-Vorträge: https://www.inovex.de/de/content-pool/vortraege/
Weitere Tech-Artikel: www.inovex.de/blog
Doctrine ORM with eZ Platform REST API and GraphQLJani Tarvainen
The eZ Platform Enterprise Content Management System (CMS) can accommodate additional data sources in addition to it's standard content repository. Written in PHP on the Symfony full stack framework developers can use relational databases, hybrid SQL engines like PostgreSQL or MySQL or NoSQL stores like MongoDB. This presentation shows some hands on examples with the Doctrine ORM, also integrating with the GraphQL protocol as well as the built in REST Framework of eZ Platform.
JAX-RS and CDI Bike the (Reactive) BridgeJosé Paumard
This session explains how JAX-RS and CDI became reactive capable in Java EE 8. We put some new features of JAX-RS 2.1 and CDI 2.0 into perspective and show some reactive patterns to improve your application. Add Java 8 CompletionStage to the mix and this API trio becomes your best bet to easily go reactive without leaving the Java EE train.
I am Joe L. I am a Python Assignment Expert at programminghomeworkhelp.com. I hold a Ph.D. in Programming from, University of Chicago, USA. I have been helping students with their homework for the past 8 years. I solve assignments related to Python Programming.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.You can also call on +1 678 648 4277 for any assistance with Python Programming Assignments.
The slides of my university talk, Devoxx Belgium 2016.
The goal of this talk is to compare the two most popular implementations of List: LinkedList and ArrayList, and provide hints on which one to use in what case.
ArrayList et LinkedList sont dans un bateauJosé Paumard
Slides de mon université à Devoxx France 2016. Le sujet est la performance des algorithmes d'implémentation de List et leur adéquation avec la structure des CPU actuels.
The slides of my JavaOne 2016 talk. This talk is a tutorial on how to write lambda expressions, how to compose them using default methods in functional interfaces, and how to create factory methods in those interfaces. Many examples and patterns are provided.
Slides from the talk we did with Maurice Naftalin for Devoxx Belgium 2019.
Functional programmers have been saying for decades that they know the way to the future.
Clearly they have been wrong, since imperative languages are still far more popular.
Clearly they have also been right, as the advantages of functional programming have become increasingly obvious. Is it possible to face both ways, and combine the two models?
Scala is one language that does this, and Java too has been on a journey, which still continues, of learning from functional languages and carefully adding features from them.
In this talk, we will review what Java has learned from functional languages, what it can still learn, and how its added features compare to Scala's original ones.
Java 8 Stream API and RxJava ComparisonJosé Paumard
The slides of my JavaOne talk: Java 8 Stream API and RxJava Comparison: Patterns and Performances.
The spliterators patterns can be found here: https://github.com/JosePaumard/jdk8-spliterators.
A brief introduction to using Apache Solr for implementing search for your website.
Download the ppt to see comments which add more detail.
Presented at eBig Java SIG, Oakland, CA. June 2008
The slides of my talk at Devoxx BE 2017. This in depth talk is all about collectors: those available, because we need to know them, those that we can create, those we had no idea they could be created, and the others, as there is in fact no limit to what can be done with this API. The concept of downstream collector will be used to show how we can write entire data processing pipelines using collectors only, and pass them as parameters to other pipelines.
Currying and Partial Function Application (PFA)Dhaval Dalal
We look at Currying and Partial Function Application (PFA) in Functional Programming. Languages like Clojure don't have currying, but PFA, where has Haskell currying and not PFA, whereas Scala has both, Groovy wants you to call methods like curry() and rcurry(). In OO paradigm, we use DI (dependency Injection) and we will see how this is automatically subsumed using Currying and PFA.
If you thought Monads are a mystery, then this demonstration would show you how to evolve your code towards a Monad without knowing about it. This demo will neither go into any Category Theory nor begin with monadic laws. Instead, we will start with typical code that you see in your daily life as a developer, attempt to DRY (Don't Repeat Yourself) it up and eventually use Monad to remove duplication and verbosity. You'll also see how Monads make your code more declarative and succinct by sequencing the steps in your domain logic.
Also, we know in Java8 Checked Exceptions + λ == Pain! To be more precise, we will evolve a Try<t> (exception handling monad) which is missing in Java8, similar to one found in Scala.
React mit TypeScript – eine glückliche Eheinovex GmbH
In seiner Brownbag sprach inovexler Johann über die Verwendung von TypeScript in einer React-Anwendung.
Als Java-Land Immigrant mit Typisierungshintergrund, fällt es einem in der neuen JavaScript-Welt erstmal schwer auf etablierte Refactoring-Traditionen und die gute, alte Code-Literatur zu verzichten. TypeScript bringt verloren geglaubte Möglichkeiten zurück und ist auch zu React eine willkommene Bereicherung.
In diesem Vortrag wird gezeigt, wie man möglichst einfach ein React-Projekt mit TypeScript aufsetzt, einfache Typisierungsregeln etabliert und bekannte Bibliotheken integriert.
Event: Brownbag bei inovex
Speaker: Johann Böhler, inovex
Datum: 25.06.2018
Weitere Tech-Vorträge: https://www.inovex.de/de/content-pool/vortraege/
Weitere Tech-Artikel: www.inovex.de/blog
Doctrine ORM with eZ Platform REST API and GraphQLJani Tarvainen
The eZ Platform Enterprise Content Management System (CMS) can accommodate additional data sources in addition to it's standard content repository. Written in PHP on the Symfony full stack framework developers can use relational databases, hybrid SQL engines like PostgreSQL or MySQL or NoSQL stores like MongoDB. This presentation shows some hands on examples with the Doctrine ORM, also integrating with the GraphQL protocol as well as the built in REST Framework of eZ Platform.
JAX-RS and CDI Bike the (Reactive) BridgeJosé Paumard
This session explains how JAX-RS and CDI became reactive capable in Java EE 8. We put some new features of JAX-RS 2.1 and CDI 2.0 into perspective and show some reactive patterns to improve your application. Add Java 8 CompletionStage to the mix and this API trio becomes your best bet to easily go reactive without leaving the Java EE train.
I am Joe L. I am a Python Assignment Expert at programminghomeworkhelp.com. I hold a Ph.D. in Programming from, University of Chicago, USA. I have been helping students with their homework for the past 8 years. I solve assignments related to Python Programming.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.You can also call on +1 678 648 4277 for any assistance with Python Programming Assignments.
The slides of my university talk, Devoxx Belgium 2016.
The goal of this talk is to compare the two most popular implementations of List: LinkedList and ArrayList, and provide hints on which one to use in what case.
ArrayList et LinkedList sont dans un bateauJosé Paumard
Slides de mon université à Devoxx France 2016. Le sujet est la performance des algorithmes d'implémentation de List et leur adéquation avec la structure des CPU actuels.
Of course Java 8 is all about lambda expressions and this new wonderful Stream API. Now the question is, what's left in Java 8, once we've removed everything : lambdas, streams, collectors, java FX and Nashorn ? This presentation gathered all these new diamonds, scattered all around the JDK, brand new classes, and new methods in existing classes.
50 nouvelles choses que l'on peut faire avec Java 8José Paumard
Java 8, c'est bien sûr l'arrivée des lambdas, des Stream et des Collectors. Mais ce n'est pas que cela. Plein de nouvelles choses sont aussi offertes : un nouvelle API pour les dates, un nouveau moteur Javascript, une nouvelle version de JavaFX, une nouvelle ConcurrentHashMap, une nouvelle HashMap, des nouveautés dans le domaine de la concurrence, et toutes sortes de petites choses qui vont nous faciliter la vie, que l'on se propose de passer en revue ici.
This is the slides I was using in my talk in the Java 8 Lambda Expressions meetup. More information about this meetup can be found at www.meetup.com/life-michael/events/234566034/ More information about the Java course I deliver can be found at java.course.lifemichael.com
Because Elixir and Phoenix borrow so many good ideas from the Rails ecosystem, it’s astoundingly easy for Ruby developers to become proficient in this powerful new set of tools. First, I’ll introduce Phoenix from a Rails POV, and then show two ways it can be used in conjunction with Rails.
This is a presentation given on October 24 by Michael Uzquiano of Cloud CMS (http://www.cloudcms.com) at the MongoDB Boston conference.
In this presentation, we cover Hazelcast - an in-memory data grid that provides distributed object persistence across multiple nodes in a cluster. When backed by MongoDB, objects are naturally written to Mongo by Hazelcast. The integration points are clean and easy to implement.
We cover a few simple cases along with code samples to provide the MongoDB community with some ideas of how to integrate Hazelcast into their own MongoDB Java applications.
Java SE 8 has brought lambdas, default methods, type annotations, compact profiles, etc. As a result, the Java SE platform specification was changed to reflect new features.
The session shows how the new Java 8 features have been implemented in Excelsior JET JVM, written from scratch, very different from the Oracle HotSpot JVM, but compatible with the Java SE specification.
As a result, an attendee will refresh his/her memory regarding new Java 8 features, will learn how they affected the JVM specification, how the lambda expressions are translated into Java bytecode and how they can be optimized at the JVM level.
«Бутылочное горлышко многопоточных программ – кто виноват, и что делать. Мастер-класс.»
BitByte: 20 апреля 2013, Санкт-Петербург
http://bitbyte.itmozg.ru/
When you work in a small collocated team many engineering practices and approaches are relatively easy to use and adapt. In large project with many teams working on the same product this task is not so simple. I want to share experience report in implementing Code Review practice in big product development team (more than 150 people, 10+ feature teams). In this talk we will review what approaches works in such setup and what don’t work, what tools and additional practices are needed to support Code Review and make it more effective, what difficulties and blockers will you probably see in the real life cases, what useful metrics could be produced by this practice.
In this webinar we will compare the complexities involved in Terracotta with the code/configuration changes to migrate to Hazelcast. You will learn about important features of Hazelcast such as IMDG capabilities, off-heap data storage, distributed collections, etc. and the feature-rich product portfolio of Hazelcast. We will cover how Hazelcast can scale up and out dynamically and without downtime against the static configuration of Terracotta. Expect to leave the webinar being more educated about Hazelcast in terms of architecture, important features and best practices.
We’ll cover these topics:
- Hazelcast architecture and features
- Terracotta distributed architecture
- Scale – Vertical + Horizontal = Showcase no downtime feature in Hazelcast
- BigMemory vs. HDC
- Ease of installation – two jars against multiple jars
- Config and Code changes – cache vs. maps, off-heap vs. HDC
- Portability of Client APIs – IMap, IQueue, Topics, etc.
- Added functionalities – Showcase IExecutorService, EntryProcessors, Multimap, etc.
- DSO – Showcase EntryProcessors taking place of DSO
- Live Q&A
Presenter:
Rahul Gupta, Senior Solutions Architect
Rahul is a technology-driven professional with 12+ years of experience in building and architecting highly scalable and concurrent, low latency business critical distributed infrastructure. His expertise lies in Big Data and Real Time Analytics space where he specializes in big data governing technologies and Enterprise Architecture. Rahul is an expert in working with decision makers across different business verticals within an organization and guiding them in right decision making through in-depth technical understanding, analysis and evaluation procedures to bring home critical deals with high business values.
Java 8 is the most impactful update to the Java ecosystem since Java 5, introducing an entirely new programming model with lambda expressions, and a whole new platform of applications with support for ARM embedded devices. In this presentation, you will see live demonstrations of Java 8 technology running on embedded platforms such as Raspberry Pi and Lego Mindstorms EV3, allowing Java-based applications to support the internet-of-things.
With new low cost devices entering the market, access to the world of embedded computing is become more cost affordable. And, with continued advances in Java, developers can easily begin creating innovative applications that leverage these low cost devices. Come and learn how to build the future of Java.
Java9 Beyond Modularity - Java 9 más allá de la modularidadDavid Gómez García
These are the slides I used for my "Java 9 beyond modularity" at several different local meetups and conferences in Spain during 2017
Java 9 is about to reach its public release scheduled for September 2017. If we ask what are the new features that this new version will include, probably the first that comes to our head is modularity.
But java 9 brings with a lot of features beyound Jigsaw, JPMS or modularity. In this talk we will talk about at least 9 other new features that include this new version of Java that are interesting and maybe will end up being more used than the modularity itself for those who embrace the new version.
Those are changes that come to complement and improve even more the set of new tools (like Streams, Optionals, etc...) that Java 8 brought to us.
We'll take a look at small changes in language syntax (such as new ways of using try-with-resources), changes in Collections APIs and Streams, new tools like VarHandles, new APIs such as the Flow API, and As we allow the inclusion of reactive programming with Java.
Do you want to see in Java 9 beyond modularity? Do you want to have a more complete view of what you can provide? Let's take a look toghether!
The amount of data collected by applications nowadays is growing at a scary pace. Many of them need to handle billions of users generating and consuming data at an incredible speed. Maybe you are wondering how to create an application like this? What is required? What works best for your project?
In this session we’ll compare popular Java and JVM persistence frameworks for NoSQL databases: Spring Data, Micronaut, Hibernate OGM, Jakarta NoSQL, and GORM. How do they compare, what are the strengths, weaknesses, differences, and similarities? We’ll show each of them with a selection of different NoSQL database systems (Key-Value, Document, Column, Graph).
The data load on applications has increased exponentially in recent years. We know the JVM (Java Virtual Machine) can cope with heavy loads very well yet we often come across the big dilemma: there are tons of persistence frameworks out there but which one performs best for my case? It would normally take ages to evaluate and choose the best fit for your use case. We’ve done those comparisons for you.
SQLAdria 2009 presentation's slides about our experience with Maven and SQLJ. It delves in some details about SQLJ and performance comparion between SQLJ and JDBC with prepared statements. It also shows surprising results for what concerns performances of (DB2) SQL PL procedures
Tutorial on developing a Solr search component pluginsearchbox-com
In this set of slides we give a step by step tutorial on how to develop a fully functional solr search component plugin. Additionally we provide links to full source code which can be used as a template to rapidly start creating your own search components.
@Devoxx 2016
This talk will introduce you to Javaslang, a library that borrows heavily from Scala and applies Scala's ideas to plain old Java. We will cover some of the productivity enhancements and syntactic sugar that Javaslang offers, such as pattern matching aka. structural composition, value types and functional data types. Javaslang can be a building block for functional business code, that is easy to maintain and understand.
Learning To Run - XPages for Lotus Notes Client DevelopersKathy Brown
You’re an experienced Lotus Notes developer. You’ve been doing “classic” development for years. You know LotusScript better than your native language. You know @Formula like the back of your hand. But when it comes to Xpages and Javascript, you feel like you’re learning to walk all over again. This session will cover some tips and tricks to get you up and running in Xpages. Learn how to translate what you already know, into what you need to know for Xpages. Find out where to get the information to be just as skillful at Xpages as you are with Notes client development.
Twitter Author Prediction from Tweets using Bayesian NetworkHendy Irawan
Can We Predict the Author from a Tweet?
Most authors have a distinct writing style
... And unique topics to talk about
... And signature distribution of words used to tweet
Can we train Bayesian Network so that occurrence of words in a tweet can be used to infer the author of that tweet?
In summary: YES!
Disclaimer: Accuracy varies
In a test suite with @dakwatuna vs @farhatabbaslaw (very different tweet topics) – 100% prediction accuracy is achieved
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in PracticeJesse Gallagher
The XPages Jakarta EE Support project on OpenNTF adds an array of modern capabilities to NSF-based Java development. These improvements can be used for wholly-new applications or added incrementally to existing ones.
In this webinar Jesse Gallagher will demonstrate how to use this project to perform common tasks in better ways, such as creating and consuming REST services, writing managed beans with CDI, and using new EL features in XPages. Though these examples will largely use Java, they do not require any knowledge of OSGi or extension library development, nor any tools other than Designer.
Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java.Never write another getter or equals method again.
After watching this you will be able to give answer on following Questions
What is lombok?
Why to use project Lombok?
How to integrate/plug lombok project jar with you Eclipse ID?
How to use lombok maven project?
What is @Getter/@Setter annotation in Lombok java?
How Project Lombok works?
What is @NonNull annotation?
What is @ToString annotation?
How to generate Equals and Hashcode using Lombok?
Check all lombok java example
What are the benefits/advantages of using lombok?
Scala is an alternative JVM language with both object-oriented and functional programming paradigms. Scala development with the Java EE 7 platform is definitely possible and can be a pleasant experience. If you have uncertainty about how Scala can fit around the Java EE 7 platform, then this session aims to illustrate the huge benefit that Scala adoption can bring to the platform. Many other developers are taking advantage and the challenge of the JVM’s capability of being a vessel for multi-language programming. You no longer have to write every single project using Java, even if you like Lambdas experiences. For the developer and engineering terms that feeling a little braver than usual, Scala is attractive as it is strongly typed and lets you set the gauge on how object oriented or how functional you want to be. You will learn how to reuse the annotations and creating Scala plain object safely and concisely. This session will highlight and contrast the experience I had developing Scala solutions with Java EE, and there will be plenty of advice about using the functional programming features against the Java object oriented API.
Scala language overview
Java EE 7 architecture and design
WildFly 8 application server
Using Gradle as a build tool
How to create beans in Scala with dependency injection
JAX-RS endpoints
Servlet Endpoints
JMS Messaging
Scala adoption advice and hints for sustainable team development
JavaCro 2014 Scala and Java EE 7 Development ExperiencesPeter Pilgrim
Scala is an alternative JVM language with both object-oriented and functional programming paradigms. Scala development with the Java EE 7 platform is definitely possible and can be a pleasant experience. If you have uncertainty about how Scala can fit around the Java EE 7 platform, then this session aims to illustrate the huge benefit that Scala adoption can bring to the platform. Many other developers are taking advantage and the challenge of the JVM’s capability of being a vessel for multi-language programming. You no longer have to write every single project using Java, even if you like Lambdas experiences.
For the developer and engineering terms that feeling a little braver than usual, Scala is attractive as it is strongly typed and lets you set the gauge on how object oriented or how functional you want to be. You will learn how to reuse the annotations and creating Scala plain object safely and concisely.
This session will highlight and contrast the experience I had developing Scala solutions with Java EE, and there will be plenty of advice about using the functional programming features against the Java object oriented API.
Scala language overview
Java EE 7 architecture and design
Using Gradle as a build tool
How to create beans in Scala with dependency injection
JAX-RS endpoints
Servlet Endpoints
JMS Messaging
Scala adoption advice and hints for sustainable team development
The Loom project has been under work for many years, and just delivered Virtual Threads as a preview feature in the JDK 19. We now have a very precise idea of what they are and what you can do with them. Our good old Threads, created more than 25 years ago, will see a new kind of lightweight threads. This presentation shows you that creating a thread is easier and much cheaper, allowing the creation of millions of them in a single JVM. These virtual threads can be block at almost no cost. These new virtual threads bring with them new notions that will be covered in this talk. Loom threads are coming, and they will change the landscape of concurrent programming in Java.
The features released between Java 11 and Java 17 have brought a greater opportunity for developers to improve application development productivity as well and code expressiveness and readability. In this deep-dive session, you will discover all the recent Project Amber features added to the Java language such as Text blocks, Records (including Records serialization), Pattern Matching for instanceof, switch expression, sealed classes, and pattern matching for switch. The main goal of the Amber Project is to bring Pattern Matching to the Java platform, which will impact both the language and the JDK APIs. You will discover record patterns, array patterns, as well as deconstruction patterns, through constructors, factory methods, and deconstructors.
The Future of Java: Records, Sealed Classes and Pattern MatchingJosé Paumard
The release of the JDK 17 brings interesting features in the Java language: sealed types and pattern matching for switch. Along with the introduction of records, the implementation of pattern matching in the Java language begins to take shape. This presentation shows you how records, sealed types, and pattern matching can change the way we write Java code, on real patterns. It also shows you what we can expect to see on this topic in the future. It is mostly a live coding presentation, with some slides when the code is shown cannot be executed.
The features released between Java 11 and Java 17 have brought a greater opportunity for developers to improve application development productivity as well and code expressiveness and readability. In this deep-dive session, you will discover all the recent Project Amber features added to the Java language such as Records (including Records serialization), Pattern Matching for `instanceof`, switch expression, sealed classes, and hidden classes. The main goal of the Amber Project is to bring Pattern Matching to the Java platform, which will impact both the language and the JDK APsI. You will discover record patterns, array patterns, as well as deconstruction patterns, through constructors, factory methods, and deconstructors.
You can find the code shown here: https://github.com/JosePaumard/devoxx-uk-2021
Designing functional and fluent API: application to some GoF patternsJosé Paumard
These are the slides of my Devnexus 2020 talk. The code is avaiblable on my GitHub account: https://github.com/JosePaumard/devnexus-2020-visitor-lambda. You can see a replay of this talk (in a slightly different version) here: https://youtu.be/gq23w9nycBs
Those are the slides of the presentation we made with Maurice Naftalin à Goto: Copenhagen 2019.
Functional programmers have been saying for decades that they know the way to the future. Clearly they've been wrong, since imperative languages are still far more popular. Clearly they've also been right, as the advantages of functional programming have become increasingly obvious. Is it possible to combine the two models? Scala is one language that does this, and Java too has been on a journey, which still continues, of learning from functional languages and carefully adding features from them. In this talk, we'll review what Java has learned from functional languages, what it can still learn, and how its added features compare to Scala's original ones.
Designing functional and fluent API: example of the Visitor PatternJosé Paumard
This is the slide deck of my talk from Devoxx Belgium 2019. You can watch the video here https://www.youtube.com/watch?v=gq23w9nycBs and get the code here: https://github.com/JosePaumard/devoxx-belgium-2019-visitor-lambda.
Among the patterns from the GoF, the Visitor is probably the more complex to implement. One of the difficulties is that you need to implement it in your object model, leading to complex refactoring for legacy applications. Based on the use of all the nifty tools brought by functional programming: chaining, composition, and partial application, you can implement Visitors without having to change your object model, using a functional and fluent API. This approach can be used to implement other patterns: Builder and Validator. Using this way of designing API leads to readable and robust code, designed following the GoF patterns.
Les slides du Tools in Action que j'ai donné à Devoxx France 2019.
Le JDK est open source et son développement aussi. L'ensemble des nouveautés vit sur des branches Mercurial qui peuvent être téléchargées et compilées à la demande. Cela permet de jouer avec des fonctionnalités encore en chantier, de regarder comment les nouvelles syntaxes fonctionneront, bref, de jouer avec un JDK du futur, qui n'existera peut-être jamais. L'objet de ce tools in action est simple : montrer comment tout ceci fonctionne, de l'installation d'une machine Ubuntu à l'exécution d'un JDK recompilé maison.
Le slide deck de l'Université que nous avons donnée avec Rémi Forax à Devoxx France 2019.
Comme promis, Java sort sa version majeure tous les 6 mois. Le train passe et amène son lot de nouveautés. Parmi elles, certaines sont sorties : une nouvelle syntaxe pour les clauses switch et l'instruction de byte code CONSTANT_DYNAMIC. D'autres sont en chantier, plus ou moins avancé : une nouvelle façon d'écrire des méthodes de façon condensée, un instanceof 'intelligent', des constantes évaluées au moment où elles sont utilisées. Les projets progressent. Loom, et son nouveau modèle de programmation concurrente que l'ont peut tester avec Jetty. Amber, qui introduit les data types et des nouvelles syntaxes. Valhalla, dont les value types donnent leurs premiers résultats. S'il est difficile de prévoir une date de sortie pour ces nouveautés, on sait en revanche qu'une fois prêtes elles sortiront en moins de 6 mois. De tout ceci nous parlerons donc au futur et en public, avec des démonstrations de code, des slides, du code, de la joie et de la bonne humeur !
Slides of the talk we gave with David Delabassee at Oracle Code One 2018.
The FnProject was released about a year ago, proposing new ways to design asynchronous systems in a very flexible way. This tutorial shows you how to set up a Fn Server on a local development machine running Windows with a first simple function. Then we cover the design of multi-functions systems, connected together in an asynchronous way, leveraging the Fn Flow API. This API is first presented, including how it compares to the the Java 8 CompletableFuture API. We then set up a real example made of several functions, producing multiple results and see how we can leverage their asynchronous nature to make a non-blocking system, handling errors in a simple and intuitive way. Most of the examples are shown both on slides and live coding parts.
Avec la version 9 sortie en septembre 2017, Java appuie sur la pédale ! Le rythme des livraisons passe à une version majeure tous les 6 mois. Java 10 est sorti en mars, prochaine version en septembre. Java 10 apporte le 'var' et l'inférence de type pour les variables locales. D'autres nouveautés sont en préparation : les constantes dynamiques, les classes de données, un nouveau switch à base de lambda, des interfaces fermées, de nouvelles choses du coté des génériques et bien plus encore.
Cela viendra-t-il en 11, 12, 15 ? Ne spéculons pas, mais quand ces nouveautés seront prêtes, elles sortiront en quelques mois. On se propose de présenter ces nouveautés, celles qui sont presque prêtes, celles qui seront prêtes bientôt, et celles qui ne seront pas prêtes avant un moment. Quels seront les impacts sur le langage, sur la JVM et donc sur les performances ? Que cela va-t-il nous apporter au quotidien, en tant que développeurs ? Quels seront les nouveaux patterns ? Voici le programme de cette présentation, avec des slides, du code, de la joie et de la bonne humeur !
The slides of my Java One 2017 talk about the Spliterator Patterns, or, how to extend the Stream API using the Spliterator API.
The video is available on YouTube: https://www.youtube.com/watch?v=xgHGpsubL5M
Les slides de ma présentation à Devoxx France 2017.
Introduite en Java 8, l'API Collector vit dans l'ombre de l'API Stream, ce qui est logique puisqu'un collecteur doit se connecter à un stream pour fonctionner. Le JDK est organisé de sorte que l'on utilise surtout les collectors sur étagère : groupingBy, counting et quelques autres. Ces deux éléments masquent non seulement le modèle de traitement de données des collectors, mais aussi sa puissance et ses performances.
Ces présentation parle des collectors qui existent et qu'il faut connaître, ceux que l'on peut créer, ceux dont on se doute que l'on peut les créer une fois que l'on comprend un peu les choses, et les autres, tant les possibilités offertes par cette API sont illimitées.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
3. @Delabassee @JosePaumard#Devoxx #SE84EE
Agenda
Java SE 8 has been released ~1.5 year ago
Java EE 7 Application Servers
- GlassFish, WildFly, Liberty Profile, WebLogic, etc.
Check some important Java SE 8 new features
for Java EE developers... with patterns!
8. The following is intended to outline our general product direction.
It is intended for information purposes only, and may not be
incorporated into any contract. It is not a commitment to deliver
any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and
timing of any features or functionality described for Oracle’s
products remains at the sole discretion of Oracle.
12. @Delabassee @JosePaumard#Devoxx #SE84EE
New Date & Time API
Date & Time API is a new introduction in Java 8
Initiated by Stephen Colebourne, based on Joda Time
Complete replacement of Date & Calendar
13. @Delabassee @JosePaumard#Devoxx #SE84EE
Date: ZonedTime
Useful for localized times
Set<String> allZonesIds = ZoneId.getAvailableZoneIds() ;
String ukTZ = ZoneId.of("Europe/Paris") ;
14. @Delabassee @JosePaumard#Devoxx #SE84EE
Date: ZonedTime
Useful for localized times
System.out.println(
ZonedDateTime.of(
1998, Month.JULY.getValue(), 12, // year / month / day
22, 0, 0, 0, // h / mn / s / nanos
ZoneId.of("Europe/Paris"))
); // prints 1998-07-22T22:00-00:01:15[Europe/London]
15. @Delabassee @JosePaumard#Devoxx #SE84EE
Date: ZonedTime
Useful for localized times
System.out.println(
ZonedDateTime.of(
1998, Month.JULY.getValue(), 12, // year / month / day
22, 0, 0, 0, // h / mn / s / nanos
ZoneId.of("Europe/Paris"))
);
ZonedDateTime nextWorldCup =
currentWorldCup.plus(Period.ofYear(4));
16. @Delabassee @JosePaumard#Devoxx #SE84EE
Date: ZonedTime
Useful for localized times
System.out.println(
ZonedDateTime.of(
1998, Month.JULY.getValue(), 12, // year / month / day
22, 0, 0, 0, // h / mn / s / nanos
ZoneId.of("Europe/Paris"))
);
ZonedDateTime nextWorldCup =
currentWorldCup.plus(Period.ofYear(4));
ZonedDateTime nexWorldCupJapan=
nextWorldCup.withZoneSameInstant(ZoneId.of("Asia/Tokyo")) ;
17. @Delabassee @JosePaumard#Devoxx #SE84EE
Date: bridges with java.util.Date
Conversions between j.u.Date and Date & Time
Time time = Time.from(localTime); // API -> legacy
LocalTime localTime = time.toLocalTime(); // legacy -> new API
Date date = Date.from(localDate); // API -> legacy
LocalDate localDate = date.toLocalDate(); // legacy -> new API
TimeStamp time = TimeStamp.from(instant); // API -> legacy
Instant instant = time.toInstant(); // legacy -> new API
Date date = Date.from(instant); // API -> legacy
Instant instant = date.toInstant(); // legacy -> new API
18. @Delabassee @JosePaumard#Devoxx #SE84EE
Usable in JPA
JPA does not support this Date & Time API (yet)
But with converters, we can still use it
@Entity
public abstract class AbstractPersistent {
@Convert(converter=DateConverter.class)
private Instant instant;
}
19. @Delabassee @JosePaumard#Devoxx #SE84EE
Usable in JPA
The converter is a classical object
public class DateConverter
implements AttributeConverter<Instant, Date> {
public Date convertToDatabaseColumn(Instant instant) {
return Date.from(instant);
}
public Instant convertToEntityAttribute(Date date) {
return date.toInstant();
}
}
20. @Delabassee @JosePaumard#Devoxx #SE84EE
Usable in JPA
The converter is a classical object
public class DateFormatConverter
implements AttributeConverter<ZonedDateTime, String> {
public String convertToDatabaseColumn(ZonedDateTime time) {
return DateTimeFormatter.ISO_DATE_TIME.format(time);
}
public ZonedDateTime convertToEntityAttribute(String formated) {
return DateTimeFormatter.ISO_DATE_TIME
.parse(formated, ZonedDateTime::from);
}
}
26. @Delabassee @JosePaumard#Devoxx #SE84EE
Annotations in Java 7
Wrapping annotations
An annotation cannot be applied more than once
@NamedQueries({
@NamedQuery(name=SELECT_ALL, query="..."),
@NamedQuery(name=COUNT_ALL, query="...")
})
public class Customer {
}
29. @Delabassee @JosePaumard#Devoxx #SE84EE
Bean Validation
Here is the Bean Validation code for @CheckCar
@Target({PARAMETER})
@Retention(RUNTIME)
@Constraint(validatedBy = CarValidator.class)
public @interface CheckCar {
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
String value();
}
30. @Delabassee @JosePaumard#Devoxx #SE84EE
Bean Validation
And for the validator
public class CarValidator
implements ConstraintValidator<CheckCar, Car> {
private String carBrand;
public void initialize(CheckCar constraintAnnotation) {
this.carBrand = constraintAnnotation.value();
}
public boolean isValid(Car obj, ConstraintValidatorContext ctrCtx) {
if (object == null) return true;
return (!obj.getBrand().toUpperCase().contains(carBrand));
}
}
31. @Delabassee @JosePaumard#Devoxx #SE84EE
Bean Validation
And the Java 8 trick to make it repeatable
@Target({PARAMETER})
@Retention(RUNTIME)
@Repeatable(CheckCars.class)
@Constraint(validatedBy = CarValidator.class)
public @interface CheckCar {
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
String value();
}
32. @Delabassee @JosePaumard#Devoxx #SE84EE
Bean Validation
And the Java 8 trick to make it repeatable
@Target({PARAMETER})
@Retention(RUNTIME)
public @interface CheckCars {
CheckCar[] value() default{};
}
34. @Delabassee @JosePaumard#Devoxx #SE84EE
Type annotations
Annotations can be now put on types
Example 1: tell that a variable should not be null
private @NonNull List<Person> persons = ... ;
35. @Delabassee @JosePaumard#Devoxx #SE84EE
Type annotations
Annotations can be now put on types
Example 1: tell that a variable should not be null
Example 2: the content should not be null neither
private @NonNull List<Person> persons = ... ;
private @NonNull List<@NonNull Person> persons = ... ;
38. @Delabassee @JosePaumard#Devoxx #SE84EE
Joining strings
StringJoiner class
And it prints:
StringJoiner sj = new StringJoiner(", ") ;
sj.add("one").add("two").add("three") ;
String s = sj.toString() ;
System.out.println(s) ;
> one, two, three
39. @Delabassee @JosePaumard#Devoxx #SE84EE
Joining strings
StringJoiner with prefix / postfix
And it prints:
StringJoiner sj = new StringJoiner(", ", "{", "}") ;
sj.add("one").add("two").add("three") ;
String s = sj.toString() ;
System.out.println(s) ;
> {one, two, three}
40. @Delabassee @JosePaumard#Devoxx #SE84EE
Joining strings
Also accessible from the String class
And it prints:
// From the String class, with a vararg
String s = String.join(", ", "one", "two", "three");
System.out.println(s);
> one, two, three
41. @Delabassee @JosePaumard#Devoxx #SE84EE
Joining strings
And directly from a List
// From a list to a String using the Stream & Collectors API
String s =
listOfStrings.stream()
.collect(Collectors.joining(", "));
System.out.println(s);
> one, two, three
42. @Delabassee @JosePaumard#Devoxx #SE84EE
Joining strings
And directly from a List
The result is
// From the String class, with a vararg
String s =
listOfStrings.stream()
.collect(Collectors.joining(", ", "{", "}"));
System.out.println(s);
> {one, two, three}
43. @Delabassee @JosePaumard#Devoxx #SE84EE
Support for Base64 decoding
After a few years…
import java.util.Base64;
String txt = "Modern Times!";
String encoded = Base64.getEncoder().encodeToString(
txt.getBytes(StandardCharsets.UTF_8));
String decoded = new String(Base64.getDecoder().decode(encoded),
StandardCharsets.UTF_8);
47. @Delabassee @JosePaumard#Devoxx #SE84EE
Readable and efficient patterns
Extract histograms from data
List<Person> people = Arrays.asList();
Map<City, Double> agesByCity =
people.stream()
.filter(p -> p.getAge() > 20)
.collect(
Collectors.groupingBy(
Person::getCity,
Collectors.averagingDouble(Person::getAge)
)
);
48. @Delabassee @JosePaumard#Devoxx #SE84EE
Readable and efficient patterns
Extract histograms from data
List<Person> people = Arrays.asList();
Map<City, Double> agesByCity =
people.stream()
.filter(p -> p.getAge() > 20)
.collect(
Collectors.groupingBy(
Person::getCity,
Collectors.averagingDouble(Person::getAge)
)
);
49. @Delabassee @JosePaumard#Devoxx #SE84EE
Readable and efficient patterns
Extract histograms from data
List<Person> people = Arrays.asList();
Map<City, Double> agesByCity =
people.stream()
.filter(p -> p.getAge() > 20)
.collect(
Collectors.groupingBy(
Person::getCity,
Collectors.averagingDouble(Person::getAge)
)
);
50. @Delabassee @JosePaumard#Devoxx #SE84EE
Readable and efficient patterns
Extract histograms from data
List<Person> people = Arrays.asList();
Map<City, Double> agesByCity =
people.stream()
.filter(p -> p.getAge() > 20)
.collect(
Collectors.groupingBy(
Person::getCity,
Collectors.averagingDouble(Person::getAge)
)
);
51. @Delabassee @JosePaumard#Devoxx #SE84EE
Readable and efficient patterns
Extract histograms from data
List<Person> people = Arrays.asList();
Map<City, Double> agesByCity =
people.stream()
.filter(p -> p.getAge() > 20)
.collect(
Collectors.groupingBy(
Person::getCity,
Collectors.averagingDouble(Person::getAge)
)
);
52. @Delabassee @JosePaumard#Devoxx #SE84EE
Readable and efficient patterns
Extract histograms from data
List<Person> people = Arrays.asList();
Map<City, Double> agesByCity =
people.stream()
.filter(p -> p.getAge() > 20)
.collect(
Collectors.groupingBy(
Person::getCity,
Collectors.averagingDouble(Person::getAge)
)
);
53. @Delabassee @JosePaumard#Devoxx #SE84EE
Building a Stream on a String
Building a Stream on the letters of a String:
String s = "hello";
IntStream stream = s.chars(); // stream on the letters of s
54. @Delabassee @JosePaumard#Devoxx #SE84EE
Building a Stream on a String
Building a Stream on the letters of a String:
String s = "hello";
IntStream stream = s.chars(); // stream on the letters of s
s.chars() // IntStream
.mapToObj(letter -> (char)letter) // Stream<Character>
.map(Character::toUpperCase)
.forEach(System.out::println); // Prints a Character
> HELLO
55. @Delabassee @JosePaumard#Devoxx #SE84EE
Build a Stream from a text file
Find the first error line from a log file
// Java 7 : try with resources and use of Paths
Path path = Paths.get("d:", "tmp", "debug.log");
try (Stream<String> stream = Files.lines(path)) {
stream.filter(line -> line.contains("ERROR"))
.findFirst()
.ifPresent(System.out::println);
} catch (IOException ioe) {
// handle the exception
}
56. @Delabassee @JosePaumard#Devoxx #SE84EE
Build a Stream from a regex
Building a Stream from a regexp
// book is a looooooooong String
Stream<String> words =
Pattern
.compile(" ")
.splitAsStream(book) ;
57. @Delabassee @JosePaumard#Devoxx #SE84EE
Build a Stream from a regex
Building a Stream from a regexp
More efficient than:
// book is a looooooooong String
Stream<String> words =
Pattern
.compile(" ")
.splitAsStream(book) ;
// book is a looooooooong String
Stream<String> words =
Stream.of(book.split(" "));
58. @Delabassee @JosePaumard#Devoxx #SE84EE
Flatmap: Files.lines + regex
Splitting a text files into words
Stream<String> streamOfLines = Files.lines(path);
Function<String, Stream<String>> splitter =
line -> Pattern.compile(" ").splitAsStream(line);
long numberOfWords =
streamOfLines.flatMap(splitter)
.map(String::toLowerCase)
.distinct()
.count();
59. @Delabassee @JosePaumard#Devoxx #SE84EE
Why is it important for Java EE?
Given this JSON file
[
{
"name":"Duke",
"gender":"m",
"phones":[
"home":"650‐123‐4567",
"mobile":"650‐111‐2222"
]
},
{
"name":"Jane", …
]
JsonArray contacts =
Json.createArrayBuilder()
.add(…
60. @Delabassee @JosePaumard#Devoxx #SE84EE
Why is it important for Java EE?
And some JSON-P magic
Map<String, Long> names =
contacts.getValuesAs(JsonObject.class).stream()
.filter(x -> "f".equals(x.getString("gender")))
.map(x -> (x.getString("name")))
.collect(
Collectors.groupingBy(
Function.identity(),
Collectors.counting()
)
);
62. @Delabassee @JosePaumard#Devoxx #SE84EE
Why is it important for Java EE?
// Today
JsonArray names =
contacts.getValuesAs(JsonObject.class).stream()
.filter(x -> "f".equals(x.getString("gender")))
.map(x -> (x.getString("name")))
.collect(
Collector.of(
Json::createArrayBuilder,
JsonArrayBuilder::add,
JsonArrayBuilder::add,
JsonArrayBuilder::build
)
);
63. @Delabassee @JosePaumard#Devoxx #SE84EE
Why is it important for Java EE?
// Today
JsonArray names =
contacts.getValuesAs(JsonObject.class).stream()
.filter(x -> "f".equals(x.getString("gender")))
.map(x -> (x.getString("name")))
.collect(
Collectors.collectingAndThen(
Collector.of(
Json::createArrayBuilder,
JsonArrayBuilder::add,
JsonArrayBuilder::add
),
JsonArrayBuilder::build
)
);
64. @Delabassee @JosePaumard#Devoxx #SE84EE
Why is it important for Java EE?
Collect into JSON
Avaiblable through the JsonCollectors factory
// Tomorrow, with JSON-P 1.1
JsonArray names =
contacts.getValuesAs(JsonObject.class).stream()
.filter(x -> "f".equals(x.getString("gender")))
.map(x -> (x.getString("name")))
.collect(
JsonCollectors.toJsonArray()
);
66. @Delabassee @JosePaumard#Devoxx #SE84EE
A warning on parallelism
All parallel operations (Streams, ConcurrentHashMap)
take place in the common ForkJoinPool
The common ForkJoinPool takes all the
available cores / CPUs
67. @Delabassee @JosePaumard#Devoxx #SE84EE
A warning on parallelism
All parallel operations (Streams, ConcurrentHashMap)
take place in the common ForkJoinPool
The common ForkJoinPool takes all the
available cores / CPUs
To preserve your Application Server:
System.setProperty(
"java.util.concurrent.ForkJoinPool.common.parallelism", "1") ;
70. @Delabassee @JosePaumard#Devoxx #SE84EE
Creation of an asynchronous task
The Jersey way to create an asynchronous call
@Path("/resource")
public class AsyncResource {
@GET
public void asyncGet(@Suspended final AsyncResponse asyncResponse) {
new Thread(new Runnable() {
public void run() {
String result = longOperation();
asyncResponse.resume(result);
}
}).start();
}
}
71. @Delabassee @JosePaumard#Devoxx #SE84EE
Creation of an asynchronous task
(let us fix this code with Java 8)
@Path("/resource")
public class AsyncResource {
@GET
public void asyncGet(@Suspended final AsyncResponse asyncResponse) {
executor.submit(() -> {
String result = longOperation();
asyncResponse.resume(result);
});
}
}
72. @Delabassee @JosePaumard#Devoxx #SE84EE
How to test it?
We want to check if the result object
is passed to the resume() method of the asyncResponse
It is a very basic test, but tricky to write since we are in an
asynchronous world
We have mocks for that!
73. @Delabassee @JosePaumard#Devoxx #SE84EE
How to test it?
We can inject a mock AsyncResponse, even mock the result
Then verify the correct interaction:
But we need to verify this once the run() method has been
called…
Mockito.verify(mockAsyncResponse).resume(result);
74. @Delabassee @JosePaumard#Devoxx #SE84EE
How to test it?
This is where CompletionStage come to the rescue!
@Path("/resource")
public class AsyncResource {
@Inject ExecutorService executor;
@GET
public void asyncGet(@Suspended final AsyncResponse asyncResponse) {
executor.submit(() -> {
String result = longOperation();
asyncResponse.resume(result);
});
}
}
75. @Delabassee @JosePaumard#Devoxx #SE84EE
How to test it?
@Path("/resource")
public class AsyncResource {
@Inject ExecutorService executor;
@GET
public void asyncGet(@Suspended final AsyncResponse asyncResponse) {
executeAsync(asyncResponse);
}
public CompletableFuture<Void> executeAsync(final AsyncResponse asyncResponse) {
return CompletableFuture.runAsync(() -> {
asyncResponse.resume(longOperation());
}, executor);
}
}
76. @Delabassee @JosePaumard#Devoxx #SE84EE
How to test it?
AsyncResource asyncResource = new AsyncResource();
asyncResource.executeAsync(mockAsyncResponse); // returns the CompletableFuture
.thenRun(() -> { // then execute this Runnable
Mockito.verify(mockAsyncResponse).resume(result);
}
);
77. @Delabassee @JosePaumard#Devoxx #SE84EE
How to test it?
Be careful of visibility issues
1) It’s better to run this in the same thread
2) Since the mocks are used and checked in this thread,
create them in this thread too
78. @Delabassee @JosePaumard#Devoxx #SE84EE
How to test it?
So the complete pattern becomes this one
1) First we create our mocks
String result = Mockito.mock(String.class);
AsyncResponse response = Mockito.mock(AsyncResponse.class);
Runnable train = () -> Mockito.doReturn(result).when(response.longOperation());
Runnable verify = () -> Mockito.verify(response).resume(result);
79. @Delabassee @JosePaumard#Devoxx #SE84EE
How to test it?
So the complete pattern becomes this one
2) Then we create the call & verify
Runnable callAndVerify = () -> {
asyncResource.executeAsync(response).thenRun(verify);
}
80. @Delabassee @JosePaumard#Devoxx #SE84EE
How to test it?
So the complete pattern becomes this one
3) Then we create the task
ExecutorService executor = Executors.newSingleThreadExecutor();
AsynResource asyncResource = new AsyncResource();
asyncResource.setExecutorService(executor);
CompletableFuture
.runAsync(train, executor) // this trains our mocks
.thenRun(callAndVerify); // this verifies our mocks
81. @Delabassee @JosePaumard#Devoxx #SE84EE
How to test it?
Since a CompletableFuture is also a Future, we can fail
with a timeout if the test does not complete fast enough
ExecutorService executor = Executors.newSingleThreadExecutor();
AsynResource asyncResource = new AsyncResource();
asyncResource.setExecutorService(executor);
CompletableFuture
.runAsync(train, executor) // this trains our mocks
.thenRun(callAndVerify) // this verifies our mocks
.get(10, TimeUnit.SECONDS);
82. @Delabassee @JosePaumard#Devoxx #SE84EE
Conclusion
Java 8 is not just about lambdas
There are also many new and very useful patterns
Ready to be used before becoming a lambda ninja!
Not covered:
- Collection framework
- Concurrency, Concurrent hashmap
- JavaScript on the JVM with Nashorn
- Security