SHOW:
|
|
- or go back to the newest paste.
1 | /** | |
2 | * Interface para implementação de sessão | |
3 | * @author fernando | |
4 | * | |
5 | */ | |
6 | @RemoteServiceRelativePath("sessaocurriculum") | |
7 | public interface SessionService extends RemoteService{ | |
8 | void setNome(String nome); | |
9 | void setCpf(String cpf); | |
10 | void setDataCadastro(String data); | |
11 | ||
12 | String getNome(); | |
13 | String getCpf(); | |
14 | String getDataCadastro(); | |
15 | ||
16 | void sairSessao(); | |
17 | } | |
18 | ||
19 | ||
20 | /** | |
21 | * Async de sessão | |
22 | * @author fernando | |
23 | * | |
24 | */ | |
25 | ||
26 | public interface SessionServiceAsync{ | |
27 | void setNome(String nome, AsyncCallback<Void> callback); | |
28 | void setCpf(String cpf, AsyncCallback<Void> callback); | |
29 | void setDataCadastro(String data, AsyncCallback<Void> callback); | |
30 | ||
31 | void getNome(AsyncCallback<String> callback); | |
32 | void getCpf(AsyncCallback<String> callback); | |
33 | void getDataCadastro(AsyncCallback<String> callback); | |
34 | ||
35 | void sairSessao(AsyncCallback<Void> callback); | |
36 | } | |
37 | ||
38 | ||
39 | /** | |
40 | * Implementação da sessão no server | |
41 | * @author fernando | |
42 | * | |
43 | */ | |
44 | public class SessionServiceImpl extends RemoteServiceServlet implements SessionService{ | |
45 | private HttpServletRequest request; | |
46 | private HttpSession session; | |
47 | ||
48 | public SessionServiceImpl(){ | |
49 | request = this.getThreadLocalRequest(); | |
50 | session = request.getSession(); | |
51 | session.setMaxInactiveInterval(30000); | |
52 | } | |
53 | ||
54 | @Override | |
55 | public void setNome(String nome) { | |
56 | // TODO Auto-generated method stub | |
57 | session.setAttribute("nome", nome); | |
58 | ||
59 | } | |
60 | ||
61 | @Override | |
62 | public void setCpf(String cpf) { | |
63 | // TODO Auto-generated method stub | |
64 | session.setAttribute("cpf", cpf); | |
65 | ||
66 | } | |
67 | ||
68 | @Override | |
69 | public void setDataCadastro(String data) { | |
70 | // TODO Auto-generated method stub | |
71 | session.setAttribute("datacadastro", data); | |
72 | } | |
73 | ||
74 | @Override | |
75 | public String getNome() { | |
76 | // TODO Auto-generated method stub | |
77 | return (String) session.getAttribute("nome"); | |
78 | } | |
79 | ||
80 | @Override | |
81 | public String getCpf() { | |
82 | // TODO Auto-generated method stub | |
83 | return (String) session.getAttribute("cpf"); | |
84 | } | |
85 | ||
86 | @Override | |
87 | public String getDataCadastro() { | |
88 | // TODO Auto-generated method stub | |
89 | return (String) session.getAttribute("datacadastro"); | |
90 | } | |
91 | ||
92 | @Override | |
93 | public void sairSessao() { | |
94 | // TODO Auto-generated method stub | |
95 | session.invalidate(); | |
96 | } | |
97 | - | } |
97 | + | |
98 | ||
99 | ||
100 | //web.xml | |
101 | <servlet> | |
102 | <servlet-name>ibgcurriculuns</servlet-name> | |
103 | <servlet-class>br.ind.ibg.server.SessionServiceImpl</servlet-class> | |
104 | </servlet> | |
105 | ||
106 | <servlet-mapping> | |
107 | <servlet-name>ibgcurriculuns</servlet-name> | |
108 | <url-pattern>/br.ind.ibg.Main/sessaocurriculum</url-pattern> | |
109 | </servlet-mapping> |