SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
1
How to cuddle your EJBs
Carlo de Wolf
EJB 3 Product Lead
JBoss by Red Hat
October 2010
2
Agenda
● Quest for The Holy Grail
● EAP
● Why use EJB?
– Simple
– Predictable
– Re-usable
– Testable
● Road-map
3
Quest for The Holy Grail
● Looking for software components that are:
– Simple
– Predictable
– Re-usable
– Testable
● Also
– Performant
4
Enterprise Application Platform
● A fork of AS 5
● Plus functional patches
● Plus performance patches
● Plus support
● Some bits available through Plugin 1.0.19
5
Why use EJB(tm)
?
● Allow rapid development of reusable
business components
● Using an easy infrastructure which does:
– Memory management
– Remote invocation
– Thread management
● Thus having a predictable QoS
6
What is an EJB(tm)
?
● It's not a POJO!
● It consists of a class + interceptor classes
+ interfaces
● Construction is different
● Invocation is different
● It's an assembly with one or more views
7
Quest for The Holy Grail
● Looking for software components that are:
– Simple
– Predictable
– Re-usable
– Testable
● Also
– Performant
8
Simplicity
● Create an EJB with a remote business
view
● Create an EJB archive
● Deploy it
9
Creating an EJB
● Learn how to code EJBs with Andrew's
book: Enterprise JavaBeans 3.1
– ISBN: 978-0-596-15802-6
– Develop your first EJBs with a
hands-on walkthrough of
EJB 3.1 concepts
10
Creating an EJB archive
● Use Ant to create an archive
<jar jarfile=”${build.lib}/myfirstejb.jar”>
<fileset dir=”${build.class}”/>
</jar>
● Or use Maven
11
Deploying an archive
● Copy into deploy
$ cp myfirstejb.jar $JBOSS_HOME/server/default/deploy/
● Use the MainDeployer
MbeanServerConnection conn =
iniCtx.lookup(“jmx/invoker/RMIAdaptor”);
conn.invoke(“jboss.system:service=MainDeployer”,
“deploy”, new URL(“file:myfirstejb.jar”));
12
Quest for The Holy Grail
● Looking for software components that are:
– Simple
– Predictable
– Re-usable
– Testable
● Also
– Performant
13
Dynamic Code Changing
● EJBTHREE-1096: Make SLSB and SFSB
hot deployable for RAD.
● Allow changing functionality / invariants
● Allow changes in the EJB structure
● Compiling (Deploying) vs Interpreted
14
Bean State
● Bean State is governed by invariants
@Stateful
public class ConsentWizard
{
private Date birthdate;
public void setBirthday(Date date)
{
if(age(date) < 18)
throw new IllegalStateException("Minors not allowed");
this.birthdate = date;
}
}
● Changing an invariant leaves artifacts
● Bean State has become non-deterministic
15
Application State
● Application state is determined by the
assembly of all components
@Stateful
public class ConsentWizard implements RemoteWizard
{
}
public class SomeServletThingy
{
@EJB RemoteWizard wizard;
}
● Changing component structure may leave
application undeployable
16
Deploying is like Compiling
● It checks whether the application is
deployable
● It sets up a clean slate to begin tests from
● So, Dynamic Code Changing is a fluffy
white rabbit. Looks cute, but will kill you in
the end.
17
Quest for The Holy Grail
● Looking for software components that are:
– Simple
– Predictable
– Re-usable
– Testable
● Also
– Performant
18
Separation of Concerns
● By making aspects configurable and
manageable
● Security
● Transaction Management
● Remoting
● Interceptors (now separated!)
● Persistence (separated into JPA)
19
Spec EJB 3.1 Async
● A re-usable component separates
concerns
● Brings an application developer
requirement to the bean developer
● Ergo doesn't make for re-usable
components
20
JBoss EJB 3.1 Async
● A callers functional concern
● If the caller resides in the same VM, let the
EJB manage it
21
Quest for The Holy Grail
● Looking for software components that are:
– Simple
– Predictable
– Re-usable
– Testable
● Also
– Performant
22
Test it using a remote view
● Create an archive, deploy it, then call it
public class RemoteTestCase
{
@Test
public void test() throws NamingException
{
MyFirstView bean = (MyFirstView) iniCtx.lookup("MyFirstBean/remote");
String result = bean.doSomething();
assertEquals("done", result);
}
}
23
Assembled Directory
● Use VFS 2
AssembledDirectory jar =
AssembledContextFactory.getInstance().create("test.jar");
jar.addClass(GreetingsBean.class);
jar.addClass(Greetings.class);
● The venerable JBoss Embeddable
Bootstrap.getInstance().deploy(jar);
● JBoss Reloaded Embedded prototype
VFSDeployment deployment =
VFSDeploymentFactory.getInstance().createVFSDeployment(root);
mainDeployer.deploy(root);
● EJB 3.1 Embeddable prototype
EJBContainer container = EJBContainer.createEJBContainer();
on(container).deploy(deployment(jar));
24
ShrinkWrap
● Easily build an archive
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test.jar")
.addClasses(GreetingsBean.class, Greetings.class);
File tempFile = File.createTempFile("test", ".jar");
jar.as(ZipExporter.class).exportZip(tempFile, true);
URL url = tempFile.toURI().toURL();
● Deploy the archive
MbeanServerConnection conn = iniCtx.lookup("jmx/invoker/RMIAdaptor");
conn.invoke("jboss.system:service=MainDeployer", "deploy", url);
● See it in action
$ git clone git://github.com/jbossejb3/jboss-ejb3-timerservice.git
$ cd jboss-ejb3-timerservice
$ mvn install
25
EJB 3.1 Embeddable
● By spec only does local session beans
● You want more services, so ultimately a
full Application Server
● Two solutions:
– Paravirtualized, not standalone
– JBoss Embedded
26
Arquillian
● Or we could go to the server
@RunWith(Arquillian.class)
public class GreetingManagerTest {
@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addClasses(GreetingsBean.class, Greetings.class);
}
@EJB
private Greetings alien;
@Test
public void shouldGreetUser() throws Exception {
String name = "Earthlings";
assertEquals("Hello, " + name, alien.greet(name));
}
}
27
Arquillian #2
● Access to local views
● Debug my EJBs and unit test
– Breakpoints
– Step through
– Happens on the VM running the Server
● JBoss AS becomes an 'OS' resource
– No worry about Server lifecycle / startup time
28
ShrinkWrap + Arquillian
● The Aliens love any container
● Complete separation of concerns
29
Road-map
● EAP 6 will do EJB 3.1
● AS 6 CR1 time-box closes Nov 16th
● AS 7 M1 is coming up
● Bug reports / requests can end up in a
milestone, get on the band-wagon.
30
EJB 4
● More separation of concerns
● Concrete aspects of Managed Beans?
● CDI Extension?
31
How to cuddle your EJBs?
● Don't try to bring the EJBs to you.
● Go to the EJBs.
● Use ShrinkWrap & Arquillian for your
travels!
Q & A
http://jboss.org/ejb3
http://jboss.org/shrinkwrap
http://jboss.org/arquillian
How to cuddle your EJBs, Carlo de Wolf

Contenu connexe

Tendances

Java Unit Testing with Unitils
Java Unit Testing with UnitilsJava Unit Testing with Unitils
Java Unit Testing with UnitilsMikalai Alimenkou
 
Monitoring And Tuning Glass Fish In The Wild Community One 2009
Monitoring And Tuning Glass Fish In The Wild   Community One 2009Monitoring And Tuning Glass Fish In The Wild   Community One 2009
Monitoring And Tuning Glass Fish In The Wild Community One 2009SteveMillidge
 
Preparing your code for Java 9
Preparing your code for Java 9Preparing your code for Java 9
Preparing your code for Java 9Deepu Xavier
 
OpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConOpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConos890
 
Java SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionJava SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionStephen Colebourne
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVMRyan Cuprak
 
What's New in Enterprise JavaBean Technology ?
What's New in Enterprise JavaBean Technology ?What's New in Enterprise JavaBean Technology ?
What's New in Enterprise JavaBean Technology ?Sanjeeb Sahoo
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring BootTrey Howard
 
Are app servers still fascinating
Are app servers still fascinatingAre app servers still fascinating
Are app servers still fascinatingAntonio Goncalves
 
Java11 New Features
Java11 New FeaturesJava11 New Features
Java11 New FeaturesHaim Michael
 
Hackathon - building and extending OpenJDK
Hackathon - building and extending OpenJDKHackathon - building and extending OpenJDK
Hackathon - building and extending OpenJDKMichał Warecki
 
OSGi & Java EE in GlassFish
OSGi & Java EE in GlassFishOSGi & Java EE in GlassFish
OSGi & Java EE in GlassFishSanjeeb Sahoo
 
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 201450 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014Arun Gupta
 

Tendances (20)

De Java 8 a Java 11 y 14
De Java 8 a Java 11 y 14De Java 8 a Java 11 y 14
De Java 8 a Java 11 y 14
 
Java Unit Testing with Unitils
Java Unit Testing with UnitilsJava Unit Testing with Unitils
Java Unit Testing with Unitils
 
Monitoring And Tuning Glass Fish In The Wild Community One 2009
Monitoring And Tuning Glass Fish In The Wild   Community One 2009Monitoring And Tuning Glass Fish In The Wild   Community One 2009
Monitoring And Tuning Glass Fish In The Wild Community One 2009
 
Preparing your code for Java 9
Preparing your code for Java 9Preparing your code for Java 9
Preparing your code for Java 9
 
OpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConOpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheCon
 
Gradle in 45min
Gradle in 45minGradle in 45min
Gradle in 45min
 
Java SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionJava SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introduction
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
 
SLF4J+Logback
SLF4J+LogbackSLF4J+Logback
SLF4J+Logback
 
What's New in Enterprise JavaBean Technology ?
What's New in Enterprise JavaBean Technology ?What's New in Enterprise JavaBean Technology ?
What's New in Enterprise JavaBean Technology ?
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Are app servers still fascinating
Are app servers still fascinatingAre app servers still fascinating
Are app servers still fascinating
 
Java modularity: life after Java 9
Java modularity: life after Java 9Java modularity: life after Java 9
Java modularity: life after Java 9
 
Java11 New Features
Java11 New FeaturesJava11 New Features
Java11 New Features
 
Hackathon - building and extending OpenJDK
Hackathon - building and extending OpenJDKHackathon - building and extending OpenJDK
Hackathon - building and extending OpenJDK
 
Play framework
Play frameworkPlay framework
Play framework
 
OSGi & Java EE in GlassFish
OSGi & Java EE in GlassFishOSGi & Java EE in GlassFish
OSGi & Java EE in GlassFish
 
Intro To OSGi
Intro To OSGiIntro To OSGi
Intro To OSGi
 
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 201450 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
 
Karaf ee-apachecon eu-2012
Karaf ee-apachecon eu-2012Karaf ee-apachecon eu-2012
Karaf ee-apachecon eu-2012
 

En vedette

Tackling Actual Problems on the Wings of the Netbeans Platform, Jure Polutnik
Tackling Actual Problems on the Wings of the Netbeans Platform, Jure PolutnikTackling Actual Problems on the Wings of the Netbeans Platform, Jure Polutnik
Tackling Actual Problems on the Wings of the Netbeans Platform, Jure PolutnikOpenBlend society
 
Memory is the new disk, disk is the new tape, Bela Ban (JBoss by RedHat)
Memory is the new disk, disk is the new tape, Bela Ban (JBoss by RedHat)Memory is the new disk, disk is the new tape, Bela Ban (JBoss by RedHat)
Memory is the new disk, disk is the new tape, Bela Ban (JBoss by RedHat)OpenBlend society
 
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)OpenBlend society
 
Java SE 7 - The Platform Evolves, Dalibor Topić (Oracle)
Java SE 7 - The Platform Evolves, Dalibor Topić (Oracle)Java SE 7 - The Platform Evolves, Dalibor Topić (Oracle)
Java SE 7 - The Platform Evolves, Dalibor Topić (Oracle)OpenBlend society
 
Seam 3 from a Web developer’s point of view, Matija Mazi (Parsek)
Seam 3 from a Web developer’s point of view, Matija Mazi (Parsek)Seam 3 from a Web developer’s point of view, Matija Mazi (Parsek)
Seam 3 from a Web developer’s point of view, Matija Mazi (Parsek)OpenBlend society
 

En vedette (6)

Migracao gae-openshift
Migracao gae-openshiftMigracao gae-openshift
Migracao gae-openshift
 
Tackling Actual Problems on the Wings of the Netbeans Platform, Jure Polutnik
Tackling Actual Problems on the Wings of the Netbeans Platform, Jure PolutnikTackling Actual Problems on the Wings of the Netbeans Platform, Jure Polutnik
Tackling Actual Problems on the Wings of the Netbeans Platform, Jure Polutnik
 
Memory is the new disk, disk is the new tape, Bela Ban (JBoss by RedHat)
Memory is the new disk, disk is the new tape, Bela Ban (JBoss by RedHat)Memory is the new disk, disk is the new tape, Bela Ban (JBoss by RedHat)
Memory is the new disk, disk is the new tape, Bela Ban (JBoss by RedHat)
 
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
 
Java SE 7 - The Platform Evolves, Dalibor Topić (Oracle)
Java SE 7 - The Platform Evolves, Dalibor Topić (Oracle)Java SE 7 - The Platform Evolves, Dalibor Topić (Oracle)
Java SE 7 - The Platform Evolves, Dalibor Topić (Oracle)
 
Seam 3 from a Web developer’s point of view, Matija Mazi (Parsek)
Seam 3 from a Web developer’s point of view, Matija Mazi (Parsek)Seam 3 from a Web developer’s point of view, Matija Mazi (Parsek)
Seam 3 from a Web developer’s point of view, Matija Mazi (Parsek)
 

Similaire à How to cuddle your EJBs, Carlo de Wolf

Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...Dan Allen
 
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010JUG Lausanne
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Arun Gupta
 
Great cup of java
Great  cup of javaGreat  cup of java
Great cup of javaCIB Egypt
 
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?Dmitri Shiryaev
 
Prepare for JDK 9
Prepare for JDK 9Prepare for JDK 9
Prepare for JDK 9haochenglee
 
Java Course 15: Ant, Scripting, Spring, Hibernate
Java Course 15: Ant, Scripting, Spring, HibernateJava Course 15: Ant, Scripting, Spring, Hibernate
Java Course 15: Ant, Scripting, Spring, HibernateAnton Keks
 
An Introduction to Play 2 Framework
An Introduction to Play 2 FrameworkAn Introduction to Play 2 Framework
An Introduction to Play 2 FrameworkPT.JUG
 
Javascript training sample
Javascript training sampleJavascript training sample
Javascript training sampleprahalad_das_in
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang YoonJesang Yoon
 
The Java EE 6 platform
The Java EE 6 platformThe Java EE 6 platform
The Java EE 6 platformLorraine JUG
 
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...ddrschiw
 
Build, logging, and unit test tools
Build, logging, and unit test toolsBuild, logging, and unit test tools
Build, logging, and unit test toolsAllan Huang
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Saeed Zarinfam
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleThierry Wasylczenko
 

Similaire à How to cuddle your EJBs, Carlo de Wolf (20)

Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
 
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
 
Glass Fishv3 March2010
Glass Fishv3 March2010Glass Fishv3 March2010
Glass Fishv3 March2010
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011
 
Great cup of java
Great  cup of javaGreat  cup of java
Great cup of java
 
EJB 3.1 and GlassFish v3 Prelude
EJB 3.1 and GlassFish v3 PreludeEJB 3.1 and GlassFish v3 Prelude
EJB 3.1 and GlassFish v3 Prelude
 
Spock pres
Spock presSpock pres
Spock pres
 
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
 
Prepare for JDK 9
Prepare for JDK 9Prepare for JDK 9
Prepare for JDK 9
 
Java On Speed
Java On SpeedJava On Speed
Java On Speed
 
Java Course 15: Ant, Scripting, Spring, Hibernate
Java Course 15: Ant, Scripting, Spring, HibernateJava Course 15: Ant, Scripting, Spring, Hibernate
Java Course 15: Ant, Scripting, Spring, Hibernate
 
An Introduction to Play 2 Framework
An Introduction to Play 2 FrameworkAn Introduction to Play 2 Framework
An Introduction to Play 2 Framework
 
Javascript training sample
Javascript training sampleJavascript training sample
Javascript training sample
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoon
 
The Java EE 6 platform
The Java EE 6 platformThe Java EE 6 platform
The Java EE 6 platform
 
Ad111
Ad111Ad111
Ad111
 
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
 
Build, logging, and unit test tools
Build, logging, and unit test toolsBuild, logging, and unit test tools
Build, logging, and unit test tools
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 

Plus de OpenBlend society

SOA architecture patterns, Matjaž Jurič (FRI/Univerza v Ljubljani)
SOA architecture patterns, Matjaž Jurič (FRI/Univerza v Ljubljani)SOA architecture patterns, Matjaž Jurič (FRI/Univerza v Ljubljani)
SOA architecture patterns, Matjaž Jurič (FRI/Univerza v Ljubljani)OpenBlend society
 
National Reference runtime environment, Boris Šaletić (MJU)
National Reference runtime environment, Boris Šaletić (MJU)National Reference runtime environment, Boris Šaletić (MJU)
National Reference runtime environment, Boris Šaletić (MJU)OpenBlend society
 
Introducing Hibernate OGM: porting JPA applications to NoSQL, Sanne Grinovero...
Introducing Hibernate OGM: porting JPA applications to NoSQL, Sanne Grinovero...Introducing Hibernate OGM: porting JPA applications to NoSQL, Sanne Grinovero...
Introducing Hibernate OGM: porting JPA applications to NoSQL, Sanne Grinovero...OpenBlend society
 
Enterprise Java Virtualization, Sacha Labourey
Enterprise Java Virtualization, Sacha LaboureyEnterprise Java Virtualization, Sacha Labourey
Enterprise Java Virtualization, Sacha LaboureyOpenBlend society
 
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...OpenBlend society
 
Android Up Close, Martin Sonc
Android Up Close, Martin SoncAndroid Up Close, Martin Sonc
Android Up Close, Martin SoncOpenBlend society
 
Successful Application Lifecycle Management in heterogeneous environments, Ma...
Successful Application Lifecycle Management in heterogeneous environments, Ma...Successful Application Lifecycle Management in heterogeneous environments, Ma...
Successful Application Lifecycle Management in heterogeneous environments, Ma...OpenBlend society
 
Becoming an Open Source developer, Dimitris Andreadis
Becoming an Open Source developer, Dimitris AndreadisBecoming an Open Source developer, Dimitris Andreadis
Becoming an Open Source developer, Dimitris AndreadisOpenBlend society
 

Plus de OpenBlend society (8)

SOA architecture patterns, Matjaž Jurič (FRI/Univerza v Ljubljani)
SOA architecture patterns, Matjaž Jurič (FRI/Univerza v Ljubljani)SOA architecture patterns, Matjaž Jurič (FRI/Univerza v Ljubljani)
SOA architecture patterns, Matjaž Jurič (FRI/Univerza v Ljubljani)
 
National Reference runtime environment, Boris Šaletić (MJU)
National Reference runtime environment, Boris Šaletić (MJU)National Reference runtime environment, Boris Šaletić (MJU)
National Reference runtime environment, Boris Šaletić (MJU)
 
Introducing Hibernate OGM: porting JPA applications to NoSQL, Sanne Grinovero...
Introducing Hibernate OGM: porting JPA applications to NoSQL, Sanne Grinovero...Introducing Hibernate OGM: porting JPA applications to NoSQL, Sanne Grinovero...
Introducing Hibernate OGM: porting JPA applications to NoSQL, Sanne Grinovero...
 
Enterprise Java Virtualization, Sacha Labourey
Enterprise Java Virtualization, Sacha LaboureyEnterprise Java Virtualization, Sacha Labourey
Enterprise Java Virtualization, Sacha Labourey
 
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
 
Android Up Close, Martin Sonc
Android Up Close, Martin SoncAndroid Up Close, Martin Sonc
Android Up Close, Martin Sonc
 
Successful Application Lifecycle Management in heterogeneous environments, Ma...
Successful Application Lifecycle Management in heterogeneous environments, Ma...Successful Application Lifecycle Management in heterogeneous environments, Ma...
Successful Application Lifecycle Management in heterogeneous environments, Ma...
 
Becoming an Open Source developer, Dimitris Andreadis
Becoming an Open Source developer, Dimitris AndreadisBecoming an Open Source developer, Dimitris Andreadis
Becoming an Open Source developer, Dimitris Andreadis
 

Dernier

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Dernier (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

How to cuddle your EJBs, Carlo de Wolf

  • 1. 1 How to cuddle your EJBs Carlo de Wolf EJB 3 Product Lead JBoss by Red Hat October 2010
  • 2. 2 Agenda ● Quest for The Holy Grail ● EAP ● Why use EJB? – Simple – Predictable – Re-usable – Testable ● Road-map
  • 3. 3 Quest for The Holy Grail ● Looking for software components that are: – Simple – Predictable – Re-usable – Testable ● Also – Performant
  • 4. 4 Enterprise Application Platform ● A fork of AS 5 ● Plus functional patches ● Plus performance patches ● Plus support ● Some bits available through Plugin 1.0.19
  • 5. 5 Why use EJB(tm) ? ● Allow rapid development of reusable business components ● Using an easy infrastructure which does: – Memory management – Remote invocation – Thread management ● Thus having a predictable QoS
  • 6. 6 What is an EJB(tm) ? ● It's not a POJO! ● It consists of a class + interceptor classes + interfaces ● Construction is different ● Invocation is different ● It's an assembly with one or more views
  • 7. 7 Quest for The Holy Grail ● Looking for software components that are: – Simple – Predictable – Re-usable – Testable ● Also – Performant
  • 8. 8 Simplicity ● Create an EJB with a remote business view ● Create an EJB archive ● Deploy it
  • 9. 9 Creating an EJB ● Learn how to code EJBs with Andrew's book: Enterprise JavaBeans 3.1 – ISBN: 978-0-596-15802-6 – Develop your first EJBs with a hands-on walkthrough of EJB 3.1 concepts
  • 10. 10 Creating an EJB archive ● Use Ant to create an archive <jar jarfile=”${build.lib}/myfirstejb.jar”> <fileset dir=”${build.class}”/> </jar> ● Or use Maven
  • 11. 11 Deploying an archive ● Copy into deploy $ cp myfirstejb.jar $JBOSS_HOME/server/default/deploy/ ● Use the MainDeployer MbeanServerConnection conn = iniCtx.lookup(“jmx/invoker/RMIAdaptor”); conn.invoke(“jboss.system:service=MainDeployer”, “deploy”, new URL(“file:myfirstejb.jar”));
  • 12. 12 Quest for The Holy Grail ● Looking for software components that are: – Simple – Predictable – Re-usable – Testable ● Also – Performant
  • 13. 13 Dynamic Code Changing ● EJBTHREE-1096: Make SLSB and SFSB hot deployable for RAD. ● Allow changing functionality / invariants ● Allow changes in the EJB structure ● Compiling (Deploying) vs Interpreted
  • 14. 14 Bean State ● Bean State is governed by invariants @Stateful public class ConsentWizard { private Date birthdate; public void setBirthday(Date date) { if(age(date) < 18) throw new IllegalStateException("Minors not allowed"); this.birthdate = date; } } ● Changing an invariant leaves artifacts ● Bean State has become non-deterministic
  • 15. 15 Application State ● Application state is determined by the assembly of all components @Stateful public class ConsentWizard implements RemoteWizard { } public class SomeServletThingy { @EJB RemoteWizard wizard; } ● Changing component structure may leave application undeployable
  • 16. 16 Deploying is like Compiling ● It checks whether the application is deployable ● It sets up a clean slate to begin tests from ● So, Dynamic Code Changing is a fluffy white rabbit. Looks cute, but will kill you in the end.
  • 17. 17 Quest for The Holy Grail ● Looking for software components that are: – Simple – Predictable – Re-usable – Testable ● Also – Performant
  • 18. 18 Separation of Concerns ● By making aspects configurable and manageable ● Security ● Transaction Management ● Remoting ● Interceptors (now separated!) ● Persistence (separated into JPA)
  • 19. 19 Spec EJB 3.1 Async ● A re-usable component separates concerns ● Brings an application developer requirement to the bean developer ● Ergo doesn't make for re-usable components
  • 20. 20 JBoss EJB 3.1 Async ● A callers functional concern ● If the caller resides in the same VM, let the EJB manage it
  • 21. 21 Quest for The Holy Grail ● Looking for software components that are: – Simple – Predictable – Re-usable – Testable ● Also – Performant
  • 22. 22 Test it using a remote view ● Create an archive, deploy it, then call it public class RemoteTestCase { @Test public void test() throws NamingException { MyFirstView bean = (MyFirstView) iniCtx.lookup("MyFirstBean/remote"); String result = bean.doSomething(); assertEquals("done", result); } }
  • 23. 23 Assembled Directory ● Use VFS 2 AssembledDirectory jar = AssembledContextFactory.getInstance().create("test.jar"); jar.addClass(GreetingsBean.class); jar.addClass(Greetings.class); ● The venerable JBoss Embeddable Bootstrap.getInstance().deploy(jar); ● JBoss Reloaded Embedded prototype VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(root); mainDeployer.deploy(root); ● EJB 3.1 Embeddable prototype EJBContainer container = EJBContainer.createEJBContainer(); on(container).deploy(deployment(jar));
  • 24. 24 ShrinkWrap ● Easily build an archive JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test.jar") .addClasses(GreetingsBean.class, Greetings.class); File tempFile = File.createTempFile("test", ".jar"); jar.as(ZipExporter.class).exportZip(tempFile, true); URL url = tempFile.toURI().toURL(); ● Deploy the archive MbeanServerConnection conn = iniCtx.lookup("jmx/invoker/RMIAdaptor"); conn.invoke("jboss.system:service=MainDeployer", "deploy", url); ● See it in action $ git clone git://github.com/jbossejb3/jboss-ejb3-timerservice.git $ cd jboss-ejb3-timerservice $ mvn install
  • 25. 25 EJB 3.1 Embeddable ● By spec only does local session beans ● You want more services, so ultimately a full Application Server ● Two solutions: – Paravirtualized, not standalone – JBoss Embedded
  • 26. 26 Arquillian ● Or we could go to the server @RunWith(Arquillian.class) public class GreetingManagerTest { @Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class, "test.jar") .addClasses(GreetingsBean.class, Greetings.class); } @EJB private Greetings alien; @Test public void shouldGreetUser() throws Exception { String name = "Earthlings"; assertEquals("Hello, " + name, alien.greet(name)); } }
  • 27. 27 Arquillian #2 ● Access to local views ● Debug my EJBs and unit test – Breakpoints – Step through – Happens on the VM running the Server ● JBoss AS becomes an 'OS' resource – No worry about Server lifecycle / startup time
  • 28. 28 ShrinkWrap + Arquillian ● The Aliens love any container ● Complete separation of concerns
  • 29. 29 Road-map ● EAP 6 will do EJB 3.1 ● AS 6 CR1 time-box closes Nov 16th ● AS 7 M1 is coming up ● Bug reports / requests can end up in a milestone, get on the band-wagon.
  • 30. 30 EJB 4 ● More separation of concerns ● Concrete aspects of Managed Beans? ● CDI Extension?
  • 31. 31 How to cuddle your EJBs? ● Don't try to bring the EJBs to you. ● Go to the EJBs. ● Use ShrinkWrap & Arquillian for your travels!