日期:2014-05-16  浏览次数:20669 次

8.4和Apache Geronimo集成
Apache Geronimo应用服务器是在应用服务器许多方面都使用了许多领先开源项目的一个fully certified Java EE 5 runtime。事实上,Geronimo更大程度上是用来创建一个定制的只包含您需要的组件的应用程序分布式服务器的工具包。

默认的,有三个取决于您的需求的不同发行版的Geronimo:
1 Java EE Certified--一个完全认证的Java EE 5分布,使用两个主要的开源web容器:
■Geronimo with Jetty 7
■Geronimo with Tomcat6
2 Little-G--一个提供一个web容器和Geronimo模块的一个子集的distribution,子集包括:
■Geronimo with Jetty 7
■Geronimo with Tomcat6
3 Micro-G--一个允许你from the ground up建立你自己定制的应用服务器。你通过Geronimo deployer决定包含哪些组件。

Geronimo 提供了大量宽广的选择性,但是我们将为本章节使用Little-G 2.2 with Tomcat 6因为它还没有安装ActiveMQ(而Java EE certified runtime确实包括ActiveMQ)。所以从Geronimo下载页面(http://mng.bz/DaoR)下载Little-G 2.2 with Tomcat 6并将它解压到你的电脑上。

在本章节中,我们将为Geronimo部署ActiveMQ插件并使用Geronimo web console来注册ActiveMQ JMS 资源到Geronimo JNDI provider。在完成了这些步骤以后,Geronimo 示例应用(jms-webapp-geronimo项目)能被部署。

8.4.1安装Geronimo并在Geronimo中配置ActiveMQ插件

在archive展开之后,启动到建立的目录并启动Geronimo,如下所示。
Listing 8.10 Start up Geronimo
$ cd ./geronimo-tomcat6-minimal-2.2
$ ./bin/start-server
Launching Geronimo Server...
Booting Geronimo Kernel (in Java 1.6.0_15)...
...
Startup completed in 6.431s seconds
Listening on Ports:
1099 0.0.0.0 RMI Naming
8009 0.0.0.0 Tomcat Connector AJP TomcatAJPConnector
8080 0.0.0.0 Tomcat Connector HTTP BIO TomcatWebConnector
8443 0.0.0.0 Tomcat Connector HTTPS BIO TomcatWebSSLConnector
9999 0.0.0.0 JMX Remoting Connector
Geronimo Server started in 0:00:08.787
Started Application Modules:
WAR: org.apache.geronimo.configs/remote-deploy-tomcat/2.2/car
Web Applications:
/remote-deploy
Geronimo Application Server started

当Geronimo启动了,它的输出显示了哪些组件被启动了。默认的所有组件都包含在Little-G中。注意ActiveMQ没有包含在输出中。现在该是使用Geronimo deployer安装ActiveMQ的时候了。

Geronimo deployer是一个用于查询和安装Geronimo插件的命令行工具。启动Geronimo deployer并使用它的search-plugins功能查看所有可用的插件的列表。
$ ./bin/deploy.sh --user system --password manager \
search-plugins http://geronimo.apache.org/plugins/geronimo-2.2
Using GERONIMO_HOME: /opt/geronimo-tomcat6-minimal-2.2
Using GERONIMO_TMPDIR: var/temp
Using JRE_HOME:
<no category>
1: ActiveMQ web console on Jetty (2.2)
2: ActiveMQ web console on Tomcat (2.2)
3: Geronimo Plugins, Clustering :: Plugin Farm Datasource (2.2)
4: Geronimo Plugins, UDDI : Database (2.2)
Administration
5: Geronimo Plugins, Console :: Debug Views (Jetty) (2.2)
...
12: Geronimo Plugins, Console :: System Database (Jetty) (2.2)
13: Geronimo Plugins, Console :: System Database (Tomcat) (2.2)
14: Geronimo Plugins, Console :: Tomcat (2.2)
15: Geronimo Plugins, OpenEJB :: Jetty (2.2)
JMS
[b]88: Geronimo Plugins, ActiveMQ v5 :: Broker (2.2)
89: Geronimo Plugins, ActiveMQ v5 :: Console (Jetty) (2.2)
90: Geronimo Plugins, ActiveMQ v5 :: Console (Tomcat) (2.2)
91: Geronimo Plugins, ActiveMQ v5 :: Resource Adapter (2.2)[/b]
JavaEE
92: Geronimo Framework, Configs :: JavaEE Specs (2.2)
...
Install Services [enter a comma separated list of numbers or 'q' to quit]:


注意  当Geronimo deployer启动了,它需要一个username和一个密码。默认的username是system并且默认的密码是manager。注意这些将作为参数传给deployer。

虽然deployer上的许多输出已被elided来节省空间,你能通过142个不同插件的列表看到这里有很大的选择空间。但是在本章需要插件仅用粗体标示--插件 14,88和91。插件14是Geronimo控制台,用于管理Geronimo的基于web的控制台。Geronimo控制台将使它更容易建立JMS资源。插件88是ActiveMQ代理。插件91是ActiveMQ 资源适配器,它将允许ActiveMQ和Java EE服务器集成。

注意deployer上输出的最后一行是允许你以逗号为间隔输入要按章的插件(通过number)的prompt。在这个prompt上,输入14,88,91并按回车。当你这么做后你将看到如下的输出:
...
Install Services [enter a comma separated list of numbers or
'q' to quit]: 14,88,91
Checking for status every 1000ms:
Downloading org.apache.geronimo.plugins/console-tomcat/2.2/car (40%)
Downloading org.apache.pluto/pluto-portal-driver/1.1.6/jar
Downloading org.apache.pluto/pluto-container/1.1.6/jar
Downloading org.apache.pluto/pluto-descriptor-impl/1.1.6/jar
Downloading commons-bean