ApacheCon EU 2014: Enterprise Development with Apache Karaf

  • View
    1.143

  • Download
    8

Embed Size (px)

DESCRIPTION

Enterprise Development with Apache Karaf, or what needs to be done to run JEE like applications in Apache Karaf

Transcript

  • 1. Enterprise Developmentwith

2. What needs to be done to runJEE like applications inside Karaf? 3. 2014-10-233@anierbeck- Karaf PMC, Apache Member- OPS4j Pax Web Project Lead- Senior IT Consultant @codecentric- co-Author of Apache Karaf Cookbook 4. Agenda Enterprise Requirements OSGi with Karaf Enterprise Requirements on Karaf Specialties Http Service Cellar - or how to cluster Karaf Summary2014-10-234 5. Enterprise Requirements 6. Enterprise JavaEJB 3.1 CDI2014-10-236Servlet 3JSF 2JSPJPA 2JTABeanValidationJAX-WS JAX-RSJAXRJAXBJMSJAASJASPICJACCJSR-88JCAJavaMailJSR-77RMIJNDIJAX-RPCSAAJ 7. OSGi with Karaf 8. OSGi - a very brief introduction Modular OSGi Bundles: High Cohesion (One classloader/bundle) Low Coupling (Package Import/Export) Versioning per bundle ( [1.0,2,0) ) Service Registry2014-10-238 9. What is Karaf Container OSGi Applications Ligthtweight expandable to Full Enterprise support Covers all major needs Logging Deployment Configuration2014-10-239 10. Karaf - Overview2014-10-2310Config Logging DeployerConsole AdminOSGi Framework - Felix / EquinoxJMXBlueprint SSH 11. Enterprise requirements on Karaf 12. KarafEJB 3.1 CDI2014-10-2312Servlet 3JSF 2JSPJPA 2JTABeanValidationJAX-WS JAX-RSJAXRJAXBJMSJAASJASPICJACCJSR-88JCAJavaMailJSR-77RMIJNDIJAX-RPCSAAJ 13. Enterprise - Pax WebEJB 3.1 CDI2014-10-2313Servlet 3JSF 2JSPJPA 2JTABeanValidationJAX-WS JAX-RSJAXRJAXBJMSJAASJASPICJACCJSR-88JCAJavaMailJSR-77RMIJNDIJAX-RPCSAAJ 14. Enterprise - Pax CDIEJB 3.1 CDI2014-10-2314Servlet 3JSF 2JSPJPA 2JTABeanValidationJAX-WS JAX-RSJAXRJAXBJMSJAASJASPICJACCJSR-88JCAJavaMailJSR-77RMIJNDIJAX-RPCSAAJ 15. Enterprise - AriesEJB 3.1 CDI2014-10-2315Servlet 3JSF 2JSPJPA 2JTABeanValidationJAX-WS JAX-RSJAXRJAXBJMSJAASJASPICJACCJSR-88JCAJavaMailJSR-77RMIJNDIJAX-RPCSAAJ 16. Enterprise - Tomee aka OpenEJBEJB 3.1 CDI2014-10-2316Servlet 3JSF 2JSPJPA 2JTABeanValidationJAX-WSJAX-RPCJAX-RSJAXRJAXBJMSJAASJASPICJACCJSR-88JCAJavaMailJSR-77RMISAAJ JNDI 17. Enterprise - CXFEJB 3.1 CDI2014-10-2317Servlet 3JSF 2JSPJPA 2JTABeanValidationJAX-WSJAX-RPCJAX-RSJAXRJAXBJMSJAASJASPICJACCJSR-88JCAJavaMailJSR-77RMISAAJ JNDI 18. Enterprise - ActiveMQEJB 3.1 CDI2014-10-2318Servlet 3JSF 2JSPJPA 2JTABeanValidationJAX-WSJAX-RPCJAX-RSJAXRJAXBJMSJAASJASPICJACCJSR-88JCAJavaMailJSR-77RMISAAJ JNDI 19. Enterprise - CellarEJB 3.1 CDI2014-10-2319Servlet 3JSF 2JSPJPA 2JTABeanValidationJAX-WSJAX-RPCJAX-RSJAXRJAXBJMSJAASJASPICJACCJSR-88JCAJavaMailJSR-77RMISAAJ JNDI 20. Enterprise - Karaf with featuresEJB 3.1 CDI2014-10-2320Servlet 3JSF 2JSPJPA 2JTABeanValidationJAX-WSJAX-RPCJAX-RSJAXRSAAJJAXBJMSJAASJASPICJACCJSR-88JCAJavaMailJSR-77RMIJNDI 21. Specialties 22. JPA - Karaf2014-10-2322org.apache.openjpa.persistence.PersistenceProviderImplosgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/cookbook)de.nierbeck.apachecon.persistence.entity.Bookde.nierbeck.apachecon.persistence.entity.Recipetrue 23. JPA - Karaf2014-10-2322org.apache.openjpa.persistence.PersistenceProviderImplosgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/cookbook)de.nierbeck.apachecon.persistence.entity.Bookde.nierbeck.apachecon.persistence.entity.RecipetrueTo have this blueprintJNDI is needed 24. JTA - Karaf2014-10-2323To have this blueprintJPA and JTA is needed 26. Client - Karaf2014-10-2324... 27. Demo 28. Persistence2014-10-2326 29. Client2014-10-2327 30. Client Shell2014-10-2328 31. Client - Shell2014-10-2329 32. Client Shell2014-10-2330 33. Client - Shell2014-10-2331 34. Http Servicewith 35. HTTP Service2014-10-2333 Using an Activator:final HttpContext httpContext = httpService.createDefaultHttpContext();// register the BookServlet// first wait for the DAO-ServiceCookBookService cookBookService;ServiceReference serviceReference = bundleContext.getServiceReference(CookBookService.class);cookBookService = bundleContext.getService(serviceReference);//now create the servletViewBookServlet viewBookServlet = new ViewBookServlet();//set the DAO to the ServletviewBookServlet.setCookBookService(cookBookService);final Dictionary initParams = new Hashtable();try {httpService.registerServlet("/book", // aliasviewBookServlet,initParams, httpContext); 36. Whiteboard Using the whiteboard approach via Activatorpublic void start(BundleContext bc) throws Exception {bundleContext = bc;// first wait for the DAO-ServiceCookBookService cookBookService;ServiceReference serviceReference = bundleContext2014-10-2334.getServiceReference(CookBookService.class);cookBookService = bundleContext.getService(serviceReference);// create new ServletViewBookServlet cookBookViewServlet = new ViewBookServlet();cookBookViewServlet.setCookBookService(cookBookService);registerServiced = bundleContext.registerService(Servlet.class,cookBookViewServlet, null);} 37. Whiteboard2014-10-2335 Using the whiteboard approach via Blueprint 38. Servlet 3.0 - Just annotation2014-10-2336@WebServlet(urlPatterns = "/book")public class ViewBookServlet extends HttpServlet {/****/private static final long serialVersionUID = 1L;@Inject@OsgiServiceCookBookService cookBookService;@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {...}} 39. LOST? 40. Registering - Servlet2014-10-2338Pax-WebHTTP ServiceService-RegistryServlet 41. Registering - Servlet2014-10-2338Pax-WebHTTP ServiceService-RegistryServletRegisterd 42. Registering - Servlet2014-10-2338Pax-WebHTTP ServiceService-RegistryServletRegisterdRegisterd 43. Registering - Whiteboard2014-10-2339Pax-WebWebContainerService-TrackerService-RegistryServlet 44. Registering - Whiteboard2014-10-2339Pax-WebWebContainerService-TrackerService-RegistryServletRegisterd 45. Registering - Whiteboard2014-10-2339Pax-WebWebContainerService-TrackerService-RegistryServletRegisterdRegisterd 46. Registering - Whiteboard2014-10-2339Pax-WebWebContainerService-TrackerService-RegistryServletRegisterdRegisterd 47. Registering - WAR2014-10-2340Pax-WebWebContainerPax-WebWAR ExtenderService-RegistryWAB-BundleServlet 48. Registering - WAR2014-10-2340Pax-WebWebContainerPax-WebWAR ExtenderService-RegistryWAB-BundleServletRegisterd 49. Registering - WAR2014-10-2340Pax-WebWebContainerPax-WebWAR ExtenderService-RegistryWAB-BundleServletRegisterd Registerd 50. Registering - WAR2014-10-2340Pax-WebWebContainerPax-WebWAR ExtenderService-RegistryWAB-BundleServletRegisterd Registerd 51. Servlet + JPA / Service2014-10-2341BlueprintExtenderPax-WebWAR ExtenderJPA-BundleService-RegistryJPA -ServiceWEB-BundleServlet 52. Servlet + JPA / Service2014-10-2341BlueprintExtenderPax-WebWAR ExtenderJPA-BundleService-RegistryJPA -ServiceWEB-BundleServletRegisterd 53. Servlet + JPA / Service2014-10-2341BlueprintExtenderPax-WebWAR ExtenderJPA-BundleService-RegistryJPA -ServiceWEB-BundleServletRegisterdInjected 54. Servlet + JPA / Service2014-10-2341BlueprintExtenderPax-WebWAR ExtenderJPA-BundleService-RegistryJPA -ServiceWEB-BundleServletRegisterd RegisterdInjected 55. Demo 56. View2014-10-2343 57. View2014-10-2344 58. Clusterprovided by Apache Karaf Cellar 59. Cellar - Cluster Communication2014-10-2346 60. Cellar - Cluster Communication2014-10-2347Hazelcast 61. Cellar - Events2014-10-2348 62. Cellar - Distributing Bundles2014-10-2349Node ANode BNode CMaven RepositoryHazelcast 63. Cellar - Distributing Bundles2014-10-2349Node ANode BNode CMaven Repositoryosgi:install mvn:groupId/artifactId/versionHazelcast 64. Cellar - Distributing Bundles2014-10-2349Node ANode BNode CMaven RepositoryHazelcast 65. Cellar - Distributing Bundles2014-10-2349Node ANode BNode CMaven RepositoryHazelcast 66. Cellar - Distributing Bundles2014-10-2349Node ANode BNode CMaven RepositoryHazelcast 67. Cellar - Distributing Bundles2014-10-2349Node ANode BNode CMaven RepositoryHazelcast 68. Cellar - Distributing Bundles2014-10-2349Node ANode BNode CMaven RepositoryHazelcast 69. Cellar - Distributing Bundles2014-10-2349Node ANode BNode CMaven RepositoryHazelcast 70. Cellar - Distributing Bundles2014-10-2349Node ANode BNode CMaven RepositoryHazelcastDEPRECATED 71. Cellar - Distributing Bundles2014-10-2349Node ANode BNode CMaven Repositorycluster:install mvn:groupId/artifactId/versionHazelcastDEPRECATED 72. Cellar - RMI2014-10-2350Group 1Node AConsumes OSGi-ServiceGroup 2Node BConsumes OSGi-ServiceNode CConsumes OSGi-ServiceNode AProvides OSGi-ServiceNode BHazelcast Provides OSGi-Service 73. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 74. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 75. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 76. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 77. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 78. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 79. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 80. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 81. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 82. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 83. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 84. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 85. Cellar - Web session failover2014-10-2351Node AHazelcastDataBaseClientFilter ServletNode BFilter Servlet 86. Cluster - Demo 87. Presentation Layer2014-10-2353 88. web.xml - Hazelcast2014-10-2354 Hazelcast for Session Replicationhazelcast-filt