Skip to content

Instantly share code, notes, and snippets.

@rlubke
rlubke / build.gradle
Last active October 19, 2021 00:13
Dependencies
dependencies {
annotationProcessor "io.micronaut:micronaut-inject-java:3.1.0"
annotationProcessor "io.micronaut:micronaut-validation:3.1.0"
annotationProcessor "io.micronaut.coherence:micronaut-coherence-data:3.0.1"
compile "com.oracle.coherence.ce:coherence:21.06.2"
compile "io.micronaut.coherence:micronaut-coherence:3.0.1"
compile "io.micronaut.coherence:micronaut-coherence-data:3.0.1"
compile "jakarta.inject:jakarta.inject-api:2.0.0"
compile "javax.inject:javax.inject:1"
@rlubke
rlubke / curl2.bash
Created October 3, 2021 18:25
cURL command to get tasks
curl -i -X GET -H "Accept: application/json" http://localhost:3000/api/tasks
@rlubke
rlubke / curl.bash
Last active October 3, 2021 18:25
cURL commands to create some tasks
curl -i -X POST -H "Content-Type: application/json" \
-d '{"description": "Learn Coherence"}' http://localhost:3000/api/task
curl -i -X POST -H "Content-Type: application/json" \
-d '{"description": "Write an article"}' http://localhost:3000/api/tasks
@rlubke
rlubke / TaskRepository.java
Created October 3, 2021 18:16
Micronaut Data Finder Queries
package com.oracle.coherence.examples.todo.server;
import io.micronaut.coherence.data.AbstractCoherenceRepository;
import io.micronaut.coherence.data.annotation.CoherenceRepository;
import java.util.Collection;
/**
* A {@code Coherence}-base {@code Micronaut Data} repository for working with {@link Task tasks}.
*/
@CoherenceRepository("task")
@rlubke
rlubke / ToDoController.java
Last active October 3, 2021 19:12
Micronaut getTasks with Finder Query
@Get
@Produces(APPLICATION_JSON)
public Collection<Task> getTasks(@Nullable @QueryValue(value = "completed") Boolean completed)
{
return completed == null
? tasks.getAll()
: tasks.findByCompleted(completed);
}
@rlubke
rlubke / TaskRepository.java
Created October 3, 2021 17:56
Repository using Finder Query
package com.oracle.coherence.examples.todo.server;
import io.micronaut.coherence.data.AbstractCoherenceRepository;
import io.micronaut.coherence.data.annotation.CoherenceRepository;
import java.util.Collection;
/**
* A {@code Coherence}-base {@code Micronaut Data} repository for working with {@link Task tasks}.
*/
@CoherenceRepository("task")
@rlubke
rlubke / build.gradle
Created October 3, 2021 17:03
Micronaut ToDo List Gradle Build
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at
* https://oss.oracle.com/licenses/upl.
*/
plugins {
id 'application'
id 'java'
id "com.github.johnrengelman.shadow" version "4.0.2"
@rlubke
rlubke / session.yaml
Created September 20, 2021 21:08
Micronaut data configuration with custom sessions
coherence:
cluster: test-cluster
role: test
ttl: 0
distributed:
localstorage: true
sessions:
mysession:
name: mysession
config: coherence-cache-config.xml
@rlubke
rlubke / application.yaml
Last active September 20, 2021 20:54
Micronaut Todo List Configuration
micronaut:
application:
name: todo-list-micronaut-server
server:
port: 3000
router:
static-resources:
default:
enabled: true
mapping: "/**"
@rlubke
rlubke / todolist-micro-pom.xml
Last active September 20, 2021 23:16
POM file for Todo List sample application using Micronaut
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-parent</artifactId>
<version>3.0.1</version> <!-- Micronaut version this example uses -->