JBoss AS7 最近發佈了 7.0.0.CR1 版本,CR意即Candidate Release(候選發佈版),是JBoss AS在Alpha → Beta以後相對比較完整的一個版本,包含了CDI,JAX-RS等諸多重要特性。此次的7.0.0.CR1版本代號White Rabbit(白兔子)。因爲採用了新的MSC內核和JBoss Modules架構,其運行和啓動速度真正作到了動若脫兔。讓咱們一塊兒來體驗下吧!java
首先是下載JBoss AS 7.0.0.CR1,訪問JBoss AS的下載頁面:web
http://www.jboss.org/jbossas/downloads
將最新版的JBoss AS7下載下來(本文撰寫時最新版本爲7.0.0.CR1,代號White Rabbit):shell
除了JBoss AS之外,咱們還能夠把quickstarts包一塊兒下載下來,這個包裏面含有一些樣例工程,能夠部署進JBoss AS 7,咱們稍後討論。apache
JBoss AS7的安裝包下載完成後,將其解壓。解壓縮完成後,咱們能夠看看AS7裏面都有什麼內容:服務器
/jboss-7.0.0.CR1$ ls bin docs jboss-modules.jar standalone bundles domain modules welcome-content
能夠看到AS7的目錄結構和AS6及以前的版本有很大的不一樣了,這是因爲AS7的架構與以前的版本相比,經歷了從新架構和代碼重寫,有了本質上的飛躍。探討AS7的設計架構不是本文重點,咱們繼續來看如何運行及啓動它:進入bin目錄,能夠看到有一些命令可供咱們使用:架構
/jboss-7.0.0.CR1/bin$ ls domain.bat jboss-admin.bat standalone.conf wsconsume.sh domain.conf jboss-admin.sh standalone.conf.bat wsprovide.bat domain.conf.bat scripts standalone.sh wsprovide.sh domain.sh standalone.bat wsconsume.bat
run.sh
沒有了。取而代之的是
standalone.sh
和
domain.sh
。AS7再也不使用統一的
run.sh
加上啓動環境參數(default, all)的方式來管理服務,而是將啓動方式區分爲獨立運行(standalone)和域運行(domain)。AS7默認支持多域,在架構上面與原來的組播羣集有很大的不一樣,我會在隨後的文章中重點介紹。在這裏咱們能夠首先試玩下以獨立模式啓動AS7,使用standalone.sh(若是是在Windows下,運行standalone.bat)啓動AS7服務器:
liweinan@cute:~/projs/jboss-7.0.0.CR1/bin$ ./standalone.sh ... 20:13:57,559 INFO [org.jboss.modules] JBoss Modules version 1.0.0.CR4 20:13:58,168 INFO [org.jboss.msc] JBoss MSC version 1.0.0.CR2 20:13:58,316 INFO [org.jboss.as] JBoss AS 7.0.0.CR1 "White Rabbit" starting 20:14:00,314 INFO [org.jboss.as] creating http management service using network interface (management) port (9990) securePort (-1) ... 20:14:00,369 INFO [org.jboss.as.connector.subsystems.datasources] (Controller Boot Thread) Deploying JDBC-compliant driver class org.h2.Driver (version 1.2) 20:14:00,664 INFO [org.jboss.as.naming] (Controller Boot Thread) Activating Naming Subsystem 20:14:00,698 INFO [org.jboss.as.naming] (MSC service thread 1-1) Starting Naming Service 20:14:00,715 INFO [org.jboss.as.osgi] (Controller Boot Thread) Activating OSGi Subsystem 20:14:00,767 INFO [org.jboss.as.security] (Controller Boot Thread) Activating Security Subsystem 20:14:00,784 INFO [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 3.2.0.Beta2 20:14:00,821 INFO [org.xnio] (MSC service thread 1-2) XNIO Version 3.0.0.Beta3 20:14:00,856 INFO [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.0.0.Beta3 20:14:01,193 INFO [org.apache.catalina.core.AprLifecycleListener] (MSC service thread 1-4) The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java 20:14:01,268 INFO [org.jboss.as.jmx.JMXConnectorService] (MSC service thread 1-1) Starting remote JMX connector 20:14:01,289 INFO [org.jboss.as.ee] (Controller Boot Thread) Activating EE subsystem 20:14:01,347 INFO [org.jboss.as.remoting] (MSC service thread 1-2) Listening on /127.0.0.1:9999 20:14:01,359 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-3) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080 20:14:01,395 WARN [org.jboss.osgi.framework.internal.URLHandlerPlugin] (MSC service thread 1-2) Unable to set the URLStreamHandlerFactory 20:14:01,398 WARN [org.jboss.osgi.framework.internal.URLHandlerPlugin] (MSC service thread 1-2) Unable to set the ContentHandlerFactory 20:14:01,882 INFO [org.jboss.as.connector] (MSC service thread 1-1) Starting JCA Subsystem (JBoss IronJacamar 1.0.0.CR2) 20:14:01,987 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) Bound data source [java:jboss/datasources/ExampleDS] 20:14:03,073 INFO [org.jboss.as.deployment] (MSC service thread 1-2) Started FileSystemDeploymentService for directory /Users/liweinan/projs/jboss-7.0.0.CR1/standalone/deployments 20:14:03,098 INFO [org.jboss.as] (Controller Boot Thread) JBoss AS 7.0.0.CR1 "White Rabbit" started in 6107ms - Started 91 of 146 services (55 services are passive or on-demand)
|
從啓動日誌裏面能夠看出來,AS7使用了新的JBoss Module來加載模塊,這是AS7中全新的設計。此外,新的MSC內核的身影也能夠在日誌中看到。此外,默認啓動的模塊還包括XNIO高速IO,JCA子系統等。看一下最後一行,AS7的啓動時間,在個人Macbook Air 1.4Ghz Core Duo + 2GB內存的低配下達到了驚人的6秒。dom
接下來咱們試着在AS7上面部署應用玩玩看,剛纔一塊兒下載的quickstart包有用了,裏面有一些可供部署了例子,咱們將壓縮包解開,使用裏面的numberguess例子,進入到numberguess目錄,執行mvn的部署命令:ide
/jboss-as-quickstarts-7.0.0.CR1/numberguess$ mvn jboss-as:deploy
22:20:28,184 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) Starting deployment of "jboss-as-numberguess.war" 22:20:28,340 INFO [org.jboss.weld] (MSC service thread 1-8) Processing CDI deployment: jboss-as-numberguess.war 22:20:28,390 INFO [org.jboss.weld] (MSC service thread 1-7) Starting Services for CDI deployment: jboss-as-numberguess.war 22:20:28,414 INFO [org.jboss.weld.Version] (MSC service thread 1-7) WELD-000900 1.1.2 (AS7) 22:20:28,437 INFO [org.jboss.weld] (MSC service thread 1-3) Starting weld service 22:20:28,777 INFO [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-8) Initializing Mojarra 2.0.4 (FCS b09) for context '/jboss-as-numberguess' 22:20:29,514 INFO [org.jboss.web] (MSC service thread 1-8) registering web context: /jboss-as-numberguess 22:20:29,557 INFO [org.jboss.as.server.controller] (pool-1-thread-1) Deployed "jboss-as-numberguess.war"
從日誌中咱們能夠看到,AS7檢測到待部署的項目須要Weld模塊,所以在此時AS7中的Weld模塊才被加載,這種加載方式被稱爲按需加載(on-demand),只有在須要的時候加載相應的模塊,從而大大加快了AS7自己的啓動速度。工具
咱們來玩玩看這個例子,訪問頁面:ui
http://127.0.0.1:8080/jboss-as-numberguess/home.jsf
是一個猜數字的遊戲:
最後提供一些經常使用的AS7參考資料