Skip to content

Commit 979f94a

Browse files
committed
Initial commit
1 parent 633f144 commit 979f94a

File tree

46 files changed

+2873
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2873
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
*.iml
3+
**/target
4+
logs

README.md

+74
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,76 @@
11
# lagomkotlin
22
An example of Lightbend's Lagom project with Kotlin
3+
4+
This is the basic Lagom's Java Hello World example. I duplicated all Java classes to Kotlin with the prefix K, e.g,:
5+
6+
GreetingMessage.java
7+
```java
8+
package org.cakesolutions.hello.api;
9+
10+
import javax.annotation.Nullable;
11+
import javax.annotation.concurrent.Immutable;
12+
13+
import com.fasterxml.jackson.annotation.JsonCreator;
14+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
15+
import com.google.common.base.MoreObjects;
16+
import com.google.common.base.Preconditions;
17+
18+
@Immutable
19+
@JsonDeserialize
20+
public final class GreetingMessage {
21+
22+
public final String message;
23+
24+
@JsonCreator
25+
public GreetingMessage(String message) {
26+
this.message = Preconditions.checkNotNull(message, "message");
27+
}
28+
29+
@Override
30+
public boolean equals(@Nullable Object another) {
31+
if (this == another)
32+
return true;
33+
return another instanceof GreetingMessage && equalTo((GreetingMessage) another);
34+
}
35+
36+
private boolean equalTo(GreetingMessage another) {
37+
return message.equals(another.message);
38+
}
39+
40+
@Override
41+
public int hashCode() {
42+
int h = 31;
43+
h = h * 17 + message.hashCode();
44+
return h;
45+
}
46+
47+
@Override
48+
public String toString() {
49+
return MoreObjects.toStringHelper("GreetingMessage").add("message", message).toString();
50+
}
51+
}
52+
```
53+
54+
KGreetingMessage.kt
55+
```kotlin
56+
package org.cakesolutions.hello.api
57+
58+
import com.fasterxml.jackson.annotation.JsonCreator
59+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
60+
import javax.annotation.concurrent.Immutable
61+
62+
@Immutable
63+
@JsonDeserialize
64+
data class KGreetingMessage @JsonCreator constructor(val message: String)
65+
```
66+
67+
As you can see, Kotlin code is a lot shorter and readable
68+
69+
## Run
70+
71+
Just type
72+
73+
```bash
74+
mvn lagom:runAll
75+
```
76+
And then go to [http://localhost:9000/api/hello/Kotlin](http://localhost:9000/api/hello/Kotlin)

cassandra-config/pom.xml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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
4+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.cakesolutions</groupId>
9+
<artifactId>lagomkotlin</artifactId>
10+
<version>1.0-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>cassandra-config</artifactId>
14+
15+
<packaging>jar</packaging>
16+
17+
<build>
18+
<plugins>
19+
<plugin>
20+
<artifactId>maven-assembly-plugin</artifactId>
21+
<configuration>
22+
<descriptors>
23+
<descriptor>src/assembly/conductr-bundle.xml</descriptor>
24+
</descriptors>
25+
</configuration>
26+
<executions>
27+
<execution>
28+
<id>conductr-bundle</id>
29+
<phase>package</phase>
30+
<goals>
31+
<goal>single</goal>
32+
</goals>
33+
</execution>
34+
</executions>
35+
</plugin>
36+
<plugin>
37+
<groupId>com.lightbend.lagom</groupId>
38+
<artifactId>lagom-maven-plugin</artifactId>
39+
<executions>
40+
<execution>
41+
<goals>
42+
<goal>renameConductRBundle</goal>
43+
</goals>
44+
</execution>
45+
</executions>
46+
</plugin>
47+
</plugins>
48+
</build>
49+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
4+
<id>conductr-bundle</id>
5+
<formats>
6+
<format>zip</format>
7+
</formats>
8+
<baseDirectory>cassandra-config-v1</baseDirectory>
9+
10+
<fileSets>
11+
<fileSet>
12+
<outputDirectory></outputDirectory>
13+
<directory>src/bundle</directory>
14+
</fileSet>
15+
</fileSets>
16+
17+
</assembly>
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name = "cassandra"
2+
system = "cassandra"
3+
components.cassandra = {
4+
endpoints = {
5+
"cas_native" = {
6+
bind-protocol = "tcp"
7+
bind-port = 0
8+
services = ["tcp://:9042/cas_native"]
9+
},
10+
// 'cas_rpc' endpoint need to be declared to override the endpoint from the cassandra bundle itself
11+
"cas_rpc" = {
12+
bind-protocol = "tcp"
13+
bind-port = 0
14+
services = []
15+
},
16+
"cas_storage" = {
17+
bind-protocol = "tcp"
18+
bind-port = 7000
19+
services = []
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)