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;
17 public SpaceListenerImplBuilder setCapi(Capi capi) {
22 public SpaceListenerImplBuilder setCref(ContainerReference cref) {
27 public SpaceListenerImplBuilder setTimeout(int timeout) {
28 this.timeout = timeout;
32 public SpaceListenerImplBuilder setSpaceAction(SpaceAction spaceAction) {
33 this.spaceAction = spaceAction;
37 public SpaceListenerImplBuilder setNotificationManager(NotificationManager mgr) {
38 this.notificationManager = mgr;
42 public SpaceListenerImplBuilder setLookaround(boolean lookaround) {
43 this.lookaround = lookaround;
47 public SpaceListenerImpl createSpaceListenerImpl() {
48 final SpaceListenerImpl spaceListener = new SpaceListenerImpl(capi, cref, timeout, spaceAction, notificationManager, lookaround);
49 spaceListener.startHandlingAbsenceOfNotifications();
51 notificationManager.createNotification(cref, spaceListener, Operation.WRITE);
52 } catch (Exception e) {
53 Util.handleSpaceErrorAndTerminate(e);