JFox(J2EE Application Server Implementation Project)

Last Modified: 2003.12.03

Your First EJB


if we want to develop a ejb named hello, steps below will be done. Concrete codes are in %JFOX_HOME%/examples/src.

1.define remote interface, Hello.java

2.define home interface, HelloHome.java

3.implement Hello EJB,HelloBean.java

4.implement Meta class, HelloMeta.java

5.package all of files using jar commmand , copy it to %JFOX_HOME%deploy, then finish deployment.

Among these steps, first three steps are similar with steps of normal ejb development. The forth step is particular . a meta class replaces ejb-jar.xml so development can be simplified. Content of HelloMeta.java is

package org.jfox.ejb.examples.stateless;
import org.jfox.ejb.meta.EJBMeta;
import org.jfox.ejb.meta.EJBMetaInfo;
import org.jfox.ejb.meta.EJBMetaHelper;

public class HelloMeta implements EJBMeta{
  public EJBMetaInfo getEJBMetaInfo() {
    // Simple Stateless SessionBean Meta Config
    return EJBMetaHelper.simpleStatelessMetaInfo(HelloHome.class);
  }
}


We can see that HelloMeta.java implemnet EJBMeta interface and implement a method getEJBMetaInfo(). This method returns EJBMetaHelper.simpleStatelessMetaInfo(HelloHome.class); the method use HelloHome. class as parameter. SimpleStatelessMetaInfo method returns a simple config Stateless EJBMeta. This EJBMeta is displayed underside


	Home => HelloHome
	Remote => Hello
	EJB Name=>Hello
	Bean Class =>HelloBean
	Jndi => HelloHome.class.getName().replace('.','/')  (如:/org/jfox/examples/stateless/HelloHome)
	Transaction=>Required
Description => ejb Hello

After write HelloMeta, a complete ejb compenent is finished. package all of files using jar commmand , copy it to %JFOX_HOME%deploy, then finish deployment.

If we want to change Hello to a Stateful SessionBean ( this change doesnot happen frequently), we will modify HelloMeta class, change EJBMetaHelper.simpleStatelessMetaInfo(HelloHome.class) to EJBMetaHelper.simpleStatefulMetaInfo(HelloHome.class),then compiler, package and deploy again . is it simple?