/** * Returns the number of observe relations that this resource has to CoAP * clients. * * @return the observer count */ public int getObserverCount() { return observeRelations.getSize(); }
@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 removeObserveRelation(ObserveRelation relation) { observeRelations.remove(relation); for (ResourceObserver obs:observers) obs.removedObserveRelation(relation); }
/** * Constructs a new resource with the specified name and makes it visible to * clients if the flag is true. * * @param name the name * @param visible if the resource is visible */ public CoapResource(String name, boolean visible) { this.name = name; this.path = ""; this.visible = visible; this.attributes = new ResourceAttributes(); this.children = new ConcurrentHashMap<String, Resource>(); this.observers = new CopyOnWriteArrayList<ResourceObserver>(); this.observeRelations = new ObserveRelationContainer(); this.notificationOrderer = new ObserveNotificationOrderer(); }
@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); }
@Override public void removeObserveRelation(ObserveRelation relation) { observeRelations.remove(relation); for (ResourceObserver obs:observers) obs.removedObserveRelation(relation); }
/** * Constructs a new resource with the specified name and makes it visible to * clients if the flag is true. * * @param name the name * @param visible if the resource is visible */ public CoapResource(String name, boolean visible) { this.name = name; this.path = ""; this.setVisible(visible); this.attributes = new ResourceAttributes(); this.children = new ConcurrentHashMap<String, Resource>(); this.observers = new CopyOnWriteArrayList<ResourceObserver>(); this.observeRelations = new ObserveRelationContainer(); this.notificationOrderer = new ObserveNotificationOrderer(); }
/** * Returns the number of observe relations that this resource has to CoAP * clients. * * @return the observer count */ public int getObserverCount() { return observeRelations.getSize(); }