GroovyConsole2

1,292 views

Published on

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,292
On SlideShare
0
From Embeds
0
Number of Embeds
22
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

GroovyConsole2

  1. 1. GroovyConsole @kiy0taka
  2. 2. ( )id:kiy0taka @kiy0taka Grails/GroovyJenkins jQuery jQueryUI Terminal TEPCO MongoDB
  3. 3. GroovyConsole http://www.slideshare.net/kiy0taka/groovyconsoleGroovyConsole http://d.hatena.ne.jp/uehaj/20110701/1309532411
  4. 4. EqualsAndHashCode?Groovy 1.8 AST 1AST AST( ) PowerAsser @EqualsAndHashCode equals() hashCode()
  5. 5. class Person { String name int age}def p1 = new Person(name:Kiyotaka Oku, age:31)def p2 = new Person(name:Kiyotaka Oku, age:31)assert p1 == p2 assert p1 == p2 | | | | | Person@20e5f01b | false Person@57f68d7c
  6. 6. import groovy.transform.EqualsAndHashCode@EqualsAndHashCodeclass Person { String name int age}def p1 = new Person(name:Kiyotaka Oku, age:31)def p2 = new Person(name:Kiyotaka Oku, age:31)assert p1 == p2assert p1.hashCode() == p2.hashCode()
  7. 7. 1.8 AST
  8. 8. @Log @Commons @Log4j @Slf4j @Field @PackageScope @AutoClone @AutoExternalizable@ThreadInterrupt @TimedInterrupt@ConditionalInterrupt @ToString @EqualsAndHashCode @TupleConstructor@Canonical @InheritConstructors @WithReadLock @WithWriteLock @ListenerList
  9. 9. 1.8
  10. 10. Compilation customizers ImportCustomizer ASTTransformationCustomizer AST SecureASTCustomizer AST (?)
  11. 11. import org.codehaus.groovy.control.CompilerConfigurationimport org.codehaus.groovy.control.customizers.*import groovy.util.logging.Logdef configuration = new CompilerConfiguration()configuration.addCompilationCustomizers( new ASTTransformationCustomizer(Log))def shell = new GroovyShell(configuration)shell.evaluate(""" class Car { Car() { log.info Car constructed } } log.info Constructing a car def c = new Car()""")
  12. 12. GroovyConsole
  13. 13. YutoriConsole.groovyimport javax.swing.UIManagerimport groovy.ui.Consoleimport org.codehaus.groovy.control.CompilerConfigurationimport org.codehaus.groovy.control.customizers.ASTTransformationCustomizerimport groovy.transform.*def transformations = [ThreadInterrupt, Canonical]Console.metaClass.newScript = { ClassLoader parent, Binding binding -> def config = new CompilerConfiguration() config.addCompilationCustomizers(*transformations.collect{ new ASTTransformationCustomizer(it)}) delegate.shell = new GroovyShell(parent, binding, config)}UIManager.lookAndFeel = UIManager.systemLookAndFeelClassNamenew Console(Console.class.classLoader.getRootLoader()).run() https://gist.github.com/1059105
  14. 14. Groovy

×