SlideShare une entreprise Scribd logo
1  sur  15
Darwino Script and Command Line
Add customization capabilities to your Darwino applications
Darwino Script Introduction
• Darwino Script is a scripting language, very similar to JavaScript
– Follows ECMA-Script 262-3 for a lot of behaviors
– Designed as a “formula language” rather than a language for writing programs
– Extended for ease of use: new operators like ?. or ?[, @functions…
– Uses the Java primitives as core language primitives, include BigDecimal
– Objects are Java objects and don’t have prototypes
• Although a custom library can easily provide this feature
• Ex: JsonArray & JsonObject
– Tailored to script Java classes/objects
• Can directly call any Java classes/objects, if security permits
• Can easily be extended through java extension points
Darwino Script Introduction
• Low resource consumption, even on mobile devices
– Fast compiler with caching capability
• Dynamic execution: interprets an AST tree in memory
– No class file is generated, so it does not require a JVM (AOT compiler works)
• Can be transpiled to other languages (Java, JavaScript, AngularJS
expressions…)
Darwino Script Usage
• Script language for citizen developers
– Can be interpreted dynamically or transpiled (see: UI generation)
• End user customization
– Workflow engine conditions, …
– Other customizations done by a user
• Database events, …
Darwino Script Main Objects
• DSEnvironment
– Maintains the global scripting options, libraries and variables
– Shared across script executions
• DSContext
– The execution context for a script execution
– Contains the local variables, and execution options
• DSScript
– An in-memory compiled script, ready to be executed
• DSLibrary
– Define a set of functions, classes or value members (including constants)
Executing a Piece of Script
// Create the execution environment
// This environment holds the libraries to use
// - standard (print, println..)
// - JavaJre (access to Java Object using reflection)
DSEnvironment env = new DSEnvironment();
env.registerLibrary(new StandardLibrary());
env.registerLibrary(new JavaJreLibrary(env));
// The context can also take extra parameters:
// this
// library to use for this context
// Note that the context contains the global variables being created by the script
// and can also be reused, with these values, while executing another script
DSProgramRuntimeContext ctx = new DSProgramRuntimeContext(env);
// Compile the script or get it from the cache
DSScript expr = ctx.getEnvironment().createScript("1+4");
// Execute and get the result
Object result = expr.execute(ctx);
assertEquals(5, result);
Creating a Reusable Library
• A library can export
– Member access (global values, object members…)
– Function calls (global function, object method…)
– Object/Array constructors
public interface DSLibrary {
public Object getMember(DSRuntimeContext context, Object instance, String member) throws DSRuntimeException;
public Object getMember(DSRuntimeContext context, Object instance, int index) throws DSRuntimeException;
public boolean putMember(DSRuntimeContext context, Object instance, String member, Object value) throws DSRuntimeException;
public boolean putMember(DSRuntimeContext context, Object instance, int index, Object value) throws DSRuntimeException;
public Object call(DSRuntimeContext context, Object instance, Object[] parameters) throws DSRuntimeException;
public Object constructObject(DSRuntimeContext context, String type, Object[] parameters) throws DSRuntimeException;
public Object constructArray(DSRuntimeContext context, String type, int dimensions, int size) throws DSRuntimeException;
}
Existing Libraries
• Java bridge
• @function
– Similar to Notes/Domino @functions
– Targets citizen developers
• Java Objects cab implement
– DSObject, DSArray, DSCallable for easy library creationb
A Word About Security
• If the script is going to be exposed to end users
– You should control what library is exposed
• Use reflection to access Java object?
– You should fine control what object can be exposed/called from the script
• Can also depend on the user profile
• All the features are exposed through libraries, so it is easy to control
– But Darwino will make it even easier with a new security interface
Darwino Command Framework
• The Darwino command framework allows the execution of text based
commands
• The lists of commands is contributed via extensions
• Generally used to exposed administration/debugging capabilities
Some Available Commands
• Built-in commands libraries are provided by the runtime
– Default: echo, set, call, profiler, classpath…
– JSON Store: manage databases, access data…
– Runtime: access to user
• And more to come over time
– Access to log files
– Java logging API settings
Darwino Command CLI
• Commands can be executed from a simple console shell
– Provided as a Java class in the dwo-apps-jstore-cli project
• Configuration file is executed when the console is launched
~/.darwino/console-init.dsh
• Example:
# Initialize with TOMCAT environment
classpath c:phildevapache-tomcat-8.0.20libsqljdbc42.jar
classpath c:phildevapache-tomcat-8.0.20libpostgresql-9.4-1203-jdbc4.jar
load-config c:phildevapache-tomcat-8.0.20
Darwino Debug Web UI
• A simple WebUI can be added to any Darwino Web application
– Access to Commands, Profiler, Script…
– Just add the maven dependency to the web project
• For security reasons, it requires a property to be explicitly set
– Commands can execute code that inspect, create or delete sensitive data
# Enabled the debug module
dwo-runtime-debug-enable=true
# only admins - this is the default
#dwo-runtime-debug-users=admin
Darwino Debug Web UI - Demo
Thank you for your attention!

Contenu connexe

Tendances

Building Server Applications Using ObjectiveC And GNUstep
Building Server Applications Using ObjectiveC And GNUstepBuilding Server Applications Using ObjectiveC And GNUstep
Building Server Applications Using ObjectiveC And GNUstep
guest9efd1a1
 

Tendances (20)

Effective out-of-container Integration Testing
Effective out-of-container Integration TestingEffective out-of-container Integration Testing
Effective out-of-container Integration Testing
 
Inside the jvm
Inside the jvmInside the jvm
Inside the jvm
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Infrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfraInfrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfra
 
Best Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker ContainersBest Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker Containers
 
1. Core Features of Apache RocketMQ
1. Core Features of Apache RocketMQ1. Core Features of Apache RocketMQ
1. Core Features of Apache RocketMQ
 
Building Server Applications Using ObjectiveC And GNUstep
Building Server Applications Using ObjectiveC And GNUstepBuilding Server Applications Using ObjectiveC And GNUstep
Building Server Applications Using ObjectiveC And GNUstep
 
Grand Central Dispatch
Grand Central DispatchGrand Central Dispatch
Grand Central Dispatch
 
Distributed Applications with Apache Zookeeper
Distributed Applications with Apache ZookeeperDistributed Applications with Apache Zookeeper
Distributed Applications with Apache Zookeeper
 
3. jvm
3. jvm3. jvm
3. jvm
 
Meetup on Apache Zookeeper
Meetup on Apache ZookeeperMeetup on Apache Zookeeper
Meetup on Apache Zookeeper
 
Common technique in Bypassing Stuff in Python.
Common technique in Bypassing Stuff in Python.Common technique in Bypassing Stuff in Python.
Common technique in Bypassing Stuff in Python.
 
Architecture diagram of jvm
Architecture diagram of jvmArchitecture diagram of jvm
Architecture diagram of jvm
 
Tech_Implementation of Complex ITIM Workflows
Tech_Implementation of Complex ITIM WorkflowsTech_Implementation of Complex ITIM Workflows
Tech_Implementation of Complex ITIM Workflows
 
What is-java
What is-javaWhat is-java
What is-java
 
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Java ain't scary - introducing Java to PL/SQL Developers
Java ain't scary - introducing Java to PL/SQL DevelopersJava ain't scary - introducing Java to PL/SQL Developers
Java ain't scary - introducing Java to PL/SQL Developers
 
Logging with Logback in Scala
Logging with Logback in ScalaLogging with Logback in Scala
Logging with Logback in Scala
 
JavaOne 2011 Recap
JavaOne 2011 RecapJavaOne 2011 Recap
JavaOne 2011 Recap
 

En vedette

Space mouse sameer kumar telikicherla
Space mouse   sameer kumar telikicherlaSpace mouse   sameer kumar telikicherla
Space mouse sameer kumar telikicherla
Sameer Telikicherla
 

En vedette (20)

05 darwino db
05   darwino db05   darwino db
05 darwino db
 
SFD 2014: Multiplatform App Development with Migeran
SFD 2014: Multiplatform App Development with MigeranSFD 2014: Multiplatform App Development with Migeran
SFD 2014: Multiplatform App Development with Migeran
 
Migeran Tech Talk at Prezi HQ
Migeran Tech Talk at Prezi HQMigeran Tech Talk at Prezi HQ
Migeran Tech Talk at Prezi HQ
 
09 business apis
09   business apis09   business apis
09 business apis
 
Migeran: iOS Apps in Java at Budapest New Tech Meetup
Migeran: iOS Apps in Java at Budapest New Tech MeetupMigeran: iOS Apps in Java at Budapest New Tech Meetup
Migeran: iOS Apps in Java at Budapest New Tech Meetup
 
IBM ConnectED SPOT104: Lightning-Fast Development of Native Mobile Apps for I...
IBM ConnectED SPOT104: Lightning-Fast Development of Native Mobile Apps for I...IBM ConnectED SPOT104: Lightning-Fast Development of Native Mobile Apps for I...
IBM ConnectED SPOT104: Lightning-Fast Development of Native Mobile Apps for I...
 
06 web applications
06   web applications06   web applications
06 web applications
 
02 configuration
02   configuration02   configuration
02 configuration
 
07 darwino rest services
07   darwino rest services07   darwino rest services
07 darwino rest services
 
10 domino integration
10   domino integration10   domino integration
10 domino integration
 
01 introduction to darwino
01   introduction to darwino01   introduction to darwino
01 introduction to darwino
 
Cooking Eclipse Plugins with BDD, Cucumber, SWTBot and Tycho
Cooking Eclipse Plugins with BDD, Cucumber, SWTBot and TychoCooking Eclipse Plugins with BDD, Cucumber, SWTBot and Tycho
Cooking Eclipse Plugins with BDD, Cucumber, SWTBot and Tycho
 
Multi-OS Engine Technology Overview
Multi-OS Engine Technology OverviewMulti-OS Engine Technology Overview
Multi-OS Engine Technology Overview
 
MOE: Cross Platform Mobile Apps in Java
MOE: Cross Platform Mobile Apps in JavaMOE: Cross Platform Mobile Apps in Java
MOE: Cross Platform Mobile Apps in Java
 
Cross-Platform Native Apps in Java (budapest.mobile)
Cross-Platform Native Apps in Java (budapest.mobile)Cross-Platform Native Apps in Java (budapest.mobile)
Cross-Platform Native Apps in Java (budapest.mobile)
 
04 darwino concepts and utility classes
04   darwino concepts and utility classes04   darwino concepts and utility classes
04 darwino concepts and utility classes
 
MWLUG 2016 - AD106
MWLUG 2016 - AD106MWLUG 2016 - AD106
MWLUG 2016 - AD106
 
Space mouse sameer kumar telikicherla
Space mouse   sameer kumar telikicherlaSpace mouse   sameer kumar telikicherla
Space mouse sameer kumar telikicherla
 
Space mouse
Space mouseSpace mouse
Space mouse
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 

Similaire à 15 darwino script & command line

Building Server Applications Using Objective C And Gn Ustep
Building Server Applications Using Objective C And Gn UstepBuilding Server Applications Using Objective C And Gn Ustep
Building Server Applications Using Objective C And Gn Ustep
wangii
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
Ulrich Krause
 
Java ScriptingJava Scripting: One VM, Many Languages
Java ScriptingJava Scripting: One VM, Many LanguagesJava ScriptingJava Scripting: One VM, Many Languages
Java ScriptingJava Scripting: One VM, Many Languages
elliando dias
 
Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016
Manuel Fomitescu
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
Murugesh33
 

Similaire à 15 darwino script & command line (20)

CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
 
Building Server Applications Using Objective C And Gn Ustep
Building Server Applications Using Objective C And Gn UstepBuilding Server Applications Using Objective C And Gn Ustep
Building Server Applications Using Objective C And Gn Ustep
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
 
Java ScriptingJava Scripting: One VM, Many Languages
Java ScriptingJava Scripting: One VM, Many LanguagesJava ScriptingJava Scripting: One VM, Many Languages
Java ScriptingJava Scripting: One VM, Many Languages
 
Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
 
Java and the JVM
Java and the JVMJava and the JVM
Java and the JVM
 
OOP with Java
OOP with JavaOOP with Java
OOP with Java
 
Java 8 in Anger, Devoxx France
Java 8 in Anger, Devoxx FranceJava 8 in Anger, Devoxx France
Java 8 in Anger, Devoxx France
 
Java 8 in Anger (QCon London)
Java 8 in Anger (QCon London)Java 8 in Anger (QCon London)
Java 8 in Anger (QCon London)
 
[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics
 
Containerization Is More than the New Virtualization
Containerization Is More than the New VirtualizationContainerization Is More than the New Virtualization
Containerization Is More than the New Virtualization
 
Road to Opscon (Pisa '15) - DevOoops
Road to Opscon (Pisa '15) - DevOoopsRoad to Opscon (Pisa '15) - DevOoops
Road to Opscon (Pisa '15) - DevOoops
 
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
 
Java >= 9
Java >= 9Java >= 9
Java >= 9
 
Java SpringMVC SpringBOOT (Divergent).ppt
Java SpringMVC SpringBOOT (Divergent).pptJava SpringMVC SpringBOOT (Divergent).ppt
Java SpringMVC SpringBOOT (Divergent).ppt
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 

Plus de darwinodb

Plus de darwinodb (7)

17 open ntf-v30-darwinoorg
17   open ntf-v30-darwinoorg17   open ntf-v30-darwinoorg
17 open ntf-v30-darwinoorg
 
16 endeavour reporter
16   endeavour reporter16   endeavour reporter
16 endeavour reporter
 
14 integrating watson services
14   integrating watson services14   integrating watson services
14 integrating watson services
 
13 deploying cloud applications
13   deploying cloud applications13   deploying cloud applications
13 deploying cloud applications
 
12 ibm connections integration
12   ibm connections integration12   ibm connections integration
12 ibm connections integration
 
11 advanced replication
11   advanced replication11   advanced replication
11 advanced replication
 
08 mobile development
08   mobile development08   mobile development
08 mobile development
 

Dernier

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Dernier (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 

15 darwino script & command line

  • 1. Darwino Script and Command Line Add customization capabilities to your Darwino applications
  • 2. Darwino Script Introduction • Darwino Script is a scripting language, very similar to JavaScript – Follows ECMA-Script 262-3 for a lot of behaviors – Designed as a “formula language” rather than a language for writing programs – Extended for ease of use: new operators like ?. or ?[, @functions… – Uses the Java primitives as core language primitives, include BigDecimal – Objects are Java objects and don’t have prototypes • Although a custom library can easily provide this feature • Ex: JsonArray & JsonObject – Tailored to script Java classes/objects • Can directly call any Java classes/objects, if security permits • Can easily be extended through java extension points
  • 3. Darwino Script Introduction • Low resource consumption, even on mobile devices – Fast compiler with caching capability • Dynamic execution: interprets an AST tree in memory – No class file is generated, so it does not require a JVM (AOT compiler works) • Can be transpiled to other languages (Java, JavaScript, AngularJS expressions…)
  • 4. Darwino Script Usage • Script language for citizen developers – Can be interpreted dynamically or transpiled (see: UI generation) • End user customization – Workflow engine conditions, … – Other customizations done by a user • Database events, …
  • 5. Darwino Script Main Objects • DSEnvironment – Maintains the global scripting options, libraries and variables – Shared across script executions • DSContext – The execution context for a script execution – Contains the local variables, and execution options • DSScript – An in-memory compiled script, ready to be executed • DSLibrary – Define a set of functions, classes or value members (including constants)
  • 6. Executing a Piece of Script // Create the execution environment // This environment holds the libraries to use // - standard (print, println..) // - JavaJre (access to Java Object using reflection) DSEnvironment env = new DSEnvironment(); env.registerLibrary(new StandardLibrary()); env.registerLibrary(new JavaJreLibrary(env)); // The context can also take extra parameters: // this // library to use for this context // Note that the context contains the global variables being created by the script // and can also be reused, with these values, while executing another script DSProgramRuntimeContext ctx = new DSProgramRuntimeContext(env); // Compile the script or get it from the cache DSScript expr = ctx.getEnvironment().createScript("1+4"); // Execute and get the result Object result = expr.execute(ctx); assertEquals(5, result);
  • 7. Creating a Reusable Library • A library can export – Member access (global values, object members…) – Function calls (global function, object method…) – Object/Array constructors public interface DSLibrary { public Object getMember(DSRuntimeContext context, Object instance, String member) throws DSRuntimeException; public Object getMember(DSRuntimeContext context, Object instance, int index) throws DSRuntimeException; public boolean putMember(DSRuntimeContext context, Object instance, String member, Object value) throws DSRuntimeException; public boolean putMember(DSRuntimeContext context, Object instance, int index, Object value) throws DSRuntimeException; public Object call(DSRuntimeContext context, Object instance, Object[] parameters) throws DSRuntimeException; public Object constructObject(DSRuntimeContext context, String type, Object[] parameters) throws DSRuntimeException; public Object constructArray(DSRuntimeContext context, String type, int dimensions, int size) throws DSRuntimeException; }
  • 8. Existing Libraries • Java bridge • @function – Similar to Notes/Domino @functions – Targets citizen developers • Java Objects cab implement – DSObject, DSArray, DSCallable for easy library creationb
  • 9. A Word About Security • If the script is going to be exposed to end users – You should control what library is exposed • Use reflection to access Java object? – You should fine control what object can be exposed/called from the script • Can also depend on the user profile • All the features are exposed through libraries, so it is easy to control – But Darwino will make it even easier with a new security interface
  • 10. Darwino Command Framework • The Darwino command framework allows the execution of text based commands • The lists of commands is contributed via extensions • Generally used to exposed administration/debugging capabilities
  • 11. Some Available Commands • Built-in commands libraries are provided by the runtime – Default: echo, set, call, profiler, classpath… – JSON Store: manage databases, access data… – Runtime: access to user • And more to come over time – Access to log files – Java logging API settings
  • 12. Darwino Command CLI • Commands can be executed from a simple console shell – Provided as a Java class in the dwo-apps-jstore-cli project • Configuration file is executed when the console is launched ~/.darwino/console-init.dsh • Example: # Initialize with TOMCAT environment classpath c:phildevapache-tomcat-8.0.20libsqljdbc42.jar classpath c:phildevapache-tomcat-8.0.20libpostgresql-9.4-1203-jdbc4.jar load-config c:phildevapache-tomcat-8.0.20
  • 13. Darwino Debug Web UI • A simple WebUI can be added to any Darwino Web application – Access to Commands, Profiler, Script… – Just add the maven dependency to the web project • For security reasons, it requires a property to be explicitly set – Commands can execute code that inspect, create or delete sensitive data # Enabled the debug module dwo-runtime-debug-enable=true # only admins - this is the default #dwo-runtime-debug-users=admin
  • 14. Darwino Debug Web UI - Demo
  • 15. Thank you for your attention!