用户操作
[即时聊天] [发私信] [加为好友]
孙福林ID:jdlsfl
30390次访问,排名3886好友111人,关注者147
软件
jdlsfl的文章
原创 92 篇
翻译 0 篇
转载 53 篇
评论 44 篇
福林天下的公告
If If you can keep your head when all about you Are losing theirs and blaming it on you; If you can trust yourself when all men doubt you, But make allowance for their doubting too; If you can wait and not be tired by waiting, Or, being lied about, don’t deal in lies, Or, being hated, don’t give way to hating, And yet don’t look too good, nor talk too wise; If you can dream - and not make dreams your master; If you can think - and not make thoughts your aim; If you can meet with triumph and disaster And treat those two impostors just the same; If you can bear to hear the truth you’ve spoken Twisted by knaves to make a trap for fools, Or watch the things you gave your life to broken, And stoop and build ’em up with 5)worn-out tools; If you can make one heap of all your winnings And risk it on one turn of pitch-and-toss, And lose, and start again at your beginnings And never breathe a word about your loss; If you can force your heart and nerve and sinew To serve your turn long after they are gone, And so hold on when there is nothing in you Except the Will which says to them: “Hold on !”; If you can talk with crowds and keep your virtue, Or walk with Kings - nor lose the common touch; If neither foes nor loving friends can hurt you; If all men count with you, but none too much; If you can fill the unforgiving minute With sixty seconds “worth of distance run”Yours is the Earth and everything that’s in it, And - which is more - you’ll be a Man !
最近评论
kaku88:論壇就是要有熱心的人才會茁壯, 感謝樓主了
everspring79:公司的架构师往往不具备架构师的基本知识储备和思路(这是最要命的),往往就从对产品最熟悉的人里面矮子里拔将军,顶多算领域专家,至于如何作出最具扩展性和封装特性的软件是毫无思路.
sap99:www.sap99.com/,SAP99资料多多

SAP免费资料下载
http://www.sap99.com

有很多的学习资料,推荐一下,
sap99:www.sap99.com/,SAP99资料多多

SAP免费资料下载
http://www.sap99.com

有很多的学习资料,推荐一下,
sb:chenjiehong? !
文章分类
收藏
    相册
    IT
    csdn(RSS)
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    转载 EJB学习之EntityBean(实体Bean)收藏

    新一篇: EJB学习之SessionBean(会话Bean) | 旧一篇: EJB学习之J2EE规范

    序言:

    那么首先我们要讲到的是EntityBean就是实体Bean

    实体 Bean

       用于封装业务实体的EJB 组件

    一.      数据源和连接池

    数据源:

    Data source , 获取数据的来源。

    作用:Web服务器只要配置好数据源的名称后,程序可以直接调用数据源而得到数据库连接。当web服务器更换或数据库更换时候,只要数据源的名称不变,并不影响程序。

    连接池:

    用来存放数据库连接的容器。

    作用:当有请求来时,直接使用已经创建好的连接对数据库进行访问。这样省略了创建连接和销毁连接的过程。

    特点:现在假设:最大维持连接数是10,最大连接数是20,最大等待时间是10000(毫秒)
    其过程:最开始在连接池中有10个连接(最大维持连接数),当有用户申请连接时,其将一个连接分配用户,直到连接池中的10个连接全都分配出去,当第 11个用户申请连接时,它将创建第11个连接并分配给该用户,直到把第20个连接(最大连接数)分配给第20个用户,当第21个用户申请连接时,它需要等待,直到前面的20个用户中某一个断开了连接,才会把那个连接分配给第21个用户,当用户断开连接时(第1120个连接),该连接不会立刻被释放而是需 要等待10000毫秒(最大等待时间),才被释放,当没有用户连接时,连接池内还保持10个连接。

    演示weblogic配置数据源和连接池

    二.      实例Bean

    什么是实体Bean:

    EntitiyBean是用来封装业务实体的持久存储的EJB组件.

    它是业务实体

    也是持久化对象

    用来存储在数据库中的数据

    业务概念/系统名词

    为什么要使用实体Bean

    在安全保护和事务上下文中执行

    可重用性高

    表示持久层数据对象

    支持同时访问(并发)

    什么是实体Bean的持久性:

    Java 对象序列化

    对象-关系映射

    对象数据库

    Java 对象保存在永久存储器中

    使用 Oracle Microsoft SQL

    Server 等关系数据库

    存放整个对象

    实体 Bean 是持久对象,即使应用程序结束,它仍然存在

    持久性

    何时使用实体Bean

    1Bean应表示业务实体而非业务过程时;

    2Bean的状态应该是持久的时候。

    实体Bean类型

    根据实体Bean的类型我们可以把它分为两类:

    一、CMP   Container-Manager Persistence

    二、BMP   Bean-Manager Persistence

    CMP是由容器来管理Bean的添加、更新、查询和删除的操作,并由EJB容器自动启动事务。

    使用CMP最大的特点是:

    BMP是由开发者自己编写的代码来管理Bean的添加、更新、查询和删除的操作,并手动控制事务。

    BMP的特点:手动编写数据库连接代码,

    实体Bean编写规范

    哪么如何才能编写一个EntityBean

    EntityBean规范
                      |
                      |___Home
    接口  提供添加、查找数据实体的方法
                      |
                      |___
    远程接口  提供访问更新和得到数据方法
                      |
                      |___Bean
        数据库操作方法

    ejbCreate() : 创建方法,调用该方法时会在数据库中插入新数据。实体Bean类可以有多个ejbCreate()方法,但参数不同。

    ejbPostCreate() : 该方法在ejbCreate()方法执行完成之后调用。每个ejbCreate()方法都有一个对象的ejbPostCreate()方法,且会调用它来完成初始化后的操作。

    ejbLoad() : 刷行数据库的实例对象的数据。容器可将持久层的数据加载到实体Bean的内存中。

    ejbStore() : 用于将实体Bean的当前字段保存在持久层。保证了数据库中和高速缓存中匹配。

    ejbRemove() : 用于从持久层删除一条记录。

    findByPrimaryKey() ; 按主键去查找一个实例Bean的实例。

    weblogic-cmp-rdbms-jar.xml 配置CMP配置文件

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE weblogic-rdbms-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB RDBMS Persistence//EN" "http://www.bea.com/servers/wls810/dtd/weblogic-rdbms20-persistence-810.dtd">

    <weblogic-rdbms-jar>

      <weblogic-rdbms-bean>

        <ejb-name>Jobs</ejb-name>

        <data-source-name>pubs</data-source-name>

        <table-map>

          <table-name>jobs</table-name>

          <field-map>

            <cmp-field>jobId</cmp-field>

            <dbms-column>job_id</dbms-column>

          </field-map>

          <field-map>

            <cmp-field>jobDesc</cmp-field>

            <dbms-column>job_desc</dbms-column>

          </field-map>

          <field-map>

            <cmp-field>minLvl</cmp-field>

            <dbms-column>min_lvl</dbms-column>

          </field-map>

          <field-map>

            <cmp-field>maxLvl</cmp-field>

            <dbms-column>max_lvl</dbms-column>

          </field-map>

        </table-map>

        <automatic-key-generation>

          <generator-type>SQLserver</generator-type>

        </automatic-key-generation>

      </weblogic-rdbms-bean>

    </weblogic-rdbms-jar>

        实体Bean调用过程

    介绍完规范后,我们来讲解一下EntityBean被客户端的调用过程:

    EntityBean不存在时由容器创建一个EntityBean,容器就会调用实体Bean类的setEntityContext()方法,将上下文传递给Bean EntityBean创建实例后即刻将实例放入实例池中。池中所有的实例都完全相同。容器调用ejbActivate()方法将实体Bean放入就绪池,容器就会给实体Bean实例指定一个标识。

    什么情况下EntityBean的实例会从入池状态转换成就绪状态?

    有两种情况:

    第一种是客户端调用create()方法,容器调用ejbCreate()ejbPostCreate()方法

    第二种是EJB容器调用ejbActive()方法。(当实体Bean处于就绪状态时,可调用业务方法。)

    什么情况下EntityBean的实例会从就绪状态转换成入池状态?

    第一种是当客户端调用remove()方法时,EJB容器调用ejbRemove()方法。

    第二种是EJB容器调用ejbPassivate()方法。

    最后,EJB容器删除池中的Bean实例就会调用unsetEntityContext()方法,因此实体Bean就不存在了。

    发表于 @ 2008年05月05日 20:09:00|评论(loading...)|收藏

    新一篇: EJB学习之SessionBean(会话Bean) | 旧一篇: EJB学习之J2EE规范

    评论:没有评论。

    发表评论  


    登录
    Csdn Blog version 3.1a
    Copyright © 福林天下