Example usage for javax.websocket Session getRequestURI

List of usage examples for javax.websocket Session getRequestURI

Introduction

In this page you can find the example usage for javax.websocket Session getRequestURI.

Prototype

URI getRequestURI();

Source Link

Usage

From source file:DataReceiverEndpoint.java

public void onError(Session session, Throwable throwable) {
    log.error("Error occurred in session ID: " + session.getId() + ", for request URI - "
            + session.getRequestURI() + ", " + throwable.getMessage(), throwable);
}

From source file:TopicSubscriptionEndpoint.java

public void onError(Session session, Throwable throwable, String topic, String adaptorName, int tenantId) {
    log.error("Error occurred in session ID: " + session.getId() + ", for request URI - "
            + session.getRequestURI() + ", " + throwable.getMessage(), throwable);
    websocketLocalOutputCallbackRegisterService.unsubscribe(tenantId, adaptorName, topic, session);
}

From source file:SubscriptionEndpoint.java

public void onError(Session session, Throwable throwable, String adaptorName, int tenantId) {
    log.error("Error occurred in session ID: " + session.getId() + ", for request URI - "
            + session.getRequestURI() + ", " + throwable.getMessage(), throwable);

    try {//  ww w .  j a va 2s  .  c o  m

        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId);
        websocketLocalOutputCallbackRegisterService.unsubscribe(adaptorName, session);
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}

From source file:DataReceiverEndpoint.java

public void onClose(Session session, CloseReason reason) {
    if (log.isDebugEnabled()) {
        log.debug("Closing a WebSocket due to " + reason.getReasonPhrase() + ", for session ID:"
                + session.getId() + ", for request URI - " + session.getRequestURI());
    }//from w  w  w  . j  a  v a 2 s .com
}

From source file:TopicSubscriptionEndpoint.java

public void onClose(Session session, CloseReason reason, String topic, String adaptorName, int tenantId) {
    if (log.isDebugEnabled()) {
        log.debug("Closing a WebSocket due to " + reason.getReasonPhrase() + ", for session ID:"
                + session.getId() + ", for request URI - " + session.getRequestURI());
    }// ww  w  . j  a v a2s .  c  o m
    websocketLocalOutputCallbackRegisterService.unsubscribe(tenantId, adaptorName, topic, session);
}

From source file:SubscriptionEndpoint.java

public void onClose(Session session, CloseReason reason, String adaptorName, int tenantId) {
    if (log.isDebugEnabled()) {
        log.debug("Closing a WebSocket due to " + reason.getReasonPhrase() + ", for session ID:"
                + session.getId() + ", for request URI - " + session.getRequestURI());
    }//  w  w w . j a v  a  2 s . c  o m

    try {
        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId);
        websocketLocalOutputCallbackRegisterService.unsubscribe(adaptorName, session);
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}

From source file:io.hops.hopsworks.api.zeppelin.socket.NotebookServer.java

@OnClose
public void onClose(Session conn, CloseReason reason) {
    LOG.log(Level.INFO, "Closed connection to {0} : {1}. Reason: {2}",
            new Object[] { conn.getRequestURI().getHost(), conn.getRequestURI().getPort(), reason });
    impl.removeConnectionFromAllNote(conn);
    impl.removeConnectedSockets(conn, notebookServerImplFactory);
    impl.removeUserConnection(this.hdfsUsername, conn);
    impl.removeUserConnection(project.getProjectGenericUser(), conn);
}

From source file:org.wso2.carbon.device.mgt.analytics.wsproxy.inbound.SubscriptionEndpoint.java

/**
 * Web socket onOpen - When client sends a message
 *
 * @param session         - Users registered session.
 *//* w  w w . j a va 2  s.  c  o  m*/
void onOpen(Session session) {
    if (log.isDebugEnabled()) {
        log.debug("WebSocket opened, for Session id: " + session.getId());
    }

    AnalyticsConfiguration analyticsConfig = AnalyticsConfiguration.getInstance();
    ArrayList<String> publisherGroups = DataPublisherUtil
            .getEndpointGroups(analyticsConfig.getAnalyticsPublisherUrl());
    List<AnalyticsClient> analyticsClients = new ArrayList<>();
    for (String publisherURLGroup : publisherGroups) {
        try {
            String[] endpoints = DataPublisherUtil.getEndpoints(publisherURLGroup);
            for (String endpoint : endpoints) {
                try {
                    endpoint = endpoint.trim();
                    if (!endpoint.endsWith("/")) {
                        endpoint += "/";
                    }
                    endpoint += session.getRequestURI().getSchemeSpecificPart()
                            .replace("secured-websocket-proxy", "");
                    AnalyticsClient analyticsClient = new AnalyticsClient(session, new URI(endpoint));
                    analyticsClients.add(analyticsClient);
                } catch (URISyntaxException e) {
                    log.error("Unable to create URL from: " + endpoint, e);
                } catch (WSProxyException e) {
                    log.error("Unable to create WS client for: " + endpoint, e);
                }
            }
        } catch (DataEndpointConfigurationException e) {
            log.error("Unable to obtain endpoints from receiverURLGroup: " + publisherURLGroup, e);
        }
    }
    if (log.isDebugEnabled()) {
        log.debug("Configured " + analyticsClients.size() + " analytics clients for Session id: "
                + session.getId());
    }
    analyticsClientsMap.put(session.getId(), analyticsClients);
}

From source file:org.wso2.carbon.device.mgt.analytics.wsproxy.inbound.SubscriptionEndpoint.java

/**
 * Web socket onClose - Remove the registered sessions
 *
 * @param session      - Users registered session.
 * @param reason       - Status code for web-socket close.
 * @param streamName   - StreamName extracted from the ws url.
 * @param version      - Version extracted from the ws url.
 * @param tenantDomain - Domain of the tenant.
 *///w  w  w .  j  av a 2s . c  o  m
public void onClose(Session session, CloseReason reason, String streamName, String version,
        String tenantDomain) {
    if (log.isDebugEnabled()) {
        log.debug("Closing a WebSocket due to " + reason.getReasonPhrase() + ", for session ID:"
                + session.getId() + ", for request URI - " + session.getRequestURI());
    }
    for (AnalyticsClient analyticsClient : analyticsClientsMap.get(session.getId())) {
        if (analyticsClient != null) {
            try {
                analyticsClient.closeConnection(reason);
            } catch (WSProxyException e) {
                log.error("Error occurred while closing ws connection due to " + reason.getReasonPhrase()
                        + ", for session ID:" + session.getId() + ", for request URI - "
                        + session.getRequestURI(), e);
            }
        }
    }
    analyticsClientsMap.remove(session.getId());
}

From source file:org.wso2.carbon.device.mgt.analytics.wsproxy.inbound.SubscriptionEndpoint.java

/**
 * Web socket onError/* ww  w .  j  a va2  s.c  om*/
 *
 * @param session      - Users registered session.
 * @param throwable    - Status code for web-socket close.
 * @param streamName   - StreamName extracted from the ws url.
 * @param version      - Version extracted from the ws url.
 * @param tenantDomain - Domain of the tenant.
 */
public void onError(Session session, Throwable throwable, String streamName, String version,
        String tenantDomain) {
    log.error("Error occurred in session ID: " + session.getId() + ", for request URI - "
            + session.getRequestURI() + ", " + throwable.getMessage(), throwable);
}