Tutorial for building J2EE Applications using JBOSS and ECLIPSE Chapter 2 part 1

來源:互聯網
上載者:User

All J2EE components are written in the Java programming language

這句話開宗明義的說明了J2EE只能用java來開發,我聽說有一些開源愛好者已經可以做到用.net來做,然後通過一些轉換器來工作,我也不是很瞭解這個東西。不過就我而言,要開發.net的就用微軟的東西,不要想太多,畢竟那個才是專業的。開發j2ee還是用java算了。

The Java 2 Enterprise Edition (J2EE) is a multitiered architecture for implementing enterprise-class applications and web based applications.

這句話已經說明了J2EE的展現方式。

The main aim of J2EE technology is to create a simple development model for enterprise applications using component based application model.

J2EE的目的是為了可以更加簡單的開發企業級應用,但是我覺得在配置J2EE的東西是的確不簡單。

Note this may not be ideal in all scenarios: for example, a small scale application might be a better fit for a light-weight Java technology solution

這句話告訴我,不要迷信J2EE,要因需而變。要按照實際情況選擇適當的架構。

我將要實現的項目會使用web client。我會話較多精力研究這部分。

從上面的圖可以看出,web browser要通過servlets或者jsp來訪問business tier,在web tier 和business tier之間還可以選擇是否使用java beans components。

下面再來看看Business Components Communication

 

Enterprise Beans有三種類型:

session beans (stateless and stateful)

entity beans (bean managed and container managed)

message-driven beans

文檔對session beans是這樣描述的“A session bean represents a transient conversation with a client. When the client finishes executing, the session bean and its data are gone”。而entity beans則有與它相反的特性,“If the client terminates or if the server shuts down, the underlying services ensure that the entity bean data is saved”。message-driven beans是session和jms介面的組合,jms這個是好東西,在我以前做的一個大型零售業系統,各個構件之間的通訊就是通過jms,但是jms現在好多實現似乎比較貴,而免費的又有一點問題,經常會無緣無故增大記憶體的消耗。

在這裡要區分兩個概念Java Beans和Enterprise Java Beans。Java Beans是可以在server端和client層使用,它可以作為一個client應用程式內部通訊的組件,也可以運行在j2ee server上,或者在server組件和資料庫之間。但是EJB就只能在server層的業務層中。下面是原文的描述,“Java Beans are not considered J2EE components by the J2EE specification as JavaBeans are different from Enterprise Beans. JavaBeans component architecture can be used in both server and client tiers to manage the communication between an application client or applet and components running on the J2EE server or between server components and a database, whereas Enterprise JavaBeans components are only used in the business tier as a part of the server tier. JavaBeans have instance variables and has an accessor and mutator methods to access properties of bean or say, accessing the data in the instance variables which simplifies the design and implementation of JavaBeans components.

J2EE Containers

J2ee的容器提供了很多便利,例如多線程,事務,狀態,線程池等處理,現在容器已經提供了。我們只需要集中精力在業務的處理。

容器其實就是業務組件與系統底層功能之間的橋樑。所以我覺得以前都一部分時間花在重複處理一些底層功能,如果有一些項目積累的,或者可以重用線程池之類的東西,現在j2ee container都提供了,不過時間卻花在配置上,所以我們要依靠工具來進行自動設定,如果沒有這些工具,那j2ee的初衷就已經喪失了,開發一個企業級的系統將會使用更多的時間。

J2EE server 本身已經整合了web container和ejb container。其實用戶端也是用java的container,就是我們熟悉的jre。

打包 Packing

我認為j2ee中最複雜的東西就是打包了,一大堆xml檔案,而且沒有什麼東西可以校正,只有到部署的時候才會知道是否正確了。如果全部要手寫,那就等於回到原始時代。還好就是lomboz會自動採用xdoclet來產生這些東西。

web 組件會打包成web archive(.war)。裡面會包括sevlets,jsp,還有一些靜態資源如html,圖片等。

業務組件會打包儲存成java archive(.jar)。裡麵包括ejb 部署的指令碼,remote,object interface檔案等等。

在用戶端我們也會見到jar這種檔案格式,其實可以說成是本地可執行檔。

J2EE程式會把上面的檔案打包成Enterprise Archive(.ear),裡麵包括所有部署所需要的檔案。如:

 

角色 J2EE Platform Roles

J2EE規範中規範了不少角色,分別是developer,assembler,deployer,system administartor,tool rovider。在現在國內的開發環境中,分工還沒有到這麼細緻的地步,經常會出現一個人擔任多個角色。除了tool provider和developer能夠明確分開之外,其他都是一個人幹。其中assembler這個角色我打算採用daily bulid的工具來處理,官方是這樣說明這個角色的,“The application assembler takes all building blocks from the application component provider and combines them into J2EE applications.”。deployer會採用開源的自動部署工具ant,所以我們還是可以把精力集中在開發業務。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.