How do I create a statefull session bean with EJB 3.0?

Byron Tymvios

 

 

To create a statefull session bean you need to make use of the @Statefull annotation. You place the annotation on the line before the class declaration. You will also need to implement an interface to allow either local or remote access to the beans methods and to define the methods.

Here is the interface, I have declared as local with the @Local annotation.

import javax.ejb.Local;

@Local
public interface StatefullInterface{
public String someMethod();
}



Here is the bean with the method implemented.

import javax.ejb.Statefull;

@Statefull
public class MyStatefullSessionBean implements StatefullInterface{
public void MyStatefullSessionBean(){
}

public String someMethod(){
return "My Statefull Session Bean";
}
}

 

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact