sap inside track singapore 2014
TRANSCRIPT
Rapid Prototyping with Grails and HANA Cloud Platform
Marc Lester Tan/SAP Mobility Innovation Center, APJJanuary 11, 2014
© 2011 SAP AG. All rights reserved. 2
Agenda
HANA Cloud Platform Overview of HANA Cloud Platform
Grails Overview of Grails Hello World
Demo
HANA Cloud Platform
© 2011 SAP AG. All rights reserved. 4
HANA Cloud Platform
• Platform as a Service (PaaS)
• Runs on JVM
• HANA or MaxDB
• Integration with backend systems
• Development Tools for Eclipse
• Free for Developers
© 2011 SAP AG. All rights reserved. 5
Development Environment
• Platform SDK
• Platform Tools
• Console Client
© 2011 SAP AG. All rights reserved. 6
Development Environment
• Platform SDK
• Platform Tools
• Console Client
© 2011 SAP AG. All rights reserved. 7
Development Environment
• Platform SDK
• Platform Tools
• Console Client
© 2011 SAP AG. All rights reserved. 8
Platform Services and Utilities
• Authentication
• SAP UI5 – open-source @ sap.github.io/openui5/
• Persistence Service
• Connectivity Service
• Document Service
• Logging
• Cloud Environment Variables
© 2011 SAP AG. All rights reserved. 9
Platform Services and Utilities
• Authentication
• SAP UI5 – open-source @ sap.github.io/openui5/
• Persistence Service
• Connectivity Service
• Document Service
• Logging
• Cloud Environment Variables
© 2011 SAP AG. All rights reserved. 10
Platform Services and Utilities
• Authentication
• SAP UI5 – open-source @ sap.github.io/openui5/
• Persistence Service
• Connectivity Service
• Document Service
• Logging
• Cloud Environment Variables
© 2011 SAP AG. All rights reserved. 11
Platform Services and Utilities
• Authentication
• SAP UI5 – open-source @ sap.github.io/openui5/
• Persistence Service
• Connectivity Service
• Document Service
• Logging
• Cloud Environment Variables
© 2011 SAP AG. All rights reserved. 12
Platform Services and Utilities
• Authentication
• SAP UI5 – open-source @ sap.github.io/openui5/
• Persistence Service
• Connectivity Service
• Document Service
• Logging
• Cloud Environment Variables
© 2011 SAP AG. All rights reserved. 13
Platform Services and Utilities
• Authentication
• SAP UI5 – open-source @ sap.github.io/openui5/
• Persistence Service
• Connectivity Service
• Document Service
• Logging
• Cloud Environment Variables
© 2011 SAP AG. All rights reserved. 14
Platform Services and Utilities
• Authentication
• SAP UI5 – open-source @ sap.github.io/openui5/
• Persistence Service
• Connectivity Service
• Document Service
• Logging
• Cloud Environment Variables
Grails
© 2011 SAP AG. All rights reserved. 16
What is Grails?
• Full stack web application framework
• Runs on JVM
• Open-source @ github.com/grails/grails-core/
• Uses Groovy programming language
• Follows Convention-over-Configuration paradigm
• Lots and lots of plugins!
© 2011 SAP AG. All rights reserved. 17
Key Features of Grails
• It includes easy to use ORM layer built on Hibernate
• Expressive view technology called GSP (Groovy Server Pages)
• Controller layer built on Spring MVC
• Scripting environment based on Groovy-based Gant
• Embedded Tomcat server configured for on-the-fly reloading
• DI provided by the built-in Spring container
Hello World你好世界Hallo Weltहे�लो� वि�श्व
హలోవరల్డ్�
© 2011 SAP AG. All rights reserved. 19
Simple Web App
• Tool to manage Tech Events in Singapore
• Develop using Grails
• Deploy on Local and Remote HCP
• Use MaxDB
• Grails on HANA – coming soon! (https://hibernate.atlassian.net/browse/HHH-8228)
© 2011 SAP AG. All rights reserved. 20
Create the Web Application and Domain Class
$ grails create-app TechEvents
| Created Grails Application at /Users/i071571/Documents/sapinsidetrack/TechEvents
$ grails create-domain-class com.sap.techevents.Event
| Created file grails-app/domain/com/sap/techevents/Event.groovy
| Created file test/unit/com/sap/techevents/EventTests.groovy
© 2011 SAP AG. All rights reserved. 21
Modify the Domain Class
package com.sap.techevents
class Event {
String name
String description
Date eventDate
Date dateCreated
Date lastUpdated
static constraints = {
name blank: false
description blank: true
eventDate blank: false
}
}
© 2011 SAP AG. All rights reserved. 22
Build the Controllers, Views and Run the App
$ grails generate-controller com.sap.techevents.Event
| Packaging Grails application.....
| Finished generation for domain class com.sap.techevents.Event
$ grails generate-views com.sap.techevents.Event
| Compiling 1 source files....
| Finished generation for domain class com.sap.techevents.Event
$ grails run-app
| Server running. Browse to http://localhost:8080/TechEvents
© 2011 SAP AG. All rights reserved. 23
Local Testing and Deployment
• Add MANIFEST.MF that contains only Manifest-Version: 1.0
• Add _Events.groovy in scripts folder
• In _Events.groovy, copy the MANIFEST.MF to staging directory
• In _Events.groovy, modify web.xml generation to include JNDI bindings for database
• In grails-app/conf/DataSource.groovy, modify the production dataSource to:
dbCreate = "update"
jndiName = "java:comp/env/jdbc/DefaultDB"
dialect = "org.hibernate.dialect.SAPDBDialect"
© 2011 SAP AG. All rights reserved. 24
Local Testing and Deployment
• In grails-app/conf/DataSource.groovy, modify the development dataSource to:
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
//url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
jndiName = "java:comp/env/jdbc/DefaultDB"
dialect = "org.hibernate.dialect.DerbyDialect"
• Copy com.sap.security.core.server.csi_1.0.1.jar from $HCP_SDK_HOME/repository/plugins to lib folder
• $ grails dev war
© 2011 SAP AG. All rights reserved. 25
Local Testing and Deployment
• Install HCP Local Server
$ neo.sh install-local
• Copy generated WAR file to HCP Local Server pickup folder
$ cp target/TechEvents-0.1.war /Applications/Dev/neo-java-web-sdk-1.43.20.3/server/pickup/
• Run HCP Local Server
$ neo.sh start-local
• Monitor log file to check if deployment is successful
$ tail -f /Applications/Dev/neo-java-web-sdk-1.43.20.3/server/log/ljs_trace.log
© 2011 SAP AG. All rights reserved. 26
Local Testing and Deployment
• Create a WAR file for Production Environment
$ grails prod war
• Deploy WAR File to HANA Cloud
$ neo.sh deploy -u SCN_USER –a ACCOUNT_NAME -b APP_NAME -h HOST_NAME -s target/TechEvents-0.1.war
• Start/Restart Application instance in HCP Cockpit
© 2011 SAP AG. All rights reserved. 27
Resources
• HANA Cloud Portal
• HANA Cloud Platform Developer Resources
• HCP Content Overview
• OpenUI5
• Grails
• Groovy
• TechEvents Source Code
Thank You!
Marc Lester Tanw: marctan.com