jboss介绍

JBoss是全世界开发者共同努力的成果,一个基于J2EE的开放源代码的应用服务器。因为JBoss代码遵循LGPL许可,可以在任何商业应用中免费使用它,而不用支付费用。2006年,Jboss公司被Redhat公司收购。JBoss 是一个管理EJB的容器和服务器,支持EJB 1.1、EJB 2.0和EJB3.0的规范。但JBoss核心服务不包括支持servlet/JSP的WEB容器,一般与Tomcat或Jetty绑定使用。
[编辑本段]优点

  1、JBoss是免费的,开放源代码J2EE的实现,通过LGPL许可证进行发布。
  2、JBoss需要的内存和硬盘空间比较小。
  3、安装非常简单。先解压缩JBoss打包文件再配置一些环境变量就可以了。
  4、JBoss能够"热部署",部署BEAN只是简单拷贝BEAN的JAR文件到部署路径下就可以了。如果没有加载就加载它;如果已经加载了就自动更新。
  5、JBoss与Web服务器在同一个Java虚拟机中运行,Servlet调用EJB不经过网络,从而大大提高运行效率,提升安全性能。
  6、用户可以直接实施J2EE-EAR,而不是以前分别实施EJB-JAR和Web-WAR,非常方便。
  7、Jboss支持集群
[编辑本段]使用技巧

  JBoss的安装和配置可以直接拷贝使用,但是要改动 %JBoss-HOME%\bin\run.bat里JAVA-HOME的设置,改成本机JDK的目录。运行run.bat来启动JBoss
  关闭JBoss:关闭JBoss的 DOS 窗口或按"CTRL + C"
  Jboss的目录结构
  1、bin:开始和停止JBoss的地方。
  其中有两个主要的批处理文件:run.bat和shutdown.bat。要启动JBoss只要执行run.bat文件即可;要停止JBoss必须执行shutdown.bat。
  注意,shutdown.bat文件直接执行并不会自动停止JBoss,它必须要输入参数,参数意义如下:
  h显示帮助信息;D设置系统属性;-停止处理选项;s停止用JNDI URL指定的远程服务;n通过制定JMX名字来停止服务;a适配到指定的JNDI名称的远程服务;u指定用户名称;p指定用户密码;S停止服务器;e从虚拟机退出;H暂停。
  一般,我们使用S选项来停止服务器。即执行shutdown.bat -S。
  2、docs:放置JBoss的例子、测试脚本和各种脚本配置文件的DTD。
  3、lib:放置JBoss所需要的部分jar包文件。
  4、client:放置EJB客户端运行时所需要的jar包。
  5、server:放置各启动类型的服务器端EJB配置所需要的文件等。
  6、backup
  以80端口服务
  修改这个文件: {%JBOSS_HOME%}\server\default\deploy\jbossweb-tomcat41.sar\META-INF\jboss-service.xml
  在"8080"的配置后加入以下代码
  <!-- A HTTP/1.1 Connector on port 80 -->
  <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
  port="80" minProcessors="5" maxProcessors="100"
  enableLookups="true" acceptCount="10" debug="0"
  connectionTimeout="20000" useURIValidationHack="false"/>
  重新启动JBoss即可
  启动过程
  设置环境变量 JBOSS_CLASSPATH (可以自己加上安全管理器和xml解析器)
  a) %JBOSS_CLASSPATH%;
  b) %JAVA_HOME%/lib/tools.jar;
  c) run.jar
  d) ../lib/crimson.jar;
  设置启动参数JAXP(xml解析器和相应工厂)
  启动
  设置配置信息
  读取配置文件JBoss.properties,保存在系统属性中(System.properties)
  设置缺省属性jboss.home和java.security.auth.login.config
  创建MBeanServer.的实例:
  把配置文件和补丁文件所在的目录指定给特定的远程类加载器Mlet
  加载保存配置文件(mlet会自动在配置文件目录中查找)
  初始化并启动MBean
  配置服务ConfigurationService
  加载配置文件
  保存配置
  服务控制ServiceControl
  初始化服务程序(init方法)
  启动服务程序(start方法)
  在JBOSS中发布文件
  1、制作JSP的war部署文件
  用"jar cvf hello.war index.jsp main.jsp"的方式生成把index.jsp和main.jsp文件加入到hello.war中。把生成的hello.war拷贝到jboss安装目录\server\default\deploy\下,部署成功。用"http://localhost:8080/hello/"或"http: //localhost:8080/hello/index.jsp"这两个地址进行测试。
  2、制作Servlet的war部署文件
  A、用"javac -classpath "%CLASSPATH%;%jboss_home%\server\default\lib\javax.servlet.jar" HelloWorld.java"的形式编译HelloWorld.java(这是一个Servlet)得到HelloWorld.class
  B、写一个web.xml配置文件
  代码如下:
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  "http://java.sun.com/dtd/web-app_2_3.dtd">
  <web-app>
  <servlet>
  <servlet-name>HelloWorld</servlet-name>
  <servlet-class>hello.HelloWorld</servlet-class>
  </servlet>
  <servlet-mapping>
  <servlet-name>HelloWorld</servlet-name>
  <url-pattern>/HelloWorld</url-pattern>
  </servlet-mapping>
  </web-app>
  每个标记必须小写,否则会出错。
  C、先在c:\servlet下建立一个web-inf目录,在目录中放入web.xml文件。
  D、在web-inf目录下建立一个classes目录,放入编译好的HelloWorld.class文件
  E、在c:\servlet下执行jar cvf hello.war *.*,很快就生成了一个名为hello.war的文件,接着把hello.war复制到jboss的安装目录\server\default\deploy\下完成部署。
  3、也可以不打包,把文件放在deploy下的同名文件夹下也可以。比如原来是制作成hello.war文件,可以建立一个名称为hello.war的文件夹,把要发布的文件拷贝到这个目录底下也可以发布成功。
  补充
  1、JBoss的默认端口是8080
  2、对于NT和Win2000系统如果你要安装NT或Win2000服务的话,可以把JBoss加在系统服务中,避免你每次需要到JBoss目录下运行run.bat命令,只是当系统启动时,自动启动JBoss服务器。
[编辑本段]发展简史

  在J2EE应用服务器领域,JBoss是发展最为迅速的应用服务器。由于JBoss遵循商业友好的LGPL授权分发,并且由开源社区开发,这使得JBoss广为流行。另外,JBoss应用服务器还具有许多优秀的特质。其一,它将具有革命性的JMX微内核服务作为其总线结构;其二,它本身就是面向服务的架构(Service-Oriented Architecture,SOA);其三,它还具有统一的类装载器,从而能够实现应用的热部署和热卸载能力。因此,它是高度模块化的和松耦合的。 JBoss用户的积极反馈告诉我们,JBoss应用服务器是健壮的、高质量的,而且还具有良好的性能。
  为满足企业级市场日益增长的需求,JBoss公司从2003年开始就推出了24*7、专业级产品支持服务。同时,为拓展JBoss的企业级市场,JBoss公司还签订了许多渠道合作伙伴。比如,JBoss公司同HP、Novell、Computer Associates、Unisys等都是合作伙伴。
  在2004年 6月,JBoss公司宣布,JBoss应用服务器通过了Sun公司的J2EE认证。这是JBoss应用服务器发展史上至今为止最重要的里程碑。与此同时, JBoss一直在紧跟最新的J2EE规范,而且在某些技术领域引领J2EE规范的开发。因此,无论在商业领域,还是在开源社区,JBoss成为了第一个通过J2EE 1.4认证的主流应用服务器。现在,JBoss应用服务器已经真正发展成具有企业强度(即,支持关键级任务的应用)的应用服务器。
  JBoss 4.0作为J2EE认证的重要成果之一,已经于2004年9月顺利发布了。同时,JBoss 4.0还提供了JBoss AOP(Aspect-Oriented Programming,面向方面编程)组件。近来,AOP吸引了大量开发者的关注。它提供的新的编程模式使得用户能够将方面(比如,事务)从底层业务逻辑中分离出来,从而能够缩短软件开发周期。用户能够单独使用JBoss AOP,即能够在JBoss应用服务器外部使用它。或者,用户也可以在应用服务器环境中使用它。JBoss AOP 1.0已经在2004年10月发布了。
  展望下一代JBoss应用服务器,其重点关注的是EJB 3.0。当前,J2EE 1.4规范使用了EJB 2.1。其中,EJB 3.0的主要目标是简化EJB模型,即用户能够更容易开发EJB组件,并且能够在EJB容器外部测试EJB组件。EJB 3.0规范草案已经于2004年6月推出。JBoss公司一直在积极参与EJB 3.0规范的制定,并且在为EJB规范的发展贡献自己的力量。其中,Gavin King(Hibernate的创立者)和Bill Burke(JBoss公司的首席架构师)已经为EJB 3.0规范草案贡献了很多内容。
  JBoss公司于2004年10月初发布了基于JBoss应用服务器实现的EJB 3.0预览版。尽管EJB 3.0规范草案还处于初期发展和评审阶段,但这为J2EE社区测试EJB 3.0、并提供反馈信息提供了很好的机会。这也证实了JBoss是一家创新型公司。JBoss一直在引领技术规范的发展。
  近年来, Hibernate已经成为了事实上的持久化引擎。JBoss公司致力于将自身发展成为开源项目的社区,比如招募Gavin King和许多Hibernate开发者。其中,最新版的JBoss应用服务器已经将Hibernate集成为JMX MBean服务。这使得用户能够在应用服务器环境中直接使用Hibernate,而不管它是否处于J2EE上下文中。
  从2003年开始,JBoss启动了JBossCache项目。JBossCache是基于内存的、可复制的、事务性的缓存系统,并且具有持久化状态存储管理能力。最近,它受到极大的关注。用户能够在JBoss应用服务器或其他应用服务器中,或单独使用JBossCache。同时,它提供的基于JBoss AOP的AOP模块能够在可复制环境中实现细粒度、域级别复制,而且能够透明地管理复杂对象。在最新版的JBoss应用服务器中,用户能够直接通过JMX MBean服务访问到JBossCache提供的服务。
  下一代的JBoss应用服务器(暂定名为,JBoss 5.0)将提供大量的新功能。除了支持最新的EJB 3.0规范外,新版的JBoss AOP将同它正式发布。同时,JBoss开发团队还计划开发新的微内核层,即独立于JMX,使得它能够独立使用。另外,有关JBoss应用服务器的架构和开发,开发者可以参考由Scott Stark博士著的《JBoss Administration and Development 3.2.x Third Edition》一书(此书已由电子工业出版社引进并翻译出版,中文版书名为《JBoss管理和开发核心技术(第三版)》)。Scott Stark博士是JBoss公司的创始人之一,他一直在领导JBoss产品的研发。该书内容涵盖了JBoss应用服务器的方方面面,比如JMX微内核、客户端和服务器端拦截器以及J2EE平台服务的实现等内容。如果开发者对JBoss内核和开发基于JBoss/J2EE的应用感兴趣,则最好能够阅读这本权威著作。


jboss-as 目录结构(Directory Structure)

Directory
Description

bin
Contains startup, shutdown and other system-specific scripts. Basically all the entry point JARs and start scripts included with the JBoss distribution are located in the bin directory.

包含了服务器启动,关闭和系统相关的脚本。基本上所有jar文件的进入点和启动脚本都在这个目录里面。

client
Stores configuration files and JAR files that may be used by a Java client application (running outside JBoss) or an external web container. You can select archives as required or use jbossall-client.jar.

保存Java客户端应用或外部web容器(在JBoss之外运行),所需的配置文件和Jar文件。

docs
Contains the XML DTDs used in JBoss for reference (these are also a useful source of documentation on JBoss configuration specifics). There are also example JCA (Java Connector Architecture) configuration files for setting up datasources for different databases (such as MySQL, Oracle, Postgres).

包含一些jboss的XML DTD文件,还有一些案例和文档。

lib
Contains startup JARs used by JBoss. Do not place your own JAR files in this directory.

包换JBoss所需的jar文件。不要把你自己的jar文件放在这个目录。

server
Contains the JBoss server configuration sets. Each of the subdirectories in here is a different server configuration. JBoss ships with minimal, default, production, and all configuration sets. The subdirectories and key configuration files contained in the default configuration set are discussed in more detail in subsequent sections.

包含JBoss服务器实例的配置集合。这里的每个子目录就是一个不同的服务器实例配置。


JBOSS_DIST/jboss-as/server/<instance-name>下面的目录结构
Directory
Description

conf
The conf directory contains the jboss-service.xml bootstrap descriptor file for a given server configuration. This defines the core services that are fixed for the lifetime of the server.

conf目录中包含了这个服务器的启动描述文件jboss-service.xml。这个文件定义了服务器运行时间内提供那些固定的核心服务。

data
The data directory is available for use by services that want to store content in the file system. It holds persistent data for services intended to survive a server restart. Serveral JBoss services, such as the embedded Hypersonic database instance, store data here.

服务中需要存储内容到文件系统的都会保存到data目录。JBoss内嵌的Hypersonic database的数据也是保存到这里的。

deploy
The deploy directory contains the hot-deployable services (those which can be added to or removed from the running server). It also contains applications for the current server configuration. You deploy your application code by placing application packages (JAR, WAR and EAR files) in the deploy directory. The directory is constantly scanned for updates, and any modified components will be re-deployed automatically. This may be overridden through the URLDeploymentScanner URLs attribute.

deploy中包含可热部署的服务(可以在服务器运行时动态添加和删除)。当然这里还包含有这个服务器实例下的应用程序。你可以发布你的应用程序代码的压缩包(JAR,WAR和EAR文件)到这里。这里目录会被搜索更新,所有修改的组件都会被自动重新部署。

lib
This directory contains JAR files (Java libraries that should not be hot deployed) needed by this server configuration. You can add required library files here for JDBC drivers etc. All JARs in this directory are loaded into the shared classpath at startup.

这个目录中包含这个服务器配置需要的JAR文件(这些java库不需要被热部署)。你可以添加需要的库文件到这里,如JDBC驱动等。所有的jar文件将在服务器启动的时候被加载到共享的classpath中。

log
This is where the log files are written. JBoss uses the Jakarta log4j package for logging and you can also use it directly in your own applications from within the server. This may be overridden through the conf/log4j.xml configuration file.

日志文件会被写到这里。如果你要修改日志输出目录,可以通过配置conf/log4j.xml实现。

tmp
The tmp directory is used for temporary storage by JBoss services. The deployer, for example, expands application archives in this directory.

tmp目录被用来提供JBoss服务的临时存储。

work
This directory is used by Tomcat for compilation of JSPs.

提供给tomcat编译jsp文件用。


Config目录里面的内容
File
Description

jboss-minimal.xml
This is a minimalist example of the jboss-service.xml configuration file. (This is the jboss-service.xml file used in the minimal configuration file set)

jboss-service.xml最小配置的例子。

jboss-service.xml
jboss-service.xml defines the core services and their configurations.

定义核心服务及其配置。

jndi.properties
The jndi.properties file specifies the JNDI InitialContext properties that are used within the JBoss server when an InitialContext is created using the no-arg constructor.

jndi.properties定义了InitialContext属性,当一个InitialContext被无参数构造函数创建时会被使用到。

jboss-log4j.xml
This file configures the Apache log4j framework category priorities and appenders used by the JBoss server code.

包含了jboss使用的log4j日志配置。

login-config.xml
This file contains sample server side authentication configurations that are applicable when using JAAS based security.

这个文件包含了服务器端验证的配置的样例,当使用基于JAAS验证时会被用到。

props/*
The props directory contains the users and roles property files for the jmx-console.

这个目录包含了jmx-console所需的用户和角色配置文件。

standardjaws.xml
This file provides the default configuration for the legacy EJB 1.1 CMP engine.

这个文件是EJB 1.1 CMP 引擎的默认配置(EJB1.1遗留)。

standardjboss.xml
This file provides the default container configurations.

提供了JBoss默认容器配置。

standardjbosscmp-jdbc.xml
This file provides a default configuration file for the JBoss CMP engine.

这个文件提供了JBoss CMP 引擎的默认配置文件。

xmdesc/*-mbean.xml
The xmdesc directory contains XMBean descriptors for several services configured in the jboss-service.xml file.

包含了jboss-service.xml 中定义的服务的XMBean描述文件。


deploy目录下的结构
<td style="padding-right: 6pt; padding-left: 6pt; padding-bottom: 1.8pt; padding-top: 1.8pt; background-color: transpar File
Description

bsh-deployer.xml
This file configures the bean shell deployer, which deploys bean shell scripts as JBoss services.

这个文件用来配置bean shell部署器(把bean shell脚本发布为JBoss服务)

cache-invalidation-service.xml
This is a service that allows for custom invalidation of the EJB caches via JMS notifications. It is disabled by default.

这个服务允许自定义的提除EJB cache。JBoss的Cahche invalidation机制。

client-deployer-service.xml
This is a service that provides support for J2EE application clients. It manages the java:comp/env enterprise naming context for client applications based on the application-client.xml descriptor.

提供给J2EE应用程序客户端的一个服务。它基于application-client.xml配置文件,管理java:comp/env企业级名字上下文给客户端程序使用。

ear-deployer.xml
The EAR deployer is the service responsible for deploying J2EE EAR files.

部署J2EE EAR应用的配置。

ejb-deployer.xml
The EJB deployer is the service responsible for deploying J2EE EJB JAR files.

部署J2EE EJB应用的配置。

hsqldb-ds.xml
hsqldb-ds.xml configures the Hypersonic embedded database service configuration file. It sets up the embedded database and related connection factories.

Hypersonic embedded database服务的配置文件

http-invoker.sar
http-invoker.sar contains the detached invoker that supports RMI over HTTP. It also contains the proxy bindings for accessing JNDI over HTTP.

http-invoker.sar包含了支持RMI over HTTP的调用者。它也包含通过HTTP存取JNDI的绑定。

jboss-aop-jdk50.deployer
This service configures the AspectManagerService and deploys JBoss AOP applications.

这个服务配置了AspectManagerService和部署JBoss AOP应用程序的功能。

jboss-bean.deployer
jboss-bean.deployer provides the JBoss microcontainer, which deploys POJO services wrapped in .beans files.

jboss-bean.deployer提供了JBoss微容器功能,通过它部署在.beans文件中包装了的POJO服务。

jboss-ha-local-jdbc.rar
jboss-ha-local-jdbc.rar is an experimental version of jboss-local-jdbc.rar that supports datasource failover.

jboss-ha-local-jdbc.rar是jboss-local-jdbc.rar一个实验性的版本,用来支持数据源失效。

jboss-ha-xa-jdbc.rar
jboss-ha-xa-jdbc.rar is an experimental version of jboss-xa-jdbc.rar that supports datasource failover.

jboss-ha-xa-jdbc.rar是boss-xa-jdbc.rar一个实验性的版本,用来支持数据源失效。

jboss-local-jdbc.rar
jboss-local-jdbc.rar is a JCA resource adaptor that implements the JCA ManagedConnectionFactory interface for JDBC drivers that support the DataSource interface but not JCA.

这是一个JCA的资源适配器,它实现的JCA ManagedConnectionFactory接口支持JDBC驱动提供DataSource接口,但不是JCA本身。

jboss-xa-jdbc.rar
jboss-xa-jdbc.rar is a JCA resource adaptor that implements the JCA ManagedConnectionFactory interface for JDBC drivers that support the XADataSource interface.

这是一个JCA的资源适配器,它实现的JCA ManagedConnectionFactory接口支持JDBC驱动提供XADataSource接口

jbossjca-service.xml
jbossjca-service.xml is the application server implementation of the JCA specification. It provides the connection management facilities for integrating resource adaptors into the JBoss server.

jbossjca-service.xml是应用服务器对JCA规范的实现。它提供了用于集成资源适配器到JBoss服务器的连接管理工具。

jboss-web.deployer
The jboss-web.deployer directory provides the Tomcat servlet engine.

jboss-web.deployer提供了tomcat servlet引擎。

jbossws.sar
jbossws.sar provides J2EE web services support.

提供了J2EE web服务支持。

jboss-messaging.sar/hsqldb-persistence-service.xml
hsqldb-persistencee-service.xml provides JMS state management using Hypersonic.

使用Hypersonic实现的JMS状态管理。

jboss-messaging.sar/destinations-service.xml
destinations-service.xml configures a number of JMS queues and topics used by the JMS unit tests.

配置一些给JMS单元测试用的JMS队列和主题。

jboss-messaging.sar/messaging-service.xml
The messaging-service.xml file configures the core JBoss Messaging JMS service.

配置核心JBoss消息系统的JMS服务。

jms-ra.rar
jms-ra.rar is a JCA resource adaptor that implements the JCA ManagedConnectionFactory interface for JMS connection factories.

jms-ra.rar是一个JCA资源适配器,它为JMS连接工厂实现了JCA ManagedConnectionFactory接口。

jmx-console.war
The jmx-console.war directory provides the JMX Console. The JMX Console provides a simple web interface for managing the MBean server.

jmx-console.war提供了JMX控制台。它提供了一个管理MBean服务器的简单web界面。

jmx-invoker-service.sar
jmx-invoker-service.sar is an unpacked MBean service archive that exposes a subset of the JMX MBeanServer interface methods as an RMI interface to enable remote access to the JMX core functionality. This is similar to the legacy jmx-rmi-adaptor.sar, with the difference that the transport is handled by the detached invoker architecture.

以RMI接口的方式暴露MBeanServer接口的一个子集,允许远程存取。

jsr-88-service.xml
jsr-88-service.xml provides the JSR 88 remote deployment service.

提供JSR88远程部署服务。

mail-ra.rar
mail-ra.rar is a resource adaptor that provides a JavaMail connector.

一个提供JavaMail连接的资源适配器。

mail-service.xml
The mail-service.xml file is an MBean service descriptor that provides JavaMail sessions for use inside the JBoss server.

MBean服务描述,提供JavaMail会话供JBoss服务器内部使用。

management/console-mgr.sar
console-mgr.sar provides the Web Console. It is a web application/applet that provides a richer view of the JMX server management data than the JMX console. You may view the console using the URL http://localhost:8080/web-console/.

提供一个web控制台。相比JMX控制台,提供了一个富客户端。


文章出处:飞诺网(www.firnow.com):http://dev.firnow.com/course/3_program/java/javashl/20100522/203642.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值