About Java

From My Limbic Wiki

Présentation de Java jusqu'en 2014

Pourquoi Java ?

java Entreprise : Java EE

Orienté Objet Web Services Riche API Amélioration constante du language Diversité des possibilités haut niveau d'abstraction (compatibilité avec tous les OS)

Fonctionnement

JVM

Compilateurs ==> Bytecode ==> JVM ==> Language station locale 1 Thread contient 1 pile gérée par 3 pointeurs: frame, vars et optop Garbage collector : libère l'espace occupé par les objets qui ne sont plus référencés

Actualités

Evolutions majeures entre les versions

  • Cycle de publication de six mois: une nouvelle version en mars et septembre de chaque année
  • Une version LTS tous les 18 mois.

Java 6

  • Evolutions douces vers 7

Java 7

  • 64 bits
  • string dans les switch case

Java 8

  • Interfaces fonctionnelles : Pas plus d'une méthode d'instance abstraite
  • Lambdas
  • Arrivée de Stream
  • une nouvelle API pour gérer les dates
  • de nouvelles annotations
  • un nouveau moteur d'exécution JavaScript
  • Plus d'informations

Java 12

Developpez.com

  • Expressions Switch
  • Collectes mixtes annulables pour G1
  • Renvoi immédiat de la mémoire non utilisée par G1 au système d'exploitation
  • Archives CDS par défaut
  • Un seul port ciblant l'architecture ARM 64 bits
  • API de constantes JVM
  • Shenandoah, un ramasse-miettes à faible temps de pause
  • Suite de microbenchmarks
  • Pas de littéraux de chaîne bruts (Raw String Literals)

Failles Majeures

  • Java 7 / inférieur
  • Janvier 2014 : Malware ==> faille JVM ==> enregistre dans le registre ==> démarrage ==>attente de commandes IRC par son propriétaire

Acronymes

Bibliotheques Logicielles (API)

Bibliotheques Graphiques

AWT: Abstract Window Toolkit

  • Java's original platform-dependent windowing, graphics, and user-interface widget toolkit, preceding Swing.

SWING

  • GUI widget toolkit

SWT: Standard Widget Toolkit

  • Graphical Widget Toolkit for use with the Java platform.

Drivers

JDBC

Server Side

EJB: Entreprise Java Beans

  • Session
  • Message Driven
  • Entity

Frameworks

Spring

Rich Client Plateform (RCP)

  • Framework Eclipse Open Source utilisé pour le développement d'applications clientes

Serveurs d'Applications

JBoss / WildFly

  • Was Jboss
  • Conteneur Web: Catalina
  • Fully featured and certified application server.
  • The big advantage of WildFly over GlassFish is that Red Hat provides an easy migration path from WildFly to its commercially supported application server called JBoss Enterprise Application Platform. This means that you can use WildFly today and quickly migrate to JBoss EAP in the future to get commercial support if you decide that’s something you need.

GlassFish

  • Fully featured and certified Java EE application server developed by Oracle
  • EJB, API JMS - permet d'envoyer et de recevoir des messages de façon asynchrone
  • More heavyweight than either Tomcat or Jetty—and, arguably
  • A bit more difficult to operate.
  • The reference implementation of the Java EE standard

Tomcat

  • Favoring Tomcat
  • Connecteur HTTP: Coyote
  • Conteneur Web: Catalina
  • Most popular application server used with Java web application
  • Developed by the Apache Software Foundation.
  • Some sources claim Tomcat’s market share to be more than a whopping 60% of all Java application server deployments.

Jetty

  • Consider Jetty if you need its smaller footprint
  • Isn’t technically a fully featured Java EE container

Build Automation Tool

Maven

  • Maven is a build automation tool used primarily for Java projects.
    • it describes how software is built
    • it describes its dependencies

Ant

  • Originated from the Apache Tomcat project in early 2000
  • Created regarding the problems of Unix Make
  • Uses XML to describe the code build process and its dependencies

Gradle

  • NO XML
  • Introduces a Groovy-based domain-specific language (DSL) instead of the XML form used by Apache Maven for declaring the project configuration.

JPA

Allows to automatically mapthe columns names of the database with java class properties names. So basically, transform the database data into Objects.

JPA Concepts

  • Mapping
  • Entity
  • Entity Manager

Frameworks

  • Hibernate
  • Spring Data
  • Spring Data JPA

Others Implementations

  • Hibernate
  • EclipseLink
  • OpenJPA

EJB: Entreprise Java Beans

Used for Business logic, theses class with special logics are defined in three different types

  • We are going to use design by contract, in java it means "interfaces"
  • It does not perform any display of the data : that's for presentation
  • It does not speak directly to the databse : that's for database / persistence layer

Specified fully in the J2EE specification:

  • Session Beans
  • Entity Beans
  • Message-Driven Beans

Interface: Access rules

uncommon: a bean can allow remote and local access

  • @Local: only one computer ?
  • @Remote: If you don't know witch type of access an entreprise bean should have, choose remote access: more flexibility
  • @WebService:

Service: Business rules

it can be two services, it is allowed by @Alternative

  • @Stateless: Stateless session beans do not share state or identity between method invocations. They are useful mainly in middle-tier application servers that provide a pool of beans to process frequent and brief requests.
  • @Local: let us pick wich business class we want to run at runtime (it is an interface, witch has to be implemented)
  • @Alternative: there are going to be another option with another class witch will be spicified as a choice in the beans.xml file
  • @Inject: allows to access to an interface that is not within this class: reason = we can have more than one version of our business service and we can tell in our XML file, wich one that we want to be using

Controller

  • @Inject: declaring the service with its type. example: "@Inject OrderBusinessInterface services;"

Injecting this interface allows us to not declare here wich service we specially want to use. it is the job of the beans.xml file. the "services" object is then usable to call the services methods depending on wich one is declared in the xml file.

Beans.xml

We need to use an XML file to describe witch particular Bean (Service) are going to be used for this application

so, what's a container ?

  • The Web Server or Container is managing the EJB given or assigned to i
  • For each bean, the container is responsible for:
    • Registering the object, providing a remote interface for it
    • Creating and destroying
    • Check for security to see if its actually allowed to run
    • Manage its state

So,we have to make sure that we notate that's is an EJB

Others Containers

  • Servlets
  • JSP

What is Inversion of Control ?

IoC, allow to bind objects at runtime and let us choose wich type of logic we want

SOAP

SOAP is a protocol. SOAP was designed with a specification. It includes a WSDL file which has the required information on what the web service does in addition to the location of the web service. SOAP is slower than REST. It runs on HTTP but envelopes the message.

Plus d'infos ici: https://www.jmdoudoux.fr/java/dej/chap-service-web.htm#service-web-1

Soap Message

A SOAP message contains:

  • SOAP Part:
  • SOAP Enveloppe: It is an obligatory root element that translates the XML document and defines the beginning and end of the message.
  • SOAP Header: Informations about the message being sent.(optionnel)
  • SOAP Body: XML data comprising the message being sent.
  • Message
  • SOAP Fault: Errors (optionnel)

En technique

  • Files = WSDL
  • Request = XML
  • Response = XML
  • Transport Method: HTTP (works well with Firewalls) and SMTP.

Annotations Spécifiques

  • @WebService (javax.jws.WebService;)
  • @XmlType
  • @WebMethod
  • @Oneway
  • @WebResult
  • @SOAPBinding
  • @ResponseWrapper

Motors Impolementations SOAP

  • Integrated to Java from EE 5.0 and Java SE 6.0
  • JWSDP from SUN
  • Axis and Axis 2 of Apache Project
  • XFire
  • CXF of Apache Project
  • JBoss WS
  • Metro of Project GlassFish

A Retenir

Optimisation

  • HashMap: is map data structure which works on hashing to retrieve stored values
  • ArrayList: ArrayList is index based data-structure backed by an array

Experience Personelle

  • SupMarket :
    • WebServices
    • EJB + updater
    • JSON
    • Hibernate
  • Chat : serveur + quelques commandes
  • Jeu 2D ==> Urban Marginal Multijoueur BTS (swing)
  • Copie de données en entreprise de façon sécurisée via un utilisateur SQL (swing)
  • Application pour calculer le TEG
  • JUG
  • Intéressé React, AngularJS