在eclipse中使用JBossIDE和xDoclet创建EJB

2008-02-23 09:45:14来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

1. create EJB module(lomboz)
2. create EJB (JBoss): package must end with: .ejb
3. Config xDoclet(Eclipse project properties)
1. add standard-->standard EJB-->ejb doclet
2. right click ejbdoclet and select jboss
set version: 4.0
set datasource: Java:/tutorial
set datasourcemapping: Oracle9i( look up D:\J2EE\jboss-4.0.1\server\default\conf\standardjbosscmp-JDBC.XML for it)
set destDir: simpleejb/META-INF/ (where the the jboss.xml and jbosscmp-jdbc.xml will create)
3. select home, interface,remoteinterface,localhome and select destdir
4. entitypk: set destdir to simpleejb/src
5. set fileset

3. click ok

4. create datasource mapping
1. copy jdbc driver to: D:\j2ee\jboss-4.0.1\server\default\lib
2. create table
3. find D:\j2ee\jboss-4.0.1\docs\examples\jca\oracle-ds.xml and copy it to D:\j2ee\jboss-4.0.1\server\default\deploy
4. update it like below:
<datasources>
<local-tx-datasource>
<jndi-name>HeliumDS</jndi-name>
<connection-url>jdbc:oracle:thin:@192.168.0.109:1521:labdb</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>helium</user-name>
<password>helium</password>
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
<!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
<!-- Checks the Oracle error codes and messages for fatal errors -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>

</datasources>
5. edit source code
1. find /**
*@ejb.bean...
replace it with:
/**
* @ejb.bean name="SimpleEntity"
* display-name="Name for SimpleEntity"
* description="Description for SimpleEntity"
* jndi-name="ejb/SimpleEntityHome"
* type="CMP"
* cmp-version="2.x"
* view-type="both"
* local-jndi-name = "ejb/SimpleEntityLocalHome"
* primkey-field = "domainid"
* @ejb.persistence table-name = "domain"
* @jboss.persistence table-name = "domain"
* @ejb:util
* generate="physical"
*
*/

2. for each field, add code like:

/**
* @ejb.interface-method view-type = "both"
* @ejb.persistence column-name = "domainid"
* @ejb.pk-field
* @return
*/
public abstract String getDomainId();

/**
* @ejb.interface-method view-type = "both"
* @param name
*
*/
public abstract void setDomainId(String id);

/**
* @ejb.interface-method view-type = "both"
* @ejb.persistence column-name = "name"
* @return
*/
public abstract String getName();

/** @ejb.interface-method view-type = "both"
* @param name
*/

public abstract void setName(String name);

3. right click project bar and select run xDoclet. Two files are generated: jboss.xml and jbosscmp-jdbc.xml
4. setup packaging configuration: addstandard-->select EJB-->select destDir
5. run packaging
6. copy classes12.jar to D:\j2ee\jboss-4.0.1\server\default\lib
6. JBoss launcher
1. go into debug...
2. select jboss4.0.X
3. put project into source
4. run the server
7. deploy the project

上一篇: sqlserver 2000h 和 jdbc 的融合问题
下一篇: 如何用servlet在客户端生成一个合成图片

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Tomcat5.5.9的安装配置

下一篇:Formatting messages with variable content