Commit 49e5b7fca7e9cb4bca8c970c96b0b4726fec009c
1 parent
986983e5
Exists in
master
Ajustes no layout do texto.
Showing
16 changed files
with
219 additions
and
326 deletions
Show diff stats
documentation/reference/pt-BR/arquetipo.xml
... | ... | @@ -38,7 +38,7 @@ |
38 | 38 | <section> |
39 | 39 | <title>Vaadin com JPA</title> |
40 | 40 | <para> |
41 | - Uma das principais novidades com relação à esta nova versão do Framework Demoiselle | |
41 | + Uma das principais novidades com relação à esta nova versão do <emphasis>Demoiselle Framework</emphasis> | |
42 | 42 | é sua integração mais completa à outras tecnologias de apresentação. Na versão anterior |
43 | 43 | apesar de ser possível a utilização de outra soluções, não havia ainda facilitadores realmente integrados ao Demoiselle. |
44 | 44 | Seguindo este princípio, um dos arquétipos disponibilizados pelo Framework gera uma aplicação de exemplo, nos mesmo moldes | ... | ... |
documentation/reference/pt-BR/bookinfo.xml
... | ... | @@ -9,7 +9,9 @@ |
9 | 9 | <abstract>Demoiselle 2.3.0: Framework de Código Aberto para o Desenvolvimento de Aplicações Java EE 6</abstract> |
10 | 10 | <titleabbrev>Demoiselle 2.3.0 - Guia de Referência</titleabbrev> |
11 | 11 | |
12 | + <!-- | |
12 | 13 | <xi:include href="revhistory.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> |
14 | + --> | |
13 | 15 | <xi:include href="authorgroup.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> |
14 | 16 | |
15 | 17 | </bookinfo> | ... | ... |
documentation/reference/pt-BR/bundle.xml
... | ... | @@ -67,7 +67,7 @@ button.save=Salvar]]></programlisting> |
67 | 67 | <programlisting role="JAVA"><![CDATA[@Inject |
68 | 68 | @Name("messages-core") |
69 | 69 | private ResourceBundle bundle; |
70 | - | |
70 | + | |
71 | 71 | public String metodoQueRetornaOValorDaChavebuttonedit() { |
72 | 72 | return bundle.getString("button.edit"); |
73 | 73 | }]]></programlisting> |
... | ... | @@ -75,9 +75,8 @@ public String metodoQueRetornaOValorDaChavebuttonedit() { |
75 | 75 | Utilizando Resource Bundle sem uso de injeção: |
76 | 76 | </para> |
77 | 77 | <programlisting role="JAVA"><![CDATA[private ResourceBundleFactory bundleFactory = new ResourceBundleFactory(Locale.getDefault()); |
78 | - | |
79 | 78 | private ResourceBundle bundle; |
80 | - | |
79 | + | |
81 | 80 | public String metodoQueRetornaOValorDaChavebuttonedit() { |
82 | 81 | bundle = bundleFactory.create("messages-core"); |
83 | 82 | return bundle.getString("button.edit"); | ... | ... |
documentation/reference/pt-BR/configuracao.xml
... | ... | @@ -77,17 +77,13 @@ |
77 | 77 | public class BookmarkConfig { |
78 | 78 | |
79 | 79 | private String applicationTitle; |
80 | - | |
81 | 80 | private boolean loadInitialData; |
82 | - | |
83 | 81 | public String getApplicationTitle() { |
84 | 82 | return applicationTitle; |
85 | 83 | } |
86 | - | |
87 | 84 | public boolean isLoadInitialData() { |
88 | 85 | return loadInitialData; |
89 | 86 | } |
90 | - | |
91 | 87 | }]]></programlisting> |
92 | 88 | <para> |
93 | 89 | Na classe os atributos devem ser tratados como sendo somente de leitura, possuindo apenas seus respectivos métodos |
... | ... | @@ -193,7 +189,6 @@ public class BookmarkConfig { |
193 | 189 | public boolean isLoadInitialData() { |
194 | 190 | return loadInitialData; |
195 | 191 | } |
196 | - | |
197 | 192 | }]]></programlisting> |
198 | 193 | <calloutlist> |
199 | 194 | <callout arearefs="resource-prefix"> |
... | ... | @@ -258,7 +253,6 @@ general.load.initial.data = true |
258 | 253 | ... |
259 | 254 | } |
260 | 255 | } |
261 | - | |
262 | 256 | }]]></programlisting> |
263 | 257 | <note> |
264 | 258 | <para> |
... | ... | @@ -302,7 +296,6 @@ public class EscolaConfig { |
302 | 296 | public List<String> getPapeis() { |
303 | 297 | return papeis; |
304 | 298 | } |
305 | - | |
306 | 299 | }]]></programlisting> |
307 | 300 | </section> |
308 | 301 | |
... | ... | @@ -332,7 +325,6 @@ public class EscolaConfig { |
332 | 325 | public String getJavaDirectory() { |
333 | 326 | return javaDirectory; |
334 | 327 | } |
335 | - | |
336 | 328 | }]]></programlisting> |
337 | 329 | </section> |
338 | 330 | ... | ... |
documentation/reference/pt-BR/excecao.xml
... | ... | @@ -17,18 +17,14 @@ |
17 | 17 | <para> |
18 | 18 | Para um correto funcionamento do Demoiselle é necessário inserir o interceptador de exceção no arquivo <filename>src/main/WEB-INF/beans.xml</filename>. |
19 | 19 | </para> |
20 | - <programlisting role="XML"> | |
21 | - <![CDATA[ | |
22 | - <beans xmlns="http://java.sun.com/xml/ns/javaee" | |
23 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee | |
25 | - http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
26 | - <interceptors> | |
27 | - <class>br.gov.frameworkdemoiselle.internal.interceptor.ExceptionHandlerInterceptor</class> | |
28 | - </interceptors> | |
29 | - </beans> | |
30 | - ]]> | |
31 | - </programlisting> | |
20 | + <programlisting role="XML"><![CDATA[<beans xmlns="http://java.sun.com/xml/ns/javaee" | |
21 | +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
22 | +xsi:schemaLocation="http://java.sun.com/xml/ns/javaee | |
23 | + http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
24 | + <interceptors> | |
25 | + <class>br.gov.frameworkdemoiselle.internal.interceptor.ExceptionHandlerInterceptor</class> | |
26 | + </interceptors> | |
27 | +</beans>]]></programlisting> | |
32 | 28 | </section> |
33 | 29 | |
34 | 30 | <section> |
... | ... | @@ -43,13 +39,9 @@ public class Simples { |
43 | 39 | |
44 | 40 | @ExceptionHandler |
45 | 41 | public void tratador(NullPointerException cause) { } |
46 | - | |
47 | 42 | public void inserir() { } |
48 | - | |
49 | 43 | public void alterar() { } |
50 | - | |
51 | 44 | public void excluir() { } |
52 | - | |
53 | 45 | }]]></programlisting> |
54 | 46 | <para> |
55 | 47 | Neste exemplo, qualquer exceção do tipo <literal>NullPointerException</literal> que ocorrer nos métodos |
... | ... | @@ -68,16 +60,11 @@ public class Simples { |
68 | 60 | |
69 | 61 | @ExceptionHandler |
70 | 62 | public void tratador(NullPointerException cause) { } |
71 | - | |
72 | 63 | @ExceptionHandler |
73 | - public void tratador(AbacaxiException cause) { } | |
74 | - | |
75 | - public void inserir() { } | |
76 | - | |
77 | - public void alterar() { } | |
78 | - | |
79 | - public void excluir() { } | |
80 | - | |
64 | + public void tratador(AbacaxiException cause) { } | |
65 | + public void inserir() { } | |
66 | + public void alterar() { } | |
67 | + public void excluir() { } | |
81 | 68 | }]]></programlisting> |
82 | 69 | <para> |
83 | 70 | Caso as exceções <literal>NullPointerException</literal> ou <literal>AbacaxiException</literal> ocorram |
... | ... | @@ -100,7 +87,6 @@ public class Simples { |
100 | 87 | |
101 | 88 | @ExceptionHandler |
102 | 89 | public void tratador(NullPointerException cause) { } |
103 | - | |
104 | 90 | public void inserir() { |
105 | 91 | try { |
106 | 92 | // tenta algo |
... | ... | @@ -108,11 +94,8 @@ public class Simples { |
108 | 94 | // trata o problema |
109 | 95 | } |
110 | 96 | } |
111 | - | |
112 | 97 | public void alterar() { } |
113 | - | |
114 | 98 | public void excluir() { } |
115 | - | |
116 | 99 | }]]></programlisting> |
117 | 100 | <para> |
118 | 101 | Neste caso a exceção <literal>AbacaxiException</literal> só será tratada no método <literal>inserir()</literal>. | ... | ... |
documentation/reference/pt-BR/inicializacao.xml
... | ... | @@ -48,7 +48,7 @@ |
48 | 48 | Eis um exemplo de implementação de inicializador em uma aplicação: |
49 | 49 | </para> |
50 | 50 | <programlisting role="JAVA"><![CDATA[public class BookmarkInitializer { |
51 | - | |
51 | + | |
52 | 52 | @Startup |
53 | 53 | @Priority(1) |
54 | 54 | public void initialize() { |
... | ... | @@ -60,7 +60,6 @@ |
60 | 60 | public void finalize() { |
61 | 61 | ... |
62 | 62 | } |
63 | - | |
64 | 63 | }]]></programlisting> |
65 | 64 | <tip> |
66 | 65 | <para> |
... | ... | @@ -106,7 +105,6 @@ public class DatabaseServer { |
106 | 105 | public void shutdown() { |
107 | 106 | server.stop(); |
108 | 107 | } |
109 | - | |
110 | 108 | }]]></programlisting> |
111 | 109 | </section> |
112 | 110 | ... | ... |
documentation/reference/pt-BR/intro.xml
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | <section> |
9 | 9 | <title>O que é o Demoiselle?</title> |
10 | 10 | <para> |
11 | - O framework Demoiselle implementa o conceito de | |
11 | + O <emphasis>Demoiselle Framework</emphasis> implementa o conceito de | |
12 | 12 | <emphasis>framework integrador</emphasis>. |
13 | 13 | Seu objetivo é facilitar a construção de aplicações minimizando tempo dedicado à escolha e integração de frameworks |
14 | 14 | especialistas, o que resulta no aumento da produtividade e garante a manutenibilidade dos sistemas. Disponibiliza |
... | ... | @@ -23,7 +23,7 @@ |
23 | 23 | técnicas para qualquer pessoa que se interessasse. |
24 | 24 | </para> |
25 | 25 | <para> |
26 | - O <emphasis>framework Demoiselle</emphasis> usa a mesma filosofia do <quote>Pai da Aviação</quote>, tendo sido | |
26 | + O <emphasis>Demoiselle Framework</emphasis> usa a mesma filosofia do <quote>Pai da Aviação</quote>, tendo sido | |
27 | 27 | disponibilizado como software livre em abril de 2009, sob a licença livre LGPL version 3. Mais informações no portal |
28 | 28 | <ulink url="http://www.frameworkdemoiselle.gov.br">"www.frameworkdemoiselle.gov.br</ulink> |
29 | 29 | </para> |
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | <title>Sobre a versão 2</title> |
34 | 34 | <para> |
35 | 35 | O principal objetivo da versão 2 do |
36 | - <emphasis>framework Demoiselle</emphasis> | |
36 | + <emphasis>Demoiselle Framework</emphasis> | |
37 | 37 | é a completa aderência à especificação |
38 | 38 | <ulink url="http://jcp.org/en/jsr/detail?id=316">JSR 316: Java Platform, Enterprise Edition 6</ulink>, ou simplesmente |
39 | 39 | <emphasis>Java EE 6</emphasis>. Para saber mais, recomendamos os links | ... | ... |
documentation/reference/pt-BR/logger.xml
documentation/reference/pt-BR/master.xml
... | ... | @@ -14,16 +14,35 @@ |
14 | 14 | </para> |
15 | 15 | <note> |
16 | 16 | <para> |
17 | - Esta documentação refere-se à release 2.3 do <emphasis>Framework Demoiselle</emphasis> | |
17 | + Esta documentação refere-se à release 2.3.0 do <emphasis>Demoiselle Framework</emphasis> | |
18 | 18 | e pode diferir significativamente das versões anteriores. |
19 | 19 | </para> |
20 | 20 | </note> |
21 | 21 | </preface> |
22 | 22 | |
23 | 23 | <toc /> |
24 | + | |
25 | + <xi:include href="intro.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
26 | + <xi:include href="arquitetura.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
27 | + <xi:include href="parentsPom.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
28 | + <xi:include href="arquetipo.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
29 | + <xi:include href="controlador.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
30 | + <xi:include href="transacao.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
31 | + <xi:include href="excecao.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
32 | + <xi:include href="configuracao.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
33 | + <xi:include href="inicializacao.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
34 | + <xi:include href="mensagem.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
35 | + <xi:include href="bundle.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
36 | + <xi:include href="parametro.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
37 | + <xi:include href="logger.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
38 | + <xi:include href="templates.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
39 | + <xi:include href="security.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
40 | + <xi:include href="paginacao.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
41 | + <xi:include href="properties.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> | |
24 | 42 | |
25 | 43 | <!-- parte 1 --> |
26 | 44 | <!-- TODO: dividir melhor os capítulos em seções --> |
45 | +<!-- | |
27 | 46 | <part id="1"> |
28 | 47 | <title>Framework</title> |
29 | 48 | <xi:include href="intro.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> |
... | ... | @@ -44,6 +63,8 @@ |
44 | 63 | <xi:include href="paginacao.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> |
45 | 64 | <xi:include href="properties.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> |
46 | 65 | </part> |
66 | +--> | |
67 | + | |
47 | 68 | <!-- parte 2 --> |
48 | 69 | <!-- <part id="2">--> |
49 | 70 | <!-- <title>Componentes</title>--> | ... | ... |
documentation/reference/pt-BR/mensagem.xml
... | ... | @@ -122,9 +122,7 @@ private MessageContext messageContext;]]></programlisting> |
122 | 122 | <programlisting role="JAVA"><![CDATA[public interface Message { |
123 | 123 | |
124 | 124 | String getText(); |
125 | - | |
126 | 125 | SeverityType getSeverity(); |
127 | - | |
128 | 126 | }]]></programlisting> |
129 | 127 | <para> |
130 | 128 | A classe <literal>DefaultMessage</literal> fornecida pelo <emphasis>Demoiselle Framework</emphasis> |
... | ... | @@ -145,7 +143,6 @@ private MessageContext messageContext;]]></programlisting> |
145 | 143 | exemplo disso utilizando a classe <literal>DefaultMessage</literal>: |
146 | 144 | </para> |
147 | 145 | <programlisting role="JAVA"><![CDATA[Message message = new DefaultMessage("Ocorreu um erro ao excluir o aluno!", SeverityType.ERROR); |
148 | - | |
149 | 146 | messageContext.add(message);]]></programlisting> |
150 | 147 | <para> |
151 | 148 | Uma vez inseridas no contexto em determinada camada da aplicação, as mensagens podem ser posteriormente |
... | ... | @@ -204,14 +201,11 @@ messageContext.add(message);]]></programlisting> |
204 | 201 | da mensagem e ao inseri-la no contexto especificar os parâmetros: |
205 | 202 | </para> |
206 | 203 | <programlisting role="JAVA"><![CDATA[Message message = new DefaultMessage("Aluno {0} inserido com sucesso"); |
207 | - | |
208 | 204 | messageContext.add(message, aluno.getNome());]]></programlisting> |
209 | 205 | <para> |
210 | 206 | Eis um exemplo mais avançado do uso de parametrizações em mensagens: |
211 | 207 | </para> |
212 | - <programlisting role="JAVA"><![CDATA[Message message = new DefaultMessage( | |
213 | - "As {1,time} do dia {1,date,short} houve {2} na turma {0}"); | |
214 | - | |
208 | + <programlisting role="JAVA"><![CDATA[Message message = new DefaultMessage("As {1,time} do dia {1,date,short} houve {2} na turma {0}"); | |
215 | 209 | messageContext.add(message, new Integer(502), new Date(), "falta de professor");]]></programlisting> |
216 | 210 | <para> |
217 | 211 | O resultado da execução deste código seria um texto como: |
... | ... | @@ -245,7 +239,6 @@ messageContext.add(message, new Integer(502), new Date(), "falta de professor"); |
245 | 239 | chaves, tal como no exemplo a seguir: |
246 | 240 | </para> |
247 | 241 | <programlisting role="JAVA"><![CDATA[Message message = new DefaultMessage("{ALUNO_INSERIR_OK}"); |
248 | - | |
249 | 242 | messageContext.add(message, aluno.getNome());]]></programlisting> |
250 | 243 | <para> |
251 | 244 | Ou seja, ao invés de usar a string literal, passamos o identificador da chave presente no arquivo de propriedades. |
... | ... | @@ -333,7 +326,6 @@ ALUNO_EXCLUIR_OK = L'étudiant {0} a été supprimé avec succès]]></programlis |
333 | 326 | final Message BOOKMARK_DELETE_OK = new DefaultMessage("{BOOKMARK_DELETE_OK}"); |
334 | 327 | final Message BOOKMARK_INSERT_OK = new DefaultMessage("{BOOKMARK_INSERT_OK}"); |
335 | 328 | final Message BOOKMARK_UPDATE_OK = new DefaultMessage("{BOOKMARK_UPDATE_OK}"); |
336 | - | |
337 | 329 | }]]></programlisting> |
338 | 330 | <para> |
339 | 331 | No exemplo em questão, o texto das mensagens será recuperado do arquivo de recursos <filename>messages.properties</filename> |
... | ... | @@ -375,7 +367,6 @@ BOOKMARK_UPDATE_OK = Bookmark atualizado: {0}]]></programlisting> |
375 | 367 | public SeverityType getSeverity() { |
376 | 368 | return msg.getSeverity(); |
377 | 369 | } |
378 | - | |
379 | 370 | }]]></programlisting> |
380 | 371 | <para> |
381 | 372 | A fim de adicionar mensagens ao contexto, eis um exemplo de código que faz uso do artefato <literal>InfoMessages</literal>, |
... | ... | @@ -413,7 +404,6 @@ public class BookmarkBC { |
413 | 404 | messageContext.add(InfoMessages.BOOKMARK_DELETE_OK, |
414 | 405 | bookmark.getDescription()); |
415 | 406 | } |
416 | - | |
417 | 407 | }]]></programlisting> |
418 | 408 | <calloutlist> |
419 | 409 | <callout arearefs="inject-context"> | ... | ... |
documentation/reference/pt-BR/paginacao.xml
... | ... | @@ -73,101 +73,77 @@ |
73 | 73 | </itemizedlist> |
74 | 74 | </para> |
75 | 75 | |
76 | - <para>Códigos internos de suporte no Core:</para> | |
77 | - | |
78 | - <programlisting role="JAVA"><![CDATA[ | |
79 | - public class Pagination { | |
80 | - | |
81 | - private int currentPage; | |
82 | - private int pageSize; | |
83 | - | |
84 | - private Long totalResults; | |
85 | - private Integer totalPages; | |
86 | - | |
87 | - // ... | |
88 | - } | |
89 | - | |
90 | - @SessionScoped | |
91 | - public class PaginationContext { | |
92 | - | |
93 | - private final Map<Class<?>, Pagination> map; | |
94 | - | |
95 | - public Pagination getPagination(Class<?> clazz) { ... } | |
96 | - | |
97 | - public Pagination getPagination(Class<?> clazz, boolean create) { ... } | |
98 | - | |
99 | - } | |
100 | - | |
101 | - @Configuration | |
102 | - public class PaginationConfig { | |
103 | - | |
104 | - @Key("default_page_size") | |
105 | - private int defaultPageSize = 10; | |
106 | - | |
107 | - @Key("max_page_links") | |
108 | - private int maxPageLinks = 5; | |
109 | - | |
110 | - } | |
111 | - ]]></programlisting> | |
112 | - | |
113 | - <para>Códigos internos de suporte em JPA:</para> | |
114 | - | |
115 | - <programlisting role="JAVA"><![CDATA[ | |
116 | - public class JPACrud<T, I> implements Crud<T, I> { | |
117 | - | |
118 | - @Inject | |
119 | - private PaginationContext paginationContext; | |
120 | - | |
121 | - // ... | |
122 | - | |
123 | - public List<T> findAll() { | |
124 | - | |
125 | - final String jpql = "select this from " + getBeanClass().getSimpleName() + " this"; | |
126 | - final Query query = getEntityManager().createQuery(jpql); | |
127 | - | |
128 | - final Pagination pagination = paginationContext.getPagination(getBeanClass()); | |
129 | - if (pagination != null) { | |
130 | - if (pagination.getTotalPages() == null) { | |
131 | - pagination.setTotalResults(this.countAll()); | |
132 | - } | |
133 | - query.setFirstResult(pagination.getFirstResult()); | |
134 | - query.setMaxResults(pagination.getPageSize()); | |
135 | - } | |
136 | - | |
137 | - // ... | |
138 | - } | |
139 | - | |
76 | + <para>Códigos internos de suporte no Core:</para><programlisting role="JAVA"><![CDATA[public class Pagination { | |
77 | + | |
78 | + private int currentPage; | |
79 | + private int pageSize; | |
80 | + private Long totalResults; | |
81 | + private Integer totalPages; | |
82 | + // ... | |
83 | +} | |
84 | + | |
85 | +@SessionScoped | |
86 | +public class PaginationContext { | |
87 | + | |
88 | + private final Map<Class<?>, Pagination> map; | |
89 | + public Pagination getPagination(Class<?> clazz) { ... } | |
90 | + public Pagination getPagination(Class<?> clazz, boolean create) { ... } | |
91 | +} | |
92 | + | |
93 | +@Configuration | |
94 | +public class PaginationConfig { | |
95 | + | |
96 | + @Key("default_page_size") | |
97 | + private int defaultPageSize = 10; | |
98 | + | |
99 | + @Key("max_page_links") | |
100 | + private int maxPageLinks = 5; | |
101 | +}]]></programlisting> | |
102 | + | |
103 | + <para>Códigos internos de suporte em JPA:</para><programlisting role="JAVA"><![CDATA[public class JPACrud<T, I> implements Crud<T, I> { | |
104 | + | |
105 | + @Inject | |
106 | + private PaginationContext paginationContext; | |
107 | + // ... | |
108 | + | |
109 | + public List<T> findAll() { | |
110 | + | |
111 | + final String jpql = "select this from " + getBeanClass().getSimpleName() + " this"; | |
112 | + final Query query = getEntityManager().createQuery(jpql); | |
113 | + final Pagination pagination = paginationContext.getPagination(getBeanClass()); | |
114 | + | |
115 | + if (pagination != null) { | |
116 | + if (pagination.getTotalPages() == null) { | |
117 | + pagination.setTotalResults(this.countAll()); | |
140 | 118 | } |
141 | - ]]></programlisting> | |
119 | + query.setFirstResult(pagination.getFirstResult()); | |
120 | + query.setMaxResults(pagination.getPageSize()); | |
121 | + } | |
122 | + // ... | |
123 | + } | |
124 | +}]]></programlisting> | |
142 | 125 | |
143 | - <para>Códigos internos de suporte em JSF:</para> | |
144 | - | |
145 | - <programlisting role="JAVA"><![CDATA[ | |
146 | - public abstract class AbstractListPageBean<T, I> extends AbstractPage | |
147 | - implements ListPageBean<T, I> { | |
148 | - | |
149 | - @Inject | |
150 | - private PaginationContext paginationContext; | |
151 | - | |
152 | - @Inject | |
153 | - private PaginationConfig paginationConfig; | |
154 | - | |
155 | - // ... | |
156 | - | |
157 | - public Pagination getPagination() { | |
158 | - return paginationContext.getPagination(getBeanClass(), true); | |
159 | - } | |
160 | - | |
161 | - public int getPageSize() { | |
162 | - return paginationConfig.getDefaultPageSize(); | |
163 | - } | |
164 | - | |
165 | - public int getMaxPageLinks() { | |
166 | - return paginationConfig.getMaxPageLinks(); | |
167 | - } | |
168 | - | |
169 | - } | |
170 | - ]]></programlisting> | |
126 | + <para>Códigos internos de suporte em JSF:</para><programlisting role="JAVA"><![CDATA[public abstract class AbstractListPageBean<T, I> extends AbstractPage implements ListPageBean<T, I> { | |
127 | + | |
128 | + @Inject | |
129 | + private PaginationContext paginationContext; | |
130 | + | |
131 | + @Inject | |
132 | + private PaginationConfig paginationConfig; | |
133 | + // ... | |
134 | + | |
135 | + public Pagination getPagination() { | |
136 | + return paginationContext.getPagination(getBeanClass(), true); | |
137 | + } | |
138 | + | |
139 | + public int getPageSize() { | |
140 | + return paginationConfig.getDefaultPageSize(); | |
141 | + } | |
142 | + | |
143 | + public int getMaxPageLinks() { | |
144 | + return paginationConfig.getMaxPageLinks(); | |
145 | + } | |
146 | +}]]></programlisting> | |
171 | 147 | </section> |
172 | 148 | |
173 | 149 | <section> |
... | ... | @@ -194,73 +170,54 @@ |
194 | 170 | </para> |
195 | 171 | <para> |
196 | 172 | À classe <emphasis>BookmarkList</emphasis> devem ser adicionados os seguintes trechos de código: |
197 | - </para> | |
198 | - | |
199 | - <programlisting role="JAVA"><![CDATA[ | |
200 | - // ... | |
201 | - import java.util.Map; | |
202 | - import br.gov.frameworkdemoiselle.pagination.Pagination; | |
203 | - | |
204 | - // ... | |
205 | - private LazyDataModel<Bookmark> lazyModel; | |
206 | - | |
207 | - public BookmarkListMB() { | |
208 | - lazyModel = new LazyDataModel<Bookmark>() { | |
209 | - | |
210 | - @Override | |
211 | - public List<Bookmark> load (int first, int pageSize, String sortField, | |
212 | - SortOrder sortOrder, Map<String, String> filters){ | |
213 | - | |
214 | - Pagination pagination = getPagination(); | |
215 | - pagination.setPageSize(pageSize); | |
216 | - pagination.setFirstResult(first); | |
217 | - | |
218 | - List<Bookmark> itemsList = bc.findAll(); | |
219 | - | |
220 | - lazyModel.setRowCount(pagination.getTotalResults()); | |
221 | - | |
222 | - return itemsList; | |
223 | - } | |
224 | - }; | |
225 | - } | |
226 | - | |
227 | - // ... | |
228 | - | |
229 | - public LazyDataModel<Bookmark> getLazyModel() { | |
230 | - return lazyModel; | |
231 | - } | |
232 | - | |
233 | - // ... | |
234 | - ]]></programlisting> | |
173 | + </para><programlisting role="JAVA"><![CDATA[// ... | |
174 | +import java.util.Map; | |
175 | +import br.gov.frameworkdemoiselle.pagination.Pagination; | |
176 | +// ... | |
177 | + | |
178 | +public BookmarkListMB() { | |
179 | + | |
180 | + private LazyDataModel<Bookmark> lazyModel; | |
181 | + lazyModel = new LazyDataModel<Bookmark>() { | |
182 | + | |
183 | + @Override | |
184 | + public List<Bookmark> load (int first, int pageSize, String sortField, | |
185 | + SortOrder sortOrder, Map<String, String> filters){ | |
186 | + | |
187 | + Pagination pagination = getPagination(); | |
188 | + pagination.setPageSize(pageSize); | |
189 | + pagination.setFirstResult(first); | |
190 | + | |
191 | + List<Bookmark> itemsList = bc.findAll(); | |
192 | + | |
193 | + lazyModel.setRowCount(pagination.getTotalResults()); | |
194 | + | |
195 | + return itemsList; | |
196 | + } | |
197 | + }; | |
198 | + // ... | |
199 | + public LazyDataModel<Bookmark> getLazyModel() { | |
200 | + return lazyModel; | |
201 | + } | |
202 | + // ... | |
203 | +}]]></programlisting> | |
235 | 204 | |
236 | 205 | <para> |
237 | 206 | No arquivo <literal>messages.properties</literal> adicione as linhas: |
238 | - </para> | |
239 | - | |
240 | - <programlisting role="JAVA"><![CDATA[ | |
241 | - page.first=0 | |
242 | - page.rows=4 | |
243 | - page.max.links=3 | |
244 | - ]]></programlisting> | |
245 | - | |
207 | + </para><programlisting role="JAVA"><![CDATA[page.first=0 | |
208 | +page.rows=4 | |
209 | +page.max.links=3]]></programlisting> | |
246 | 210 | <para> |
247 | 211 | Na página JSF <literal>bookmark_list.xhtml</literal>, substitua a linha: |
248 | 212 | </para> |
249 | - | |
250 | - <programlisting role="JAVA"><![CDATA[ | |
251 | - <p:dataTable id="list" var="bean" value="#{bookmarkListMB.resultList}"> | |
252 | - ]]></programlisting> | |
213 | + <programlisting role="JAVA"><![CDATA[<p:dataTable id="list" var="bean" value="#{bookmarkListMB.resultList}">]]></programlisting> | |
253 | 214 | |
254 | 215 | <para> |
255 | 216 | por: |
256 | - </para> | |
257 | - | |
258 | - <programlisting role="JAVA"><![CDATA[ | |
259 | - <p:dataTable id="list" var="bean" | |
260 | - value="#{bookmarkListMB.lazyModel}" lazy="true" paginator="true" | |
261 | - first="#{messages['page.first']}" rows="#{messages['page.rows']}" | |
262 | - pageLinks="#{messages['page.max.links']}"> | |
263 | - ]]></programlisting> | |
217 | + </para><programlisting role="JAVA"><![CDATA[<p:dataTable id="list" var="bean" | |
218 | +value="#{bookmarkListMB.lazyModel}" lazy="true" paginator="true" | |
219 | +first="#{messages['page.first']}" rows="#{messages['page.rows']}" | |
220 | +pageLinks="#{messages['page.max.links']}">]]></programlisting> | |
264 | 221 | |
265 | 222 | <para> |
266 | 223 | Com essas alterações simples, a aplicação Bookmarks passa a utilizar o mecanismo de paginação oferecido pelo <emphasis>Demoiselle Framework</emphasis>. | ... | ... |
documentation/reference/pt-BR/parametro.xml
... | ... | @@ -20,13 +20,12 @@ |
20 | 20 | Captura do parâmetro pelo Page Bean |
21 | 21 | </para> |
22 | 22 | <programlisting role="JAVA"><![CDATA[public class Classe { |
23 | - | |
23 | + | |
24 | 24 | public void metodo() { |
25 | 25 | FacesContext context = FacesContext.getCurrentInstance(); |
26 | 26 | HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest(); |
27 | 27 | String param = req.getParameter("parametro"); |
28 | 28 | } |
29 | - | |
30 | 29 | }]]></programlisting> |
31 | 30 | |
32 | 31 | <section> |
... | ... | @@ -54,16 +53,15 @@ http://localhost:8080/aplicacao/pagina.jsf?parametroString=valorParametroString] |
54 | 53 | Captura do parâmetro pelo Page Bean |
55 | 54 | </para> |
56 | 55 | <programlisting role="JAVA"><![CDATA[public class Classe { |
57 | - | |
56 | + | |
58 | 57 | @ViewScoped |
59 | 58 | @Inject |
60 | 59 | private Parameter<Long> parametro; |
61 | - | |
60 | + | |
62 | 61 | @Name("parametroString") |
63 | 62 | @SessionScoped |
64 | 63 | @Inject |
65 | 64 | private Parameter<String> objetoComNomeDiferenteDoParametro; |
66 | - | |
67 | 65 | }]]></programlisting> |
68 | 66 | </section> |
69 | 67 | |
... | ... | @@ -78,15 +76,14 @@ http://localhost:8080/aplicacao/pagina.jsf?parametroString=valorParametroString] |
78 | 76 | <function>getValue()</function>, tal como mostrado a seguir: |
79 | 77 | </para> |
80 | 78 | <programlisting role="JAVA"><![CDATA[public class Classe { |
81 | - | |
79 | + | |
82 | 80 | @ViewScoped |
83 | 81 | @Inject |
84 | 82 | private Parameter<Long> parametro; |
85 | - | |
83 | + | |
86 | 84 | public void metodo() { |
87 | 85 | System.out.println("Valor do parâmetro: " + parametro.getValue()); |
88 | 86 | } |
89 | - | |
90 | 87 | }]]></programlisting> |
91 | 88 | </section> |
92 | 89 | ... | ... |
documentation/reference/pt-BR/parentsPom.xml
... | ... | @@ -21,7 +21,11 @@ |
21 | 21 | <para>Seguindo esse conceito, foram criados alguns arquivos (pom.xml) e também disponibilizados no repositório Maven do Demoiselle , que facilitam a configuração dos projetos, e inclusive para o desenvolvimento do próprio Demoiselle. |
22 | 22 | Os arquivos gerados foram divididos em perfis, para que o desenvolvedor possa escolher qual usar de acordo com o tipo de aplicação que está desenvolvendo. |
23 | 23 | Assim, a alteração no POM.XML da aplicação será a minima possível. Outra vantagem, é que as bibliotecas apontadas como dependências são testadas pela equipe do Demoiselle o que evita eventuais incompatibilidades.</para> |
24 | - <tip>Para excluir uma dependência vinda do Parent, mas não necessária utilize a tag Exclusions </tip> | |
24 | + <tip> | |
25 | + <para> | |
26 | + Para excluir uma dependência vinda do Parent, mas não necessária utilize a tag Exclusions | |
27 | + </para> | |
28 | + </tip> | |
25 | 29 | |
26 | 30 | <section> |
27 | 31 | <title>Demoiselle-Minimal-Parent</title> | ... | ... |
documentation/reference/pt-BR/security.xml
... | ... | @@ -22,19 +22,15 @@ |
22 | 22 | <para> |
23 | 23 | Para um correto funcionamento do Demoiselle é necessário inserir os interceptadores de segurança no arquivo <filename>src/main/WEB-INF/beans.xml</filename>. |
24 | 24 | </para> |
25 | - <programlisting role="XML"> | |
26 | - <![CDATA[ | |
27 | - <beans xmlns="http://java.sun.com/xml/ns/javaee" | |
28 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
29 | - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee | |
30 | - http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
31 | - <interceptors> | |
32 | - <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredPermissionInterceptor</class> | |
33 | - <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredRoleInterceptor</class> | |
34 | - </interceptors> | |
35 | - </beans> | |
36 | - ]]> | |
37 | - </programlisting> | |
25 | + <programlisting role="XML"><![CDATA[<beans xmlns="http://java.sun.com/xml/ns/javaee" | |
26 | +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
27 | +xsi:schemaLocation="http://java.sun.com/xml/ns/javaee | |
28 | + http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
29 | + <interceptors> | |
30 | + <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredPermissionInterceptor</class> | |
31 | + <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredRoleInterceptor</class> | |
32 | + </interceptors> | |
33 | +</beans>]]></programlisting> | |
38 | 34 | </section> |
39 | 35 | |
40 | 36 | <section> |
... | ... | @@ -66,11 +62,8 @@ |
66 | 62 | public class Credential { |
67 | 63 | |
68 | 64 | private String login; |
69 | - | |
70 | 65 | private String senha; |
71 | - | |
72 | 66 | // ... |
73 | - | |
74 | 67 | }]]></programlisting> |
75 | 68 | <para> |
76 | 69 | Feito isso, podemos implementar a classe na qual se deseja adicionar o mecanismo de segurança: |
... | ... | @@ -90,7 +83,6 @@ public class Credential { |
90 | 83 | // codigo do metodo |
91 | 84 | context.logout(); |
92 | 85 | } |
93 | - | |
94 | 86 | }]]></programlisting> |
95 | 87 | <para> |
96 | 88 | Neste caso, a interface SecurityContext e o bean Credential estão sendo injetados na classe utilizando o CDI. |
... | ... | @@ -129,7 +121,6 @@ public class Credential { |
129 | 121 | @RequiredPermission(resource = "contact", operation = "insert") |
130 | 122 | public void requiredPermissionWithDeclaredResourceAndOperation() { |
131 | 123 | } |
132 | - | |
133 | 124 | }]]></programlisting> |
134 | 125 | <para> |
135 | 126 | Observe o método cuja anotação não possui parâmetros. Nesse caso serão considerados como recurso e operação o nome da classe e |
... | ... | @@ -158,7 +149,6 @@ public class Credential { |
158 | 149 | @RequiredRole({ "firstRole", "secondRole", "thirdRole", "fourthRole", "fifthRole" }) |
159 | 150 | public void requiredRoleWithArrayOfRoles() { |
160 | 151 | } |
161 | - | |
162 | 152 | }]]></programlisting> |
163 | 153 | <para> |
164 | 154 | As restrições de segurança pode ser utilizadas, ainda, em páginas web, com o auxílio de Expression Language, como no |
... | ... | @@ -183,8 +173,7 @@ public class Credential { |
183 | 173 | a implementação, e torna essa classe a implementação padrão dessas interfaces:<!-- Essas classes devem ser |
184 | 174 | anotadas com @Alternative para que o CDI saiba que se trata de uma estratégia: --> |
185 | 175 | </para> |
186 | - <programlisting role="JAVA"><![CDATA[ | |
187 | -public class MeuAuthenticator implements Authenticator { | |
176 | + <programlisting role="JAVA"><![CDATA[public class MeuAuthenticator implements Authenticator { | |
188 | 177 | |
189 | 178 | @Override |
190 | 179 | public boolean authenticate() { |
... | ... | @@ -201,12 +190,9 @@ public class MeuAuthenticator implements Authenticator { |
201 | 190 | @Override |
202 | 191 | public void unAuthenticate() { |
203 | 192 | // Escreva aqui seu codigo de desautenticacao |
204 | - | |
205 | 193 | } |
206 | - | |
207 | 194 | }]]></programlisting> |
208 | - <programlisting role="JAVA"><![CDATA[ | |
209 | -public class MeuAuthorizer implements Authorizer { | |
195 | + <programlisting role="JAVA"><![CDATA[public class MeuAuthorizer implements Authorizer { | |
210 | 196 | |
211 | 197 | @Override |
212 | 198 | public boolean hasRole(String role) { |
... | ... | @@ -219,7 +205,6 @@ public class MeuAuthorizer implements Authorizer { |
219 | 205 | // Escreva aqui seu codigo de verificação de permissao |
220 | 206 | return false; |
221 | 207 | } |
222 | - | |
223 | 208 | }]]></programlisting> |
224 | 209 | <!-- <para> |
225 | 210 | Feito isso deve-se definir no arquivo <filename>demoiselle.properties</filename>, as classes criadas: |
... | ... | @@ -236,10 +221,8 @@ public class MeuAuthorizer implements Authorizer { |
236 | 221 | Se você tem mais de uma implementação de <literal>Authenticator</literal> e/ou <literal>Authorizer</literal> (o que pode acontecer, por exemplo, quando |
237 | 222 | se necessite de uma implementação na aplicação principal, e outra para os testes), deverá definir no arquivo <filename>demoiselle.properties</filename> |
238 | 223 | qual classe será a padrão: |
239 | - <programlisting> | |
240 | - frameworkdemoiselle.security.authenticator.class=projeto.MeuAuthenticatorPadrao | |
241 | - frameworkdemoiselle.security.authorizer.class=projeto.MeuAuthorizerPadrao | |
242 | - </programlisting> | |
224 | + <programlisting>frameworkdemoiselle.security.authenticator.class=projeto.MeuAuthenticatorPadrao | |
225 | +frameworkdemoiselle.security.authorizer.class=projeto.MeuAuthorizerPadrao</programlisting> | |
243 | 226 | </para> |
244 | 227 | </section> |
245 | 228 | <caution> <para>O Demoiselle também oferece o componente | ... | ... |
documentation/reference/pt-BR/templates.xml
... | ... | @@ -39,7 +39,6 @@ public class SuaEntidadeDAO extends JPACrud<SuaEntidade, Long> { |
39 | 39 | query.setParameter("criterio", criterio); |
40 | 40 | return query.getResultList(); |
41 | 41 | } |
42 | - | |
43 | 42 | }]]></programlisting> |
44 | 43 | </section> |
45 | 44 | |
... | ... | @@ -65,7 +64,7 @@ public class SuaEntidadeDAO extends JPACrud<SuaEntidade, Long> { |
65 | 64 | </para> |
66 | 65 | <programlisting role="JAVA"><![CDATA[@BusinessController |
67 | 66 | public class SuaEntidadeBC extends DelegateCrud<SuaEntidade, Long, SuaEntidadeDAO> { |
68 | - | |
67 | + | |
69 | 68 | private void validateInsert(SuaEntidade se) { |
70 | 69 | // valida os atributos da entidade |
71 | 70 | } |
... | ... | @@ -76,7 +75,6 @@ public class SuaEntidadeBC extends DelegateCrud<SuaEntidade, Long, SuaEntidadeDA |
76 | 75 | validateInsert(se); |
77 | 76 | super.insert(se); |
78 | 77 | } |
79 | - | |
80 | 78 | }]]></programlisting> |
81 | 79 | </section> |
82 | 80 | |
... | ... | @@ -99,14 +97,12 @@ public class SuaEntidadeBC extends DelegateCrud<SuaEntidade, Long, SuaEntidadeDA |
99 | 97 | </para> |
100 | 98 | <programlisting role="JAVA"><![CDATA[@ViewController |
101 | 99 | public class SuaEntidadeListMB extends AbstractListPageBean<SuaEntidade, Long> { |
102 | - | |
103 | 100 | }]]></programlisting> |
104 | 101 | <para> |
105 | 102 | Estendendo o <literal>AbstractEditPageBean</literal>: |
106 | 103 | </para> |
107 | 104 | <programlisting role="JAVA"><![CDATA[@ViewController |
108 | 105 | public class SuaEntidadeEditMB extends AbstractEditPageBean<SuaEntidade, Long> { |
109 | - | |
110 | 106 | }]]></programlisting> |
111 | 107 | </section> |
112 | 108 | ... | ... |
documentation/reference/pt-BR/transacao.xml
... | ... | @@ -26,20 +26,17 @@ |
26 | 26 | <section> |
27 | 27 | <title>Configurando</title> |
28 | 28 | <para> |
29 | - Para um correto funcionamento do Demoiselle é necessário inserir o interceptador de transação no arquivo <filename>src/main/WEB-INF/beans.xml</filename>. | |
29 | + Para um correto funcionamento do Demoiselle é necessário inserir o interceptador de transação no arquivo <filename>src/main/WEB-INF/beans.xml</filename>. | |
30 | 30 | </para> |
31 | - <programlisting role="XML"> | |
32 | - <![CDATA[ | |
33 | - <beans xmlns="http://java.sun.com/xml/ns/javaee" | |
34 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
35 | - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee | |
36 | - http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
37 | - <interceptors> | |
38 | - <class>br.gov.frameworkdemoiselle.internal.interceptor.TransactionalInterceptor</class> | |
39 | - </interceptors> | |
40 | - </beans> | |
41 | - ]]> | |
42 | - </programlisting> | |
31 | + <programlisting role="XML"><![CDATA[<beans xmlns="http://java.sun.com/xml/ns/javaee" | |
32 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
33 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee | |
34 | + http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
35 | + | |
36 | + <interceptors> | |
37 | + <class>br.gov.frameworkdemoiselle.internal.interceptor.TransactionalInterceptor</class> | |
38 | + </interceptors> | |
39 | +</beans>]]></programlisting> | |
43 | 40 | </section> |
44 | 41 | |
45 | 42 | <section> |
... | ... | @@ -56,13 +53,9 @@ public void inserir() { }]]></programlisting> |
56 | 53 | </para> |
57 | 54 | <programlisting role="JAVA"><![CDATA[@Transactional |
58 | 55 | public class Simples { |
59 | - | |
60 | - public void inserir() { } | |
61 | - | |
56 | + public void inserir() { } | |
62 | 57 | public void alterar() { } |
63 | - | |
64 | 58 | public void excluir() { } |
65 | - | |
66 | 59 | }]]></programlisting> |
67 | 60 | <para> |
68 | 61 | Neste exemplo, os métodos <function>inserir()</function>, <function>alterar()</function> e |
... | ... | @@ -78,7 +71,6 @@ public class Simples { |
78 | 71 | </para> |
79 | 72 | <programlisting role="JAVA"><![CDATA[@ApplicationException(rollback = false) |
80 | 73 | public class AbacaxiException { |
81 | - | |
82 | 74 | }]]></programlisting> |
83 | 75 | </section> |
84 | 76 | |
... | ... | @@ -88,10 +80,8 @@ public class AbacaxiException { |
88 | 80 | Para ter acesso à instância da transação corrente, basta injetá-la em sua classe. |
89 | 81 | </para> |
90 | 82 | <programlisting role="JAVA"><![CDATA[public class Simples { |
91 | - | |
92 | 83 | @Inject |
93 | 84 | private Transaction transaction; |
94 | - | |
95 | 85 | }]]></programlisting> |
96 | 86 | </section> |
97 | 87 | |
... | ... | @@ -136,10 +126,10 @@ public class AbacaxiException { |
136 | 126 | <tip><para> Caso não esteja utilizando o arquétipo JSF-JPA fornecidos pelo Demoiselle, confira se a dependência para a |
137 | 127 | extensão está indicada corretamente no arquivo POM.XML.</para> |
138 | 128 | <programlisting role="XML"><![CDATA[<dependency> |
139 | - <groupId>br.gov.frameworkdemoiselle</groupId> | |
140 | - <artifactId>demoiselle-jpa</artifactId> | |
141 | - <scope>compile</scope> | |
142 | - </dependency>]]></programlisting></tip> | |
129 | + <groupId>br.gov.frameworkdemoiselle</groupId> | |
130 | + <artifactId>demoiselle-jpa</artifactId> | |
131 | + <scope>compile</scope> | |
132 | +</dependency>]]></programlisting></tip> | |
143 | 133 | </section> |
144 | 134 | |
145 | 135 | <section> |
... | ... | @@ -173,34 +163,32 @@ public class AbacaxiException { |
173 | 163 | É preciso também informar no arquivo <filename>persistence.xml</filename> o endereço da conexão |
174 | 164 | JTA gerenciada. Veja um exemplo utilizando o servidor de aplicações JBoss-AS6 e com o provider Hibernate (embutido no JBoss-AS) como implementação JPA: |
175 | 165 | </para> |
176 | - <programlisting role="XML"><![CDATA[ | |
177 | - <?xml version="1.0" encoding="UTF-8"?> | |
178 | - <persistence version="2.0" | |
179 | - xmlns="http://java.sun.com/xml/ns/persistence" | |
180 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
181 | - xsi:schemaLocation="http://java.sun.com/xml/ns/persistence | |
182 | - http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> | |
183 | - | |
184 | - <persistence-unit name="bookmark-ds" transaction-type="JTA"> | |
185 | - <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source> | |
186 | - <properties> | |
187 | - <property name="hibernate.show_sql" value="true" /> | |
188 | - <property name="hibernate.format_sql" value="false" /> | |
189 | - <property name="hibernate.hbm2ddl.auto" value="update" /> | |
190 | - <property name="hibernate.transaction.jta.platform" | |
191 | - value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" /> | |
192 | - </properties> | |
193 | - </persistence-unit> | |
194 | - </persistence>]]></programlisting> | |
166 | +<programlisting role="XML"><![CDATA[<?xml version="1.0" encoding="UTF-8"?> | |
167 | +<persistence version="2.0" | |
168 | + xmlns="http://java.sun.com/xml/ns/persistence" | |
169 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
170 | + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence | |
171 | + http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> | |
172 | + | |
173 | + <persistence-unit name="bookmark-ds" transaction-type="JTA"> | |
174 | + <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source> | |
175 | + <properties> | |
176 | + <property name="hibernate.show_sql" value="true" /> | |
177 | + <property name="hibernate.format_sql" value="false" /> | |
178 | + <property name="hibernate.hbm2ddl.auto" value="update" /> | |
179 | + <property name="hibernate.transaction.jta.platform" | |
180 | + value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" /> | |
181 | + </properties> | |
182 | + </persistence-unit> | |
183 | +</persistence>]]></programlisting> | |
195 | 184 | |
196 | 185 | <tip><para> Caso não esteja utilizando o arquétipo JSF-JPA fornecidos pelo Demoiselle, confira se a dependência para a |
197 | 186 | extensão está indicada corretamente, no arquivo POM.XML.</para> |
198 | - <programlisting role="XML"><![CDATA[ | |
199 | - <dependency> | |
200 | - <groupId>br.gov.frameworkdemoiselle</groupId> | |
201 | - <artifactId>demoiselle-jta</artifactId> | |
202 | - <scope>compile</scope> | |
203 | - </dependency>]]></programlisting></tip> | |
187 | + <programlisting role="XML"><![CDATA[<dependency> | |
188 | + <groupId>br.gov.frameworkdemoiselle</groupId> | |
189 | + <artifactId>demoiselle-jta</artifactId> | |
190 | + <scope>compile</scope> | |
191 | +</dependency>]]></programlisting></tip> | |
204 | 192 | |
205 | 193 | </section> |
206 | 194 | |
... | ... | @@ -223,25 +211,15 @@ public class AbacaxiException { |
223 | 211 | import br.gov.frameworkdemoiselle.transaction.Transaction; |
224 | 212 | |
225 | 213 | public class MegaTransaction implements Transaction { |
226 | - | |
227 | 214 | public void begin() { } |
228 | - | |
229 | 215 | public void commit() { } |
230 | - | |
231 | 216 | public void rollback() { } |
232 | - | |
233 | 217 | public void setRollbackOnly() { } |
234 | - | |
235 | 218 | public int getStatus() { } |
236 | - | |
237 | 219 | public void setTransactionTimeout(int seconds) { } |
238 | - | |
239 | 220 | public boolean isActive() { } |
240 | - | |
241 | 221 | public boolean isMarkedRollback() { } |
242 | - | |
243 | -} | |
244 | -]]></programlisting> | |
222 | +}]]></programlisting> | |
245 | 223 | <para> |
246 | 224 | Pronto, é só isso! Agora, os métodos anotados com <literal>@Transactional</literal> irão utilizar a estratégia criada em seu projeto de forma automática, |
247 | 225 | mesmo que as extensões <literal>demoiselle-jpa</literal> e <literal>demoiselle-jta</literal> sejam adicionadas ao projeto, pois o framework da prioridade |
... | ... | @@ -263,15 +241,9 @@ public class MegaTransaction implements Transaction { |
263 | 241 | arquivo <filename>demoiselle.properties</filename> qual estratégia será utilizada. Veja alguns exemplos de definição de estratégias própria, |
264 | 242 | <literal>JTATransaction</literal> e <literal>JPATransaction</literal> (importante notar que apenas uma estratégia pode estar ativa por vez): |
265 | 243 | </para> |
266 | - <programlisting> | |
267 | - frameworkdemoiselle.transaction.class=projeto.MyTransaction | |
268 | - </programlisting> | |
269 | - <programlisting> | |
270 | - frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JTATransaction | |
271 | - </programlisting> | |
272 | - <programlisting> | |
273 | - frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JPATransaction | |
274 | - </programlisting> | |
244 | + <programlisting>frameworkdemoiselle.transaction.class=projeto.MyTransaction</programlisting> | |
245 | + <programlisting>frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JTATransaction</programlisting> | |
246 | + <programlisting>frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JPATransaction</programlisting> | |
275 | 247 | </section> |
276 | 248 | |
277 | 249 | </chapter> | ... | ... |