chapter 3.
creating a stateless session bean 【程序编程相关:用Java实现基于SOAP的XML文档网】
【推荐阅读:Java Web 服务学习报告—Web简】
【扩展信息:Eclipse 运行命令行参数大全】
this chapter covers how to create a stateless session ejb component. this bean will be responsible for authenticating the user by communicating with the database using data access object (dao) which encapsulates java database connectivity (jdbc) code. a dao has all attributes (fields) and behavior (methods) corresponding to the bean it is being used for.
all customers, supplier and manager of mystore have been assigned a unique username and userid to access services of mystore, but in order to access these services all these entities have to first login into the system (mystore). the method for authentication is named loginuser, which takes two string parameters, username and password and returns the userid if authentication is successful.
note : this method loginuser is a business method, normally business methods carry out operations or processing on values ejb components. from clients perspective, clients can see only business methods and invoke them on bean.
tasks :
create a j2ee project named mystore.
create a stateless session bean named storeaccess.
add a business method in bean named loginuser with the following signature
public string loginuser (string username, string password)
create a dao named storeaccessdaoimpl under package au.com.tusc.dao. generate the dao interface.
implement the method named loginuser, generated in dao interface, in storeaccessdaoimpl. method signature is
public string loginuser (string username, string password)
add callback methods and implement them.
deploy storeaccess bean.
create your test client named sessionclient under package au.com.tusc.client.
run your client and test the bean.
create j2ee project :
now, lets start to write our first component of this tutorial.
go to file > new > lombozj2ee project, project creation wizard will pop up.
insert project name mystore > next .
under java settings check source, should be mystore/src , libraries pointing to $java_home > go next as shown in fig below.
note: this step is shown in chapter1, as there is a bug in eclipse 2.1, so its important that you check your library settings are right.under create j2ee module, select web modules tab > add.., enter module name as onlinestore > ok as shown in figure below.
under create j2ee module, select ejb modules tab > add.., enter module name as mystoremgr > ok .
... 下一页