Package org.richfaces.application.push

Examples of org.richfaces.application.push.Session


            if ("GET".equals(httpReq.getMethod())) {

                String pushSessionId = httpReq.getParameter(PUSH_SESSION_ID_PARAM);

                Session session = null;

                if (pushSessionId != null) {
                    ensureServletContextAvailable(request);
                    PushContext pushContext = (PushContext) servletContext.getAttribute(PushContext.INSTANCE_KEY_NAME);
                    session = pushContext.getSessionManager().getPushSession(pushSessionId);
View Full Code Here


        @ArquillianResource
        PushContextFactory pushContextFactory;

        @BeforeServlet
        public void beforeServlet() throws Exception {
            Session session = getCurrentSession();
            assertEquals("messages for current session must be empty before pushing", 0, session.getMessages().size());

            // TODO should be invokable by separate session
            sendMessage("1");
        }
View Full Code Here

        }

        @AfterServlet
        public void afterServlet() throws InterruptedException {
            // TODO instead of waiting, we should be able intercept Atmosphere's onBroaddcast/.. methods
            final Session session = getCurrentSession();
            while (session.getMessages().size() > 0) {
                Thread.sleep(50);
            }
        }
View Full Code Here

        }

        private Session getCurrentSession() {
            PushContext pushContext = pushContextFactory.getPushContext();
            String pushSessionId = request.getParameter(PushHandlerFilter.PUSH_SESSION_ID_PARAM);
            Session session = pushContext.getSessionManager().getPushSession(pushSessionId);
            return session;
        }
View Full Code Here

    public Session take() throws InterruptedException {
        final ReentrantLock lock = this.lock;
        lock.lockInterruptibly();
        try {
            while (active) {
                Session first = queue.peek();
                if (first == null) {
                    available.await();
                } else {
                    long delay = getDelay(first, TimeUnit.NANOSECONDS);
                    if (delay > 0) {
                        available.awaitNanos(delay);
                    } else {
                        Session x = queue.poll();
                        assert x != null;
                        if (queue.size() != 0) {
                            available.signalAll(); // wake up other takers
                        }
                        return x;
View Full Code Here

        PushContext pushContext = pushContextFactory.getPushContext();

        String forgetPushSessionId = externalContext.getRequestParameterMap().get(FORGET_PUSH_SESSION_ID_PARAM);
        if (forgetPushSessionId != null) {
            Session oldSession = pushContext.getSessionManager().getPushSession(forgetPushSessionId);
            if (oldSession != null) {
                oldSession.invalidate();
            }
        }

        Session session = pushContext.getSessionFactory().createSession(UUID.randomUUID().toString());

        String[] topicNames = externalContext.getRequestParameterValuesMap().get(PUSH_TOPIC_PARAM);

        if (topicNames == null) {
            throw new IllegalArgumentException(PUSH_TOPIC_PARAM + " request parameter must be present");
        }

        session.subscribe(topicNames);

        Map<String, Object> subscriptionData = new HashMap<String, Object>(4);
        subscriptionData.put("sessionId", session.getId());

        Map<TopicKey, String> failedSubscriptions = session.getFailedSubscriptions();
        subscriptionData.put("failures", getFailuresMap(failedSubscriptions));

        Writer outWriter = facesContext.getExternalContext().getResponseOutputWriter();
        ScriptUtils.appendScript(outWriter, subscriptionData);
    }
View Full Code Here

        try {
            boolean exists = queue.remove(session);

            if (exists || addIfNotExists) {
                Session first = queue.peek();
                queue.offer(session);
                if (first == null || SESSIONS_COMPARATOR.compare(session, first) < 0) {
                    available.signalAll();
                }
            }
View Full Code Here

     * (non-Javadoc)
     *
     * @see org.richfaces.application.push.SessionFactory#createSession(java.lang.String)
     */
    public Session createSession(String pushSessionId) {
        Session session = new SessionImpl(pushSessionId, sessionManager, topicsContext);
        sessionManager.putPushSession(session);

        return session;
    }
View Full Code Here

     *
     * @see org.richfaces.application.push.SessionManager#putPushSession(org.richfaces.application.push.Session)
     */
    @Override
    public void putPushSession(Session session) throws IllegalStateException {
        Session existingSession = sessionMap.putIfAbsent(session.getId(), session);
        if (existingSession != null) {
            throw new IllegalStateException();
        }

        sessionQueue.requeue(session, true);
View Full Code Here

    }

    private final class SessionsExpirationRunnable implements Runnable {
        public void run() {
            try {
                Session session = sessionQueue.take();

                if (session instanceof DestroyableSession) {
                    ((DestroyableSession) session).destroy();
                }

                sessionMap.remove(session.getId());

                executorService.submit(this);
            } catch (InterruptedException e) {
                LOGGER.debug(e.getMessage(), e);
            }
View Full Code Here

TOP

Related Classes of org.richfaces.application.push.Session

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.