Skip to main content

Benx Shen's Library tagged groovy   View Popular

02 Mar 09

InfoQ: What's New in Groovy 1.6

icro-benchmarks obviously rarely reflect the kind of code you have in your own projects, but the overal performa

www.infoq.com/groovy-1-6 - Preview

groovy what-new

21 Nov 07

Groovy - Tutorial 4 - Regular expressions basics

  • the simplest expression involving a regular expression uses the ==~ operator. So for example to match Dan Quayle's spelling of 'potato':



    "potatoe" ==~ /potatoe/

建議Groovy1.0 暫時不要在多線程環境下使用GroovyScriptEngine - Agile - BlogBus.com

  • 晚上壞消息傳來了,同事把我剛提交的代碼更新到生產機上了,發現在執行Groovy腳本時經常出現 ConcurrentModificationException 異常,Google 一下,已經有相同命運的人提交了這個問題,看來是Groovy 實現的問題。
    下載Groovy源碼,找到GroovyScriptEngine,在Eclipse裡debug,發現問題所在了,updateCacheEntry方法的實現有問題,沒有適當的加鎖保護,造成對Map迭代時發生ConcurrentModificationException 異常了。
  • 另外發現updateCacheEntry每回執行的時候都會被調用,都要求執行一段同步塊兒的代碼,真讓人擔心這個效率問題。

Groovy - User Guide

Groovy - Regular Expressions

  • Groovy supports regular expressions natively using the ~"pattern" expression
  • Groovy also supports the =~ (create Matcher) and ==~ (matches regex) operators.
  • 6 more annotations...
14 Jun 07

Groovy - Groovy Categories

  • There are many situations where you might find that it would be useful if a class not under your control had additional methods that you define. In order to enable this capability, Groovy implements a feature borrowed from Objective-C , called Categories.
  • import groovy.xml.*

    def html = DOMBuilder.newInstance().html {
    head {
    title (class:'mytitle', 'Test')
    }
    body {
    p (class:'mystyle', 'This is a test.')
    }
    }

    use (groovy.xml.dom.DOMCategory.class) {
    assert html.head.title.text() == 'Test'
    assert html.body.p.text() == 'This is a test.'
    assert html.find{ it.tagName == 'body' }.tagName == 'body'
    assert html.getElementsByTagName('*').grep{ it.'@class' }.size() == 2
    }
1 - 20 of 39 Next ›
Showing 20 items per page

Diigo is about better ways to research, share and collaborate on information. Learn more »

Join Diigo