/** * Removes the specified observe relation. * * @param relation the observe relation * @return true, if successful */ public boolean remove(ObserveRelation relation) { if (relation == null) throw new NullPointerException(); return observeRelations.remove(relation.getKey(), relation); }
/** * Removes the specified observe relation. * * @param relation the observe relation * @return true, if successful */ public boolean remove(ObserveRelation relation) { if (relation == null) throw new NullPointerException(); return observeRelations.remove(relation.getKey(), relation); }
/** * Adds the specified observe relation. * * @param relation the observe relation * @return true, if a old relation was replaced by the provided one, * false, if the provided relation was added. */ public boolean add(ObserveRelation relation) { if (relation == null) throw new NullPointerException(); ObserveRelation previous = observeRelations.put(relation.getKey(), relation); if (null != previous) { previous.cancel(); return true; } return false; }
/** * Adds the specified observe relation. * * @param relation the observe relation * @return true, if a old relation was replaced by the provided one, * false, if the provided relation was added. */ public boolean add(ObserveRelation relation) { if (relation == null) throw new NullPointerException(); ObserveRelation previous = observeRelations.put(relation.getKey(), relation); if (null != previous) { previous.cancel(); return true; } return false; }
@Override public void addObserveRelation(ObserveRelation relation) { if (observeRelations.add(relation)) { LOGGER.log(Level.INFO, "Replacing observe relation between {0} and resource {1}", new Object[]{relation.getKey(), getURI()}); } else { LOGGER.log(Level.INFO, "Successfully established observe relation between {0} and resource {1}", new Object[]{relation.getKey(), getURI()}); } for (ResourceObserver obs:observers) obs.addedObserveRelation(relation); }
@Override public void addObserveRelation(ObserveRelation relation) { if (observeRelations.add(relation)) { LOGGER.info("Replacing observe relation between "+relation.getKey()+" and resource "+getURI()); } else { LOGGER.info("Successfully established observe relation between "+relation.getKey()+" and resource "+getURI()); } for (ResourceObserver obs:observers) obs.addedObserveRelation(relation); }
/** * Cancel this observe relation. This methods invokes the cancel methods of * the resource and the endpoint. */ public void cancel() { LOGGER.log(Level.FINE, "Canceling observe relation {0} with {1}", new Object[]{getKey(), resource.getURI()}); // stop ongoing retransmissions if (exchange.getResponse()!=null) exchange.getResponse().cancel(); setEstablished(false); resource.removeObserveRelation(this); endpoint.removeObserveRelation(this); exchange.setComplete(); }
/** * Cancel this observe relation. This methods invokes the cancel methods of * the resource and the endpoint. */ public void cancel() { LOGGER.fine("Canceling observe relation "+getKey()+" with "+resource.getURI()); // stop ongoing retransmissions if (exchange.getResponse()!=null) exchange.getResponse().cancel(); setEstablished(false); resource.removeObserveRelation(this); endpoint.removeObserveRelation(this); exchange.setComplete(); }