Académique Documents
Professionnel Documents
Culture Documents
en développement
Sommaire
• Introduction
• Les modules
• Les plugins
• Configuration serveur
• Ecosystème
• Infinispan
• Troubleshooting
• Tests
• Ressources
Introduction
JBoss AS / JBoss EAP
Open source Subscription version
• Domain
– Multi JVM, multi serveur
– Notion de « host controller » et « domain controller »
– Administration centralisée
Architecture JBoss : Le mode « domain »
• 3 types d'acteurs :
• JBOSS_BASE
– Correspond au répertoire /jboss de votre projet
– Contient :
• La configuration JBoss (standalone.xml, …)
• Les modules personnalisés (BC, mysql, …)
• Les « logs » du serveur
• …
.
Structure d’un projet └── project
├── jboss
│ ├── modules
• JBOSS_BASE correspond au │ └── standalone
répertoire « jboss » │ ├── configuration
│ │ ├── logging.properties
│ │ └── standalone.xml
│ ├── data
• Attention de ne « commiter » que les │ ├── deployments
fichiers de configuration │ └── log
├── pom.xml
└── src
└── main
├── java
└── resources
.
Déploiement └── project
├── jboss
│ ├── modules
│ └── standalone
│ ├── configuration
cp demo.war $JBOSS_BASE/standalone/deployments │ │ ├── logging.properties
│ │ └── standalone.xml
│ ├── data
│ ├── deployments
│ └── log
09:37:24, 923 INFO … Deployed « demo.war » ├── pom.xml
└── src
└── main
├── java
└── resources
Déploiement : Les états
rm $JBOSS_BASE/standalone/deployments/demo.war.deployed
https://docs.jboss.org/author/display/AS7/Application+deployment
Archetype Maven
• Archetype = Template de projet
mvn archetype:
generate
-DgroupId=votr
• Le plugin Maven « jboss-as-maven-plugin » pré- -DartifactId=v
eGroupId
otreArtifactID
configuré -Dversion=1.0.
0-SNAPSHOT
-DarchetypeGro
• La watchService -DarchetypeArt
upId=com.world
ifactId=archet
line.bfi.ita
-DarchetypeVer yp e-war-ita-jbos
• Un logback pré-configuré -DinteractiveM
sion=1.0.1 s
ode=false
• La « Kanazination »
http://cookbook-ita.a
pps.zone52.org /jboss#
• Modules pré-configurés (configuration, MySQL, BC) Arch etype_Maven
Mod-A
Server CL Mod-j
your.app.war Mod-K
Mod-L
Deployment CL Deployment CL
Hierarchical CL Modular CL
Alexis Hassler, Devoxx 2013 : Le classpath n'est pas mort, mais presque
Les modules
• JDBC (MySQL)
• Bouncy Castle
• Externalisation des fichiers de configuration
• Apache Lucene / Hibernate Search
• …
http://cookbook-ita.apps.zone52.org/jboss#Modules
Les modules : Pourquoi ?
• Librairies utilisées au démarrage (Divers JDBC)
http://www.mastertheboss.com/jboss-frameworks/maven-tutorials/jboss-maven/maven-jboss-as-7-plugin-tutorial?showall=&start=1
Les modules : Déclaration explicite
• Les dépendances explicites
doivent être déclarées dans :
<?xml version="1.0" encoding="UTF-8"?>
– jboss-deployment- <jboss-deployment-structure>
<deployment>
structure.xml <dependencies>
<module name="net.atos.configuration"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
Dependencies: net.atos.configuration
– META-INF/MANIFEST.MF
Les modules : Déclaration explicite
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Dependencies>net.atos.configuration</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
Les modules : Déclaration implicite
• META/ejb-jar.xml, @Stateless, @Stateful, @MessageDriven, …
→import javaee.api module
https://docs.jboss.org/jbossas/7/plugins/maven/latest/
Les plugins : jboss-as-maven-plugin
• jboss-as:run -> jboss-as:undeploy -> jboss-as:shutdown
• jboss-as:run -> jboss-as:redeploy
<deployments>
<deployment name="demo.war" runtime-name= "demo.war">
<content sha1="c42ebac74d8a9a39c3fb804bd40f3b902b3340a8"/>
</deployment>
</deployments>
Les plugins : jboss-as-maven-plugin
shutdown
deployed deployed
undeploy+shutdown
undeploy
deploy
run(+deploy)
undeployed undeployed
shutdown
stopped started
Les plugins : Maven Clean Plugin
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>jboss/standalone/configuration/standalone_xml_history</directory>
</fileset>
<fileset>
<directory>jboss/standalone/data</directory>
</fileset>
<fileset>
<directory>jboss/standalone/tmp</directory>
</fileset>
<fileset>
<directory>jboss/standalone/log</directory>
</fileset>
</filesets>
</configuration>
</plugin>
http://maven.apache.org/plugins/maven-clean-plugin/
Les plugins : jboss-mods
• Problème : Il est déconseillé de « commiter/pusher » des
« jar » sur un SCM
• Solutions :
– Configurer convenablement les
fichiers .svnignore / .hgignore / .gitignore
– Utiliser le plugin « jboss-mods »
https://kazan.priv.atos.fr/xwiki/wiki/jbossmodsxwiki1
Configuration serveur
Configuration
• Centralisée dans le fichier « standalone.xml »
(ou « domain.xml ») :
– DataSource
– Port
– Propriétés systeme
– ...
Configuration : Définition d’une datasource
Nom de la jta-data-source (persistence.xml)
<subsystem xmlns="urn:jboss:domain:datasources:1.2">
<datasources>
<datasource jndi-name="java:jboss/datasources/jbossDS" pool-name= " jbossDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/jboss</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<passwprd>root</password>
</security>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql"/>
</drivers>
</datasources>
</subsystem>
Nom du module à utiliser
./standalone.sh -Djboss.socket.binding.port-offset=100
Configuration : Administration
• API Java (The native management API)
• API HTTP/JSON
Ecosystème
JBOSS_HOME\modules\system\layers\base
JBoss Enterprise Application Platform Component Details
http://www.jboss.org/projects/
Infinispan
• « key/value data store and data grid platform »
• JSR 107 (JCache)
• JSR 347 (Data Grids for the Java Platform)
• Cache local
• Cache distribué (réplication ou distribution)
Infinispan
• Utilisations :
– Comme cache : Hibernate, Lucene, HTTP session, cache applicatif, …
– Comme data grid
• Features :
– Persistence (JDBC, JPA, MongoDB, …)
– Transaction
– Query
– Map/Reduce
http://cookbook-ita.apps.zone52.org/using-infinispan-as-hibernate-second-level-cache-provider
Infinispan : Cache et CDI
public class Config {
http://infinispan.org/docs/5.3.x/user_guide/user_guide.html#_cdi_support
Infinispan : JCache
• JSR 107 : API Java permettant de gérer le cache de façon
standard
• 4 Annotations à disposition :
– @CacheResult : Caches the result of a method call
– @CachePut : Caches a method parameter
– @CacheRemove : Removes an entry from a cache
– @CacheRemoveAll : Removes all entries from a cache
http://infinispan.org/docs/5.3.x/user_guide/user_guide.html#_use_jcache_caching_annotations
Infinispan : JCache
@CacheResult(cacheName = "sample-cache")
public String result(String value) {
return value;
}
@CachePut(cacheName = "sample-cache")
public void put(@CacheKey long id, @CacheValue String value) {
}
@CacheRemove(cacheName = "sample-cache")
public void remove(@CacheKey long id) {
}
@CacheRemoveAll(cacheName = "sample-cache")
public void removeAll() {
}
https://kazan.priv.atos.fr/share/data/technical-user-paylib/cookbook-sample/jboss-cache/index.html
Infinispan : La suite…
Troubleshooting
+ beans.xml
+ beans.xml p ach e -d e lta s p ike.properties
jar +a
jar
http://deltaspike.apache.org/documentation/spi.html#_global_alternative
Tests
• @RunWith(EJBContainerRunner.class) –
openejb-junit
• Arquillian
• @RunWith(CdiTestRunner.class) – DeltaSpike
Test-Control Module
• …
Ressources
• https://github.com/jboss-developer/jboss-eap-quickstarts
• https://wiki.priv.atos.fr/wiki/index.php/JBoss_Application_Server
• http://cookbook-ita.apps.zone52.org/?s=jboss
• https://docs.jboss.org/author/display/AS7/Documentation
• http://www.mastertheboss.com
REMARQUES/QUESTIONS