- Timestamp:
- 06/24/13 13:38:40 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/remote/RemoteInstance.java
r84 r85 17 17 import com.framsticks.util.lang.Casting; 18 18 import com.framsticks.util.lang.Pair; 19 import com.framsticks.util.dispatching.RunAt; 19 20 20 21 import org.apache.commons.configuration.Configuration; … … 33 34 protected ClientConnection connection; 34 35 35 protected final Set<Pair<Path, Subscription >> subscriptions = new HashSet<Pair<Path, Subscription>>();36 37 public Pair<Path, Subscription > getSubscription(Path path) {38 for (Pair<Path, Subscription > s : subscriptions) {36 protected final Set<Pair<Path, Subscription<?>>> subscriptions = new HashSet<>(); 37 38 public Pair<Path, Subscription<?>> getSubscription(Path path) { 39 for (Pair<Path, Subscription<?>> s : subscriptions) { 39 40 if (s.first.matches(path)) { 40 41 return s; … … 67 68 } 68 69 69 invokeLater(new Run nable() {70 invokeLater(new RunAt<Instance>() { 70 71 @Override 71 72 public void run() { … … 85 86 EventParam param = getParam(simulator, "running_changed", EventParam.class); 86 87 assert param != null; 87 connection.subscribe(simulator.getTextual() + "/" + param.getId(), new LoggingSubscriptionCallback(log, "server running state change", new EventCallback() {88 connection.subscribe(simulator.getTextual() + "/" + param.getId(), RemoteInstance.this, new LoggingSubscriptionCallback<Instance>(log, "server running state change", new EventCallback() { 88 89 @Override 89 90 public void call(List<File> files) { 90 invokeLater(new Run nable() {91 invokeLater(new RunAt<Instance>() { 91 92 @Override 92 93 public void run() { … … 96 97 } 97 98 })); 98 new PeriodicTask (RemoteInstance.this, 1000) {99 new PeriodicTask<Instance>(RemoteInstance.this, 1000) { 99 100 @Override 100 101 public void run() { … … 187 188 assert param != null; 188 189 assert path.isResolved(); 189 connection.send(new GetRequest(). setField(param.getId()).setPath(path.getTextual()), this, new ResponseCallback() {190 connection.send(new GetRequest().field(param.getId()).path(path.getTextual()), this, new ResponseCallback<Instance>() { 190 191 @Override 191 192 public void process(Response response) { … … 232 233 233 234 //TODO: if the info is in the cache, then don't communicate 234 connection.send(new InfoRequest(). setPath(path.getTextual()), this, new ResponseCallback() {235 connection.send(new InfoRequest().path(path.getTextual()), this, new ResponseCallback<Instance>() { 235 236 @Override 236 237 public void process(Response response) { … … 268 269 269 270 log.trace("fetching values for " + path); 270 connection.send(new GetRequest(). setPath(path.getTextual()), this, new ResponseCallback() {271 connection.send(new GetRequest().path(path.getTextual()), this, new ResponseCallback<Instance>() { 271 272 @Override 272 273 public void process(Response response) { … … 344 345 } 345 346 346 final Pair<Path, Subscription > temporary = new Pair<Path, Subscription>(path, null);347 final Pair<Path, Subscription<?>> temporary = new Pair<>(path, null); 347 348 subscriptions.add(temporary); 348 349 349 connection.subscribe(path.getTextual() + "_changed", new SubscriptionCallback() {350 @Override 351 public EventCallback subscribed(final Subscription subscription) {350 connection.subscribe(path.getTextual() + "_changed", this, new SubscriptionCallback<Instance>() { 351 @Override 352 public EventCallback subscribed(final Subscription<? super Instance> subscription) { 352 353 if (subscription == null) { 353 354 log.error("failed to subscribe for change event for " + path); … … 355 356 } 356 357 log.debug("subscribed for change event for " + path); 357 subscription.setDispatcher(RemoteInstance.this);358 RemoteInstance.this.invokeLater(new Run nable() {358 // subscription.setDispatcher(RemoteInstance.this); 359 RemoteInstance.this.invokeLater(new RunAt<Instance>() { 359 360 @Override 360 361 public void run() { 361 362 subscriptions.remove(temporary); 362 subscriptions.add(new Pair<Path, Subscription >(path, subscription));363 subscriptions.add(new Pair<Path, Subscription<?>>(path, subscription)); 363 364 } 364 365 }); … … 459 460 460 461 log.trace("storing value " + param + " for " + path); 461 connection.send(new SetRequest().value(value.toString()). setField(param.getId()).setPath(path.getTextual()), this, new StateCallback() {462 connection.send(new SetRequest().value(value.toString()).field(param.getId()).path(path.getTextual()), this, new StateCallback<Instance>() { 462 463 @Override 463 464 public void call(Exception e) {
Note: See TracChangeset
for help on using the changeset viewer.