Search in sources :

Example 26 with Session

use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.

the class DevTool method onActionFromKill.

Object onActionFromKill() {
    if (!productionMode) {
        Session session = request.getSession(false);
        if (session == null) {
            alertManager.info("No server-side session currently exist.");
        } else {
            session.invalidate();
            alertManager.info("Server-side session invalidated.");
        }
    }
    return devmodezone.getBody();
}
Also used : Session(org.apache.tapestry5.http.services.Session)

Example 27 with Session

use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.

the class FlashPersistentFieldStrategyTest method post_change_to_root_component.

@Test
public void post_change_to_root_component() {
    Session session = mockSession();
    Request request = mockRequest();
    Object value = new Object();
    train_getSession(request, true, session);
    session.setAttribute("flash:foo.Bar::field", value);
    replay();
    PersistentFieldStrategy strategy = new FlashPersistentFieldStrategy(request);
    strategy.postChange("foo.Bar", null, "field", value);
    verify();
}
Also used : PersistentFieldStrategy(org.apache.tapestry5.services.PersistentFieldStrategy) Request(org.apache.tapestry5.http.services.Request) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Example 28 with Session

use of org.apache.tapestry5.http.services.Session in project tapestry5-hotel-booking by ccordenier.

the class BasicAuthenticator method logout.

public void logout() {
    Session session = request.getSession(false);
    if (session != null) {
        session.setAttribute(AUTH_TOKEN, null);
        session.invalidate();
    }
}
Also used : Session(org.apache.tapestry5.services.Session)

Example 29 with Session

use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.

the class AbstractSessionPersistentFieldStrategy method discardChanges.

public void discardChanges(String pageName) {
    Session session = request.getSession(false);
    if (session == null)
        return;
    String fullPrefix = prefix + pageName + ":";
    for (String name : session.getAttributeNames(fullPrefix)) {
        session.setAttribute(name, null);
    }
}
Also used : Session(org.apache.tapestry5.http.services.Session)

Example 30 with Session

use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.

the class AbstractSessionPersistentFieldStrategy method gatherFieldChanges.

public final Collection<PersistentFieldChange> gatherFieldChanges(String pageName) {
    Session session = request.getSession(false);
    if (session == null)
        return Collections.emptyList();
    List<PersistentFieldChange> result = newList();
    String fullPrefix = prefix + pageName + ":";
    for (String name : session.getAttributeNames(fullPrefix)) {
        Object persistedValue = session.getAttribute(name);
        Object applicationValue = persistedValue == null ? null : convertPersistedToApplicationValue(persistedValue);
        PersistentFieldChange change = buildChange(name, applicationValue);
        result.add(change);
        didReadChange(session, name);
    }
    return result;
}
Also used : PersistentFieldChange(org.apache.tapestry5.services.PersistentFieldChange) Session(org.apache.tapestry5.http.services.Session)

Aggregations

Test (org.testng.annotations.Test)31 Session (org.apache.tapestry5.http.services.Session)30 Request (org.apache.tapestry5.http.services.Request)14 HttpSession (javax.servlet.http.HttpSession)10 Logger (org.slf4j.Logger)8 ClusteredSessionImpl (org.apache.tapestry5.http.internal.services.ClusteredSessionImpl)7 Session (org.hibernate.Session)7 SessionImpl (org.apache.tapestry5.http.internal.services.SessionImpl)6 ApplicationStatePersistenceStrategy (org.apache.tapestry5.services.ApplicationStatePersistenceStrategy)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 Resource (org.apache.tapestry5.commons.Resource)5 SessionLock (org.apache.tapestry5.http.internal.services.SessionLock)5 MutableComponentModel (org.apache.tapestry5.model.MutableComponentModel)5 HibernateEntityValueEncoder (org.apache.tapestry5.hibernate.web.internal.HibernateEntityValueEncoder)4 ReadOnlyBean (org.apache.tapestry5.internal.transform.pages.ReadOnlyBean)4 EntityPersistentFieldStrategy (org.apache.tapestry5.hibernate.web.internal.EntityPersistentFieldStrategy)3 RequestImpl (org.apache.tapestry5.http.internal.services.RequestImpl)3 TapestrySessionFactory (org.apache.tapestry5.http.internal.services.TapestrySessionFactory)3 PersistentFieldChange (org.apache.tapestry5.services.PersistentFieldChange)3 Enumeration (java.util.Enumeration)2