Slide 1

Slide 1 text

2016.6.1 Kenji Kazumura Fujitsu Limited Challenge for GlassFish Buildpack Copyright 2016 FUJITSU LIMITED Cloud Foundry Tokyo Meetup #2

Slide 2

Slide 2 text

About me Copyright 2016 FUJITSU LIMITED Java VM developer Working for Fujitsu Interstage Application Server JSR 204 Expert Group Board Member of Executive Committee Author of On-line Java Learning Courses https://directshop.fom.fujitsu.com/shop/commodity_param/ctc/el_middleit/shc/0/cmc/ASP03737 JCP (Java Community Process) https://directshop.fom.fujitsu.com/shop/commodity_param/ctc/el_middleit/shc/0/cmc/ASP03738 1

Slide 3

Slide 3 text

Agenda Copyright 2016 FUJITSU LIMITED Motivation GlassFish Buildpack RDS Context Root Summary Logging 2

Slide 4

Slide 4 text

Motivation Copyright 2016 FUJITSU LIMITED Why we need GlassFish ? Based on Tomcat Java Buildpack already exists Standardized framework on which WebSocket, JAX-RS, JPA, etc is available Play and Spring also available Enterprise system like this Help migrating from on-premise to cloud 3

Slide 5

Slide 5 text

GlassFish Buildpack Copyright 2016 FUJITSU LIMITED Based on GlassFish 4.1 WebProfile Servlet 3.1 JavaServer Pages(JSP) 2.3 Unified Expression Language(EL) 3 Debugging Support for Other Languages (JSR-45) 1 JavaServer Pages Standard Tag Library(JSTL) 1.2 JavaServer Faces(JSF) 2.2 Java API for RESTful Web Services(JAX-RS) 2 Java API for WebSocket(WebSocket) 1 Java API for JSON Processing(JSON-P) 1 Common Annotations for the Java Platform (JSR-250) 1.2 Enterprise JavaBeans(EJB) 3.2 Lite Java Transaction API(JTA) 1.2 Java Persistence API(JPA) 2.1 Bean Validation 1.1 Managed Beans 1 Interceptors 1.2 Contexts and Dependency Injection for the Java EE Platform 1.1 Dependency Injection for Java APIs 4

Slide 6

Slide 6 text

Challenge Copyright 2016 FUJITSU LIMITED 20 engineers 5 months No one had experience to use Cloud Foundry before All are application server developers Start project without Cloud Foundry 5

Slide 7

Slide 7 text

Context Root Copyright 2016 FUJITSU LIMITED Context root is different between GlassFish and Cloud Foundry standard You can use old way by setting FJBP_CONTEXT_ROOT to ‘app’ URL Cloud Foundry app.paas.fujitsu.com GlassFish app.paas.fujitsu.com/app ‘app’ is a name of your application Change GlassFish default URL to the same as Cloud Foundry standard 6

Slide 8

Slide 8 text

Logging Copyright 2016 FUJITSU LIMITED Local storage should not be used on Cloud Foundry GlassFish supposes local storage http access logs logs of GlassFish itself Change all output to standard out 7

Slide 9

Slide 9 text

Relational Database Service Copyright 2016 FUJITSU LIMITED On-Premise Tightly coupled with JDBC Describe JDBC information at config file Cloud Should couple loosely with JDBC How do you do that ? Usually get info from environment vars 8

Slide 10

Slide 10 text

Example1 Copyright 2016 FUJITSU LIMITED public class DBAccess extends HttpServlet { Connection getConnection() { String env = System.getenv("VCAP_SERVICES"); if ( env != null ) { try { JsonReader reader = Json.createReader(new StringReader(env)); JsonObject servicesObject = jsonReader.readObject(); reader.close(); JsonObject rdsObject = servicesObject.getJsonObject("fujitsurds"); String uri = rdsObject.getString("uri"); Connection connection = DriverManager.getConnection(uri); return connection; } catch ( Exception e ) { return null; …… 9

Slide 11

Slide 11 text

Example2 Copyright 2016 FUJITSU LIMITED public class DBAccess extends HttpServlet { @Resource (name = “jdbc/porstresqlService”) private DataSource ds; … GlassFish Buildpack provides auto binding feature ‘postgresqlService’ is the name of the service bound to your app i.e. % cf bind-service myApp postgresqlService 10

Slide 12

Slide 12 text

Summary Copyright 2016 FUJITSU LIMITED Give it a try ! Any feedbacks are appreciated 11

Slide 13

Slide 13 text

Q/A Copyright 2016 FUJITSU LIMITED 12

Slide 14

Slide 14 text

Copyright 2016 FUJITSU LIMITED Trademarks of other companies are used in this documentation only to identify particular products or systems. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other company and product names in this documentation are trademarks or registered trademarks of their respective owners. 13

Slide 15

Slide 15 text

Copyright 2010 FUJITSU LIMITED