Are app servers still fascinating

4,231 views

Published on

This slides give you an overview of the technical challgens that Java EE application servers have faced to reinvent themselves. From monolithic to jigsaw puzzles, app servers are not the burden developpers use to use anymore

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,231
On SlideShare
0
From Embeds
0
Number of Embeds
183
Actions
Shares
0
Downloads
0
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Are app servers still fascinating

  1. 1. Are application servers stillfascinating for developers ? by antonio goncalves @agoncal
  2. 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. 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. 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. 5. « Application server » antonio goncalves 5
  6. 6. Wikipedia « Server which providessoftware applications with services»
  7. 7. Gartner« Server that acts as a container for applications business logic... and brings services »
  8. 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. 9. We use application servers not to reinvent the wheel (i.e the technical services)
  10. 10. « Application » server● Market dominated by ● Java ● .Net● Proprietary● Other programming models antonio goncalves 10
  11. 11. Lets focus on Java Java EE 6 Web Profile 6 Servlet antonio goncalves 11
  12. 12. Web profile● Java EE 6 ● 28 specifications● Web profile ● 12 specifications● Other profiles will come● Brings modularity antonio goncalves 12
  13. 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. 14. History JPE J2EE 1.2 J2EE 1.3 J2EE 1.4 Java EE 5 Java EE 6 Java EE 71995 May 1998 Dec 1999 Sept 2001 Nov 2003 May 2006 Dec 2009 Mar 2013 antonio goncalves 14
  15. 15. Startup time of JBossUsing a Windows XP virtual machine (Virtual Box) antonio goncalves 15
  16. 16. Startup time of other serversUsing a Windows XP virtual machine (Virtual Box) antonio goncalves 16
  17. 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. 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. 19. Magic quadrant - Sep 2011 antonio goncalves 19
  20. 20. Magic quadrant - Sep 2011 ● Leaders ● Oracle ● IBM ● RedHat antonio goncalves 20
  21. 21. Magic quadrant - Sep 2011 ● Visionary ● Resin antonio goncalves 21
  22. 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. 23. Lets quickly have a look at some “new” application servers
  24. 24. WebSphere Liberty 8.5
  25. 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. 26. Composable runtime antonio goncalves 26
  27. 27. WAS 8.5 Licensing antonio goncalves 27
  28. 28. Demo
  29. 29. TomEE 1.0
  30. 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. 31. Whats in antonio goncalves 31
  32. 32. Demo
  33. 33. Resin 4.x
  34. 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. 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. 36. Demo
  37. 37. And now, the developers point of view
  38. 38. How is it to use these servers on a day to day basis ?
  39. 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. 40. Demo of the Yaps Petstore with GlassFish 3.x
  41. 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
  42. 42. Demo with JRebel
  43. 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. 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. 45. Integration test with EJBContainerpublic 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. 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. 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. 48. Demo of an integration test with Arquillian
  49. 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 its not that easy antonio goncalves 49
  50. 50. JPA● Lazy Loading bidirectional entities ● Spec has undefined behaviour ● Works well with EclipseLink ● Doesnt with Hibernate (use Fetch Join) ● Fetch Joins dont work with EclipseLink antonio goncalves 50
  51. 51. Lazy loadingList<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. 52. Lazy loadingList<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. 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 its own in memory DB● Derby ● Not in JBoss (add derby.jar to .war) antonio goncalves 53
  54. 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. 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>@Injectprivate EntityManager em; antonio goncalves 55
  56. 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. 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. 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. 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. 60. Use a Singleton with @Startup@Singleton@Startuppublic class DBPopulator { @Inject private CatalogService catalogService; @PostConstruct private void populateDB() { catalogService.createCategory(new Category("Fish")) }} antonio goncalves 60
  61. 61. Demo of the Yaps Petstore with JBoss 7.x
  62. 62. Portable ?● TCK doesnt 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 its getting better● … and Java EE 7 will improve some bits● Any way, you dont change app server every day● … except for the Yaps Petstore ;o) antonio goncalves 62
  63. 63. Are application servers stillfascinating for developers ?
  64. 64. Are application servers still fascinating for developers ?Maybe not “fascinating” but much easier to use than before
  65. 65. Thanks www.antoniogoncalves.organtonio.goncalves@gmail.com @agoncal @lescastcodeurs
  66. 66. Thanks● Antoine Sabot Durand @antoine_sd● Jean-Louis Monteiro @JLouisMonteiro● Romain Manni-Bucau @rmannibucau● Sébastien Stormacq @sebsto antonio goncalves 66
  67. 67. Q&A
  68. 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

×