Today your customers want to tailor applications to their specific needs, in terms of both business logic and user interface. In short, they want to inject custom code to transform a mainstream system into a platform as a service (PaaS). To support this vision, Amadeus built an extensibility framework relying on the JVM and JSR 223 to turn its business-critical solutions into a PaaS. Attend this session to hear how it dealt with JSR 223 limitations, why it picked Groovy as its favorite language, and the challenges it faced with sandboxing and hot swap on multitenant systems. The presentation also shares what Amadeus expects from invokedynamic and the coming support of JavaScript on the JVM.
6. ?2013AmadeusITGroupSA
Amadeus
? Leading provider of IT solutions for the travel
industry
? Connect Providers (ex. airlines) and Resellers (ex. TAs)
? Provide IT solutions (ex. check-in or inventory system)
9. ?2013AmadeusITGroupSA
Technical platform
? A clear technical strategy
? RIA even for the mobile
? Community products
? SaaS, multi-tenants
infrastructure
Web-based
Common
hardware
Common code
Java, JEE,
JavaScript
12. ?2013AmadeusITGroupSA
From SaaS to PaaS
Application logic
Middleware & Framework
Script execution
environment
A
P
I
Application UI
Custom logic
Custom UI
Custom UI
13. ?2013AmadeusITGroupSA
Features and ambition
Dev. Env.
?Distributed version control
?Self service loads and fallbacks
?Access control and traceability
?Life cycle management
UI
?Custom dialogs
?UI extensions
API
?Call reservation systems
?Call any external Web services
?Store and retrieve custom data
?Send emails
?¡
Runtime
?Hotswap
?Sandboxing
?Isolation
?Usage monitoring
29. ?2013AmadeusITGroupSA
Common API
Interface Description
ScriptEngine Main wrapper
ScriptEngineFactory Factory for ScriptEngine
Compilable
ScriptEngine which contains methods
to compile script
Invocable
ScriptEngine whose methods allow
scripts to be executed.
Bindings
A mapping of key/value pairs, all of
whose keys are Strings.
ScriptContext Context
Classes Description
ScriptEngineManager
Discovery and instantiation
mechanism for ScriptEngine
AbstractScriptEngine Super Class
CompiledScript Store results of compilations.
SimpleBindings HashMap bindings
SimpleScriptContext Simple ScriptContext.
31. ?2013AmadeusITGroupSA
Availability
? 800 languages on JVM
? Around 60 are maintained
? 20 have JSR 223 Implementation
Language Availability
Groovy Yes
Scala Yes
Jython Yes
JRuby Yes
Clojure Yes
Ceylon No
Golo No
¡ ..
34. ?2013AmadeusITGroupSA
Hot swapping Groovy
? Run 2 versions of the same script
Passport.groovy
got changed
Passport.class
new code
1110000011
new hash
new code
1110000011
new hash
Custom classloader
37. ?2013AmadeusITGroupSA
? Bad things can happen
? Consume resources (CPU, disk, threads)
? Java and Amadeus API is available
Sandbox
java.lang.System.exit(1)
39. ?2013AmadeusITGroupSA
Compile : How ?
? Check every node in AST @ compile time
org.codehaus.groovy.control.customizers.CompilationCustomizer
org.codehaus.groovy.ast.GroovyCodeVisitor
45. ?2013AmadeusITGroupSA
Sandbox code (for stability)
? Timeout enforcement
? Protection against infinite loops and other patterns
? Injected @ compile time via AST transformation
@groovy.transform.TimedInterrupt(
value = 10L,
unit = TimeUnit.SECONDS
)
def config = new CompilerConfiguration()
def customizer = new ASTTransformationCustomizer(
[value:10L, unit:TimeUnit.SECONDS],
TimedInterrupt)
config.addCompilationCustomizers(customizer)
46. ?2013AmadeusITGroupSA
We are not alone
? Oracle Application Developer Framework
? https://github.com/sjurgemeyer/GR8ConfUS2013/tree/
master/JimDriscoll
? Jenkins
? http://kohsuke.org/2012/04/27/groovy-
secureastcustomizer-is-harmful/
? Call to the community for improvement !
48. ?2013AmadeusITGroupSA
Remoting
? AST can optimize the Contextual information sent
to the Execution Farm.
Application
farm
Scripting
farm(s)
REST/Json
with application
context
49. ?2013AmadeusITGroupSA
Remoting
? Isolation
? SandBox Failure
? Memory or IO contentions
? No Resources Impact on Main application Farm
? Customers or staging isolation
? On demand provisioning
? Fine grain usage reports
? Billing Model
55. ?2013AmadeusITGroupSA
A practical case ²õ³Ù³Ü»å²â¡
UI
Hook
Action
Server
Placeholder import amadeus.pnr.tripplan
// get PNR in-memory representation (a.k.a. TripPlan)
def tripplan = TripPlan.getTripPlan()
// defining a list of eligible countries
def COUNTRY_LIST=["US", "PR", "AS", "VI", "MP", "GU"]
// defining a list of eligible carriers
def CARRIER_LIST=["UA","AA"]
// business condition if one goes to or comes from US,
// or if carrier is UA or AA
def eligibleTrip =
!tripplan.AIR.LIST_ITINERARY.LIST_SEGMENT.findAll {
((it.E_LOCATION.COUNTRY_CODE in COUNTRY_LIST) ||
(it.B_LOCATION.COUNTRY_CODE in COUNTRY_LIST)) ||
(it.AIRLINE.CODE in CARRIER_LIST)
}.isEmpty()
// if trip eligible, trigger the UI enrichment
bean.with {
if (eligibleTrip) {
// the id of the product UI placeholder in which to display.
placeholder = "customTSAPlaceholder"
// the script to be called during the next step to
// process the user inputs.
actionId = "CustomTSAProcess"
}
}
{Template}
{macro init()}
<div style="padding-left: 20px;">
{@aria:TextField { label: 'Maiden name', labelWidth: 210,
block: true, bind: to("pspt") } /}
{@aria:TextField { label: 'Redress number', block: true,
labelWidth: 210, bind: to("redn") } /}
{@aria:TextField { label: 'Known traveler id', block: true,
labelWidth: 210, bind: to("knwt") } /}
</div>
{/macro}
{/Template}
61. ?2013AmadeusITGroupSA
Take home messages
? Groovy is great to customize applications
? The JVM and JSR223 give you access to other
languages
? Sandboxing and isolation are a must
? Unfortunately sandboxing and isolation are
specific to the language
62. ?2013AmadeusITGroupSA
Some more¡
Special thanks to the team!
UI produced using AriaTemplates ? (github.com/ariatemplates)
To know more about Amadeus: http://www.amadeus.com
JavaOne
? Polyglot Enterprise Development on the JVM [CON2382]
Mark Little ¨C VP Red Hat Inc
? The JVM Is Over: The Polyglot Virtual Machine Is Here [CON5344]
Marcus Lagergren - Runtime Futurist, Oracle
? Liftoff with Groovy 2.1 [CON2591]
Guillaume Laforge - Pivotal
? Embedded DSL: Groovy and Scala Fair Duel [TUT4524]
Corinne Krych - RedHat and Pascal Cohen - Amadeus
#7: Amadeus provides transaction processing power and technology solutions to both travel providers (airlines, hotels, rail operators, cruise and ferry operators, car rental, tour operators) and travel agencies (online and offline).?A?worldwide network?connecting travel providers and travel agencies through a highly effective processing platform for the?distribution of travel products and services, and as a provider of a comprehensive portfolio of?IT solutions?which automate mission-critical business processes.
#11: Struggle to address differentiation and local requirementsWe are concerned with two last[A corporate booking tool deploy in Chile -> Chilean railway]No time, always more pressing demands, leads to adoption issues or misfit with some markets
#12: Typical e-Commerce setup, web-server, app-server, database, EIS. Running on iPlanet, Weblogic, Windows, blue part: Linux, in-house
#44: Allows safe timed executions of scripts by adding elapsed time checks on loops (for, while, do), the first statement of closures, and the first statement of methods.?This is especially useful when executing foreign scripts that you do not have control over. Inject this transformation into a script that you want to timeout after a specified amount of time.?Allows "interrupt-safe" executions of scripts by adding Thread.currentThread().isInterrupted() checks on loops (for, while, do) and first statement of closures. By default, also adds an interrupt check statement on the beginning of method calls.
#46: Used annotations coming with groovy 1 to specify at compile time methods maximum execution time transformation add a statement checking the condition as the first statement of for/while/do loops (so one check at the beginning of each iteration) closure/method calls (so one check when entering a user defined method/closure) nothing stops a script doing long I/Os in a procedural script But we can inject this annotation automatically in compiler configuration so it applies to all scripts We even used the transformation // (we could maybe use transformations directly but annotations provide a nicer API than manipulating AST nodes)
#59: Distributed CVSDevelop, test and debug locallyDeploy and activateIntegrate automatic provisioning in the deployment processReport on usage in a multi-tenant environmentMain candidate Javascript
#60: Distributed CVSDevelop, test and debug locallyDeploy and activateIntegrate automatic provisioning in the deployment processReport on usage in a multi-tenant environmentMain candidate Javascript
#61: Distributed CVSDevelop, test and debug locallyDeploy and activateIntegrate automatic provisioning in the deployment processReport on usage in a multi-tenant environmentMain candidate Javascript