/** * Constructs an element with the specified id. * * @param id the id representing this element. */ AbstractContextElement(URI id) { this.setId(id); context = null; }
/** * Returns a copy of the set of observers of this element. * * @return a copy of the set of observers of this element. */ protected Set<ContextObserverCallback> getAllObservers() { synchronized (observersLock) { Set<ContextObserverCallback> clone = setUpObservers(); clone.addAll(observers); return clone; } }
/** * Notifies a {@code ContextEvent} from this element with the specified event type and argument. * * @param eventType the event type of the {@code ContextEvent}. * @param arg the argument to attach to the {@code ContextEvent}. * @see ContextEvent */ protected void notifyElementUpdated(int eventType, Object arg) { synchronized (observersLock) { for (ContextObserverCallback observer : observers) FaerieExecutorService.getExecutorService().execute( createNotifyElementUpdatedTask(observer, eventType, arg)); } }
@Override public void run() { ContextEvent event = createContextEvent(eventType, arg); if ((observer.handle(event) & ContextObserver.HANDLE_READ) != 0) observer.elementUpdated(event); } }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); observers = setUpObservers(); }