Package org.jboss.errai.bus.server

Examples of org.jboss.errai.bus.server.QueueSession


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        String sessionId = request.getSession().getId();
        final QueueSession session = sessionProvider.getSession(request.getSession());
        PrintWriter attach = response.getWriter();

        if (context == null) {

            context = createCometContext(sessionId);
View Full Code Here


                    try {

                        System.out.println("getQueue !!!!!! first try block");

                        Set<HttpServletResponse> activeSessEvents;
                        QueueSession session;
                        session = queueToSession.get(queue);
                        if (session == null) {
                            System.out.println("getQueue !!!!!! session is null");

                            queue.stopQueue();
View Full Code Here

        QueueSession session = message.getResource(QueueSession.class, "Session");
        session.setAttribute(ErraiService.SESSION_AUTH_DATA, loginSubject);
    }

    public boolean isAuthenticated(Message message) {
        QueueSession session = message.getResource(QueueSession.class, "Session");
        return session != null && session.hasAttribute(ErraiService.SESSION_AUTH_DATA);
    }
View Full Code Here

            e.printStackTrace();
        }
    }

    private void addAuthenticationToken(Message message, AuthSubject loginSubject) {
        QueueSession session = message.getResource(QueueSession.class, "Session");
        session.setAttribute(ErraiService.SESSION_AUTH_DATA, loginSubject);
    }
View Full Code Here

     * @throws IOException      - thrown if there is a read/write error
     * @throws ServletException - thrown if a servlet error occurs
     */
    public void event(final CometEvent event) throws IOException, ServletException {
        final HttpServletRequest request = event.getHttpServletRequest();
        final QueueSession session = sessionProvider.getSession(request.getSession());

        MessageQueue queue;
        switch (event.getEventType()) {
            case BEGIN:
                boolean post = "POST".equals(request.getMethod());
                if ((queue = getQueue(session, !post)) != null) {
                    synchronized (activeEvents) {
                        Set<CometEvent> events = activeEvents.get(session);


                        if (post) {
                            // do not pause incoming messages.
                            break;
                        } else if (queue.messagesWaiting()) {
                            transmitMessages(event.getHttpServletResponse(), queue);
                            event.close();
                            break;
                        }

                        if (!queueToSession.containsKey(queue)) {
                            queueToSession.put(queue, session);
                        }

                        if (events == null) {
                            activeEvents.put(session, events = new HashSet<CometEvent>());
                        }
                        if (events.contains(event)) {
                            break;
                        } else {
                            event.setTimeout(30000);
                            events.add(event);
                        }
                    }
                } else {
                    sendDisconnectWithReason(event.getHttpServletResponse().getOutputStream(),
                            "There is no queue associated with this session.");
                }
                break;

            case END:
                event.close();
                synchronized (activeEvents) {
                    Set<CometEvent> evt = activeEvents.get(session);
                    if (evt != null && !evt.remove(event)) {
                        return;
                    }
                }

                if ((queue = getQueue(session, false)) != null) {
                    queue.heartBeat();
                } else {
                    return;
                }


                break;

            case ERROR:
                log.error("An Error Occured: " + (event != null ? event.getEventSubType() : "<null>"));

                queue = getQueue(session, false);
                if (queue == null) {
                    return;
                }

                synchronized (activeEvents) {
                    Set<CometEvent> evt = activeEvents.get(session);
                    if (evt != null && !evt.remove(event)) {
                        return;
                    }
                }

                if (event.getEventSubType() == CometEvent.EventSubType.TIMEOUT) {
                    if (queue != null) queue.heartBeat();
                } else {
                    if (queue != null) {
                        queueToSession.remove(queue);
                        service.getBus().closeQueue(session.getSessionId());
                        activeEvents.remove(session);
                    }

                }

View Full Code Here

                    resumed = true;
                    queue.setActivationCallback(null);

                    try {
                        Set<CometEvent> activeSessEvents;
                        QueueSession session;
                        session = queueToSession.get(queue);
                        if (session == null) {
                            log.error("Could not resume: No session.");
                            queue.stopQueue();
                            return;
View Full Code Here

     * @throws IOException      - thrown if there is a read/write error
     * @throws ServletException - thrown if a servlet error occurs
     */
    public void event(final HttpEvent event) throws IOException, ServletException {
        final HttpServletRequest request = event.getHttpServletRequest();
        final QueueSession session = sessionProvider.getSession(request.getSession());

        MessageQueue queue;
        switch (event.getType()) {
            case BEGIN:
                boolean post = "POST".equals(request.getMethod());
                queue = getQueue(session, !post);
                if (queue == null) {
                    sendDisconnectWithReason(event.getHttpServletResponse().getOutputStream(),
                            "There is no queue associated with this session.");
                }

                synchronized (activeEvents) {

                    if (post) {
                        // do not pause incoming messages.
                        break;
                    } else if (queue.messagesWaiting()) {
                        transmitMessages(event.getHttpServletResponse(), queue);
                        event.close();
                        break;
                    }

                    if (!queueToSession.containsKey(queue)) {
                        queueToSession.put(queue, session);
                    }


                    Set<HttpEvent> events = activeEvents.get(session);
                    if (events == null) {
                        activeEvents.put(session, events = new LinkedHashSet<HttpEvent>());
                    }

                    if (events.contains(event)) {
                        event.close();
                    } else {
                        events.add(event);
                    }
                }
                break;


            case END:
                if ((queue = getQueue(session, false)) != null) {
                    queue.heartBeat();
                }

                synchronized (activeEvents) {
                    Set<HttpEvent> evt = activeEvents.get(session);
                    if (evt != null) {
                        evt.remove(event);
                    }
                }

                event.close();
                break;

            case EOF:
                event.close();
                break;

            case TIMEOUT:
            case ERROR:
                queue = getQueue(session, false);

                synchronized (activeEvents) {
                    Set<HttpEvent> evt = activeEvents.get(session);
                    if (evt != null) {
                        evt.remove(event);
                    }
                }

                if (event.getType() == HttpEvent.EventType.TIMEOUT) {
                    if (queue != null) queue.heartBeat();
                } else {
                    if (queue != null) {
                        queueToSession.remove(queue);
                        service.getBus().closeQueue(session.getSessionId());
                        //   session.invalidate();
                        activeEvents.remove(session);
                    }
                    log.error("An Error Occured" + event.getType());
                }
View Full Code Here

                    queue.setActivationCallback(null);

                    //     log.info("Attempt to resume queue: " + queue.hashCode());
                    try {
                        Set<HttpEvent> activeSessEvents;
                        QueueSession session;
                        session = queueToSession.get(queue);
                        if (session == null) {
                            log.error("Could not resume: No session.");
                            return;
                        }
View Full Code Here

TOP

Related Classes of org.jboss.errai.bus.server.QueueSession

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.