/** * {@inheritDoc} */ public <EventType> TimerPushNode<EventType> installNode(final Component component, final IPushEventHandler<EventType> handler) { return installNode(component, handler, _defaultPollingInterval); }
/** * @see IAjaxPushBehavior#addComponent(Component) */ public void addComponent(final Component component) { synchronized (currentTrigger) { currentTrigger.addCall(ADD_COMPONENT_METHOD, new Object[] { component }); } }
public TimerPushTarget(final Application application, final Session session, final String id, final Duration timeout) { super(); this.id = id; this.timeout = timeout; this.currentTrigger = new DelayedMethodCallList(application, session); }
public <EventType> TimerPushNode<EventType> installNode(final Component component, final IPushEventHandler<EventType> handler, final Duration pollingInterval) { TimerPushBehavior behavior = _findPushBehaviour(component); if (behavior == null) { behavior = new TimerPushBehavior(pollingInterval); component.add(behavior); } final TimerPushNode<EventType> node = behavior.addNode(handler, pollingInterval); _onConnect(node); return node; }
<EventType> TimerPushNode<EventType> addNode( final IPushEventHandler<EventType> pushEventHandler, final Duration pollingInterval) { if (pollingInterval.lessThan(getUpdateInterval())) setUpdateInterval(pollingInterval); final TimerPushNode<EventType> node = new TimerPushNode<EventType>(pollingInterval); handlers.put(node, pushEventHandler); return node; }
public void addChannelListener(final Component component, final String listenerChannel, final IChannelListener listener) { final TimerChannelBehavior timerChannelBehavior = new TimerChannelBehavior( duration); final IPushTarget pushTarget = timerChannelBehavior.newPushTarget(); component.add(timerChannelBehavior); EventStore.get().addEventStoreListener(new EventStoreListener() { public void eventTriggered(final String eventChannel, final Map<String, String> data) { if (listenerChannel.equals(eventChannel)) { listener.onEvent(listenerChannel, data, pushTarget); pushTarget.trigger(); } } }); }
int removeNode(final IPushNode<?> node) { handlers.remove(node); // adjust the polling interval based on the fastest remaining node Duration newPollingInterval = Duration.MAXIMUM; for (final TimerPushNode n : handlers.keySet()) if (n.getPollingInterval().lessThan(newPollingInterval)) newPollingInterval = n.getPollingInterval(); setUpdateInterval(newPollingInterval); return handlers.size(); }
/** * {@inheritDoc} */ public void destroy(final Application application) { TimerPushService.onApplicationShutdown(application); }
@Override protected TimerPushService lookupService() { return TimerPushService.get(); } };
public IPushTarget installPush(final Component component) { final TimerChannelBehavior tcb = new TimerChannelBehavior(duration); component.add(tcb); return tcb.newPushTarget(); }
/** * Methods used to access the triggers queued for the the behavior to * which this target corresponds. * * @return a List of triggers queued for the current component */ private List<DelayedMethodCallList> getTriggers() { return TimerChannelBehavior.getTriggers(currentTrigger.application, id); } }
public boolean isConnected() { return TimerChannelBehavior.isConnected(currentTrigger.application, id, timeout); }
/** * Invokes all the {@link DelayedMethodCall} in the list on the given * Object * * @see java.lang.reflect.Method#invoke(Object, Object[]) * @param o * the object on which delayed methods should be called * @throws IllegalArgumentException * @throws IllegalAccessException * @throws InvocationTargetException */ public void invoke(final Object o) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { for (final DelayedMethodCall dmc : calls) { dmc.invoke(o); } }
<EventType> TimerPushNode<EventType> addNode( final IPushEventHandler<EventType> pushEventHandler, final Duration pollingInterval) { if (pollingInterval.lessThan(getUpdateInterval())) setUpdateInterval(pollingInterval); final TimerPushNode<EventType> node = new TimerPushNode<EventType>(pollingInterval); handlers.put(node, pushEventHandler); return node; }
/** * {@inheritDoc} */ public <EventType> TimerPushNode<EventType> installNode(final Component component, final IPushEventHandler<EventType> handler) { return installNode(component, handler, _defaultPollingInterval); }
/** * @see IAjaxPushBehavior#focusComponent(Component) */ public void focusComponent(final Component component) { synchronized (currentTrigger) { currentTrigger.addCall(FOCUS_COMPONENT_METHOD, new Object[] { component }); } }
/** * @see IAjaxPushBehavior#addComponent(Component, String) */ public void addComponent(final Component component, final String markupId) { synchronized (currentTrigger) { currentTrigger.addCall(ADD_COMPONENT_WITH_MARKUP_ID_METHOD, new Object[] { component, markupId }); } }
/** * @see IAjaxPushBehavior#appendJavascript(String) */ public void appendJavascript(final String javascript) { synchronized (currentTrigger) { currentTrigger.addCall(APPEND_JAVASCRIPT_METHOD, new Object[] { javascript }); } }
/** * @see IAjaxPushBehavior#prependJavascript(String) */ public void prependJavascript(final String javascript) { synchronized (currentTrigger) { currentTrigger.addCall(PREPEND_JAVASCRIPT_METHOD, new Object[] { javascript }); } }