-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
519 lines (405 loc) · 23.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Play Framework - Criando Aplicações Web</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/white.css" id="theme">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<link rel="stylesheet" href="css/custom.css">
</head>
<body>
<div class="reveal">
<div class="slides">
<section data-background-transition="zoom" data-background="#bb9f59">
<img class="logo" data-src="img/app-construindo.png">
<h1 id="titleapp" style="color:white">Criando Aplicações Web</h1>
<br />
<p style="color:white">com o Play Framework</p>
<img data-src="img/play_icon.png" style="width: 5%;">
</section>
<section data-background-image="http://scarbroughstudios.com/img/codepen.svg">
<div class="pen">
<div class="profile">
<img id="picture" data-src="img/profile_author.jpg">
<p>Daniel Gonçalves</p>
<p><small>Desenvolvedor Java Web</small></p><br />
<ul id="descricao">
<li><p>Atualmente trabalha na Universidade Federal do ABC, como Analista de TI.</p></li>
<li><p>Iniciando mestrado em Ciência da Computação.</p></li>
</ul>
</div>
</div>
</section>
<section>
<section data-background-color="#B7CECE">
<h1 style="color: white;"> O que é o Play ?</h1>
<img data-src="img/thinking_guy.png" style="width: 80%;">
</section>
<section data-background="black">
<p>É um <i>framework</i> para desenvolvimento Web em<b>Scala</b>, e também em <b>Java</b>. Diferentemente de outros frameworks Java EE, ele não utiliza servlets.</p>
<p>Outra ponto diferente é o uso de um servidor HTTP embutido, o Netty.</p>
</section>
<section data-background="yellow">
<h1>Algumas vantagens:</h1>
<ul>
<li><b>Aumento considerável da produtividade:</b> Toda a mudança é compilada em tempo real. Então você altera algo no código, e assim que salvar poderá ver a atualização sem a necessidade de reiniciar a aplicação.</li>
</ul>
</section>
<section data-background="yellow">
<h1>Algumas vantagens:</h1>
<ul>
<li><b>Manipulação de erros diferenciado:</b>O Play! tem um tratamento de erros fácil de correção no modo de desenvolvimento: tanto para erros de compilação como tempo de execução. É mostrado o caminho do arquivo, o número da linha e o código através do navegador. Não é mais necessário acessar arquivos de logs aleatórios (como por exemplo o do Tomcat).</li>
</ul>
</section>
<section data-background="yellow">
<h1>Algumas vantagens:</h1>
<ul>
<li><b>Suporte para tecnologias como: </b>REST, JSON/XML, ORM (mapeamento objeto-relacional), suporte NoSQL e muitos outros modelos compatíveis.</li>
</ul>
</section>
<section data-background="yellow">
<h1>Algumas vantagens:</h1>
<ul>
<li><b>Bibliotecas para uso de programação concorrente (Akka)</b></li>
</ul>
</section>
</section>
<section>
<section data-background="orange">
<table><tr>
<td><img data-src="img/arquitetura_ti.png" style="width: 400%;"></td>
<td style="vertical-align: middle;"><p class="title">Arquitetura do Play Framework</p></td>
</tr>
</table>
</section>
<section ><h1>Stack (Core)</h1>
<img data-src="img/stack_play.png" style="width: 120%;">
</section>
<section>
<h2>Arquitetura</h2>
<div>
<div class="left">
<ul>
<li>MVC</li>
<li>Netty - Servidor Web integrado sem uso de servlets</li>
<li>Construido na linguagem Scala</li>
</ul>
</div>
<div class="right">
<img data-src="img/arquitetura_play.png">
</div>
</div>
</section>
<section><h2>Ciclo de Vida da Requisição</h2>
<img data-src="img/ciclo_vida_req.png" id="ciclo_vida_req">
</section>
<section><h2>Ciclo de Vida da Requisição</h2>
<img data-src="img/ciclo_vida_req01.png" id="ciclo_vida_req01">
</section>
<section><h2>Ciclo de Vida da Requisição</h2>
<img data-src="img/ciclo_vida_req02.png" id="ciclo_vida_req02">
</section>
<section><h2>Ciclo de Vida da Requisição</h2>
<img data-src="img/ciclo_vida_req03.png" id="ciclo_vida_req03">
</section>
<section> <h2>Estrutura de Projeto</h2>
<pre><code>
└-app -------------> código fonte
| └-controllers --> controles de requisições
| └-views --------> arquivos de template para renderizar html
| └-models -------> camada que representa os dados
└-conf ------------> arquivos de configuração
└-project ---------> definição de projeto sbt
└-public ----------> pasta contendo recursos estáticos
| └-images-------> imagens
| └-javascripts--> arquivos de javascript
| └-stylesheets--> arquivos de css
└-test ------------> código fonte de casos de testes
</code></pre>
</section>
</section>
<section>
<section><h1>Instalação</h1>
<ol>
<li><p>Baixe o Activator na página do Play Framework, <a href="https://www.playframework.com/download#activator">aqui</a>.</p></li>
<li><p>Depois configure as variáveis de ambiente, de acordo com o Sistema Operacional</p> </li>
</ol>
<ul>
<li><a href="#linux">Linux</a></li>
<li><a href="#macosx">MacOSX</a></li>
<li><a href="#windows">Windows</a></li>
</ul>
</section>
<section id="linux">
<h2>Linux</h2>
<ol>
<li><p>Adicione no arquivo .bashrc ou .profile:</p></li>
<pre>
<code class="bash" data-trim data-noescape contenteditable>
export PATH=/pasta/activator-x.x.x/bin:$PATH</code></pre>
<li><p>Adicione a permissão de execução:</p></li>
<pre>
<code class="bash" data-trim data-noescape contenteditable>
chmod u+x /pasta/activator-x.x.x/bin/activator</code></pre>
</ol>
</section>
<section id="macosx"><h2>Mac</h2>
<ol>
<li><p>Adicione no arquivo .bash_profile:</p></li>
<pre>
<code class="bash" data-trim data-noescape contenteditable>
export PATH=/pasta/activator-x.x.x/bin:$PATH</code></pre>
</ol>
</section>
<section id="windows"><h2>Windows</h2>
<table>
<tr>
<td><small>1.</small></td>
<td><small>2.</small></td>
<td><small>3. Adicione o caminho <b>C:\pasta\activator-x.x.x\bin</b></small></td>
</tr>
<tr>
<td><img data-src="img/01prop_sistema.png" style="float:left;"></td>
<td><img data-src="img/02var_amb.png" style=" float:left;"></td>
<td><img data-src="img/03edit.png" style=" float:left;"></td>
</tr>
</table>
</section>
</section>
</section>
<section>
<section data-background="#03ca03">
<table><tr>
<td style="vertical-align: middle; width: 50%; height:100%;">
<img data-src="img/coding.svg" style="width: 100%"></td>
<td><p class="title">Criando um novo projeto</p></td>
</tr>
</table>
</section>
<section>
<div>
<ol>
<li><p>Criar novo projeto:</p></li>
<pre><code class="bash" data-trim data-noescape contenteditable>
activator new [nome-do-projeto]
</code></pre>
<li><p>Entrar na pasta do projeto:</p></li>
<pre><code class="bash" data-trim data-noescape contenteditable>
cd nome-do-projeto
</code></pre>
<li><p>Subir o projeto no terminal:</p></li>
<pre><code class="bash" data-trim data-noescape contenteditable>
nome-do-projeto$ activator
</code></pre>
<li><p>Com build automático:</p></li>
<pre><code class="bash" data-trim data-noescape contenteditable>
[nome-do-projeto] ~run
</code></pre>
<li><p>Alterando a porta:</p></li>
<pre><code class="bash" data-trim data-noescape contenteditable>
[nome-do-projeto] ~run -Dhttp.port=8080
</code></pre>
</ol>
</div>
</section>
<section><h1>Importando para IDE</h1>
<ul>
<li>IntelliJ Community</li>
<li><a href="#eclipse">Eclipse</a></li>
</ul>
</section>
<section id="eclipse"><h1>Eclipse</h1>
<p><small>1. Para configurar o projeto Eclipse, precisamos primeiro adicionar um plugin. Abra o arquivo project/plugins.sbt e adicione após a última linha:</small></p>
<pre><code class="java" data-trim data-noescape contenteditable>
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
</code></pre><br />
<p><small>2. Abra também o arquivo build.sbt que fica na raiz do projeto e adicione:</small></p>
<pre><code class="java" data-trim data-noescape contenteditable>
EclipseKeys.preTasks := Seq(compile in Compile)
EclipseKeys.projectFlavor := EclipseProjectFlavor.Java
EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)
</code></pre>
</section>
</section>
<section >
<section data-background="#6aa4b8"><p class="title" style="color: white">Codando ...</p>
<img data-src="img/coding.jpg" style="width: 60%;">
</section>
<section>
<h1>Hello World</h1><br />
<p>controllers/HomeController.java </p>
<pre><code class="java" data-trim data-noescape contenteditable>
public Result helloWorld(){
return ok(views.html.hello.render("Hello World"));
}</code></pre><br />
<p>views/hello.scala.html</p>
<pre><code class="scala" data-trim data-noescape contenteditable>@(mensagem: String)
@main("Hello World Title"){
@mensagem
}
</code></pre>
</section>
<section>
<h1>Hello World</h1><br />
<p>conf/routes</p>
<pre><code data-trim data-noescape contenteditable> GET /hello controllers.HomeController.helloWorld() </code></pre> <br />
<p>Passando parâmetros via URL:</p>
<pre><code data-trim data-noescape contenteditable>GET /hello controllers.HomeController.hello(parametro ?= "")</code></pre>
<p>ou também:</p>
<pre><code data-trim data-noescape contenteditable>GET /hello controllers.HomeController.hello(parametro: String)</code></pre>
</section>
<section>
<p>Limpar projeto:</p>
<pre><code>clean</code></pre>
<p>Compilar:</p>
<pre><code>compile</code></pre>
<p>Criar versão para produção:</p>
<pre><code>dist</code></pre>
</section>
<section>
<h1>Console</h1>
<p>Compilação automática:</p>
<pre><code>~run</code></pre>
<p>Acessar banco de dados h2 database:</p>
<pre><code>h2-browser</code></pre>
<p>Versão para debug:</p>
<pre><code>activator -jvm-debug 9999</code></pre>
</section>
<section><h1>Projeto Agenda</h1>
<br />
<img data-src="img/playagenda.png" style="width: 30%;">
<p><small>Repositório: <a href="https://github.com/danielgoncalvesti/phonebook-play-java-nodatabase">https://github.com/danielgoncalvesti/phonebook-play-java-nodatabase</a></small></p>
<p><small>Link: <a href="playagenda.herokuapp.com">playagenda.herokuapp.com</a></small></p>
</section>
<section> <h2> Classe Contato</h2>
<pre><code class="java" data-trim data-noescape contenteditable>
package models;
import static play.data.validation.Constraints.*;
public class Contato{
public Long id;
@Required
public String nome;
@Required
public String telefone;
}
</code></pre>
</section>
<section><h2>Classe ContatoDao</h2>
<pre><code class="java" data-trim data-noescape contenteditable>
package models;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
public class ContatoDao {
private static Map<Long, Contato> contatos = new ConcurrentHashMap<Long, Contato>();
private static AtomicLong uuid = new AtomicLong();
public static Contato findById(long id) {
return contatos.get(id);
}
public static List<Contato> findByName(String filter){
List<Contato> result = new ArrayList<Contato>();
for (Contato contato: contatos.values()){
if (contato.nome.toLowerCase().toLowerCase().contains(filter.toLowerCase())){
result.add(contato);
}
}
return result;
}
public static List<Contato> findAll(){
List<Contato> result = new ArrayList<Contato>();
for (Contato contato: contatos.values()){
result.add(contato);
}
return result;
//return new ArrayList<Contato>(contatos.values());
}
public static void save(Contato contato) {
if (contato.id == null) {
contato.id = uuid.incrementAndGet();
}
contatos.put(contato.id, contato);
}
public static void delete(long id) {
contatos.remove(id);
}
}
</code></pre>
</section>
</section>
</section>
<section><h1>Criando Serviços</h1>
<pre><code class="java" data-trim data-noescape contenteditable>
public Result apiAll(String filter){
List<Contato> contatos = models.ContatoHelper.findAll();
return ok(Json.toJson(contatos));
}</code></pre>
</section>
</section>
<section>
<h2>Publicando o Projeto no Heroku</h2>
<p>Criar arquivo Procfile, com conteúdo:</p>
<pre><code>web: target/universal/stage/bin/play_agenda -Dhttp.port=$PORT -Dplay.version=2.5.9</code></pre>
<p><small><a href="https://www.playframework.com/documentation/2.5.x/ProductionHeroku">Documentação para o Heroku</a></small></p>
</section>
<section><h1>Links</h1>
<ol>
<li><a href="http://blog.sabercompartilhar.com.br/conheca-o-play-framework-rapido-e-agil/">Conheça o Play Framework: Rápido e Ágil no Desenvolvimento Web</a></li>
<li><a href="http://blog.sabercompartilhar.com.br/primeiros-passos-com-o-play-framework-hello-world/">Criando um HelloWorld com Play Framework</a>
</li>
<li><a href="https://github.com/danielgoncalvesti/phonebook-play-java-nodatabase">Repositório Phonebook</a></li>
<li><a href="https://www.youtube.com/watch?v=gpaIwB18XL0">YouTube - Criando um Hello World</a></li>
</ol>
</section>
<!--
<section data-background="http://i.giphy.com/90F8aUepslB84.gif" data-background-transition="zoom">
</section>
-->
<section><h2>Configuração de Tema</h2>
<p>
<!-- Hacks to swap themes after the page has loaded. Not flexible and only intended for the reveal.js demo deck. -->
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/black.css'); return false;">Black (default)</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/white.css'); return false;">White</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/league.css'); return false;">League</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/sky.css'); return false;">Sky</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/beige.css'); return false;">Beige</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/simple.css'); return false;">Simple</a> <br>
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/serif.css'); return false;">Serif</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/blood.css'); return false;">Blood</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/night.css'); return false;">Night</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/moon.css'); return false;">Moon</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/solarized.css'); return false;">Solarized</a>
</p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
history: true,
center: false,
// More info https://github.com/hakimel/reveal.js#dependencies
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>