Hi Scott,
I'm deploying Resin 4.0.2 snapshot to a cluster and found my
@ApplicationScoped bean not distributed across the cluster nodes.
Is there anything to config to make it possible?
I searched Gavin's blog and found some examples regarding @Observes to
resolve this situation.
If I dispatch events to my @ApplicationScoped bean, instead of call
its methods directly, could I make the data synchronized across the
cluster?
like this:
============= original implementation ===============
@ApplicationScoped
public class MyAppScopedBean implements Serializable {
private Map<Integer, MyModel> models;
public void addModel(MyModel model) {
models.put(model.getId(), model);
}
}
public class MyController {
@Inject
MyAppScopedBean appScopedBean;
public void execute() {
appScopedBean.addModel(model);
}
}
this implementation was not distributable.
============= proposed implementation ===============
@ApplicationScoped
public class MyAppScopedBean implements Serializable {
private Map<Integer, MyModel> models;
public void addModel(@Observes @MyEventAnno MyEvent event) {
MyModel model = event.getModel();
models.put(model.getId(), model);
}
}
public class MyController {
public void execute() {
beanManager.fireEvent(new MyEvent(model), ... );
}
}
should this event be distributated to all MyAppScopedBean instances in
cluster nodes?
-Wesley
_______________________________________________
resin-interest mailing list
[email protected]
http://maillist.caucho.com/mailman/listinfo/resin-interest