내용으로 건너뛰기
권남
사용자 도구
로그인
사이트 도구
검색
도구
문서 보기
이전 판
역링크
최근 바뀜
미디어 관리자
사이트맵
로그인
>
최근 바뀜
미디어 관리자
사이트맵
추적:
groovy:script
이 문서는 읽기 전용입니다. 원본을 볼 수는 있지만 바꿀 수는 없습니다. 문제가 있다고 생각하면 관리자에게 문의하세요.
====== Groovy Script ====== * [[http://groovy.codehaus.org/Scripts+and+Classes|Groovy - Scripts and Classes]] * [[http://groovy.codehaus.org/Groovy+as+script|Groovy - Groovy as script]] * [[http://groovy.codehaus.org/gapi/groovy/lang/Script.html|groovy.lang.Script]] ===== include functions ===== * 하나의 스크립트에서 다른 스크립트에 정의된 변수,함수들을 사용하려면 [[http://groovy.codehaus.org/gapi/groovy/lang/Script.html#evaluate%28java.lang.String%29|evaluate]]를 사용한다. * 호출측 ''main.groovy''<code groovy> // 부모 스크립트에 바인딩된 객체를 include 되는 측에서 사용가능한지 테스트 myprint = { arg -> println("# MyPrint : " + arg) } // include 측에서 main.groovy의 def 설정 변수와 메소드를 사용하기위해 parent = this def defprint() { println("# defprint") } // GroovyShell을 사용할 수도 있음. 명시적 Binding 객체로 현재 스크립트의 값들을 넘겨줘야함 //def includeBinding = new Binding(this.binding.variables) //new GroovyShell(includeBinding).evaluate(new File('include.groovy').text) // Script.evaluate 사용. 현재 스크립트의 바인딩이 자동으로 넘어감. evaluate(new File('include.groovy').text) // import.groovy에 선언된 클로저를 그냥 바로 호출할 수 있다. whoami("from script1 한글") calldefprint() </code> * include 대상 스크립트 ''include.groovy''<code groovy> whoami = { arg -> myprint("# from who am i : " + arg) } calldefprint = { parent.defprint() } </code> * 결과<code> # MyPrint : # from who am i : from script1 한글 # defprint </code>
groovy/script.txt
· 마지막으로 수정됨: 2013/07/12 00:51 저자
kwon37xi
문서 도구
문서 보기
이전 판
역링크
맨 위로