GroovyでJavaMailの使い方を勉強した時のサンプルコードです。 基本的に JavaMailでのメール送信まとめその1 - あられねこのめも をGroovyでちょこっと手直しした感じのものになります。
01 - 09 まではひたすらMimeMessageを元にしたメッセージの組み立て方の勉強です。
| package gjt2; | |
| public class Calc { | |
| private int v1; | |
| private int v2; | |
| public Calc(int a, int b) { | |
| v1 = a; | |
| v2 = b; | |
| } | |
| public int calc() { |
| package gjt1; | |
| public class Calc1 { | |
| int v1; | |
| int v2; | |
| def Calc1(int a, int b) { | |
| v1 = a; | |
| v2 = b; | |
| } | |
| int calc() { |
| package gjt3; | |
| public class Singleton { | |
| private static Singleton instance = null; | |
| private String myarg; | |
| private Singleton(String arg) { | |
| myarg = arg; | |
| } | |
| public synchronized static Singleton getInstance(String arg) { | |
| if (Singleton.instance == null) { |
| // "(root)/t1/TestFoo.java" | |
| package t1; | |
| import static org.testng.Assert.*; | |
| import org.testng.annotations.*; | |
| public class TestFoo { | |
| static void log(Class k, String mes) { | |
| System.out.println(Thread.currentThread() + " - " + k.toString() + " - " + mes); | |
| } |
| # move to https://github.com/msakamoto-sf/dot-files |
| @Grab(group='com.github.plecong', module='hogan-groovy', version='3.0') | |
| import com.github.plecong.hogan.Hogan | |
| def expected = '' | |
| def template = null | |
| def data = [:] | |
| def template_s = '' | |
| // {{{ basic compile() |
| @Grapes([ | |
| @Grab('org.eclipse.jetty.aggregate:jetty-all:8.1.10.v20130312'), | |
| @Grab('com.h2database:h2:1.3.171'), | |
| @Grab('javax.servlet:servlet-api:2.5'), | |
| ]) | |
| import org.eclipse.jetty.server.Server | |
| import org.eclipse.jetty.servlet.* | |
| import org.eclipse.jetty.webapp.* | |
| import javax.servlet.* | |
| import javax.servlet.http.* |
GroovyでJavaMailの使い方を勉強した時のサンプルコードです。 基本的に JavaMailでのメール送信まとめその1 - あられねこのめも をGroovyでちょこっと手直しした感じのものになります。
01 - 09 まではひたすらMimeMessageを元にしたメッセージの組み立て方の勉強です。
| // tested on Groovy 1.8.9. | |
| enum GreetEnum { | |
| MORNING("Good Morning"), | |
| AFTERNOON("Good Afternoon"), | |
| EVENING("Good Evening"); | |
| static { | |
| MORNING.metaClass.greeting = { String you -> | |
| return delegate.emphasize() + " " + you + ", I'm sleeping..." | |
| } |
| /* | |
| * JNA and Linux 2.6 (x86_64) system call example #1. | |
| * (no copyright, license-free, AS-IS, for any commercial or oss or free source code) | |
| */ | |
| @Grapes( | |
| @Grab(group='net.java.dev.jna', module='jna', version='4.0.0') | |
| ) | |
| import com.sun.jna.* | |
| /** @see /usr/include/asm/unistd_64.h */ |