Skip to content
Snippets Groups Projects
Commit 156c82a8 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

Support for LocalDate

parent 6d1dbffb
No related merge requests found
......@@ -50,7 +50,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
......@@ -85,7 +85,8 @@
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-config-yaml</artifactId>
</dependency><!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
......@@ -110,6 +111,10 @@
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.4.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
......
package java2.lab12.client;
import java.time.LocalDate;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.Getter;
......@@ -29,4 +31,8 @@ public class Course {
@Getter
@Setter
private String semester;
@Getter
@Setter
private LocalDate startDate;
}
package java2.lab12.client;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import java.time.LocalDate;
import java.util.Collection;
import java.util.Collections;
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
import javafx.application.Application;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.collections.FXCollections;
......@@ -26,7 +32,9 @@ import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import lombok.extern.log4j.Log4j2;
@Log4j2
public class TableViewSample extends Application {
......@@ -194,6 +202,7 @@ public class TableViewSample extends Application {
}
private void createCourse(Course course) {
course.setStartDate(LocalDate.now());
long id = getClient().createCourse(course);
course.setId(id);
}
......@@ -207,8 +216,11 @@ public class TableViewSample extends Application {
}
private CourseResourceClient getClient() {
ObjectMapper mapper = new ObjectMapper();
mapper.findAndRegisterModules();
return JAXRSClientFactory.create("http://localhost:8080",
CourseResourceClient.class, Collections.singletonList(
JacksonJaxbJsonProvider.class));
new JacksonJaxbJsonProvider(mapper,
JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS)));
}
}
\ No newline at end of file
package java2.lab12.server;
import java.time.LocalDate;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
......@@ -36,4 +38,8 @@ public class Course {
@Getter
@Setter
private int semester;
@Getter
@Setter
private LocalDate startDate;
}
package java2.lab12.server;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.quarkus.jackson.ObjectMapperCustomizer;
import javax.inject.Singleton;
@Singleton
public class JacksonObjectMapperCustomizer implements ObjectMapperCustomizer {
@Override
public void customize(ObjectMapper mapper) {
mapper.findAndRegisterModules();
}
}
package java2.lab12.server;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.quarkus.jackson.ObjectMapperCustomizer;
import javax.enterprise.inject.Instance;
import javax.inject.Singleton;
import lombok.extern.log4j.Log4j2;
@Log4j2
public class ObjectMapperConfiguration {
@Singleton
ObjectMapper objectMapper(Instance<ObjectMapperCustomizer> customizers) {
// Your own `ObjectMapper` or one provided by another library
ObjectMapper mapper = new ObjectMapper();
// Apply customizations (includes customizations from Quarkus)
for (ObjectMapperCustomizer customizer : customizers) {
customizer.customize(mapper);
}
log.info("mapper {}", mapper);
return mapper;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment