Your SlideShare is downloading. ×
0
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Java, Up to Date
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Java, Up to Date

1,352

Published on

the Topics in JavaSE7 and some of Key features in JavaEE6. …

the Topics in JavaSE7 and some of Key features in JavaEE6.

the codes in this presentation are here. http://www.slideshare.net/akirakoyasu/java-up-to-date-sources

Published in: Technology, News & Politics
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,352
On Slideshare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
50
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. JAVA, UP TO DATE JavaSE7 & JavaEE6 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 2. JavaOne Tokyo 2012 April 4-52 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 3. JavaOne Tokyo 2012 April 4-52 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 4. 今使える、Javaの最新技術3 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 5. 今使える、Javaの最新技術 JavaSE7 Project Coin Fork/Join Framework InvokeDynamic More New I/O3 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 6. 今使える、Javaの最新技術 JavaSE7 JavaEE6 Project Coin Simplified Packaging Fork/Join Framework ManagedBean InvokeDynamic CDI More New I/O3 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 7. JavaSE7 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 8. JavaSE Roadmap 2011 2012 2013 2011/7/28 2012 later 2013 Summer JavaSE7 JavaSE7u6 JavaSE8 JRE for MacOSX Jigsaw 2012/4/27 Auto-update Lambda JavaFX3.0 JavaSE7u4 HotRockit JDK for MacOSX Nashorn JavaFX2.1 2012/11 G1GC JRE default JavaSE6 Last public update5 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 9. Themes of JavaSE7 (from JSR 336)6 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 10. Themes of JavaSE7 (from JSR 336) Compatiblity6 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 11. Themes of JavaSE7 (from JSR 336) Compatiblity Productivity Universality Performance Integration6 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 12. JavaSE7 Project Coin Fork/Join Framework InvokeDynamic More New I/O7 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 13. Project Coin 言語仕様の小さな変更 photo.18 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 14. Project Coin 言語仕様の小さな変更 Small Change = Coin photo.18 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 15. Project Coin 言語仕様の小さな変更 Small Change = Coin Strings in switch photo.18 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 16. Project Coin 言語仕様の小さな変更 Small Change = Coin Strings in switch Numeric literal improvements photo.18 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 17. Project Coin 言語仕様の小さな変更 Small Change = Coin Strings in switch Numeric literal improvements Multi-catch with more precise rethrow photo.18 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 18. Project Coin 言語仕様の小さな変更 Small Change = Coin Strings in switch Numeric literal improvements Multi-catch with more precise rethrow try-with-resources photo.18 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 19. Project Coin 言語仕様の小さな変更 Small Change = Coin Strings in switch Numeric literal improvements Multi-catch with more precise rethrow try-with-resources Diamond photo.18 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 20. Project Coin 言語仕様の小さな変更 Small Change = Coin Strings in switch Numeric literal improvements Multi-catch with more precise rethrow try-with-resources Diamond Safe varargs photo.18 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 21. Strings in switch9 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 22. Strings in switch String flag = "aaa"; switch (flag) { case "aaa": System.out.println("aaa"); break; case "bbb": System.out.println("bbb"); break; case "ccc": System.out.println("ccc"); break; }9 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 23. Strings in switch String flag = "aaa"; コンパイル時に switch (flag) { hashCode()などを case "aaa": System.out.println("aaa"); 使用した比較に break; case "bbb": 書き換えられる System.out.println("bbb"); break; case "ccc": System.out.println("ccc"); break; }9 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 24. Strings in switch String flag = "aaa"; コンパイル時に switch (flag) { hashCode()などを case "aaa": System.out.println("aaa"); 使用した比較に break; case "bbb": 書き換えられる System.out.println("bbb"); break; case "ccc": System.out.println("ccc"); break; } nullに注意9 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 25. Numeric literal improvements10 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 26. Numeric literal improvements Binary literals int b = 0b1110; // binary (new!) int o = 016; // octal int d = 14; // decimal int x = 0xE; // hexadecimal10 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 27. Numeric literal improvements Binary literals int b = 0b1110; // binary (new!) int o = 016; // octal int d = 14; // decimal int x = 0xE; // hexadecimal Underscores in numeric literals int m = 1_000_000;10 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 28. Multi-catch with more precise rethrow11 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 29. Multi-catch with more precise rethrow try { “|”で複数の例外を foo(); // throws Exception1, Exception2 } catch (Exception1 | Exception2 e) { catch } e.printStackTrace();11 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 30. Multi-catch with more precise rethrow try { “|”で複数の例外を foo(); // throws Exception1, Exception2 } catch (Exception1 | Exception2 e) { catch } e.printStackTrace(); スーパータイプでcatch → 実際のサブタイプでthrows宣言可能 void callBar() throws SubException1, SubException2 { try { bar(); // throws SubException1, SubException2 } catch (SuperException e) { throw e; } }11 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 31. try-with-resources12 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 32. try-with-resources tryに続けて宣言したリソースが 自動的にclose()される12 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 33. try-with-resources tryに続けて宣言したリソースが 自動的にclose()される try (Writer writer = new FileWriter(file)) { writer.write("hello!!"); } catch (IOException e) { e.printStackTrace(); }12 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 34. try-with-resources tryに続けて宣言したリソースが 自動的にclose()される try (Writer writer = new FileWriter(file)) { writer.write("hello!!"); } catch (IOException e) { e.printStackTrace(); } java.lang.AutoCloseable / java.io.Closeable “;”で複数リソースを宣言可12 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 35. Diamond13 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 36. Diamond 型推論により、 コンストラクタの ジェネリクスパラメータを省略可能 Map<String, List<Integer>> map = new HashMap<>();13 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 37. Diamond 型推論により、 コンストラクタの ジェネリクスパラメータを省略可能 Map<String, List<Integer>> map = new HashMap<>(); 省略できないケース // 匿名クラス List<String> list = new ArrayList<>(){}; void call() { doSomething(new ArrayList<>()); // メソッド呼び出し }13 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 38. Safe Varargs (1)14 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 39. Safe Varargs (1) ジェネリック型の可変長引数をもつメソッド static void pol(List<String>... strLists) { // ... }14 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 40. Safe Varargs (1) ジェネリック型の可変長引数をもつメソッド static void pol(List<String>... strLists) { // ... } 呼び出し側に警告(今まで通り) List<String> b = ... List<String> s = ... // WARNING: Type safety: A generic array of List<String> // is created for a varargs parameter pol(b, s);14 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 41. Safe Varargs (1) ジェネリック型の可変長引数をもつメソッド static void pol(List<String>... strLists) { // ... } 加えて定義側にも警告が出るように // WARNING: Type safety: Potential heap pollution // via varargs parameter strLists static void pol(List<String>... strLists) { // ... }14 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 42. Safe Varargs (2)15 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 43. Safe Varargs (2) @SafeVarargs このメソッドは安全であるという表明 @SafeVarargs static void notpol(List<String>... strLists) { // ... }15 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 44. Safe Varargs (2) @SafeVarargs このメソッドは安全であるという表明 @SafeVarargs static void notpol(List<String>... strLists) { // ... } 呼び出し側の警告も抑制される List<String> b = ... List<String> s = ... notpol(b, s);15 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 45. JavaSE7 Project Coin Fork/Join Framework InvokeDynamic More New I/O16 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 46. Fork/Join Framework photo.217 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 47. Fork/Join Framework 並列処理のためのフレームワーク photo.217 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 48. Fork/Join Framework 並列処理のためのフレームワーク ? photo.217 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 49. Concurrency Utilities18 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 50. Concurrency Utilities java.util.concurrent.ExecutorService (since: JavaSE5)18 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 51. Concurrency Utilities java.util.concurrent.ExecutorService (since: JavaSE5) ExecutorService executor = Executors.newCachedThreadPool(); executor.submit(new Runnable() { @Override public void run() { // ... } }); executor.shutdown();18 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 52. Concurrency Utilities java.util.concurrent.ExecutorService (since: JavaSE5) ExecutorService executor = Executors.newCachedThreadPool(); executor.submit(new Runnable() { @Override public void run() { // ... } }); executor.shutdown(); 1つのタスクの粒度が大きい18 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 53. 分割統治法 (Divide and Conquer Algorithm)19 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 54. 分割統治法 (Divide and Conquer Algorithm) (再帰的に)小さなタスクへ分割して並列に処理できるようなタスク Task19 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 55. 分割統治法 (Divide and Conquer Algorithm) (再帰的に)小さなタスクへ分割して並列に処理できるようなタスク Task fork() Task Task19 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 56. 分割統治法 (Divide and Conquer Algorithm) (再帰的に)小さなタスクへ分割して並列に処理できるようなタスク Task fork() Task Task Task Task Task Task19 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 57. 分割統治法 (Divide and Conquer Algorithm) (再帰的に)小さなタスクへ分割して並列に処理できるようなタスク Task fork() Task Task Task Task Task Task19 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 58. 分割統治法 (Divide and Conquer Algorithm) (再帰的に)小さなタスクへ分割して並列に処理できるようなタスク Task join() fork() Task Task Task Task Task Task19 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 59. Fork/Join Framework20 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 60. Fork/Join Framework ForkJoinPool pool = new ForkJoinPool(); Integer r = pool.invoke(new MyTask()); pool.shutdown(); static class MyTask extends RecursiveTask<Integer> { private static final long serialVersionUID = 1L; @Override protected Integer compute() { if (size <= SMALL_ENOUGH) { return computeDirect(); // 直接処理 } MyTask task1 = divideTask(); // 分割 MyTask task2 = divideTask(); task1.fork(); Integer i2 = task2.compute(); Integer i1 = task1.join(); return combine(i1, i2); // 統合 } }20 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 61. ワークスレッドの動き(1) WorkThread-1 processing push Deque task task task task pop take(steal) WorkThread-2 processing Deque task21 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 62. ワークスレッドの動き(2) ワークスレッドはタスクを各々のDequeに持つ fork()したタスクをDequeの先頭にpushする join()してタスクの結果を取得する。 まだ結果が出ていない場合は、Dequeの先頭から 次のタスクをpopして処理を行う(LIFO) Dequeにタスクが無くなった場合、 他のワークスレッドのDequeの末尾からタスクを takeして処理を行う(work-stealing)22 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 63. Merge Sort マージソートを Fork/Join Frameworkで 実装してみましょう23 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 64. Merge Sort マージソートを 2 7 6 4 8 1 3 5 Fork/Join Frameworkで 実装してみましょう23 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 65. Merge Sort マージソートを 2 7 6 4 8 1 3 5 Fork/Join Frameworkで 2 7 6 4 8 1 3 5 実装してみましょう23 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 66. Merge Sort マージソートを 2 7 6 4 8 1 3 5 Fork/Join Frameworkで 2 7 6 4 8 1 3 5 実装してみましょう 2 7 6 4 8 1 3 523 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 67. Merge Sort マージソートを 2 7 6 4 8 1 3 5 Fork/Join Frameworkで 2 7 6 4 8 1 3 5 実装してみましょう 2 7 6 4 8 1 3 5 2 7 4 6 1 8 3 523 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 68. Merge Sort マージソートを 2 7 6 4 8 1 3 5 Fork/Join Frameworkで 2 7 6 4 8 1 3 5 実装してみましょう 2 7 6 4 8 1 3 5 2 7 4 6 1 8 3 5 2 4 6 7 1 3 5 823 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 69. Merge Sort マージソートを 2 7 6 4 8 1 3 5 Fork/Join Frameworkで 2 7 6 4 8 1 3 5 実装してみましょう 2 7 6 4 8 1 3 5 2 7 4 6 1 8 3 5 2 4 6 7 1 3 5 8 1 2 3 4 5 6 7 823 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 70. JavaSE7 Project Coin Fork/Join Framework InvokeDynamic More New I/O24 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 71. InvokeDynamic (indy) 動的型付け言語向けの新たなサポート invokedynamic 新しいJavaバイトコード命令(メソッド呼び出し) MethodHandle 新しいメソッド・リンケージ・メカニズム25 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 72. JavaSE7 Project Coin Fork/Join Framework InvokeDynamic More New I/O26 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 73. More New I/O JavaSE1.4で導入されたNIOの積み残し NIO.2と呼ばれます27 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 74. More New I/O JavaSE1.4で導入されたNIOの積み残し NIO.2と呼ばれます 新しいファイルシステムAPI 非同期I/O ソケットチャネルの機能追加27 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 75. 新しいファイルシステムAPI java.nio.fileパッケージ以下 FileSystem ファイルシステム Attribute Files Path View ユーティリティ ファイル メタデータ ディレクトリ リンク Watch FileVisitor Service ツリー走査 監視28 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 76. Basic Use FileSystem fs = FileSystems.getDefault(); Path path = fs.getPath("/path", "to", "file"); try (BufferedWriter bw = Files.newBufferedWriter(path, StandardCharsets.UTF_8, StandardOpenOption.CREATE)) { bw.write("Oh, NIO.2 !!"); } catch (IOException e) { e.printStackTrace(); }29 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 77. Files Files.createFile(path1); Files.createSymbolicLink(link, path1); Files.copy(path1, path2, StandardCopyOption.COPY_ATTRIBUTES); Files.move(path1, path2, StandardCopyOption.ATOMIC_MOVE); byte[] bytes = Files.readAllBytes(path2); try (DirectoryStream<Path> ds = Files.newDirectoryStream(dir)) { for (Path path : ds) { System.out.println(path); } }30 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 78. AttributeView Path path = Paths.get("/path", "to", "file"); BasicFileAttributeView view = Files.getFileAttributeView(path, BasicFileAttributeView.class); PosixFileAttributeView view2 = Files.getFileAttributeView(path, PosixFileAttributeView.class); try { if (view != null) { BasicFileAttributes attributes = view.readAttributes(); System.out.println(attributes.creationTime()); System.out.println(attributes.lastModifiedTime()); System.out.println(attributes.lastAccessTime()); } if (view2 != null) { PosixFileAttributes attributes2 = view2.readAttributes(); System.out.println(attributes2.owner()); System.out.println(attributes2.group()); System.out.println(attributes2.permissions()); } } catch (IOException e) { e.printStackTrace(); }31 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 79. FileVisitor ディレクトリツリーを深さ優先探索 Files.walkFileTree(dir, new SimpleFileVisitor<Path>(){ @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { System.out.println("preVisitDir: " + dir); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { System.out.println("postVisitDir: " + dir); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { System.out.println("visitFile: " + file); return FileVisitResult.CONTINUE; } });32 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 80. FileVisitor ディレクトリツリーを深さ優先探索 Files.walkFileTree(dir, new SimpleFileVisitor<Path>(){ Visitor Pattern @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { System.out.println("preVisitDir: " + dir); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { System.out.println("postVisitDir: " + dir); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { System.out.println("visitFile: " + file); return FileVisitResult.CONTINUE; } });32 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 81. FileVisitor ディレクトリツリーを深さ優先探索 Files.walkFileTree(dir, new SimpleFileVisitor<Path>(){ Visitor Pattern @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { System.out.println("preVisitDir: " + dir); return FileVisitResult.CONTINUE; コールバック } @Override メソッドを実装 public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { System.out.println("postVisitDir: " + dir); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { System.out.println("visitFile: " + file); return FileVisitResult.CONTINUE; } });32 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 82. FileVisitor ディレクトリツリーを深さ優先探索 Files.walkFileTree(dir, new SimpleFileVisitor<Path>(){ Visitor Pattern @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { System.out.println("preVisitDir: " + dir); return FileVisitResult.CONTINUE; コールバック } @Override メソッドを実装 public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { System.out.println("postVisitDir: " + dir); 戻り値4種類 return FileVisitResult.CONTINUE; } •CONTINUE @Override public FileVisitResult visitFile(Path file, •TERMINATE BasicFileAttributes attrs) throws IOException { System.out.println("visitFile: " + file); •SKIP_SUBTREE return FileVisitResult.CONTINUE; •SKIP_SIBLINGS }); }32 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 83. WatchService 監視対象イベントの種類を指定して監視 WatchService watcher = fs.newWatchService(); dir.register(watcher, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_DELETE); boolean valid; do { WatchKey key = watcher.take(); // ブロック for(WatchEvent<?> event : key.pollEvents()) { if (event.kind() == StandardWatchEventKinds.OVERFLOW) { System.out.println("overflow!!"); } else { System.out.println( event.kind() + " : " + event.context()); } } valid = key.reset(); } while (valid);33 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 84. 非同期I/O java.nio.channelsパッケージに追加 AsynchronousChannel Future<V> operation(...) or void operation(..., CompletionHandler<V, A>)34 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 85. Puzzle Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 86. Puzzle36 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 87. Puzzle 次のコードは何を表示しますか?36 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 88. Puzzle 次のコードは何を表示しますか? List<String>[] stringLists = new List<String>[10]; stringLists[0] = Arrays.asList("first string!"); Object[] array = stringLists; array[0] = Arrays.asList(0); System.out.println(stringLists[0].get(0));36 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 89. Answer コンパイルエラー 通常、ジェネリック型の配列を生成することはできません。 仮に1行目の記述が許されるとすれば、5行目 でClassCastExceptionが発生することにな List<String>[] stringLists = new List<String>[10]; り、結果としてジェネリクスの型安全性が損 stringLists[0] = Arrays.asList("first string!"); なわれるためです。 Object[] array = stringLists; array[0] = Arrays.asList(0); このように潜在的な危険性を持つジェネリッ System.out.println(stringLists[0].get(0)); ク型の配列を生成できてしまうのが、ジェネ リック型の可変長引数を持つメソッドです。37 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 90. JavaEE6 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 91. JavaEE Roadmap 2009 2010 2011 2012 2013 2009/12/10 2013 Q2 JavaEE6 JavaEE7 Extensibility Provisioning Profile 2011/2/28 Elasticity Pruning Multi-tenancy Glassfish Orchestration Server 3.1 Clustering Glassfish Glassfish v3 JavaEE6 support Server 4 JavaEE7 support39 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 92. Themes of JavaEE6 (from JSR 316) In the past 8 years, the Java EE platform has grown and matured, and is now able to cover a wide range of enterprise and web application development needs. In addition, the Java EE platform has fostered a vibrant community and marketplace for additional technologies, frameworks, and applications that work with the platform. Some of these provide facilities that are missing from the platform. Others provide alternatives to platform facilities. A major theme for this release is to embrace and support those technologies as part of the overall Java EE landscape, while also continuing to simplify the platform to better target a wider range of developers. To that end we propose two goals for this release - extensibility and profiles.40 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 93. Themes of JavaEE6 (from JSR 316) Simplify and Embrace40 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 94. What’s New in JavaEE6 Servlet 3.0 CDI/DI JSF 2.0 / EL 2.2 Interceptors 1.1 EJB 3.1 (+Lite) Bean Validation Managed Beans JAX-RS 2.141 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 95. JavaEE6 Simplified Packaging ManagedBean CDI Sample42 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 96. Simplified Packaging43 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 97. Simplified Packaging javaee5.war WEB-INF/classes/ MyServlet.class MyFilter.class WEB-INF/lib/ someFramework.jar WEB-INF/ web.xml index.html css/style.css js/jquery.js js/plugin/jplugin.js43 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 98. Simplified Packaging javaee5.war javaee6.war WEB-INF/classes/ WEB-INF/classes/ MyServlet.class MyServlet.class MyFilter.class MyFilter.class WEB-INF/lib/ WEB-INF/lib/ someFramework.jar someFramework.jar someResource.jar WEB-INF/ web.xml index.html index.html css/style.css css/style.css js/jquery.js js/plugin/jplugin.js43 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 99. javax.servlet.annotation44 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 100. javax.servlet.annotation @WebServlet(name="MyServlet", urlPatterns="/myServlet") @WebServlet public class MyServlet extends HttpServlet { // ... }44 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 101. javax.servlet.annotation @WebServlet(name="MyServlet", urlPatterns="/myServlet") @WebServlet public class MyServlet extends HttpServlet { // ... } @WebFilter(filterName="MyFilter", urlPatterns="/*") @WebFilter public class MyFilter implements Filter { // ... }44 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 102. javax.servlet.annotation @WebServlet(name="MyServlet", urlPatterns="/myServlet") @WebServlet public class MyServlet extends HttpServlet { // ... } @WebFilter(filterName="MyFilter", urlPatterns="/*") @WebFilter public class MyFilter implements Filter { // ... } @WebListener public class MyListener @WebListener implements ServletContextListener { // ... }44 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 103. web-fragment.xml someFramework.jar com/fw/SomeFWServlet.class com/fw/SomeFWFilter.class META-INF/web-fragment.xml45 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 104. web-fragment.xml someFramework.jar com/fw/SomeFWServlet.class com/fw/SomeFWFilter.class META-INF/web-fragment.xml web-fragment.xml <?xml version="1.0" encoding="UTF-8"?> <web-fragment xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd" version="3.0"> <!-- servlet --> <!-- filter --> <!-- ... --> </web-fragment>45 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 105. Resource Jar app.war WEB-INF/lib/ someResource.jar http://serv.com:8080/app/ META-INF/resources/ js/jquery.js js/jquery.js js/plugin/jplugin.js js/plugin/jplugin.js css/jplugin.css css/jplugin.css images/jplugin.png images/jplugin.png46 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 106. JavaEE6 Simplified Packaging ManagedBean CDI Sample47 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 107. ManagedBean photo.348 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 108. ManagedBean Plain Java Objects photo.348 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 109. ManagedBean Plain Java Objects Lifecycle managed by container photo.348 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 110. ManagedBean Plain Java Objects Lifecycle managed by container @ManagedBean (javax.annotation) photo.348 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 111. Lifecycle49 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 112. Lifecycle Scope (javax.enterprise.context)49 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 113. Lifecycle @ApplicationScoped @SessionScoped Scope @ConversationScoped (javax.enterprise.context) @RequestScoped49 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 114. Lifecycle @ApplicationScoped @SessionScoped Scope @ConversationScoped (javax.enterprise.context) @RequestScoped Callbacks (javax.annotation)49 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 115. Lifecycle @ApplicationScoped @SessionScoped Scope @ConversationScoped (javax.enterprise.context) @RequestScoped @PostConstruct Callbacks @PreDestroy (javax.annotation)49 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 116. JavaEE6 Simplified Packaging ManagedBean CDI Sample50 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 117. CDI51 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 118. CDI Context and Dependency Injection51 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 119. CDI Context and Dependency Injection @Inject (javax.annotation)51 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 120. Injection Points52 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 121. Injection Points Field @Inject private MyService myService; Injection52 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 122. Injection Points Field @Inject private MyService myService; Injection @Inject Constructor private MyBean(MyService myService) { // ... Injection }52 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 123. Injection Points Field @Inject private MyService myService; Injection @Inject Constructor private MyBean(MyService myService) { // ... Injection } @Inject Parameter void init(MyService myService) { // ... Injection }52 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 124. javax.enterprise.inject. Produces Factory Method provides Injection Object public class Factory { @Produces public static ComplexObject getInstance() { return new ComplexObject("prop1", "prop2"); } }53 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 125. javax.inject.Qualifier @Qualifier @Retention(RetentionPolicy.RUNTIME) public @interface MyQualifier { } SomeInterface @MyQualifier public class OneImpl implements SomeInterface { // ... } OneImpl AnotherImpl @Inject @MyQualifier private SomeInterface some;54 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 126. JavaEE6 Simplified Packaging ManagedBean CDI Sample55 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 127. index.xhtml56 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 128. index.xhtml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html> <html xmlns:h="http://java.sun.com/jsf/html"> <head> <title>Greeting</title> </head> <h:body> #{myBean.greeting} </h:body> </html>56 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 129. MyBean.java57 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 130. MyBean.java @Named public class MyBean { @Inject private MyService myService; public String getGreeting() { return myService.getGreeting(); } }57 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 131. MyService.java58 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 132. MyService.java @ManagedBean public class MyService { public String getGreeting() { return "Hello JavaEE6!!"; } }58 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 133. beans.xml59 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 134. beans.xml (empty)59 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 135. faces-config.xml60 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 136. faces-config.xml (empty)60 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 137. Packaging app.war `---WEB-INF/ `---classes/ `---MyBean.class `---MyService.class `---beans.xml `---faces-config.xml `---index.xhtml61 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 138. Deploy62 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 139. Deploy $ asadmin deploy /path/to/app.war62 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 140. Deploy $ asadmin deploy /path/to/app.war appという名前のアプリケーションがデプロイされました。 コマンドdeployは正常に実行されました。62 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 141. Deploy $ asadmin deploy /path/to/app.war appという名前のアプリケーションがデプロイされました。 コマンドdeployは正常に実行されました。 $ curl "http://localhost:8080/app/index.jsf"62 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 142. Deploy $ asadmin deploy /path/to/app.war appという名前のアプリケーションがデプロイされました。 コマンドdeployは正常に実行されました。 $ curl "http://localhost:8080/app/index.jsf" <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html> <html> <head> <title>Greeting</title> </head><body> Hello JavaEE6!! </body> </html>62 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 143. Conclusion Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 144. Conclusion InvokeDynamic Fork/Join Framework Servlet 3.0 EJB 3.0 (+Lite) More New I/O G1GC CDI/DI Project Coin Bean Validation JAX-RS Managed Bean64 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 145. Conclusion InvokeDynamic Fork/Join Framework Servlet 3.0 EJB 3.0 (+Lite) More New I/O Your Java, Update now!! G1GC CDI/DI Project Coin Bean Validation JAX-RS Managed Bean64 Copyright © 2012 Akira Koyasu. Some rights reserved.
    • 146. Notes This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/ licenses/by-nc/3.0/. photo.1 http://www.flickr.com/photos/brockli/475833924/ from photo.2 http://www.flickr.com/photos/29487767@N02/2866453076/ from photo.3 http://www.flickr.com/photos/amanda28192/6216031916/ from65 Copyright © 2012 Akira Koyasu. Some rights reserved.

    ×