[jboss-user] [EJB 3.0 Users] - Re: EJB 3.0 lookup from Pojo and Injection
MirekSz
do-not-reply at jboss.com
Tue Dec 1 08:59:47 EST 2009
I try explain exacly what I doing, the prevoius example wasn't real(but describe problem)
I have fasade
| @Stateful
| public class FasadeBean implements Fasade{
|
| @EJB
| private ChangedIdsCollectorService;
|
|
|
| public ServerResponse execute(String serviceName, String serviceMethod, Object[] arguments){
|
| Object result = serviceExecutor.execute(serviceName,serviceMethod, arguments);
|
| return new ServerResponse(result, ChangedIdsCollectorService.getChangedIds());
|
|
| }
|
|
| }
|
and service which collect ids of changed object(ENTITY)
| @stateles
| public class ChangedIdsCollectorServiceBean inplements ChangedIdsCollectorService{
|
| private List<Long> changedIds;
|
| public void addChangedId(Long id){
| changedIds.add(id);
| }
|
| public List<Long> getChangedIds(){
| return changedIds;
| }
|
| }
|
When i call fasade and execute for example ("OperatorService","update" , operatorEntity) this fasade invokes "OperatorService" and return updated enitity, but I also have in my Entity
metod which lookup for ChangedIdsCollectorService and add yourself to his list:
| public class AbstractEntity {
|
| @javax.persistence.PostUpdate
| public void changeListener(){
| Context context = new InitialContext();
| ChangedIdsCollectorService ChangedIdsCollectorService = ChangedIdsCollectorServicecontext.lookup("ChangedIdsCollectorService/local");
| ChangedIdsCollectorService.addChangedId(this.id);
|
|
| }
| }
|
In this way I get information about changed objects....update of operator can invokes some businness rule which can updates another object and I also will be have this Ids.
Now I don't now if in FasadeBean I will be have the same instance of ChangedIdsCollectorService (from injection) like in Entity(from lookup)
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4268305#4268305
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4268305
More information about the jboss-user
mailing list