vendredi 22 mai 2015

Invoke a SessionBean method from Singleton EJB

In my scenario, a singleton bean listens a TCP port and should have to inform all Sessions on incoming data. If i register a session bean to singleton ejb bean then invoke a method of session bean inside singleton bean i got "no active contexts for scope type javax.enterprise.context.SessionContext" exception.

I realized BoundSessionContext might helpfull , but is there any elegant way to register all active session in a singleton bean and call a method.

@Startup
@Singleton
public class TopicListener {
  .
  List<TopicManagerSessionBean> sessionTopicManagers = new .......

  public void register(TopicManagerSessionBean manager){
      .......
  }
  public void onNewData(Data data){
      for(TopicManagerSessionBean  manager in sessionTopicManagers ){
          manager.process(data);
      }
  }
}

I'm using wildfly 8.1.0-Final

Aucun commentaire:

Enregistrer un commentaire