SlideShare uma empresa Scribd logo
1 de 68
Are application servers still
fascinating for developers ?

          by antonio goncalves
                     @agoncal
Antonio Goncalves
●
    Freelance software architect
●
    Author (Java EE 5 and Java EE 6)
●
    JCP expert member (Java EE 6, Java EE 7)
●
    Co-leader of the Paris JUG
●
    Les Cast Codeurs podcast
●   Java Champion




                    antonio goncalves          2
Co-creator of Devoxx France
●
    Little brother of Devoxx (Belgium)
●
    3 days conference (18th to 20th April 2012)
●
    140 talks (75% in French)
●
    In Paris
●
    Cheap (450€)
●   www.devoxx.fr




                    antonio goncalves             3
Why am I talking here today
●
    Former BEA employee
●
    Started working with J2EE in 1998
●
    With Weblogic 3.x
●
    Java EE 6 / 7 Expert Member
●
    Has used/played with most app servers
●   Blogs about app servers




                   antonio goncalves        4
« Application server »




             antonio goncalves   5
Wikipedia



     « Server which provides
software applications with services»
Gartner



« Server that acts as a container for
   applications' business logic...
       and brings services »
Server and services
●
    Server                             ●
                                           Services
    ●   « Program running to               ●   Security
        serve the requests of              ●   Transaction
        other programs »
                                           ●   Load balancing
    ●   Application server
                                           ●   Distribution
    ●   Database server
                                           ●   Management
    ●   Communication server
                                           ●   Performance
    ●   File server
                                           ●   ...
    ●   Fax server
    ●   ...
                       antonio goncalves                        8
We use application servers not to
      reinvent the wheel
  (i.e the technical services)
« Application » server
●
    Market dominated by
    ●   Java
    ●   .Net
●
    Proprietary
●
    Other programming models




                  antonio goncalves   10
Let's focus on Java
                    Java EE 6

      Web Profile 6

  Servlet




               antonio goncalves   11
Web profile
●
    Java EE 6
    ●   28 specifications
●   Web profile
    ●   12 specifications
●
    Other profiles will come
●
    Brings modularity




                       antonio goncalves   12
Modularity
●
    OSGi / Modules / What ever
    ●   Java modules in Java SE 8 / Java EE 8 ?
●   App servers become jigsaw puzzles
●
    Only startup needed modules
●   Faster
●
    Lighter
●
    Time is changing



                       antonio goncalves          13
History




         JPE      J2EE 1.2   J2EE 1.3     J2EE 1.4   Java EE 5   Java EE 6   Java EE 7
1995   May 1998   Dec 1999   Sept 2001    Nov 2003   May 2006    Dec 2009    Mar 2013

                             antonio goncalves                                  14
Startup time of JBoss




Using a Windows XP virtual machine (Virtual Box)

                                     antonio goncalves   15
Startup time of other servers




Using a Windows XP virtual machine (Virtual Box)

                                     antonio goncalves   16
Industrial strengh
●
    App servers implement the same specs
●
    They all do the same basic stuff...
●
    … so they must find a differentiator
    ●   Startup time
    ●   Memory footprint
    ●   Administration
    ●   Add ons
    ●   Clustering



                         antonio goncalves   17
Money, get away
●
    Why is the app server battle so tough ?
●
    *Because there is money involved :
    ●   2010 : app server market = $3.2 billion
    ●   9% growth per year
    ●   2015 : reaching $5 billion




(*)Gartner 2010

                       antonio goncalves          18
Magic quadrant - Sep 2011




            antonio goncalves   19
Magic quadrant - Sep 2011
                                ●   Leaders
                                    ●   Oracle
                                    ●   IBM
                                    ●   RedHat




            antonio goncalves                 20
Magic quadrant - Sep 2011




                                ●   Visionary
                                    ●   Resin




            antonio goncalves               21
Future<App Server>
●
    « *In the next 5 years most app servers will be
    extended for cloud computing purposes » 
●
    Elastic resource allocation
●
    Dynamic clustering
●
    Horizontal scaling
●
    Multitenancy (Java EE 7)




(*)Gartner 2011

                    antonio goncalves                 22
Let's quickly have a look at some
    “new” application servers
WebSphere Liberty 8.5
Webs.... fear
●
    Ops love it
●
    Devs hate it
    ●   … and IBM wants us to love it now
●
    OGSi
●   Simple, Lightweight, Fast
●
    Liberty Profile (not the web profile)
    ●   No EJB Lite, no CDI
●
    Free for development


                       antonio goncalves    25
Composable runtime




           antonio goncalves   26
WAS 8.5 Licensing




            antonio goncalves   27
Demo
TomEE 1.0
TomEE
●
    Based on Tomcat
●
    … everybody knows Tomcat
●
    Web Profile
●
    Passed the TCK
●
    TomEE + (web profile + JAX-RS / JAX-WS / JMS)
●   Everything is free




                     antonio goncalves          30
What's in




            antonio goncalves   31
Demo
Resin 4.x
Resin
●
    Created in 1999 (web server)
●
    First web profile certified in 2011
●
    4.7 millions web sites hosted on Resin
    ●   Mostly in finance
●   “Visionary” on Gartner Magic Quadrant
●
    Resin open source (free)
●
    Resin professional
    ●   Commercial license


                       antonio goncalves     34
Inside Resin
●
    Based on CanDI
●
    Quercus (PHP)
●
    Watchdog
●
    Cloud ready (dynamic clustering)
●
    Remote EJBs use Hessian (instead of RMI)
●   Multitenancy




                     antonio goncalves         35
Demo
And now, the developers point of
             view
How is it to use these servers on a
         day to day basis ?
Yaps Petstore
●
    Inspired from Sun Petstore Blueprint
●
    Java EE 6 - Web profile (packaged in a war)
●
    No external dependencies
●
    Portable (well, kind of)
    ●   GlassFish 3.x / JBoss 7.x / TomEE / Resin / ...
●
    JPA 2.0 / EJB 3.1 Lite / CDI 1.0 / JSF 2.0 / Bean
    Validation 1.0 / JAX-RS 1.1
●   https://github.com/agoncal/agoncal-
    application-petstore-ee6

                       antonio goncalves                  39
Demo of the Yaps Petstore
   with GlassFish 3.x
Developing / Debugging
●
    Good old “develop/package/deploy/start”
    ●   Event if app servers start quickly
    ●   Takes too much time
●
    JRebel...
    ●   … is your friend
    ●   Hot deployment
    ●   Reload classes
    ●   Updates web resources
    ●   Saves you time

                         antonio goncalves    41
Demo with JRebel
Testing
●
    Unit Tests
    ●   Mock container services
●   Integration Tests
    ●   WYTIWYR (What You Test Is What You Run)
    ●   Use container services
    ●   EJBContainer API (in Java EE 6)
    ●   Arquillian




                       antonio goncalves          43
Unit test with Mockito
@RunWith(MockitoJUnitRunner.class)
public class ItemEJBTest {

    @Mock
    private EntityManager mockedEntityManager;
    @Mock
    private TypedQuery mockedQuery;
    private ItemEJB itemEJB;

    @Before
    public void init() throws Exception {
      itemEJB = new ItemEJB();
      itemEJB.setEntityManager(mockedEntityManager);
    }
}

                    antonio goncalves              44
Integration test with EJBContainer
public class ItemEJBIT {

    private static EJBContainer ec;
    private static Context ctx;

    @BeforeClass
    public static void init() throws Exception {
      Map<String, Object> properties = new HashMap<>();
      properties.put(EJBContainer.MODULES, new
        File("target/classes"));
      ec = EJBContainer.createEJBContainer(properties);
      ctx = ec.getContext();
    }
}


                    antonio goncalves              45
Integration test with Arquillian
@RunWith(Arquillian.class)
public class ItemEJBIT {

  @Inject
  private ItemEJB itemEJB;

  @Deployment
  public static JavaArchive createTestArchive() {
    JavaArchive archive = ShrinkWrap
      .create(JavaArchive.class)
      .addPackage(Book.class.getPackage())
      .addAsManifestResource(INSTANCE, "beans.xml")
      .addAsResource("META-INF/persistence.xml"..);
    return archive;
  }

                  antonio goncalves              46
Integration Testing
●
    In memory database
●
    In memory container
    ●   EJBContainer API
●
    Embedded container with Arquillian
●   Remote container with Arquillian
●
    IT richer but slower that UT




                      antonio goncalves   47
Demo of an integration test with
          Arquillian
Portable ?
●
    Java EE is a standard
●
    Yaps Petstore only uses standards
●
    Standards should run everywhere
●
    I want my Yaps Petstore to run everywhere
    ●   But it's not that easy




                        antonio goncalves       49
JPA
●
    Lazy Loading bidirectional entities
    ●   Spec has undefined behaviour
    ●   Works well with EclipseLink
    ●   Doesn't with Hibernate (use Fetch Join)
    ●   Fetch Joins don't work with EclipseLink




                       antonio goncalves          50
Lazy loading
List<Product> products = em.createQuery
("SELECT p FROM Product p WHERE p.category.name =:n")
.getResultList();

for (Product product : products) {
  Category category = product.getCategory();


}




                  antonio goncalves              51
Lazy loading
List<Product> products = em.createQuery
("SELECT p FROM Product p WHERE p.category.name =:n")
.getResultList();

for (Product product : products) {
  Category category = product.getCategory();
  if (category != null)
    category.getName();              Can return a proxy
}
                    Makes sure you get the entity




                     antonio goncalves                    52
Datasource
●
    Needs to be defined
    ●   In the container through admin
    ●   Via web.xml, application.xml, ejb-jar.xml
    ●   Or via annotation
●
    Points to a database
●
    In memory DB are good for development
●   Each app server uses it's own in memory DB
●   Derby
    ●   Not in JBoss (add derby.jar to .war)
                       antonio goncalves            53
Datasource
@DataSourceDefinition(
  className ="org.apache.derby.jdbc.EmbeddedDataSource
  name = "java:global/jdbc/applicationPetstoreDS",
  ...)

<persistence>
  <persistence-unit name="applicationPetstorePU"...>
  <jta-data-source>
    java:global/jdbc/applicationPetstoreDS
  ...
</persistence>

@PersistenceContext(unitName = "applicationPetstorePU"
private EntityManager em;


                  antonio goncalves              54
Default Datasource in Java EE 7
@DataSourceDefinition(
  className ="org.apache.derby.jdbc.EmbeddedDataSource
  name = "java:global/jdbc/applicationPetstoreDS",
  ...)

<persistence>
  <persistence-unit name="applicationPetstorePU"...>
  <jta-data-source>
    java:global/jdbc/applicationPetstoreDS
  ...
</persistence>

@Inject
private EntityManager em;


                  antonio goncalves              55
Other resources in Java EE 7
@JMSConnectionFactoryDefinition(
    name="java:app/MyJMSFactory",
    resourceType="javax.jms.QueueConnectionFactory",
    clientId="foo",resourceAdapter="jmsra",
    InitialPoolSize=5, maxPoolSize=15
)

@JMSDestinationDefinition(
    name="java:app/orderQueue",
    resourceType="javax.jms.Queue",
    resourceAdapter="jmsra",
    destinationName="orderQueue"
)



                  antonio goncalves              56
Properties not all standard
<persistence-unit name="applicationPetstorePU"...>
...
<properties>
<!-- Standard Properties -->
<property name="javax.persistence.xxx" value="xxx"/>


<!-- Properties for EclipseLink -->
<property name="eclipselink.ddl-generation" value="create-tables

<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>

<!-- Properties for OpenJPA -->
<property name="openjpa.jdbc.SynchronizeMappings"
          value="buildSchema(ForeignKeys=true)"/>
</properties>
</persistence-unit>
                      antonio goncalves                    57
Persistence properties in Java EE 7
<persistence-unit name="applicationPetstorePU"...>
...
<properties>
<!-- Standard Properties -->
<property name="javax.persistence.xxx" value="xxx"/>
<property name="javax.persistence.ddl" value="drop-and-create"/>

<!-- Properties for EclipseLink -->
<property name="eclipselink.ddl-generation" value="create-tables

<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>

<!-- Properties for OpenJPA -->
<property name="openjpa.jdbc.SynchronizeMappings"
          value="buildSchema(ForeignKeys=true)"/>
</properties>
</persistence-unit>
 Not sure of the syntax                             Not sure of the syntax

                          antonio goncalves                            58
Initialize database
●
    Having some data in the DB
●
    Running sql script
●
    derbytools.jar has an API
●
    Hibernate : import.sql (but not with other ORMs)




                    antonio goncalves             59
Use a Singleton with @Startup
@Singleton
@Startup
public class DBPopulator {

    @Inject
    private CatalogService catalogService;

    @PostConstruct
    private void populateDB() {
      catalogService.createCategory(new Category("Fish"))
    }
}




                    antonio goncalves               60
Demo of the Yaps Petstore
     with JBoss 7.x
Portable ?
●
    TCK doesn't cover all the cases
    ●   e.x. all the possible JPQL query syntax
●   Implementations fill (or not) black holes
●
    100% portability is still a myth...
●   … but it's getting better
●
    … and Java EE 7 will improve some bits
●
    Any way, you don't change app server every day
●
    … except for the Yaps Petstore ;o)

                       antonio goncalves          62
Are application servers still
fascinating for developers ?
Are application servers still
   fascinating for developers ?

Maybe not “fascinating” but much
    easier to use than before
Thanks


   www.antoniogoncalves.org
antonio.goncalves@gmail.com
                   @agoncal
             @lescastcodeurs
Thanks
●
    Antoine Sabot Durand @antoine_sd
●
    Jean-Louis Monteiro @JLouisMonteiro
●
    Romain Manni-Bucau @rmannibucau
●
    Sébastien Stormacq @sebsto




                  antonio goncalves       66
Q&A
Creative Commons
●
    Attribution — You must attribute the work in
    the manner specified by the author or licensor
    (but not in any way that suggests that they
    endorse you or your use of the work).
●   Noncommercial — You may not use this work for
    commercial purposes.
●   Share Alike — If you alter, transform, or build
    upon this work, you may distribute the resulting
    work only under the same or similar license to
    this one.

                   antonio goncalves                 68

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andev
 
Quickly Testing Qt Desktop Applications
Quickly Testing Qt Desktop ApplicationsQuickly Testing Qt Desktop Applications
Quickly Testing Qt Desktop Applications
 
Code generation with javac plugin
Code generation with javac pluginCode generation with javac plugin
Code generation with javac plugin
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJS
 
Daggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processorDaggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processor
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
Mobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast diveMobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast dive
 
Bytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMBytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASM
 
JavaFX8 TestFX - CDI
JavaFX8   TestFX - CDIJavaFX8   TestFX - CDI
JavaFX8 TestFX - CDI
 
A friend in need - A JS indeed
A friend in need - A JS indeedA friend in need - A JS indeed
A friend in need - A JS indeed
 
Internal Android Library Management (DroidCon SF 2016, Droidcon Italy 2016)
Internal Android Library Management (DroidCon SF 2016, Droidcon Italy 2016)Internal Android Library Management (DroidCon SF 2016, Droidcon Italy 2016)
Internal Android Library Management (DroidCon SF 2016, Droidcon Italy 2016)
 
Angular testing
Angular testingAngular testing
Angular testing
 
Test-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsTest-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS Applications
 
RichFaces - Testing on Mobile Devices
RichFaces - Testing on Mobile DevicesRichFaces - Testing on Mobile Devices
RichFaces - Testing on Mobile Devices
 
Using hilt in a modularized project
Using hilt in a modularized projectUsing hilt in a modularized project
Using hilt in a modularized project
 
Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University - Exploring Angular 2
Commit University - Exploring Angular 2
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
 
Qt test framework
Qt test frameworkQt test framework
Qt test framework
 
Angular2
Angular2Angular2
Angular2
 
Speed up your GWT coding with gQuery
Speed up your GWT coding with gQuerySpeed up your GWT coding with gQuery
Speed up your GWT coding with gQuery
 

Destaque

Lightweight AOP with CDI and JPA
Lightweight AOP with CDI and JPALightweight AOP with CDI and JPA
Lightweight AOP with CDI and JPA
mh0708
 
Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7
Hirofumi Iwasaki
 

Destaque (14)

Java EE 6 Adoption in One of the World's Largest Online Financial Systems (fo...
Java EE 6 Adoption in One of the World's Largest Online Financial Systems (fo...Java EE 6 Adoption in One of the World's Largest Online Financial Systems (fo...
Java EE 6 Adoption in One of the World's Largest Online Financial Systems (fo...
 
Lightweight AOP with CDI and JPA
Lightweight AOP with CDI and JPALightweight AOP with CDI and JPA
Lightweight AOP with CDI and JPA
 
Future of Java EE with SE 8 (revised)
Future of Java EE with SE 8 (revised)Future of Java EE with SE 8 (revised)
Future of Java EE with SE 8 (revised)
 
Whats New In Java Ee 6
Whats New In Java Ee 6Whats New In Java Ee 6
Whats New In Java Ee 6
 
Case Study of Financial Web System Development and Operations with Oracle Web...
Case Study of Financial Web System Development and Operations with Oracle Web...Case Study of Financial Web System Development and Operations with Oracle Web...
Case Study of Financial Web System Development and Operations with Oracle Web...
 
Move from J2EE to Java EE
Move from J2EE to Java EEMove from J2EE to Java EE
Move from J2EE to Java EE
 
Java EE 7 for Real Enterprise Systems
Java EE 7 for Real Enterprise SystemsJava EE 7 for Real Enterprise Systems
Java EE 7 for Real Enterprise Systems
 
Java one 2015 [con3339]
Java one 2015 [con3339]Java one 2015 [con3339]
Java one 2015 [con3339]
 
Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7
 
Just enough app server
Just enough app serverJust enough app server
Just enough app server
 
Java EE 7 - Overview and Status
Java EE 7  - Overview and StatusJava EE 7  - Overview and Status
Java EE 7 - Overview and Status
 
IBM WebSphere Application Server (Clustering) Concept
IBM WebSphere Application Server (Clustering) ConceptIBM WebSphere Application Server (Clustering) Concept
IBM WebSphere Application Server (Clustering) Concept
 
Java EE Introduction
Java EE IntroductionJava EE Introduction
Java EE Introduction
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuse
 

Semelhante a Are app servers still fascinating

blueMarine Sailing with NetBeans Platform
blueMarine Sailing with NetBeans PlatformblueMarine Sailing with NetBeans Platform
blueMarine Sailing with NetBeans Platform
Fabrizio Giudici
 
Android Frameworks: Highlighting the Need for a Solid Development Framework 
Android Frameworks: Highlighting the Need for a Solid Development Framework Android Frameworks: Highlighting the Need for a Solid Development Framework 
Android Frameworks: Highlighting the Need for a Solid Development Framework 
Mutual Mobile
 
EEF : Sexy Properties, Wizards and Views - EclipseCon 11
EEF : Sexy Properties, Wizards and Views - EclipseCon 11EEF : Sexy Properties, Wizards and Views - EclipseCon 11
EEF : Sexy Properties, Wizards and Views - EclipseCon 11
Chauvin Mariot
 
Aws uk ug #8 not everything that happens in vegas stay in vegas
Aws uk ug #8   not everything that happens in vegas stay in vegasAws uk ug #8   not everything that happens in vegas stay in vegas
Aws uk ug #8 not everything that happens in vegas stay in vegas
Peter Mounce
 

Semelhante a Are app servers still fascinating (20)

Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplate
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
 
Launchpad: Lessons Learnt
Launchpad: Lessons LearntLaunchpad: Lessons Learnt
Launchpad: Lessons Learnt
 
blueMarine Sailing with NetBeans Platform
blueMarine Sailing with NetBeans PlatformblueMarine Sailing with NetBeans Platform
blueMarine Sailing with NetBeans Platform
 
CON6423: Scalable JavaScript applications with Project Nashorn
CON6423: Scalable JavaScript applications with Project NashornCON6423: Scalable JavaScript applications with Project Nashorn
CON6423: Scalable JavaScript applications with Project Nashorn
 
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
 
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
 
Introduction to react native @ TIC NUST
Introduction to react native @ TIC NUSTIntroduction to react native @ TIC NUST
Introduction to react native @ TIC NUST
 
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?
 
Guides To Analyzing WebKit Performance
Guides To Analyzing WebKit PerformanceGuides To Analyzing WebKit Performance
Guides To Analyzing WebKit Performance
 
Android Frameworks: Highlighting the Need for a Solid Development Framework 
Android Frameworks: Highlighting the Need for a Solid Development Framework Android Frameworks: Highlighting the Need for a Solid Development Framework 
Android Frameworks: Highlighting the Need for a Solid Development Framework 
 
EEF : Sexy Properties, Wizards and Views - EclipseCon 11
EEF : Sexy Properties, Wizards and Views - EclipseCon 11EEF : Sexy Properties, Wizards and Views - EclipseCon 11
EEF : Sexy Properties, Wizards and Views - EclipseCon 11
 
GeoServer Developers Workshop
GeoServer Developers WorkshopGeoServer Developers Workshop
GeoServer Developers Workshop
 
Devoxx : being productive with JHipster
Devoxx : being productive with JHipsterDevoxx : being productive with JHipster
Devoxx : being productive with JHipster
 
Aws uk ug #8 not everything that happens in vegas stay in vegas
Aws uk ug #8   not everything that happens in vegas stay in vegasAws uk ug #8   not everything that happens in vegas stay in vegas
Aws uk ug #8 not everything that happens in vegas stay in vegas
 
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
 
IntoWebGL - Unite Melbourne 2015
IntoWebGL - Unite Melbourne 2015IntoWebGL - Unite Melbourne 2015
IntoWebGL - Unite Melbourne 2015
 
CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...
CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...
CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...
 
eXoer on the grill: eXo Add-ons factory using Docker and Codenvy
eXoer on the grill: eXo Add-ons factory using Docker and CodenvyeXoer on the grill: eXo Add-ons factory using Docker and Codenvy
eXoer on the grill: eXo Add-ons factory using Docker and Codenvy
 
Web App Prototypes with Google App Engine
Web App Prototypes with Google App EngineWeb App Prototypes with Google App Engine
Web App Prototypes with Google App Engine
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Are app servers still fascinating

  • 1. Are application servers still fascinating for developers ? by antonio goncalves @agoncal
  • 2. Antonio Goncalves ● Freelance software architect ● Author (Java EE 5 and Java EE 6) ● JCP expert member (Java EE 6, Java EE 7) ● Co-leader of the Paris JUG ● Les Cast Codeurs podcast ● Java Champion antonio goncalves 2
  • 3. Co-creator of Devoxx France ● Little brother of Devoxx (Belgium) ● 3 days conference (18th to 20th April 2012) ● 140 talks (75% in French) ● In Paris ● Cheap (450€) ● www.devoxx.fr antonio goncalves 3
  • 4. Why am I talking here today ● Former BEA employee ● Started working with J2EE in 1998 ● With Weblogic 3.x ● Java EE 6 / 7 Expert Member ● Has used/played with most app servers ● Blogs about app servers antonio goncalves 4
  • 5. « Application server » antonio goncalves 5
  • 6. Wikipedia « Server which provides software applications with services»
  • 7. Gartner « Server that acts as a container for applications' business logic... and brings services »
  • 8. Server and services ● Server ● Services ● « Program running to ● Security serve the requests of ● Transaction other programs » ● Load balancing ● Application server ● Distribution ● Database server ● Management ● Communication server ● Performance ● File server ● ... ● Fax server ● ... antonio goncalves 8
  • 9. We use application servers not to reinvent the wheel (i.e the technical services)
  • 10. « Application » server ● Market dominated by ● Java ● .Net ● Proprietary ● Other programming models antonio goncalves 10
  • 11. Let's focus on Java Java EE 6 Web Profile 6 Servlet antonio goncalves 11
  • 12. Web profile ● Java EE 6 ● 28 specifications ● Web profile ● 12 specifications ● Other profiles will come ● Brings modularity antonio goncalves 12
  • 13. Modularity ● OSGi / Modules / What ever ● Java modules in Java SE 8 / Java EE 8 ? ● App servers become jigsaw puzzles ● Only startup needed modules ● Faster ● Lighter ● Time is changing antonio goncalves 13
  • 14. History JPE J2EE 1.2 J2EE 1.3 J2EE 1.4 Java EE 5 Java EE 6 Java EE 7 1995 May 1998 Dec 1999 Sept 2001 Nov 2003 May 2006 Dec 2009 Mar 2013 antonio goncalves 14
  • 15. Startup time of JBoss Using a Windows XP virtual machine (Virtual Box) antonio goncalves 15
  • 16. Startup time of other servers Using a Windows XP virtual machine (Virtual Box) antonio goncalves 16
  • 17. Industrial strengh ● App servers implement the same specs ● They all do the same basic stuff... ● … so they must find a differentiator ● Startup time ● Memory footprint ● Administration ● Add ons ● Clustering antonio goncalves 17
  • 18. Money, get away ● Why is the app server battle so tough ? ● *Because there is money involved : ● 2010 : app server market = $3.2 billion ● 9% growth per year ● 2015 : reaching $5 billion (*)Gartner 2010 antonio goncalves 18
  • 19. Magic quadrant - Sep 2011 antonio goncalves 19
  • 20. Magic quadrant - Sep 2011 ● Leaders ● Oracle ● IBM ● RedHat antonio goncalves 20
  • 21. Magic quadrant - Sep 2011 ● Visionary ● Resin antonio goncalves 21
  • 22. Future<App Server> ● « *In the next 5 years most app servers will be extended for cloud computing purposes »  ● Elastic resource allocation ● Dynamic clustering ● Horizontal scaling ● Multitenancy (Java EE 7) (*)Gartner 2011 antonio goncalves 22
  • 23. Let's quickly have a look at some “new” application servers
  • 25. Webs.... fear ● Ops love it ● Devs hate it ● … and IBM wants us to love it now ● OGSi ● Simple, Lightweight, Fast ● Liberty Profile (not the web profile) ● No EJB Lite, no CDI ● Free for development antonio goncalves 25
  • 26. Composable runtime antonio goncalves 26
  • 27. WAS 8.5 Licensing antonio goncalves 27
  • 28. Demo
  • 30. TomEE ● Based on Tomcat ● … everybody knows Tomcat ● Web Profile ● Passed the TCK ● TomEE + (web profile + JAX-RS / JAX-WS / JMS) ● Everything is free antonio goncalves 30
  • 31. What's in antonio goncalves 31
  • 32. Demo
  • 34. Resin ● Created in 1999 (web server) ● First web profile certified in 2011 ● 4.7 millions web sites hosted on Resin ● Mostly in finance ● “Visionary” on Gartner Magic Quadrant ● Resin open source (free) ● Resin professional ● Commercial license antonio goncalves 34
  • 35. Inside Resin ● Based on CanDI ● Quercus (PHP) ● Watchdog ● Cloud ready (dynamic clustering) ● Remote EJBs use Hessian (instead of RMI) ● Multitenancy antonio goncalves 35
  • 36. Demo
  • 37. And now, the developers point of view
  • 38. How is it to use these servers on a day to day basis ?
  • 39. Yaps Petstore ● Inspired from Sun Petstore Blueprint ● Java EE 6 - Web profile (packaged in a war) ● No external dependencies ● Portable (well, kind of) ● GlassFish 3.x / JBoss 7.x / TomEE / Resin / ... ● JPA 2.0 / EJB 3.1 Lite / CDI 1.0 / JSF 2.0 / Bean Validation 1.0 / JAX-RS 1.1 ● https://github.com/agoncal/agoncal- application-petstore-ee6 antonio goncalves 39
  • 40. Demo of the Yaps Petstore with GlassFish 3.x
  • 41. Developing / Debugging ● Good old “develop/package/deploy/start” ● Event if app servers start quickly ● Takes too much time ● JRebel... ● … is your friend ● Hot deployment ● Reload classes ● Updates web resources ● Saves you time antonio goncalves 41
  • 43. Testing ● Unit Tests ● Mock container services ● Integration Tests ● WYTIWYR (What You Test Is What You Run) ● Use container services ● EJBContainer API (in Java EE 6) ● Arquillian antonio goncalves 43
  • 44. Unit test with Mockito @RunWith(MockitoJUnitRunner.class) public class ItemEJBTest { @Mock private EntityManager mockedEntityManager; @Mock private TypedQuery mockedQuery; private ItemEJB itemEJB; @Before public void init() throws Exception { itemEJB = new ItemEJB(); itemEJB.setEntityManager(mockedEntityManager); } } antonio goncalves 44
  • 45. Integration test with EJBContainer public class ItemEJBIT { private static EJBContainer ec; private static Context ctx; @BeforeClass public static void init() throws Exception { Map<String, Object> properties = new HashMap<>(); properties.put(EJBContainer.MODULES, new File("target/classes")); ec = EJBContainer.createEJBContainer(properties); ctx = ec.getContext(); } } antonio goncalves 45
  • 46. Integration test with Arquillian @RunWith(Arquillian.class) public class ItemEJBIT { @Inject private ItemEJB itemEJB; @Deployment public static JavaArchive createTestArchive() { JavaArchive archive = ShrinkWrap .create(JavaArchive.class) .addPackage(Book.class.getPackage()) .addAsManifestResource(INSTANCE, "beans.xml") .addAsResource("META-INF/persistence.xml"..); return archive; } antonio goncalves 46
  • 47. Integration Testing ● In memory database ● In memory container ● EJBContainer API ● Embedded container with Arquillian ● Remote container with Arquillian ● IT richer but slower that UT antonio goncalves 47
  • 48. Demo of an integration test with Arquillian
  • 49. Portable ? ● Java EE is a standard ● Yaps Petstore only uses standards ● Standards should run everywhere ● I want my Yaps Petstore to run everywhere ● But it's not that easy antonio goncalves 49
  • 50. JPA ● Lazy Loading bidirectional entities ● Spec has undefined behaviour ● Works well with EclipseLink ● Doesn't with Hibernate (use Fetch Join) ● Fetch Joins don't work with EclipseLink antonio goncalves 50
  • 51. Lazy loading List<Product> products = em.createQuery ("SELECT p FROM Product p WHERE p.category.name =:n") .getResultList(); for (Product product : products) { Category category = product.getCategory(); } antonio goncalves 51
  • 52. Lazy loading List<Product> products = em.createQuery ("SELECT p FROM Product p WHERE p.category.name =:n") .getResultList(); for (Product product : products) { Category category = product.getCategory(); if (category != null) category.getName(); Can return a proxy } Makes sure you get the entity antonio goncalves 52
  • 53. Datasource ● Needs to be defined ● In the container through admin ● Via web.xml, application.xml, ejb-jar.xml ● Or via annotation ● Points to a database ● In memory DB are good for development ● Each app server uses it's own in memory DB ● Derby ● Not in JBoss (add derby.jar to .war) antonio goncalves 53
  • 54. Datasource @DataSourceDefinition( className ="org.apache.derby.jdbc.EmbeddedDataSource name = "java:global/jdbc/applicationPetstoreDS", ...) <persistence> <persistence-unit name="applicationPetstorePU"...> <jta-data-source> java:global/jdbc/applicationPetstoreDS ... </persistence> @PersistenceContext(unitName = "applicationPetstorePU" private EntityManager em; antonio goncalves 54
  • 55. Default Datasource in Java EE 7 @DataSourceDefinition( className ="org.apache.derby.jdbc.EmbeddedDataSource name = "java:global/jdbc/applicationPetstoreDS", ...) <persistence> <persistence-unit name="applicationPetstorePU"...> <jta-data-source> java:global/jdbc/applicationPetstoreDS ... </persistence> @Inject private EntityManager em; antonio goncalves 55
  • 56. Other resources in Java EE 7 @JMSConnectionFactoryDefinition( name="java:app/MyJMSFactory", resourceType="javax.jms.QueueConnectionFactory", clientId="foo",resourceAdapter="jmsra", InitialPoolSize=5, maxPoolSize=15 ) @JMSDestinationDefinition( name="java:app/orderQueue", resourceType="javax.jms.Queue", resourceAdapter="jmsra", destinationName="orderQueue" ) antonio goncalves 56
  • 57. Properties not all standard <persistence-unit name="applicationPetstorePU"...> ... <properties> <!-- Standard Properties --> <property name="javax.persistence.xxx" value="xxx"/> <!-- Properties for EclipseLink --> <property name="eclipselink.ddl-generation" value="create-tables <!-- Properties for Hibernate --> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> <!-- Properties for OpenJPA --> <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/> </properties> </persistence-unit> antonio goncalves 57
  • 58. Persistence properties in Java EE 7 <persistence-unit name="applicationPetstorePU"...> ... <properties> <!-- Standard Properties --> <property name="javax.persistence.xxx" value="xxx"/> <property name="javax.persistence.ddl" value="drop-and-create"/> <!-- Properties for EclipseLink --> <property name="eclipselink.ddl-generation" value="create-tables <!-- Properties for Hibernate --> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> <!-- Properties for OpenJPA --> <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/> </properties> </persistence-unit> Not sure of the syntax Not sure of the syntax antonio goncalves 58
  • 59. Initialize database ● Having some data in the DB ● Running sql script ● derbytools.jar has an API ● Hibernate : import.sql (but not with other ORMs) antonio goncalves 59
  • 60. Use a Singleton with @Startup @Singleton @Startup public class DBPopulator { @Inject private CatalogService catalogService; @PostConstruct private void populateDB() { catalogService.createCategory(new Category("Fish")) } } antonio goncalves 60
  • 61. Demo of the Yaps Petstore with JBoss 7.x
  • 62. Portable ? ● TCK doesn't cover all the cases ● e.x. all the possible JPQL query syntax ● Implementations fill (or not) black holes ● 100% portability is still a myth... ● … but it's getting better ● … and Java EE 7 will improve some bits ● Any way, you don't change app server every day ● … except for the Yaps Petstore ;o) antonio goncalves 62
  • 63. Are application servers still fascinating for developers ?
  • 64. Are application servers still fascinating for developers ? Maybe not “fascinating” but much easier to use than before
  • 65. Thanks www.antoniogoncalves.org antonio.goncalves@gmail.com @agoncal @lescastcodeurs
  • 66. Thanks ● Antoine Sabot Durand @antoine_sd ● Jean-Louis Monteiro @JLouisMonteiro ● Romain Manni-Bucau @rmannibucau ● Sébastien Stormacq @sebsto antonio goncalves 66
  • 67. Q&A
  • 68. Creative Commons ● Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). ● Noncommercial — You may not use this work for commercial purposes. ● Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one. antonio goncalves 68