All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.seam.contexts.SessionContext Maven / Gradle / Ivy

There is a newer version: 3.2.26.ayg
Show newest version
/*
 * JBoss, Home of Professional Open Source
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.seam.contexts;

import java.util.ArrayList;
import java.util.Map;

import org.jboss.seam.ScopeType;
import org.jboss.seam.Seam;

/**
 * Session context - state associated with a user session.
 * Session state may be passivated or replicated.
 * 
 * @author Gavin King
 */
public class SessionContext extends BasicContext {

	public SessionContext(Map map) {
		super(ScopeType.SESSION, map);
	}

	@Override
	public String[] getNames() {
		ArrayList results = new ArrayList();
		String prefix = ScopeType.CONVERSATION.getPrefix();
		for (String name : super.getNames()) {
			if (!name.contains(prefix)) {
				results.add(name);
			}
		}
		return results.toArray(new String[] {});
	}

	@Override
	public void flush() {
		for (String name : getNames()) {
			Object attribute = get(name);
			boolean dirty = attribute != null && (Contexts.isAttributeDirty(attribute) || Seam.isEntityClass(attribute.getClass()));
			if (dirty) {
				set(name, attribute);
			}
		}
	}

	@Override
	public String toString() {
		return "SessionContext";
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy