crash the shell for the java virtual machine
DESCRIPTION
CRaSH is the open source shell for the JVM. The shell can be accessed by various ways, remotely using network protocols such as SSH, locally by attaching a shell to a running virtual machine or via a web interface. Commands are written Groovy and can be developed live making the extensibility of the shell easy with quick development cycles. Since the version 1.3, the REPL also speaks the Groovy language, allowing Groovy combination of command using pipes. CRaSH comes with commands such as thread management, log management, database access and JMX. The session will begin with an introduction to the shell. The main part of the session will focus on showing CRaSH commands development with few examples, showing how easy and powerful the development is. The audience will learn how to use CRaSH for their own needs: it can be a simple usage or more advanced like developing a command or embedding the shell in their own runtime like a web application or a Grails application.TRANSCRIPT
![Page 1: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/1.jpg)
w w w . c r a s h u b . o r g
CRaSH The shell for the JVM
w w w . c r a s h u b . o r g
Julien Viet exoplatform
![Page 2: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/2.jpg)
w w w . c r a s h u b . o r g
All semicolons characters appearing in this work are fictitious. Any resemblance to real characters, living or dead, is purely coincidental.
Disclaimer
![Page 3: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/3.jpg)
w w w . c r a s h u b . o r g
http://www.julienviet.com / @julienviet
10 years of portal development (you know Portlets…)
Working at eXoPlatform delivering enterprise social networks
> me --verbose
![Page 4: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/4.jpg)
w w w . c r a s h u b . o r g
You can use @crashub or #crashub Try it online try.crashub.org/gists/
e61cb08d93746e576209 (pro tip follow @crashub)
About this talk
![Page 5: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/5.jpg)
w w w . c r a s h u b . o r g
Once upon a time …
Why did I do that ? what is CRaSH
![Page 6: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/6.jpg)
w w w . c r a s h u b . o r g
Latest 1.2.9 / 1.3.0-cr5
Java 6+ / Groovy 1.7+
Base commands : jdbc, jmx, thread, jpa, log, etc..
Extensions: mail, cron
CRaSH
![Page 7: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/7.jpg)
w w w . c r a s h u b . o r g
Modes Standalone / attach (download / brew / gvm) Embedded
Connectors jvm (standalone & attach) ssh, telnet crash.js over websocket
Concepts
![Page 8: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/8.jpg)
w w w . c r a s h u b . o r g
Standalone mode
![Page 9: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/9.jpg)
w w w . c r a s h u b . o r g
Return "hello world"
Command script
![Page 10: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/10.jpg)
w w w . c r a s h u b . o r g
class helloworld { @Command String main() { return "Hello World" } }
Command class
![Page 11: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/11.jpg)
w w w . c r a s h u b . o r g
class hello { @Command String world() { return "Hello World" } }
Git style
![Page 12: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/12.jpg)
w w w . c r a s h u b . o r g
Command pipelining
![Page 13: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/13.jpg)
w w w . c r a s h u b . o r g
Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.
- Ken Thompson
Unix philosophy
![Page 14: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/14.jpg)
w w w . c r a s h u b . o r g
% thread ls | thread dump | mail -s "something you should look at" [email protected]
Pipeline example
![Page 15: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/15.jpg)
w w w . c r a s h u b . o r g
<Void, Thread> is a producer
<Thread, Object> is a pipe <String, String> is a pipe
Pipeline example
![Page 16: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/16.jpg)
w w w . c r a s h u b . o r g
class daemon { @Command Pipe<Thread, Thread> main() { [provide: { if (it.daemon) context.provide(it) }] as Pipe<Thread, Thread> } }
Pipe command
![Page 17: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/17.jpg)
w w w . c r a s h u b . o r g
# log ls -f org.crsh.* | log send -m "hello"
# system propls | filter -p NAME:java.* | sort -f NAME
# jmx query -p java.lang:type=GarbageCollector,name=* | jmx get -a Name -a CollectionCount -a CollectionTime
Other examples
![Page 18: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/18.jpg)
w w w . c r a s h u b . o r g
Read Eval Print Loop aka REPL
![Page 19: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/19.jpg)
w w w . c r a s h u b . o r g
By default the script REPL parses CLI familiar for most CLI users
Script REPL
![Page 20: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/20.jpg)
w w w . c r a s h u b . o r g
very much like groovysh evaluates Groovy expressions
DSL for creating CLI
compose pipes and closures
New Groovy REPL since 1.3
![Page 21: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/21.jpg)
w w w . c r a s h u b . o r g
% (thread.ls | thread.dump | mail { S="something you should look at” "[email protected]" })()
Our command pipeline in Groovy
![Page 22: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/22.jpg)
w w w . c r a s h u b . o r g
More cool stuff
![Page 23: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/23.jpg)
w w w . c r a s h u b . o r g
Completers
Renderers
Keyboard: interruption / events
Screen: streaming / styling
More cool stuff
![Page 24: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/24.jpg)
w w w . c r a s h u b . o r g
Attach mode
![Page 25: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/25.jpg)
w w w . c r a s h u b . o r g
Embedding CRaSH
![Page 26: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/26.jpg)
w w w . c r a s h u b . o r g
Bootstrap: programmatic / Spring / Servlet
Designed for embedding Lighweight : core jar about 600kb Modular : pay for what you need
Virtual File System integration
Embedding
![Page 27: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/27.jpg)
w w w . c r a s h u b . o r g
Ecosystem
![Page 28: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/28.jpg)
w w w . c r a s h u b . o r g
Created in Nov 2012 by Stephan Jaetzold
Contributions by Burt Beckwith
Recently updated to CRaSH 1.3 with additional features
Grails Plugin
![Page 29: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/29.jpg)
w w w . c r a s h u b . o r g
And the story just begins
![Page 30: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/30.jpg)
w w w . c r a s h u b . o r g
Multi facet, powerful and extensible tool for all of us
Join the community www.crashub.org @crashub [email protected]
Wrap up
![Page 31: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/31.jpg)
w w w . c r a s h u b . o r g
Extra slides
![Page 32: CRaSH the shell for the Java Virtual Machine](https://reader031.vdocument.in/reader031/viewer/2022020217/555874bbd8b42aaa7e8b5365/html5/thumbnails/32.jpg)
w w w . c r a s h u b . o r g
new UIBuilder().table { header { label("key") label("value") } System.properties.each { k,v -> row { label(k).style(Color.red.fg()); label(v).style(Color.blue.fg()) } } }
Building more complex UI with a DSL