Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JavaOne 2012 Report for Java EE

JavaOne 2012 Report for Java EE

Avatar for Yoshio Terada

Yoshio Terada

November 09, 2012
Tweet

Other Decks in Technology

Transcript

  1. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    1 Yoshio Terada Java Evangelist http://yoshio3.com, Twitter : @yoshioterada
  2. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    2 ҎԼͷࣄ߲͸ɺฐࣾͷҰൠతͳ੡඼ͷํ޲ੑʹؔ͢Δ֓ཁΛઆ໌͢Δ΋ͷ Ͱ͢ɻ·ͨɺ৘ใఏڙΛ།Ұͷ໨తͱ͢Δ΋ͷͰ͋Γɺ͍͔ͳΔܖ໿ʹ΋ ૊ΈࠐΉ͜ͱ͸Ͱ͖·ͤΜɻҎԼͷࣄ߲͸ɺϚςϦΞϧ΍ίʔυɺػೳΛ ఏڙ͢Δ͜ͱΛίϛοτϝϯτʢ֬໿ʣ͢Δ΋ͷͰ͸ͳ͍ͨΊɺߪങܾఆ Λߦ͏ࡍͷ൑அࡐྉʹͳ͞Βͳ͍ͰԼ͍͞ɻΦϥΫϧ੡඼ʹؔͯ͠هࡌ͞ Ε͍ͯΔػೳͷ։ൃɺϦϦʔε͓Αͼ࣌ظʹ͍ͭͯ͸ɺฐࣾͷࡋྔʹΑΓ ܾఆ͞Ε·͢ɻ 0SBDMF͸ɺถࠃΦϥΫϧίʔϙϨʔγϣϯٴͼͦͷࢠձࣾɺؔ࿈ձࣾͷถࠃٴͼͦͷଞͷࠃʹ͓͚Δొ࿥঎ ඪͰ͢ɻจதͷ໊ࣾɺ঎඼໊౳͸֤ࣾͷ঎ඪ·ͨ͸ొ࿥঎ඪͰ͋Δ৔߹͕͋Γ·͢ɻ
  3. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    4 .BLFUIF'VUVSF+BWB +BWBͷະདྷΛ૑଄ 
  4. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    5 May 1998 Enterprise Java Platform Dec 1999 10 specs Robustness Sep 20110 13 specs Web Services Nov 2003 20 specs Ease of Development May 2006 23 specs Lightweight Dec 2009 28 specs JPE Project J2EE 1.3 CMP, Connector Architecture Java EE 5 Ease of Development, Annotations, EJB 3.0, JPA, JSF, Updated Web Services J2EE 1.4 Web Services Mgmt, Deployment, Async Connector Java EE 6 Pruning, Extensibility Ease of Dev, CDI, JAX-RS Web Profile Servlet 3.0, EJB 3.1 Lite J2EE 1.2 Servlet, JSP, EJB, JMS RMI/IIOP +BWB&&ͷྺ࢙
  5. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    7 §  +BWB&&Λ೥य़ϦϦʔε §  +BWB&&ͰΫϥ΢υରԠ Ϋϥ΢υػೳʹ͍ͭͯ +BWB&&ͷϩʔυϚοϓʹ͍ͭͯ
  6. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16 +BWB&&͸ύοέʔδํ๏ɺ഑උɺҠ২ੑͷ໘ʹ஫ ໨͢Δͱطʹ͕Ϋϥ΢υରԠʹͳ͍ͬͯΔͱݴ ͑ΔͰ͠ΐ͏ɻΫϥ΢υ؀ڥͰඞཁͳ࢒Γͷຬ ͨ͞Εͯͳ͍ࣄʹͳΔͱɺܦݧΛੵΜͩ࣌ʹ໌Β͔ʹ ͳΔͨΊɺ ·ͩඪ४ԽΛߦ͏ஈ֊Ͱ͸͋ Γ·ͤΜɻ ϕϯμʔʹΑΔٕज़ֵ৽ͱ૯߹ͯ͠ඪ४ԽΛߦ͍·͢ɻ զʑ͸ݱ࣌఺Ͱ·ͩ͜ͷ෼໺ʹ͓͍ٕͯज़ֵ৽Λߦͬ ͍ͯ·ͤΜɻ %BWJE#MFWJOT "QBDIF5PN&& (FSPOJNP Apache ϩʔυϚοϓʹର͢ΔϑΟʔυόοΫ
  7. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16  ਖ਼͍͠൑அͰ͢ɻ Ϋϥ΢υͷඪ४Խ͸ࢢ৔ʹରͯ͠ɺඇৗʹ େ͖ͳมԽΛ༩͑ѱ͍ಈ͖ʹͳΓ·͢ɻ ࢧ࣋   twiigs ϩʔυϚοϓʹର͢ΔϑΟʔυόοΫ
  8. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16  ίϛϡχςΟͷཁ๬ʹԠ͑ΔͨΊ+BWB&&Λ࠶ฤ ੒͢Δࣄ͸ɺ ΤΩεύʔτάϧʔϓͷ༐׶ Ͱ੣࣮ͳӳஅͰ͢ɻ ೥ͷय़ʹ༧ఆ͞Ε͍ͯΔ+BWB&&ͰΫϥ΢ υͱ1BB4ػೳͷ࣮૷Λ࠶౓ࢼΈ͍ͯͩ͘͞ɻ   .BSLVT&JTFMF +BWB&&$POTVMUBOU IUUQCMPHFJTFMFOFU Java EE Consultant ϩʔυϚοϓʹର͢ΔϑΟʔυόοΫ
  9. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16  +BWB&&ͷ࣮૷ऀͱͯ͠ਃ্͛͠ΔͳΒ͹ɺ զʑ 3FE)BU ͸͜ͷܾஅʹର ͠ଟ͍ʹࢧ͍࣋ͯ͠·͢ɻ ࢲͨͪ͸͔Ͷ͔ͯΒ+BWB&&ίϛϡχςΟ͸·ͩΫ ϥ΢υͷඪ४Խͷ४උ͕Ͱ͖͍ͯͳ͍ࣄΛఏএ͖ͯ͠ ·ͨ͠ɻͦͯ͜͠Ε͸ࢲ͕ͨͪఏڙ͢ΔΫϥ΢υαʔ ϏεͰ͋Δ0QFO4IJGUͷ࣮੷ʹΑͬͯײ͍ͯ͡·͢ɻ 0QFO4IJGU͸+BWB&&ͱ͏·͘ద߹͍ͯ͠·͢ɻ  1FUF.VJS 3FE)BU redhat ϩʔυϚοϓʹର͢ΔϑΟʔυόοΫ
  10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    13 ຤௕͘࢖ΘΕΔٕज़ͷ ඪ४Խʹ͸४උظ͕ؒඞཁ
  11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    14 § +BWB&& –  )5.-ͱγϯϓϧԽʹϑΥʔΧε § +BWB&& –  Ϋϥ΢υରԠͱϞδϡʔϧԽରԠ΁ͷ ܧଓతͳ౤ࢿ +BWB&&ͷࠓޙ Java EE Hasan Rizvi
  12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    15 May 1998 Enterprise Java Platform Dec 1999 10 specs Robustness Sep 20110 13 specs Web Services Nov 2003 20 specs Ease of Development May 2006 23 specs Lightweight Dec 2009 28 specs Simplicity & HTML5 CY 2013 33+ specs JPE Project J2EE 1.3 CMP, Connector Architecture Java EE 5 Ease of Development, Annotations, EJB 3.0, JPA, JSF, Updated Web Services J2EE 1.4 Web Services Mgmt, Deployment, Async Connector Java EE 6 Pruning, Extensibility Ease of Dev, CDI, JAX-RS Web Profile Servlet 3.0, EJB 3.1 Lite Java EE 7 JMS 2.0, Batch, JCache, TX Interceptors HTML5: WebSocket, JSON Web Profile JAX-RS 2.0 J2EE 1.2 Servlet, JSP, EJB, JMS RMI/IIOP +BWB&&ͷྺ࢙
  13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    16 τϐοΫ +BWB&&ͷ8FC1SPpMFʹ  +"934͕ಋೖ
  14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    17 +BWB&&΁ؚ·ΕΔ༧ఆͷ+43Ұཡ $POOFDUPS  +1" +5" +.4 .BOBHFE#FBO &+# $PNNPO "OOPUBUJPOT *OUFSDFQUPST $%* 1PSUBCMF &YUFOTJPOT 4FSWMFU +41 +4' +"934  &-  #FBO7BMJEBUJPO  +BWB$BDIJOH "1* +43  #BUDI "QQMJDBUJPO +43  +BWB"1*GPS +40/ +43  +BWB"1*GPS 8FC4PDLFU +43  ৽ن௥Ճ େ෯ͳߋ৽ ௨ৗͷߋ৽
  15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    19 ࠓ೔͝঺հ͢Δ಺༰ γϯϓϧԽʹؔ͢ΔςʔϚ
  16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    20 8FC4PDLFUͷৄࡉ͸ ໌೔ͷ++6($$$Ͱ Ͱ΋গ͚ͩ͠ɺσϞ
  17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    21 5XJUUFS Singleton 8FC4PDLFU5XJUUFS5JNF-JOFΞϓϦ 3FNPUF &OEQPJOU RE RE RE Session Session Session 8FC4PDLFU &OEQPJOU 5XJUUFS+
  18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    22 ࠓ೔͝঺հ͢Δ಺༰ γϯϓϧԽʹؔ͢ΔςʔϚ
  19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    23 +43 +BWB"1*GPS 1SPDFTTJOH+40/
  20. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    24 3'$ 5IFBQQMJDBUJPOKTPO.FEJB5ZQFGPS +BWB4DSJQU0CKFDU/PUBUJPO  ܰྔɺςΩετϕʔεɺϓϩάϥϛϯάݴޠʹඇґଘ Ҡ২ੑ͕ߴ͘ɺߏ଄Խ͞Εͨσʔλަ׵ϑΥʔϚοτ {“name”:”Bob”,”age”:20,”phone”:[“276 1234”,”124 4567”]} +40/ͱ͸
  21. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    25 JSR 353 : Java API for Processing JSON § 4USFBNJOH"1* –  ௿Ϩϕϧ –  +40/ͷղੳ΍ੜ੒ͷޮ཰తͳํ๏ § 0CKFDU.PEFM"1* –  ߴϨϕϧ –  4USFBNJOHΑΓ΋͔ΜͨΜʹ࣮૷Մೳ –  4USFBNJOH"1*্ʹ࣮૷ Streaming & Object Model
  22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    26 +40/"1*ͷΞʔΩςΫνϟ +40/ϓϩόΠμ 41* 4USFBNJOH"1* 0CKFDU.PEFM "1* "11 "11 "11O ・・・ ศརͳػೳ ௿Ϩϕϧ"1*
  23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    27 {! "firstName": "John", "lastName": "Smith", ! "age": 25,! "phoneNumber": [! { "type": "home", "number": "212 555-1234" }, ! { "type": "fax", "number": "646 555-4567" }! ]! } +40/σʔλͷαϯϓϧ
  24. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    28 0CKFDU.PEFM"1* ѻ͍қ͍%0.ϥΠΫͳ࣮૷ 
  25. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    29 0CKFDU.PEFM"1* ѻ͍қ͍"1*  +TPO0CKFDU +TPO"SSBZ +TPO#VJMEFS +TPO3FBEFS+TPO8SJUFS
  26. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    30 +4PO0CKFDU ,FZ7BMVFͷϖΞͰૢ࡞ .BQ4USJOH +TPO7BMVFͰૢ࡞Մೳ
  27. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    31 JsonObject jobj = ...! Map<String, JsonValue> map = jobj.getValues();! ! if (map.containsKey(“firstName”)) {! JsonString jstring = jobj.getValue(“firstName”, ! JsonString.class);! String lastName = jstring.getValue();! } +4PO0CKFDU͔Βಛఆ,FZͷ7BMVFΛऔಘ ,FZͱ7BMVFͷܕ͕෼͔͍ͬͯΔ৔߹ʹ༗ޮ \pSTU/BNF:PTIJP ʜʜ^
  28. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    32 if (map.containsKey("phoneNumber")) {! JsonArray jarray = jobj.getValue("phoneNumber", ! JsonArray.class);! for (int i = 0; i < jarray.size(); i++) {! JsonValue jvalue = jarray.getValue(i);! if (jvalue.getValueType() == JsonValueType.OBJECT) {! JsonObject jobj2 = jarray.getValue(i, JsonObject.class);! QIPOF/VNCFS< \UZQFIPNFz ^ \UZQFIPNFz ^ʜʜ> +4PO0CKFDU͔Βಛఆ"SSBZΛऔಘ
  29. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    33 +4PO#VJMEFS͔Β+TPO0CKFDUͷੜ੒ JsonObject jsono = new JsonBuilder().! beginObject().! add("KEY1", "VALUE1").! beginArray("KEY2").! beginObject().! add("KEY3", "VALUE3").! endObject().! endArray().! endObject().! build();! \,&:7"-6& ,&:<\,&: 7"-6&z^>^
  30. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    34 try (JsonReader reader = new JsonReader(! ɹɹɹɹɹɹɹɹɹɹɹɹnew FileReader("/tmp/json.dat"));) {! JsonObject jobj = reader.readObject();! Person person = json2Person(jobj);! printPerson(person);! } catch (IOException ioe) {! ioe.printStackTrace();! } *0͔Β+4PO0CKFDUͷಡΈࠐΈ
  31. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    35 try (FileWriter f = new FileWriter(! "/tmp/jsonout.dat");! JsonWriter writer = new JsonWriter(f)) {! writer.writeObject(jsono);! }catch(IOException ioe){! ioe.printStackTrace();! } *0΁+4PO0CKFDUͷॻ͖ࠐΈ
  32. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    36 ࠓ೔͝঺հ͢Δ಺༰ γϯϓϧԽʹؔ͢ΔςʔϚ
  33. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    37 +43 #BUDI"QQMJDBUJPOT GPSUIF+BWB1MBUGPSN
  34. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    38 §  όονॲཧ༻ͷϑϨʔϜϫʔΫ §  +BWB4&&&؀ڥͰར༻Մೳ §  όονॲཧʹඞཁͳɺೖྗɺॲཧɺग़ྗͷ࣮૷Λඪ४Խ §  γʔέϯγϟϧɺฒྻॲཧʹରԠ ػೳͷҰཡ KCBUDI
  35. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    39 KCBUDIͷΞʔΩςΫνϟ +PC3FQPTJUPSZ +PC 0QFSBUPS Item Reader Item Processor Item Writer +PC 4UFQ ̍ɹ  ̍ ̍ ̍ ̍ ̍ ̍ શମΞʔΩςΫνϟ
  36. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    40 +PC0QFSBUPS +PC3FQPTJUPSZ +PC 0QFSBUPS Item Reader Item Processor Item Writer +PC 4UFQ ̍ɹ  ̍ ̍ ̍ ̍ ̍ ̍ δϣϒॲཧͷશମΛ؅ཧ ʢىಈɾఀࢭɾ࠶ىಈɾϨϙδτϦ৘ใऔಘͳͲʣ
  37. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    41 +PC +PC3FQPTJUPSZ +PC 0QFSBUPS Item Reader Item Processor Item Writer +PC 4UFQ ̍ɹ  ̍ ̍ ̍ ̍ ̍ ̍ όονͷॲཧ಺༰ΛӅณ +4- δϣϒ࢓༷هड़ݴޠ Ͱهࡌͨ͠಺༰ͱؔ࿈෇͚
  38. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    42 4UFQ +PC3FQPTJUPSZ +PC 0QFSBUPS Item Reader Item Processor Item Writer +PC 4UFQ ̍ɹ  ̍ ̍ ̍ ̍ ̍ ̍ όονͷॲཧ಺༰ΛӅณ +4- δϣϒ࢓༷هड़ݴޠ Ͱهࡌͨ͠಺༰ͱؔ࿈෇͚ ํࣜɿDIVOL CBUDIMFU
  39. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    43 <job id="job1" xmlns="http://batch.jsr351/js1">! <split id="split1">! <flow id="flow1" next="flow2">! <step id="step1" next="step2">! <batchlet ref="MyBatchlet"/>! </step>! <step id="step2" next="stepDONE">! <batchlet ref="MyBatchlet2"/>! </step>! </flow>… </job>!  +PC4QFDJpDBUJPO-BOHVBHF +4-δϣϒ࢓༷هड़ݴޠ 
  40. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    44 <flow id="flow2">! <step id="step3">! <chunk reader="MyReader" processor="MyProcessor" ! write="MyWriter” commit-interval=“2”>! <properties>! <property name="audit" value="true"/>! </properties>! </chunk>! </step>! </flow></split></job>!  +PC4QFDJpDBUJPO-BOHVBHF +4-δϣϒ࢓༷هड़ݴޠ 
  41. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    45 DIVOLํࣜ +PC3FQPTJUPSZ +PC 0QFSBUPS Item Reader Item Processor Item Writer +PC 4UFQ ̍ɹ  ̍ ̍ ̍ ̍ ̍ ̍ όονΛΞΠςϜʢೖྗɺॲཧɺग़ྗʣຖʹ෼͚࣮ͯ૷ *UFN3FBEFSσʔλͷೖྗ *UFN1SPDFTTPSσʔλͷॲཧ *UFN8SJUFSσʔλͷग़ྗ
  42. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    46 DIVOLํࣜͷγʔέϯεਤͷྫ DPNNJUJOUFSWBMlzͷ৔߹
  43. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    47 package javax.batch.api;! import java.io.Externalizable;! public interface ItemReader <T> {! public void open(Externalizable checkpoint) throws Exception;! public void close() throws Exception;! public T readItem() throws Exception;! public Externalizable checkpointInfo() throws Exception;! } *UFN3FBEFSΠϯλϑΣʔε
  44. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    48 import javax.batch.api.ItemReader;! @Named! public class MyReader implements ItemReader { ! ɹ...! } *UFN3FBEFSͷ࣮૷ྫ ΠϯλϑΣʔε࣮૷༗ 
  45. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    49 *UFN3FBEFSͷ࣮૷ྫ ΠϯλϑΣʔε࣮૷ແ  import javax.batch.annotation.*;! @Named! public class MyReader {! @Open void open(MyCheckpointData checkpoint) ! throws Exception {...}! @Close void close() throws Exception {...}! @ReadItem MyBatchInputRecord read() throws Exception {...}! @CheckpointInfo Externalizable MyCheckpointData getChkpt() ! throws Exception {...}! }
  46. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    50 package javax.batch.api;! public interface ItemProcessor <T, R> {! public R processItem(T item) throws Exception;! }! *UFN1SPDFTTPSΠϯλϑΣʔε
  47. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    51 *UFN3FBEFSͱಉ༷  ɹ˔ΠϯλϑΣʔεͷ࣮૷༗ ɹ˔ΠϯλϑΣʔεͷ࣮૷ແ ɹɹʢϝιουϨϕϧɾΞϊςʔγϣϯʣ
  48. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    52 package javax.batch.api; ! import java.io.Externalizable;! import java.util.List;! public interface ItemWriter <T> {! public void open(Externalizable checkpoint) throws Exception;! public void close() throws Exception;! public void writeItems(List<T> items) throws Exception;! public Externalizable checkpointInfo() throws Exception;! }! *UFN8SJUFSΠϯλϑΣʔε
  49. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    53 *UFN3FBEFSͱಉ༷  ɹ˔ΠϯλϑΣʔεͷ࣮૷ ɹ˔ΠϯλϑΣʔεͷະ࣮૷ ɹɹʢϝιουϨϕϧɾΞϊςʔγϣϯʣ
  50. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    54 Batchlet #BUDIMFUํࣜ +PC3FQPTJUPSZ +PC 0QFSBUPS +PC 4UFQ ̍ɹ  ̍ ̍ όονΛ̍ͭͷλεΫͱ࣮ͯ͠૷ Ұ୴ॲཧΛ࣮ߦ͢Δͱ࠷ޙ·ͰॲཧΛଓߦ
  51. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    55 package javax.batch.api;! public interface Batchlet {! public String process() throws Exception;! public void stop() throws Exception;! }! #BUDIMFUΠϯλϑΣʔε
  52. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    56 package javax.batch.api;! public interface Batchlet {! public String process() throws Exception;! public void stop() throws Exception;! }! #BUDIMFUΠϯλϑΣʔε @Named! public class MyBatchLet{! @Process String process() throws Exception {...} ! @Stop void stopMe() throws Exception {...}! }! ΠϯλϑΣʔε࣮૷༗ ΠϯλϑΣʔε࣮૷ແ
  53. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    57 +PC3FQPTJUPSZ +PC3FQPTJUPSZ +PC 0QFSBUPS Item Reader Item Processor Item Writer +PC 4UFQ ̍ɹ  ̍ ̍ ̍ ̍ ̍ ̍ +PCʹؔ͢Δݱࡏɾաڈͷ৘ใΛอ࣋
  54. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    58 ࠓ೔͝঺հ͢Δ಺༰ γϯϓϧԽʹؔ͢ΔςʔϚ
  55. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    60 §  ͔ΜͨΜʹ࣮૷Ͱ͖ΔΑ͏ʹͳͬͨ"1* –  +.4$POUFYU +.41SPEVDFS +.4$POTVNFSͷ௥Ճ §  ྫ֎ͷ࣮૷ํ๏ͷมߋ §  طଘ"1*ʹର͢Δվળ §  $%*Λར༻ͨ͠৑௕ίʔυͷഉআ §  Ϋϥ΢υػೳ͸+BWB&&΁ ৽ػೳͷҰཡ +.4 ஫ҙɿ ڈ೥ͷ+BWB0OF  +BWB0OF5PLZPͷ಺ ༰͔Βएׯมߋ͋Γ
  56. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    61 @Resource( mappedName="jms/MyConnectionFactory” )! private static ConnectionFactory connectionFactory; ! @Resource( mappedName="jms/mySampleQueue” )! private static Queue queue;! public void sendMessage(String text){! Connection con = connectionFactory.createConnection();! Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);! MessageProducer prod = session.createProducer(queue);! TextMessage message = session.createTextMessage(text);! message.setText(message);! prod.send(message);! con.close();} طଘͷϝοηʔδૹ৴ίʔυ
  57. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    62 @Resource( mappedName="jms/MyConnectionFactory” )! private static ConnectionFactory connectionFactory; ! @Resource( mappedName="jms/mySampleQueue” )! private static Queue queue;! public void sendMessage(String text){! Connection con = connectionFactory.createConnection();! Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);! MessageProducer prod = session.createProducer(queue);! TextMessage message = session.createTextMessage(text);! message.setText(message);! prod.send(message);! con.close();} طଘͷίʔυͷ՝୊ ୯ͳΔϝοηʔδૹ৴ʹ தؒΦϒδΣΫτ͕ඞཁ
  58. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    63 @Resource( mappedName="jms/MyConnectionFactory” )! private static ConnectionFactory connectionFactory; ! @Resource( mappedName="jms/mySampleQueue” )! private static Queue queue;! public void sendMessage(String text){! Connection con = connectionFactory.createConnection();! Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);! MessageProducer prod = session.createProducer(queue);! TextMessage message = session.createTextMessage(text);! message.setText(message);! prod.send(message);! con.close();} طଘͷίʔυͷ՝୊ ఆܕతͳίʔυ
  59. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    64 javax.jms.JMSContext インタフェース +.4$POUFYU $POOFDUJPO 4FTTJPO •  ผʑͷΫϥεΛ̍ͭʹ౷߹ –  $POOFDUJPO –  4FTTJPO •  +.41SPEVDFSͷఏڙ •  +.4$POTVNFSͷఏڙ ৽نʹ+.4$POUFYUΠϯλϑΣʔεΛఏڙ
  60. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    65 JMScontext = conFactory.createContext();! TextMessage textMsg = context.createTextMessage(message);! context.createProducer(). send(queue, textMsg);! ! JMSContext context = conFactory.! createContext(AUTO_ACKNOWLEDGE);! MessageListener mListener = new MyMsgListener();! context.createConsumer(dest).setMessageListener(mListener);! ϝοηʔδૹ৴ྫ ϝοηʔδड৴ +.4$POUFYUΛར༻࣮ͨ͠૷ྫ
  61. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    66 MessageProducer producer = session.createProducer(); ! producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); ! producer.setPriority(1);! producer.setTimeToLive(1000); ! producer.send(destination,message);! context.createProducer().setDeliveryMode(DeliveryMode.NON_ ! PERSISTENT). setPriority(1).setTimeToLive(1000).send( ! destination,message);! +.4 +.4 +.41SPEVDFSͷར༻ྫ ϝιουɾνΣʔϯʹΑΔઃఆ 
  62. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    67  public void sendMessage(String text){!   Connection con = null;!   try{!   con = connectionFactory.createConnection();!   Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);!   MessageProducer prod = session.createProducer(queue);!   TextMessage message = session.createTextMessage(text);!   message.setText(message);!   prod.send(message);!  }finally{!   con.close();!  } ࢖༻ޙίωΫγϣϯͷ Ϋϩʔζ͕ඞཁ ૹ৴ίʔυʹ͓͚Δطଘͷίʔυͷ՝୊
  63. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    68 AutoCloseable による実装 (close()の実装が不要) ! public void sendMessage(String text){! ɹ try(JMSContext context = conFactory.createContext();){! TextMessage message = session.createTextMessage(text);! context.createProducer().send(outQueue,message);! message.sendText(outQueue,message);! }! }! +BWB4&USZXJUISFTPVSDFʹରԠ
  64. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    69  public void sendMessage(String text){!   try{!   ……// 送信処理!   prod.send(message);!   }catch(JMSException jmse){!   // 例外処理!   }finally{!   try{!   if(con != null) con.close();!   }catch (JMSException jmse2){!   // 例外処理!   }}} ྫ֎ॲཧͷ࣮૷͕ ඞཁ ૹ৴ίʔυʹ͓͚Δطଘͷίʔυͷ՝୊
  65. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    70 νΣοΫྫ֎͔ΒඇνΣοΫྫ֎΁ աڈͷྫ֎Ϋϥε ࠓޙͷྫ֎Ϋϥε JMSException JMSRuntimeException TransactionRolledBackException TransactionRolledBackRuntimeException IllegalStateException IllegalStateRuntimeException! InvalidDestinationException IllegalDestinationRuntimeException! InvalidSelectorException InvalidSelectorRuntimeException MessageFormatException MessageFormatRuntimeException ྫ֎ͷ࣮૷ํ๏͕มߋ
  66. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    71 ྫ֎͕3VOUJNF&YDFQUJPOʹมߋ public void sendMessage(String text){! try{! ……// ૹ৴ॲཧ! prod.send(message);! } catch (JMSRuntimeException ex) {! Logger.getLogger(getClass().getName()).! log(Level.SEVERE, null, ex); ! }! } ྫ֎ͷ࣮૷ํ๏͕มߋ
  67. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    72 §  +/%*ϧοΫΞοϓͰίϯςφͷ઀ଓϑΝΫτϦΛ࢖༻ –  ίωΫγϣϯɾϓʔϧ౳Λར༻Մೳ §  +/%*໊Λະࢦఆ࣌ɺγεςϜͷσϑΥϧτ࢖༻ +.4$POUFYUʹର͢Δ஫ೖ @Inject! @JMSConnectionFactory(“jms/MyConFactory”)! private JMSContext context; ΞϊςʔγϣϯΛར༻ͨ͠ґଘੑ஫ೖ
  68. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    73 +.4$POUFYUʹର͢Δ஫ೖ @Inject! @JMSConnectionFactory(“jms/MyConFactory”) ! @JMSPasswordCredential(userName=“admin”,password=“admin”)! @JMSSessionMode(JMSContext.AUTO_ACKNOWLEDGE)! private JMSContext context; パスワードやセッションモードの設定 ΞϊςʔγϣϯΛར༻ͨ͠ґଘੑ஫ೖ
  69. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    75 @Resource( mappedName="jms/MyConnectionFactory” )! private static ConnectionFactory connectionFactory; ! @Resource( mappedName="jms/mySampleQueue” )! private static Queue queue;! ! public void sendMessage(String text){! Connection con = connectionFactory.createConnection();! Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);! MessageProducer prod = session.createProducer(queue);! TextMessage message = session.createTextMessage(text);! message.setText(message);! prod.send(message);! con.close(); +BWB&&·Ͱͷϝοηʔδૹ৴ίʔυ
  70. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    76 @Inject! @JMSConnectionFactory(“jms/MyConFactory”) ! private JMSContext context;! @Resource(mappedName = “jms/queue”)! private Queue queue;! ! public void sendNewMessage(String msg){! context.createProducer().send(queue, msg);! } +BWB&&͔Βͷϝοηʔδૹ৴ίʔυ
  71. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    77 ࠓ೔͝঺հ͢Δ಺༰ γϯϓϧԽʹؔ͢ΔςʔϚ
  72. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    79 §  -BNCEBࣜରԠ –  "SSBZ -JTU .BQͷߏ੒ §  ίϨΫγϣϯʹର͢ΔΫΤϦԋࢉࢠ -*/2ࣜ  §  +BWB4&؀ڥͰར༻͢ΔͨΊͷ"1*Λఏڙ §  σϑΥϧτͷ&-࣮ߦ؀ڥϚωʔδϟͷ௥Ճ §  Ϋϥε TUBUJD ม਺ɺΫϥε TUBUJD ϝιουɺFOVNఆ਺ରԠ §  ΫϥεɺύοέʔδͷΠϯϙʔτ ৽ػೳͷҰཡ &-
  73. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    80 §  ໊લۭؒΛ࣋ͭ/BNF –  SFGFSFODF JNQPSU §  ؔ਺ఆٛ §  ίϯετϥΫλ §  ৽͍͠ԋࢉࢠ –  จࣈྻ࿈݁ԋࢉࢠɺม਺ׂ౰༻ԋࢉࢠ §  ܕม׵ §  දهͷධՁ༻ͷϦεφʔ ৽ػೳͷҰཡ &-
  74. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    81 +BWB&&೥य़ࠒ ఏڙ։࢝༧ఆ   ςʔϚɿ)5.-ͱ։ൃੜ࢈ੑͷ޲্ +BWB&&4%,ͷఏڙ։࢝
  75. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

    83 /FX"OOPVODFNFOU ೥य़ࠒ +BWBΠϕϯτ։࠵༧ఆ