/** * Updates sessions corresponds to a particular member from the {@link #establishedSessions} * @param member subjected {@link Member} */ public void removeSessionsOfMember(Member member){ for (Iterator<SessionInformation> iterator = establishedSessions.values().iterator(); iterator.hasNext();) { SessionInformation info = iterator.next(); if (member.equals(info.getMember())) { //We don't want to lose sessions of this member. So we merely set the member to null and //put it back to establishedSessions so that those can be used later. info.setMember(null); iterator.remove(); establishedSessions.put(info.getId(),info); log.debug("Session associated with member " + member.toString() + " is updated ; session id : " + info.getId()); } } }
/** * Returns endpoint sequence related to the given session * * @param information Session information * @return endpoint sequence */ public List<Endpoint> getChildEndpoints(SessionInformation information) { List<Endpoint> endpoints; if (isClustered) { endpoints = getEndpoints(information.getPath(), information.getRootEndpointName()); } else { endpoints = information.getEndpointList(); } if (log.isDebugEnabled()) { log.debug("Retrieving endpoint sequence : " + endpoints + " for session " + information.getId()); } if (endpoints == null || endpoints.isEmpty()) { handleException("Session with id " + information.getId() + " is invalid ." + " A session must have a endpoint sequence associated with it"); } List<Endpoint> toBeSent = new ArrayList<Endpoint>(); toBeSent.addAll(endpoints); //remove the root as only expect children toBeSent.remove(0); return toBeSent; }
/** * Returns endpoint sequence related to the given session * * @param information Session information * @return endpoint sequence */ public List<Endpoint> getChildEndpoints(SessionInformation information) { List<Endpoint> endpoints; if (isClustered) { endpoints = getEndpoints(information.getPath(), information.getRootEndpointName()); } else { endpoints = information.getEndpointList(); } if (log.isDebugEnabled()) { log.debug("Retrieving endpoint sequence : " + endpoints + " for session " + information.getId()); } if (endpoints == null || endpoints.isEmpty()) { handleException("Session with id " + information.getId() + " is invalid ." + " A session must have a endpoint sequence associated with it"); } List<Endpoint> toBeSent = new ArrayList<Endpoint>(); toBeSent.addAll(endpoints); //remove the root as only expect children toBeSent.remove(0); return toBeSent; }
String id = information.getId(); if (log.isDebugEnabled()) { log.debug("Expired session with id :" + id);
String id = information.getId(); if (log.isDebugEnabled()) { log.debug("Expired session with id :" + id);
} else { String oldSessionID = oldSession.getId(); if (!sessionID.equals(oldSessionID)) {
} else { String oldSessionID = oldSession.getId(); if (!sessionID.equals(oldSessionID)) {
log.debug("sessionInfo object[" + sessionInfoObj.getId()+ "] found with a null member. " + "Looks like this is attached to a failed member.");
log.debug("Current session id : " + sessionInformation.getId());
log.debug("Current session id : " + sessionInformation.getId());
log.debug("Current session id : " + sessionInformation.getId());
log.debug("Current session id : " + sessionInformation.getId());
Assert.assertEquals("Session not updated!", "testCookie2", sessionInformation.getId());
/** * Test updating session with session id * * @throws Exception */ @Test public void testUpdateWithId() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); messageContext.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpoints); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); salSessions.updateSession(messageContext, "testSession"); SessionInformation sessionInformation = salSessions.getSession("testSession"); Assert.assertEquals("Session not updated!", "testSession", sessionInformation.getId()); }
/** * Test updating session with session id and old session * * @throws Exception */ @Test public void testUpdateWithOldSession() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); SessionInformation oldSessionInfo = new SessionInformation("oldTestSession", endpoints, 30000); messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo); salSessions.updateSession(messageContext, "testSession2"); SessionInformation sessionInformation = salSessions.getSession("testSession2"); Assert.assertEquals("Session not updated!", "testSession2", sessionInformation.getId()); }
Assert.assertEquals("Session not updated!", "testCookie3", sessionInformation.getId());
/** * Test updating session with session id and old session where the old session id is same as current session id * * @throws Exception */ @Test public void testUpdateWithOldSessionSameName() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); messageContext.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpoints); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); SessionInformation oldSessionInfo = new SessionInformation("testSession3", endpoints, 30000); messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo); salSessions.updateSession(messageContext, "testSession3"); SessionInformation sessionInformation = salSessions.getSession("testSession3"); Assert.assertEquals("Session not updated!", "testSession3", sessionInformation.getId()); }
/** * Test updating session with cookie * * @throws Exception */ @Test public void testUpdateWithCookie() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); messageContext.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpoints); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); SessionCookie sessionCookie = new SessionCookie(); sessionCookie.setSessionId("testCookie"); salSessions.updateSession(messageContext, sessionCookie); SessionInformation sessionInformation = salSessions.getSession("testCookie"); Assert.assertEquals("Session not updated!", "testCookie", sessionInformation.getId()); }