1 package at.ac.tuwien.sbc.valesriegler.xvsm.spacehelpers;
3 import at.ac.tuwien.sbc.valesriegler.common.Util;
4 import org.mozartspaces.core.Capi;
5 import org.mozartspaces.core.ContainerReference;
6 import org.mozartspaces.notifications.NotificationManager;
7 import org.mozartspaces.notifications.Operation;
9 public class SpaceListenerImplBuilder {
11 private ContainerReference cref;
12 private int timeout = 3000;
13 private SpaceAction spaceAction;
14 private boolean lookaround = false;
15 private NotificationManager notificationManager;
16 private boolean countAll = false;
18 private boolean noNotification = false;
20 public SpaceListenerImplBuilder setCapi(Capi capi) {
25 public SpaceListenerImplBuilder setCref(ContainerReference cref) {
30 public SpaceListenerImplBuilder setTimeout(int timeout) {
31 this.timeout = timeout;
35 public SpaceListenerImplBuilder setSpaceAction(SpaceAction spaceAction) {
36 this.spaceAction = spaceAction;
40 public SpaceListenerImplBuilder setNotificationManager(NotificationManager mgr) {
41 this.notificationManager = mgr;
45 public SpaceListenerImplBuilder enableCountAll() {
50 public SpaceListenerImplBuilder setLookaround(boolean lookaround) {
51 this.lookaround = lookaround;
55 public SpaceListenerImpl createSpaceListenerImpl() {
56 final SpaceListenerImpl spaceListener = new SpaceListenerImpl(capi, cref, timeout, spaceAction, notificationManager, lookaround, countAll, name, noNotification);
57 spaceListener.startHandlingAbsenceOfNotifications();
59 if(! noNotification) {
60 notificationManager.createNotification(cref, spaceListener, Operation.WRITE);
62 } catch (Exception e) {
63 Util.handleSpaceErrorAndTerminate(e);
68 public SpaceListenerImplBuilder setName(String name) {
73 public SpaceListenerImplBuilder noNotification() {
74 this.noNotification = true;