Skip to content
Snippets Groups Projects
Commit 2bbd936b authored by Emmanuel Bruno's avatar Emmanuel Bruno
Browse files

fixes DAO typos and cleans WS.

parent f96fe0b7
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,8 @@ package fr.univtln.bruno.samples.jee91.dao; ...@@ -3,6 +3,8 @@ package fr.univtln.bruno.samples.jee91.dao;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import java.util.List;
public class DAO2 { public class DAO2 {
private EntityManager entityManager; private EntityManager entityManager;
...@@ -11,4 +13,8 @@ public class DAO2 { ...@@ -11,4 +13,8 @@ public class DAO2 {
this.entityManager = entityManager; this.entityManager = entityManager;
} }
public List<Person> findAll() {
return entityManager.createNamedQuery("Person.findAll").getResultList();
}
} }
...@@ -30,7 +30,7 @@ RUN keytool -importkeystore -noprompt -destkeystore /opt/payara/appserver/glassf ...@@ -30,7 +30,7 @@ RUN keytool -importkeystore -noprompt -destkeystore /opt/payara/appserver/glassf
keytool -importcert -noprompt -trustcacerts -destkeystore /opt/payara/appserver/glassfish/domains/domain1/config/cacerts.jks -file /tmp/mycert.crt -alias mycert -srcstorepass storepass -deststorepass ${STORE_PASSWORD} -deststoretype pkcs12 keytool -importcert -noprompt -trustcacerts -destkeystore /opt/payara/appserver/glassfish/domains/domain1/config/cacerts.jks -file /tmp/mycert.crt -alias mycert -srcstorepass storepass -deststorepass ${STORE_PASSWORD} -deststoretype pkcs12
# COPY target/*.war $DEPLOY_DIR # COPY target/*.war $DEPLOY_DIR
COPY --from=build /app/restApp/target/*.war \ #COPY --from=build /app/restApp/target/*.war \
$DEPLOY_DIR # $DEPLOY_DIR
COPY --from=build /app/wsApp/target/*.war \ #COPY --from=build /app/wsApp/target/*.war \
$DEPLOY_DIR # $DEPLOY_DIR
package fr.univtln.bruno.samples.jee91.dao; package fr.univtln.bruno.samples.jee91.dao;
import jakarta.persistence.Entity; import jakarta.persistence.*;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@Entity @Entity
@NamedQueries({
@NamedQuery(name = "Person.findAll",
query = "select p from Person p"),
@NamedQuery(
name = "Person.findAllOrderedByName",
query = "SELECT p FROM Person p ORDER BY p.name")
})
public class Person { public class Person {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>rest</artifactId> <artifactId>restApp</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<dependencies> <dependencies>
......
package fr.univtln.bruno.samples.jee91.rs; package fr.univtln.bruno.samples.jee91.rs;
import fr.univtln.bruno.samples.jee91.dao.DAO1;
import fr.univtln.bruno.samples.jee91.dao.DAO2;
import fr.univtln.bruno.samples.jee91.dao.Person;
import fr.univtln.bruno.samples.jee91.ejb.Hello; import fr.univtln.bruno.samples.jee91.ejb.Hello;
import fr.univtln.bruno.samples.jee91.ejb.qualifiers.SpokenLanguage; import fr.univtln.bruno.samples.jee91.ejb.qualifiers.SpokenLanguage;
import fr.univtln.bruno.samples.jee91.dao.DAO1;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
...@@ -12,6 +14,7 @@ import jakarta.ws.rs.core.MediaType; ...@@ -12,6 +14,7 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import org.eclipse.microprofile.config.inject.ConfigProperty; import org.eclipse.microprofile.config.inject.ConfigProperty;
import java.util.List;
import java.util.Map; import java.util.Map;
@Path("sample") @Path("sample")
...@@ -24,6 +27,9 @@ public class SampleResource { ...@@ -24,6 +27,9 @@ public class SampleResource {
@Inject @Inject
DAO1 dao1; DAO1 dao1;
@Inject
DAO2 dao2;
@Inject @Inject
@ConfigProperty(name = "message") @ConfigProperty(name = "message")
private String message; private String message;
...@@ -49,7 +55,7 @@ public class SampleResource { ...@@ -49,7 +55,7 @@ public class SampleResource {
@GET @GET
@Path("dao2") @Path("dao2")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> dao2() { public List<Person> dao2() {
return dao1.getMetadata(); return dao2.findAll();
} }
} }
...@@ -3,9 +3,6 @@ package fr.univtln.bruno.samples.jee91.wsclient; ...@@ -3,9 +3,6 @@ package fr.univtln.bruno.samples.jee91.wsclient;
import jakarta.websocket.*; import jakarta.websocket.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.glassfish.grizzly.ssl.SSLContextConfigurator; import org.glassfish.grizzly.ssl.SSLContextConfigurator;
import org.glassfish.grizzly.ssl.SSLEngineConfigurator;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment