• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Are app servers still fascinating
 

Are app servers still fascinating

on

  • 3,843 views

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 ...

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

Statistics

Views

Total Views
3,843
Views on SlideShare
3,693
Embed Views
150

Actions

Likes
4
Downloads
0
Comments
0

5 Embeds 150

http://www.redditmedia.com 135
http://www.linkedin.com 11
https://si0.twimg.com 2
http://iblunk.com 1
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Are app servers still fascinating Are app servers still fascinating Presentation Transcript

    • Are application servers stillfascinating 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 providessoftware 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
    • Lets 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 71995 May 1998 Dec 1999 Sept 2001 Nov 2003 May 2006 Dec 2009 Mar 2013 antonio goncalves 14
    • Startup time of JBossUsing a Windows XP virtual machine (Virtual Box) antonio goncalves 15
    • Startup time of other serversUsing 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
    • Lets 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
    • Whats 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 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
    • 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 its not that easy antonio goncalves 49
    • 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
    • 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
    • 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
    • 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
    • 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>@Injectprivate 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@Startuppublic 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 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
    • Are application servers stillfascinating for developers ?
    • Are application servers still fascinating for developers ?Maybe not “fascinating” but much easier to use than before
    • Thanks www.antoniogoncalves.organtonio.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