Session Bean Example
//STEP 1 THE INTERFACE CLASS - publishes the business classes.
package helloworld;
/**
* Interface of the HelloWorld example.
* @author You
*/
public interface HelloWorldInterface {
/**
* Hello world.
*/
void helloWorld();
}
//STEP 2 THE BEAN CLASS - creates the buisness classes.
This bean will be a stateless session bean, thus the class will be annotated with @Stateless annotation.
The interface must be a remote interface to be available for remote clients. This is done by using the @Remote annotation.
package helloword;
import javax.ejb.Remote;
import javax.ejb.Stateless;
/**
* Business code for the HelloWorld interface.
* @author Me
*/
@Stateless
@Remote(HelloWorldInterface.class)
public class HelloWorldBean implements HelloWorldInterface {
/**
* Hello world implementation. */
public void helloWorld() {
System.out.println("Hello world !");
}
} |