Software:
News ToolsReg Shops |
Migrating EJB 2.1 Entity and Session Beans to EJB 3.0The nuts and boltsPublished Tuesday 25th April 2006 06:02 GMT Listing 5. EJB 3.0 Session Bean Client Class
public class CatalogClient {
@Inject CatalogBean;
CatalogBean catalogBean;
String publisher="OReilly";
String journal=catalogBean.getJournal(publisher);
System.out.println("Journal for Publisher: "+publisher +" "+journal);
}
Migrating an Entity BeanIn this section, we shall migrate an EJB 2.1 entity bean to the EJB 3.0 specification. An EJB 2.1 entity bean implements the Listing 6. CatalogBean.java. EJB 2.1 Entity Bean
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
public class CatalogBean implements EntityBean {
private EntityContext ctx;
public abstract void setCatalogId();
public abstract String getCatalogId();
public abstract void setJournal();
public abstract String getJournal();
public abstract void setPublisher();
public abstract String getPublisher();
public abstract void setEditions(java.util.Collection editions);
public abstract java.util.Collection getEditions();
public String ejbCreate(String catalogId) {
setCatalogId(catalogId);
return null;
}
public void ejbRemove() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbLoad() {}
public void ejbStore() {}
public void setEntityContext(EntityContext ctx) {
this.ctx=ctx;
}
public void unsetEntityContext() {
ctx = null;
}
}
The
Track this type of story as a custom Atom/RSS feed or by email.
|
Developer HeadlinesThe UK's latest developer news from MSDN |
Top 20 stories • All The Week’s Headlines • Archive • Search