/** * @author Arun Gupta * * This class represents a Session Scoped CDI bean. Once injected, the container will hold on to the instance of this bean until * the HTTP session expires. A new instance would be created with start of a fresh HTTP session */ @SessionScoped public class MySessionScopedBean implements Serializable { public String getID() { return this + ""; } }
/** * @author Javier Rojas Blum Date: 02.22.2012 */ @Named @SessionScoped public class CheckSessionAction implements Serializable { private static final long serialVersionUID = 6513115606594205672L; @Inject private Logger log; private String checkSessionEndpoint; public String getCheckSessionEndpoint() { return checkSessionEndpoint; } public void setCheckSessionEndpoint(String checkSessionEndpoint) { this.checkSessionEndpoint = checkSessionEndpoint; } }
@SessionScoped public class SimpleBeanA implements Serializable { private static final long serialVersionUID = 1L; @Inject @SessionScoped private SimpleBeanZ z; public SimpleBeanZ getZ() { return z; } }
@Stateful @SessionScoped public class Cup_Broken { @Inject @SuppressWarnings("unused") private Foo foo; }
@SessionScoped public class MultiServicesManagerImpl implements MultiServicesManager, Serializable { @Inject @Any private Instance<OAuthService> serviceInstances; @Inject @Any private Instance<SocialNetworkServicesHub> hubInstances; @Inject private SeamSocialExtension socialConfig; @Produces @Named @Current private OAuthSession currentSession;
@Stateful @SessionScoped @Named("Charlie") @Default public class InitializerSimpleBean implements Serializable, InitializerSimpleBeanLocal { private static final long serialVersionUID = 1L; private static int initializerCalls = 0; @SuppressWarnings("unused") @Inject private BeanManager beanManager; @Inject public void initializer() { initializerCalls++; } public void businessMethod() { } public int getInitializerCalls() { return initializerCalls; } public void setInitializerCalls(int initializerCalls) { InitializerSimpleBean.initializerCalls = initializerCalls; } }
@Named @SessionScoped public class SimpleSessionBean extends AbstractBean implements Serializable { private static final long serialVersionUID = 1L; public void simpleMethod() { } }
/** * Locale for a User Session. Defaults to the Locale within DefaultLocale and is altered when it receives the @Changed event. * * @author Ken Finnigan */ @SessionScoped public class UserLocaleProducer implements Serializable { private static final long serialVersionUID = -7602504535585397561L; @Produces @Client @Named private Locale userLocale; @Inject public void init(Locale defaultLocale) { this.userLocale = defaultLocale; } public void changeLocale(@Observes @Alter @Client Locale lc) { this.userLocale = lc; } }
@SuppressWarnings("serial") @SessionScoped @Stateful @Named("John") public class WrappedEnterpriseBean implements WrappedEnterpriseBeanLocal { @Remove public void bye() { } }
public class WheatProducer { public @Produces @SessionScoped Wheat wheat = new Wheat(); }
@Stateful public class SessionBeanProducerFieldWithTooManyScopeTypes_Broken { @Produces @SessionScoped @ConversationScoped @Word public static String word = "producer_field"; }
@Stateful @SessionScoped public class SessionScopedSessionBean implements SessionScopedSessionInterface { @Remove public void remove() { } }
@Named @SessionScoped public class TranslateController implements Serializable { @Inject private TextTranslator textTranslator;
@SessionScoped public class SimpleBeanB implements Serializable { private static final long serialVersionUID = 1L; @Inject @SessionScoped private SimpleBeanZ z; public SimpleBeanZ getZ() { return z; } }
@Stateful @SessionScoped public class FieldInjectionCorralBroken extends Ranch { @Inject @British Cow cow; public void ping() { } }
/** * Created by wagner.araujo on 09/03/16. */ @SessionScoped @Named public class SessionInformation implements Serializable { private Map<String, Object> map = new HashMap<>(); public void put(String key, Object value) { map.put(key, value); } public Object get(String key) { return map.get(key); } public void remove(String key) { map.remove(key); } }
/** * DateTimeZone for a User Session. Defaults to the DateTimeZone within DefaultDateTimeZone and is altered when it receives the @Alter * event. * * @author Ken Finnigan */ @SessionScoped public class UserDateTimeZoneProducer implements Serializable { private static final long serialVersionUID = -9008203923830420841L; @Produces @Client @Named private DateTimeZone userDateTimeZone; @Inject public void init(DateTimeZone defaultDateTimeZone) { this.userDateTimeZone = defaultDateTimeZone; } public void alterTimeZone(@Observes @Alter @Client DateTimeZone tz) { this.userDateTimeZone = tz; } }
@SessionScoped @Stateful @Named("John") public class WrappedEnterpriseBean implements WrappedEnterpriseBeanLocal { @Remove public void bye() { } }
@Produces @SessionScoped public RTClient produceInstanceHandler() { return null; }
@Stateful @SessionScoped public class Espoo_Broken implements EspooLocal_Broken { @Remove public void bye() { } }