FFFF modelos cdi · SouJava-Rio/soujava-rio-labs@33b5190 · GitHub
[go: up one dir, main page]

Skip to content

Commit 33b5190

Browse files
committed
modelos cdi
1 parent 3c98a78 commit 33b5190

File tree

6 files changed

+171
-0
lines changed

6 files changed

+171
-0
lines changed

MVC1.0-samples/Krazo-CDI/pom.xml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>br.org.soujava.rio</groupId>
6+
<artifactId>krazo-cdi</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<packaging>war</packaging>
9+
<name>krazo-cdi</name>
10+
<description>krazo-cdi</description>
11+
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
15+
<maven.compiler.source>1.8</maven.compiler.source>
16+
<maven.compiler.target>1.8</maven.compiler.target>
17+
<failOnMissingWebXml>false</failOnMissingWebXml>
18+
<krazo.version>1.0.0-SNAPSHOT</krazo.version>
19+
<version.payara>1.0.3</version.payara>
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>javax</groupId>
25+
<artifactId>javaee-web-api</artifactId>
26+
<version>8.0</version>
27+
<scope>provided</scope>
28+
</dependency>
29+
30+
<dependency>
31+
<groupId>org.eclipse.krazo</groupId>
32+
<artifactId>krazo-core</artifactId>
33+
<version>${krazo.version}</version>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>org.eclipse.krazo</groupId>
38+
<artifactId>krazo-jersey</artifactId>
39+
<version>${krazo.version}</version>
40+
</dependency>
41+
</dependencies>
42+
43+
<build>
44+
<finalName>MVC1.0.Ozark</finalName>
45+
<plugins>
46+
<plugin>
47+
<groupId>fish.payara.maven.plugins</groupId>
48+
<artifactId>payara-micro-maven-plugin</artifactId>
49+
<version>${version.payara}</version>
50+
<executions>
51+
<execution>
52+
<goals>
53+
<goal>bundle</goal>
54+
<goal>start</goal>
55+
</goals>
56+
</execution>
57+
</executions>
58+
<configuration>
59+
<useUberJar>true</useUberJar>
60+
<deployWar>false</deployWar>
61+
<daemon>false</daemon>
62+
<payaraVersion>5.184</payaraVersion>
63+
</configuration>
64+
</plugin>
65+
</plugins>
66+
</build>
67+
68+
<repositories>
69+
<repository>
70+
<id>sonatype-oss-snapshots</id>
71+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
72+
<releases>
73+
<enabled>false</enabled>
74+
</releases>
75+
<snapshots>
76+
<enabled>true</enabled>
77+
</snapshots>
78+
</repository>
79+
</repositories>
80+
</project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package br.org.soujava.rio.app;
2+
import java.util.HashMap;
3+
import java.util.Map;
4+
5+
import javax.ws.rs.ApplicationPath;
6+
import javax.ws.rs.core.Application;
7+
8+
import org.eclipse.krazo.Properties;
9+
10+
@ApplicationPath("app")
11+
public class App extends Application {
12+
13+
@Override
14+
public Map<String, Object> getProperties() {
15+
Map<String, Object> defaultViewExtension = new HashMap<>();
16+
defaultViewExtension.put(Properties.DEFAULT_VIEW_FILE_EXTENSION, "jsp");
17+
return defaultViewExtension;
18+
}
19+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package br.org.soujava.rio.controller;
2+
3+
import javax.inject.Inject;
4+
import javax.mvc.Controller;
5+
import javax.mvc.Models;
6+
import javax.mvc.View;
7+
import javax.ws.rs.GET;
8+
import javax.ws.rs.Path;
9+
10+
import br.org.soujava.rio.model.Pessoa;
11+
12+
@Controller
13+
@Path("hello")
14+
public class HelloController {
15+
16+
@Inject
17+
private Models models;
18+
19+
@Inject
20+
private Pessoa pessoa;
21+
22+
@View("hello")
23+
@GET
24+
public void getHello() {
25+
this.models.put("nome","Daniel");
26+
}
27+
28+
@View("hello")
29+
@Path("cdi")
30+
@GET
31+
public void getHelloCDI() {
32+
this.pessoa.setNome("Daniel Dias");
33+
}
34+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package br.org.soujava.rio.model;
2+
3+
import javax.enterprise.context.RequestScoped;
4+
import javax.inject.Named;
5+
6+
@Named
7+
@RequestScoped
8+
public class Pessoa {
9+
10+
private String nome;
11+
12+
public String getNome() {
13+
return nome;
14+
}
15+
16+
public void setNome(String nome) {
17+
this.nome = nome;
18+
}
19+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0"?>
2+
<beans bean-discovery-mode="all" version="2.0"
3+
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"/>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8"
2+
pageEncoding="UTF-8"%>
3+
<!DOCTYPE html>
4+
<html>
5+
<head>
6+
<meta charset="UTF-8">
7+
<title>Insert title here</title>
8+
</head>
9+
<body>
10+
<h1>Hello ${nome}</h1>
11+
12+
<h1>Hello com CDI: ${pessoa.nome}</h1>
13+
14+
</body>
15+
</html>

0 commit comments

Comments
 (0)
0