Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright (C) 2014 Zach Melamed
  * Latest version available online at
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package com.tectonica.gae;
PhaseListener to ensure the HttpSession data is written to the datastore.

To use, add the following to your faces-config.xml:

If properly configured, an application deployed on GAE platform can leverage HttpSessions to store data between requests. Session data is stored in the datastore and memcache is also used for speed. Session data is persisted at the end of the request.

The App Engine session implementation will not recognize if properties of objects stored in the session are changed which is why we have this PhaseListener which will modify a session attribute with the current date and time (in milliseconds) at the end of every phase.

See also:
public class GaePhaseListener implements PhaseListener
	private static final long serialVersionUID = 1L;
	public void afterPhase(PhaseEvent event)
		FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("CURRENT_TIME", System.currentTimeMillis());
	public void beforePhase(PhaseEvent event)
	public PhaseId getPhaseId()
New to GrepCode? Check out our FAQ X