01: package org.vraptor.scope;
02:
03: import org.vraptor.LogicRequest;
04:
05: /**
06: * All scope types for injection and outjection.
07: *
08: * @author Guilherme Silveira
09: * @author Paulo Silveira
10: */
11: public enum ScopeType {
12: /**
13: * Uses variables in the HttpServletRequest attributes, and also in the
14: * parameters, if not found as attribute.
15: */
16: REQUEST {
17: public Context getContext(LogicRequest request) {
18: return request.getRequestContext();
19: }
20: },
21: /**
22: * Uses variables in the HttpSession
23: */
24: SESSION {
25: public Context getContext(LogicRequest request) {
26: return request.getSessionContext();
27: }
28:
29: }
30:
31: ,
32: /**
33: * Use variables in the servletContext.
34: */
35: APPLICATION {
36: public Context getContext(LogicRequest request) {
37: return request.getApplicationContext();
38: }
39:
40: }
41:
42: ,
43: FLASH {
44: public Context getContext(LogicRequest request) {
45: return request.getFlashContext();
46: }
47:
48: };
49:
50: /**
51: * Returns the repective context for the given ScopeType
52: *
53: * @param request
54: * @return
55: */
56: public abstract Context getContext(LogicRequest request);
57: }
|