Jakarta EE
出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2023/03/20 15:29 UTC 版)
例
以下に、Java EE 7の様々な技術を組み合わせて作成した、ユーザーの登録を行うWeb入力画面のサンプルを示す。
Jakarta EEには、サーブレットにJSP、またJSFとFaceletsといった、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が用意されている。データの永続化ではJDBCやJPAが使用できる。以下は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;
}
}
- ^ “Eclipse Foundationに移管する「Java EE」、新名称は「Jakarta EE」に”. OSDN (2018年2月28日). 2018年3月6日閲覧。
- ^ http://www.oracle.com/technetwork/java/javaee/community/testedconfiguration-glassfish4-0-1957654.html
- ^ a b https://glassfish.dev.java.net/public/comparing_v2_and_v3.html
- ^ “Java EE Compatibility”. Java.sun.com (2010年9月7日). 2012年7月18日閲覧。
- ^ http://wcc.on24.com/event/37/57/27/rt/1/documents/player_docanchr_3/weblogic12c_launch_tech_webinar_v8.pdf
- ^ http://wildfly.org/news/2018/08/30/WildFly14-Final-Released/
- ^ wildfly.org/about/#compliant
- ^ https://issues.jboss.org/browse/WFLY-469
- ^ http://lists.jboss.org/pipermail/wildfly-dev/2013-May/000062.html
- ^ “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日閲覧。
- ^ Java EE Compatibility
- ^ JBoss AS is now EE5 certified
- ^ “Red Hat JBoss Enterprise Application Platform 7.2 Availability”. 2019年4月30日閲覧。
- ^ 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日閲覧。
- ^ “What's new in WebSphere Application Server V8”. Ibm.com. 2012年7月18日閲覧。
- ^ “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日閲覧。
- ^ http://oracle.com/technetwork/java/javaee/overview/waslibertyprofile8556-2587134.html
- ^ https://developer.ibm.com/wasdev/blog/2015/06/25/java-ee-7-has-landed-in-was-liberty
- ^ http://www.oracle.com/technetwork/java/javaee/community/ibm-javaee6-web-tested-configs-1961333.html
- ^ IBM WebSphere Application Server Community Edition - Wikipedia, the free encyclopedia, En.wikipedia.org
- ^ “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日閲覧。
- ^ http://www.oracle.com/technetwork/java/javaee/community/tmax-jeus-8-tested-configuration-1995477.html
- ^ http://tmaxsoft.com/product/jeus/certification
- ^ https://blogs.oracle.com/theaquarium/entry/tmaxsoft_jeus_8_now_java
- ^ “Tested Configurations, Java EE 6 - TMAX JEUS 7”. Oracle.com (2010年9月7日). 2012年7月18日閲覧。
- ^ “Java EE6 Web Application Server, WAS Software”. Us.tmaxsoft.com. 2012年7月18日閲覧。
- ^ Fujitsu Interstage Application Server powered by Windows Azure
- ^ “Tested Configurations, Java EE6 - Fujitsu Interstage”. Oracle.com (2010年9月7日). 2012年7月18日閲覧。
- ^ https://www.oracle.com/java/technologies/necjavaee7.html
- ^ http://www.oracle.com/technetwork/java/javaee/community/nec-webotx-v9x-certification-2002719.html
- ^ http://www.caucho.com/articles/Caucho_Web%20Profile%20JavaEE6_whitepaper_byRR.pdf
- ^ “Apache TomEE”. Openejb.apache.org. 2012年7月18日閲覧。
- ^ “MarketWatch.com”. MarketWatch.com. 2012年7月18日閲覧。
- ^ http://jonas.ow2.org/xwiki/bin/view/Blog/JOnAS+530+RC1+released
- ^ https://blogs.oracle.com/theaquarium/entry/sap_netweaver_cloud_java_ee
- ^ EAServer
- Jakarta EEのページへのリンク