protected final void doOnOpen(Session session, EndpointConfig config) { PojoMethodMapping methodMapping = getMethodMapping(); Object pojo = getPojo(); Map<String,String> pathParameters = getPathParameters(); if (methodMapping.getOnOpen() != null) { try { methodMapping.getOnOpen().invoke(pojo, methodMapping.getOnOpenArgs( pathParameters, session, config)); } catch (IllegalAccessException e) { // Reflection related problems log.error(sm.getString( "pojoEndpointBase.onOpenFail", pojo.getClass().getName()), e); handleOnOpenError(session, e); return; } catch (InvocationTargetException e) { Throwable cause = e.getCause(); handleOnOpenError(session, cause); return; } catch (Throwable t) { handleOnOpenError(session, t); return; } } for (MessageHandler mh : methodMapping.getMessageHandlers(pojo, pathParameters, session, config)) { session.addMessageHandler(mh); } }
private void handleOnOpenError(Session session, Throwable t) { // If really fatal - re-throw ExceptionUtils.handleThrowable(t); // Trigger the error handler and close the session onError(session, t); try { session.close(); } catch (IOException ioe) { WebsocketsLogger.ROOT_LOGGER.closeSessionFailed(ioe); } }
protected final void doOnOpen(Session session, EndpointConfig config) { PojoMethodMapping methodMapping = getMethodMapping(); Object pojo = getPojo(); Map<String,String> pathParameters = getPathParameters(); // Add message handlers before calling onOpen since that may trigger a // message which in turn could trigger a response and/or close the // session for (MessageHandler mh : methodMapping.getMessageHandlers(pojo, pathParameters, session, config)) { session.addMessageHandler(mh); } if (methodMapping.getOnOpen() != null) { try { methodMapping.getOnOpen().invoke(pojo, methodMapping.getOnOpenArgs( pathParameters, session, config)); } catch (IllegalAccessException e) { // Reflection related problems log.error(sm.getString( "pojoEndpointBase.onOpenFail", pojo.getClass().getName()), e); handleOnOpenOrCloseError(session, e); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); handleOnOpenOrCloseError(session, cause); } catch (Throwable t) { handleOnOpenOrCloseError(session, t); } } }
@Override public final void onClose(Session session, CloseReason closeReason) { if (methodMapping.getOnClose() != null) { try { methodMapping.getOnClose().invoke(pojo, methodMapping.getOnCloseArgs(pathParameters, session, closeReason)); } catch (Throwable t) { log.error(sm.getString("pojoEndpointBase.onCloseFail", pojo.getClass().getName()), t); handleOnOpenOrCloseError(session, t); } } // Trigger the destroy method for any associated decoders Set<MessageHandler> messageHandlers = session.getMessageHandlers(); for (MessageHandler messageHandler : messageHandlers) { if (messageHandler instanceof PojoMessageHandlerWholeBase<?>) { ((PojoMessageHandlerWholeBase<?>) messageHandler).onClose(); } } }
@Override public final void onClose(Session session, CloseReason closeReason) { if (methodMapping.getOnClose() != null) { try { methodMapping.getOnClose().invoke(pojo, methodMapping.getOnCloseArgs(pathParameters, session, closeReason)); } catch (Throwable t) { log.error(sm.getString("pojoEndpointBase.onCloseFail", pojo.getClass().getName()), t); handleOnOpenOrCloseError(session, t); } } // Trigger the destroy method for any associated decoders Set<MessageHandler> messageHandlers = session.getMessageHandlers(); for (MessageHandler messageHandler : messageHandlers) { if (messageHandler instanceof PojoMessageHandlerWholeBase<?>) { ((PojoMessageHandlerWholeBase<?>) messageHandler).onClose(); } } }
protected final void doOnOpen(Session session, EndpointConfig config) { PojoMethodMapping methodMapping = getMethodMapping(); Object pojo = getPojo(); Map<String,String> pathParameters = getPathParameters(); "pojoEndpointBase.onOpenFail", pojo.getClass().getName()), e); handleOnOpenError(session, e); return; } catch (InvocationTargetException e) { Throwable cause = e.getCause(); handleOnOpenError(session, cause); return; } catch (Throwable t) { handleOnOpenError(session, t); return;
protected final void doOnOpen(Session session, EndpointConfig config) { PojoMethodMapping methodMapping = getMethodMapping(); Object pojo = getPojo(); Map<String,String> pathParameters = getPathParameters(); // Add message handlers before calling onOpen since that may trigger a // message which in turn could trigger a response and/or close the // session for (MessageHandler mh : methodMapping.getMessageHandlers(pojo, pathParameters, session, config)) { session.addMessageHandler(mh); } if (methodMapping.getOnOpen() != null) { try { methodMapping.getOnOpen().invoke(pojo, methodMapping.getOnOpenArgs( pathParameters, session, config)); } catch (IllegalAccessException e) { // Reflection related problems log.error(sm.getString( "pojoEndpointBase.onOpenFail", pojo.getClass().getName()), e); handleOnOpenOrCloseError(session, e); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); handleOnOpenOrCloseError(session, cause); } catch (Throwable t) { handleOnOpenOrCloseError(session, t); } } }
private void handleOnOpenError(Session session, Throwable t) { // If really fatal - re-throw ExceptionUtils.handleThrowable(t); // Trigger the error handler and close the session onError(session, t); try { session.close(); } catch (IOException ioe) { log.warn(sm.getString("pojoEndpointBase.closeSessionFail"), ioe); } }
protected final void doOnOpen(Session session, EndpointConfig config) { PojoMethodMapping methodMapping = getMethodMapping(); Object pojo = getPojo(); Map<String,String> pathParameters = getPathParameters(); handleOnOpenError(session, e); return; } catch (InvocationTargetException e) { Throwable cause = e.getCause(); handleOnOpenError(session, cause); return; } catch (Throwable t) { handleOnOpenError(session, t); return; } finally {
private void handleOnOpenOrCloseError(Session session, Throwable t) { // If really fatal - re-throw ExceptionUtils.handleThrowable(t); // Trigger the error handler and close the session onError(session, t); try { session.close(); } catch (IOException ioe) { log.warn(sm.getString("pojoEndpointBase.closeSessionFail"), ioe); } }
private void handleOnOpenOrCloseError(Session session, Throwable t) { // If really fatal - re-throw ExceptionUtils.handleThrowable(t); // Trigger the error handler and close the session onError(session, t); try { session.close(); } catch (IOException ioe) { log.warn(sm.getString("pojoEndpointBase.closeSessionFail"), ioe); } }
private void handleOnOpenError(Session session, Throwable t) { // If really fatal - re-throw ExceptionUtils.handleThrowable(t); // Trigger the error handler and close the session onError(session, t); try { session.close(); } catch (IOException ioe) { log.warn(sm.getString("pojoEndpointBase.closeSessionFail"), ioe); } }
private void handleOnCloseError(Session session, Throwable t) { try { // If really fatal - re-throw ExceptionUtils.handleThrowable(t); // Trigger the error handler and close the session onError(session, t); try { session.close(); } catch (IOException ioe) { WebsocketsLogger.ROOT_LOGGER.closeSessionFailed(ioe); } } finally { if(instanceHandle != null) { instanceHandle.release(); instanceHandle = null; } } }