Jakarta EE 例

Jakarta EE

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2023/03/20 15:29 UTC 版)

以下に、Java EE 7の様々な技術を組み合わせて作成した、ユーザーの登録を行うWeb入力画面のサンプルを示す。

Jakarta EEには、サーブレットJSP、またJSFFaceletsといった、Web UIを作ることが可能ないくつかの技術が存在する。以下はJSFとFaceletsを用いた例である。コード上では明示されていないが、入力コンポーネントでは入力値の検証にBean Validationを使用している。

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core">
    
    <f:metadata>
        <f:viewParam name="user_id" value="#{userEdit.user}" converter="#{userConvertor}" />
    </f:metadata>
    
    <h:body>
    
        <h:messages />
        
        <h:form>
            <h:panelGrid columns="2">
                <h:outputLabel for="firstName" value="First name" />
                <h:inputText id="firstName" value="#{userEdit.user.firstName}" label="First name" />
                
                <h:outputLabel for="lastName" value="Last name" />
                <h:inputText id="lastName" value="#{userEdit.user.lastName}" label="Last name" />
                
                <h:commandButton action="#{userEdit.saveUser}" value="Save" />
            </h:panelGrid>
        </h:form>
    
    </h:body>
</html>

バッキングBeanの例

JJakarta EEでは、ビューの処理の実装にバッキングBean(画面の背後で処理するBean、管理Beanとも)と呼ばれる仕組みを用いる。以下はCDIとEJBを用いたバッキングBeanの例である。

@Named
@ViewScoped
public class UserEdit {

    private User user;
    
    @Inject
    private UserDAO userDAO;
    
    public String saveUser() {
        userDAO.save(this.user); 
        addFlashMessage("User " + this.user.getId() + " saved");
        
        return "users.xhtml?faces-redirect=true";
    }
    
    public void setUser(User user) {
        this.user = user;
    }
    
    public User getUser() {
        return user;
    }
}

DAOの例

Jakarta EEでは、ビジネスロジックの実装のためにEJBが用意されている。データの永続化ではJDBCJPAが使用できる。以下はEJBとJPAを用いたData Access Object (DAO) の例である。コード上では明示されていないが、EJBではトランザクション管理にJTAが使用される。

@Stateless
public class UserDAO {

    @PersistenceContext
    private EntityManager entityManager;
    
    public void save(User user) {
        entityManager.persist(user);
    }
    
    public void update(User user) {
        entityManager.merge(user);
    }
    
    public List<User> getAll() {
        return entityManager.createNamedQuery("User.getAll", User.class)
                            .getResultList();
    }

}

エンティティの例

Jakarta EEでは、エンティティ/モデルクラスのためにJPAが用意されており、またバリデーション(値の検証)ではBean Validationが使用できる。以下は両者を用いた例である。

@Entity
public class User {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Integer id;
    
    @Size(min = 2, message="First name too short")
    private String firstName;
    
    @Size(min = 2, message="Last name too short")
    private String lastName;
    
    public Integer getId() {
        return id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }
    
    public String getFirstName() {
        return firstName;
    }
    
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    
    public String getLastName() {
        return lastName;
    }
    
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

}

  1. ^ Eclipse Foundationに移管する「Java EE」、新名称は「Jakarta EE」に”. OSDN (2018年2月28日). 2018年3月6日閲覧。
  2. ^ http://www.oracle.com/technetwork/java/javaee/community/testedconfiguration-glassfish4-0-1957654.html
  3. ^ a b https://glassfish.dev.java.net/public/comparing_v2_and_v3.html
  4. ^ Java EE Compatibility”. Java.sun.com (2010年9月7日). 2012年7月18日閲覧。
  5. ^ http://wcc.on24.com/event/37/57/27/rt/1/documents/player_docanchr_3/weblogic12c_launch_tech_webinar_v8.pdf
  6. ^ http://wildfly.org/news/2018/08/30/WildFly14-Final-Released/
  7. ^ wildfly.org/about/#compliant
  8. ^ https://issues.jboss.org/browse/WFLY-469
  9. ^ http://lists.jboss.org/pipermail/wildfly-dev/2013-May/000062.html
  10. ^ JBoss AS 7.1.0.Final "Thunder" released - Java EE 6 Full Profile certified! | My Wiki | Planet JBoss Community”. Planet.jboss.org (2012年2月17日). 2012年7月18日閲覧。
  11. ^ Java EE Compatibility
  12. ^ JBoss AS is now EE5 certified
  13. ^ Red Hat JBoss Enterprise Application Platform 7.2 Availability”. 2019年4月30日閲覧。
  14. ^ Business Wire (2012年6月20日). “Red Hat Launches JBoss Enterprise Application Platform 6 to Help Enterprises Move Application Development and Deployment to the Cloud”. Business Wire. 2012年7月18日閲覧。
  15. ^ What's new in WebSphere Application Server V8”. Ibm.com. 2012年7月18日閲覧。
  16. ^ IBM WebSphere Application Server Liberty delivers the first production-ready, Java EE 8-compatible application server and broadens support for Spring Boot applications”. IBM. 2018年7月12日閲覧。
  17. ^ http://oracle.com/technetwork/java/javaee/overview/waslibertyprofile8556-2587134.html
  18. ^ https://developer.ibm.com/wasdev/blog/2015/06/25/java-ee-7-has-landed-in-was-liberty
  19. ^ http://www.oracle.com/technetwork/java/javaee/community/ibm-javaee6-web-tested-configs-1961333.html
  20. ^ IBM WebSphere Application Server Community Edition - Wikipedia, the free encyclopedia, En.wikipedia.org 
  21. ^ Apache Geronimo fully certified for Java EE 6 - The H Open: News and Features”. H-online.com (2011年11月14日). 2012年4月20日時点のオリジナルよりアーカイブ。2012年7月18日閲覧。
  22. ^ http://www.oracle.com/technetwork/java/javaee/community/tmax-jeus-8-tested-configuration-1995477.html
  23. ^ http://tmaxsoft.com/product/jeus/certification
  24. ^ https://blogs.oracle.com/theaquarium/entry/tmaxsoft_jeus_8_now_java
  25. ^ Tested Configurations, Java EE 6 - TMAX JEUS 7”. Oracle.com (2010年9月7日). 2012年7月18日閲覧。
  26. ^ Java EE6 Web Application Server, WAS Software”. Us.tmaxsoft.com. 2012年7月18日閲覧。
  27. ^ Fujitsu Interstage Application Server powered by Windows Azure
  28. ^ Tested Configurations, Java EE6 - Fujitsu Interstage”. Oracle.com (2010年9月7日). 2012年7月18日閲覧。
  29. ^ https://www.oracle.com/java/technologies/necjavaee7.html
  30. ^ http://www.oracle.com/technetwork/java/javaee/community/nec-webotx-v9x-certification-2002719.html
  31. ^ http://www.caucho.com/articles/Caucho_Web%20Profile%20JavaEE6_whitepaper_byRR.pdf
  32. ^ Apache TomEE”. Openejb.apache.org. 2012年7月18日閲覧。
  33. ^ MarketWatch.com”. MarketWatch.com. 2012年7月18日閲覧。
  34. ^ http://jonas.ow2.org/xwiki/bin/view/Blog/JOnAS+530+RC1+released
  35. ^ https://blogs.oracle.com/theaquarium/entry/sap_netweaver_cloud_java_ee
  36. ^ EAServer





英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Jakarta EE」の関連用語

Jakarta EEのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Jakarta EEのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
ウィキペディアウィキペディア
All text is available under the terms of the GNU Free Documentation License.
この記事は、ウィキペディアのJakarta EE (改訂履歴)の記事を複製、再配布したものにあたり、GNU Free Documentation Licenseというライセンスの下で提供されています。 Weblio辞書に掲載されているウィキペディアの記事も、全てGNU Free Documentation Licenseの元に提供されております。

©2024 GRAS Group, Inc.RSS