当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: Chapter 6. Creating a CMP Entit
 

 

    摘要: chapter 8. creating web clientsthis chapter describes how to create web clients in the client tier/presentation tier to access or otherwise communicate with the business tier. servlets and jsp pages ......
 ·使用ejb3.o简化ejb开发(一)    »显示摘要«
    摘要: 使用ejb3.o简化ejb开发 原著:debu panda我们引入ejb来构造分布式的组件。它诞生之时是为了解决所有corba的问题和复杂性。经历过几次重要的版本更新和增加许多特性之后,ejb已经成为了j2ee的核心。在早期,很多开发人员沉迷于ejb甚至在没有任何意义的情况下在他们的工程中使用ejb。而当他们发现所使用的工程并没有质的变化后,谴责ejb成了一种趋势。开发ejb从来没有变得简单甚至......


Tutorial for building J2EE Applications using JBOSS and ECLIPSE (6)

chapter 6.

creating a cmp entity bean 【程序编程相关:Struts中tiles的使用

【推荐阅读:spring+hibernate开发网站

【扩展信息:java.net.URLClassLoa

this chapter covers how to create a container managed persistence (cmp) ejb component. we will create two cmp beans, item and supplier as shown below. the item bean will be responsible for storing the details of items, such as their availabability and their prices, for mystore. the supplier bean stores details of suppliers to mystore. both beans interact with corresponding tables in the database. in cmp this interaction is controlled by the container, in this case the jboss cmp container.

all items have been assigned a unique itemid for housekeeping purposes within mystore, and all suppliers have been assigned a unique supplierid in addition to their username which is what they use in accessing the services of mystore.

note : it is normal practice to access the business methods of cmp beans via a session bean, that encapsulates the business logic and acts as an interface to the lower-level ejb components. in this case supplier and items are accessed via storeaccess.

tasks :

create a cmp bean named items under package au.com.tusc.cmp.

implement the ejbcreate method, with the values of all attributes being passed as arguments and then assigned to the attributes using mutator (setter) methods.

add a finder method named findbysupplierid with the following query and signature:

query "select object(b) from mystoreitem as b where b.supplierid = ?1"

method "java.util.collection findbysupplierid(java.lang.string supplierid)"

add a finder method named findbyoutofstock with the following query and signature:

query "select object(c) from mystoreitem as c where c.quantity = 0"

method "java.util.collection findbyoutofstock()"

add a business method to get item details with the signature:

public itemdata getitemdata()

add another business method to register delivery of items with the signature:

public void fillstock(java.lang.integer quantity)

add callback methods, required for getting/setting bean context for bean with signatures:

public void setentitycontext(entitycontext ctx)

public void unsetentitycontext()

deploy the item bean.

add a field to the storeaccess bean to store the item reference (obtained from jndi lookup):

private itemlocalhome itemlocalhome

in the ejbcreate method of the storeaccess bean store this reference in the itemlocalhome variable by invoking the getlocalhome static method in itemutil.

add a business method to storeaccess bean with the signature:

public itemdata getitemdata(string itemid)

add another business method to storeaccess bean with the signature:

public java.util.arraylist getoutofstockitems()

add another business method to storeaccess bean with the signature:

public java.util.arraylist getitembysupplier(string supplierid)

create a test client named sessioncmpclient under package au.com.tusc.client.

run your client and test the bean.

create items cmp entity bean :


...   下一页
 ·java规则——开发篇    »显示摘要«
    摘要: 本文介绍的java规则的说明分为3个主要级别,本篇抛弃了平时开发中很少遇到的情况,那些用得比较少的以后再高级篇里面出现。并有六个有用的国际软件开发重要注意的有关string的问题,遵守了这些规则可以提高程序的效率、使代码又更好的可读性等。(1) 如果有jdbc连接没有关掉的话,需要在"finally"方法中关掉如果数据库连接失败或者是没有释放连接,看上去无关紧要。但是其他的用......
» 本期热门文章:
· 热门栏目:
» 相关精选文章
» 其它相关:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE