Skip to content

Commit a23fc91

Browse files
committed
Merge pull request #213 from abhirockzz/cdi_scope_branch
Cdi scope branch
2 parents b050b37 + 6082a92 commit a23fc91

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MyApplicationScopedBean.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@
3939
*/
4040
package org.javaee7.cdi.bean.scopes;
4141

42-
import javax.enterprise.context.RequestScoped;
42+
import javax.enterprise.context.ApplicationScoped;
4343

4444
/**
4545
* @author Arun Gupta
46+
*
47+
* This class represents an Application Scoped CDI bean. Once injected, the container will hold on to the instance of this bean until
48+
* the application itself terminates (server restart/redeployment of the application).
4649
*/
47-
@RequestScoped
50+
@ApplicationScoped
4851
public class MyApplicationScopedBean {
4952
public String getID() {
5053
return this + "";

cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MyRequestScopedBean.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343

4444
/**
4545
* @author Arun Gupta
46+
*
47+
* This class represents a Request Scoped CDI bean. The container will create a new instance of this bean for every single HTTP request.
4648
*/
4749
@RequestScoped
4850
public class MyRequestScopedBean {

cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MySessionScopedBean.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@
3939
*/
4040
package org.javaee7.cdi.bean.scopes;
4141

42-
import javax.enterprise.context.RequestScoped;
42+
import java.io.Serializable;
43+
import javax.enterprise.context.SessionScoped;
4344

4445
/**
4546
* @author Arun Gupta
47+
*
48+
* This class represents a Session Scoped CDI bean. Once injected, the container will hold on to the instance of this bean until
49+
* the HTTP session expires. A new instance would be created with start of a fresh HTTP session
4650
*/
47-
@RequestScoped
48-
public class MySessionScopedBean {
51+
@SessionScoped
52+
public class MySessionScopedBean implements Serializable{
4953
public String getID() {
5054
return this + "";
5155
}

0 commit comments

Comments
 (0)