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

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,所以我们还是可以把精力集中在开发业务。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值