diff --git a/.gradle/7.6/checksums/checksums.lock b/.gradle/7.6/checksums/checksums.lock new file mode 100644 index 0000000..badea3d Binary files /dev/null and b/.gradle/7.6/checksums/checksums.lock differ diff --git a/.gradle/7.6/checksums/md5-checksums.bin b/.gradle/7.6/checksums/md5-checksums.bin new file mode 100644 index 0000000..a789805 Binary files /dev/null and b/.gradle/7.6/checksums/md5-checksums.bin differ diff --git a/.gradle/7.6/checksums/sha1-checksums.bin b/.gradle/7.6/checksums/sha1-checksums.bin new file mode 100644 index 0000000..82bf507 Binary files /dev/null and b/.gradle/7.6/checksums/sha1-checksums.bin differ diff --git a/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock b/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..17ec484 Binary files /dev/null and b/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock differ diff --git a/.gradle/7.6/dependencies-accessors/gc.properties b/.gradle/7.6/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/7.6/executionHistory/executionHistory.bin b/.gradle/7.6/executionHistory/executionHistory.bin new file mode 100644 index 0000000..23b44b6 Binary files /dev/null and b/.gradle/7.6/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.6/executionHistory/executionHistory.lock b/.gradle/7.6/executionHistory/executionHistory.lock new file mode 100644 index 0000000..5e35069 Binary files /dev/null and b/.gradle/7.6/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.6/fileChanges/last-build.bin b/.gradle/7.6/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/.gradle/7.6/fileChanges/last-build.bin differ diff --git a/.gradle/7.6/fileHashes/fileHashes.bin b/.gradle/7.6/fileHashes/fileHashes.bin new file mode 100644 index 0000000..270d138 Binary files /dev/null and b/.gradle/7.6/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.6/fileHashes/fileHashes.lock b/.gradle/7.6/fileHashes/fileHashes.lock new file mode 100644 index 0000000..8f29b77 Binary files /dev/null and b/.gradle/7.6/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.6/fileHashes/resourceHashesCache.bin b/.gradle/7.6/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..ae3fd78 Binary files /dev/null and b/.gradle/7.6/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/7.6/gc.properties b/.gradle/7.6/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..c9c43a4 Binary files /dev/null and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..0bc465d --- /dev/null +++ b/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Mon Dec 18 22:00:55 CET 2023 +gradle.version=7.6 diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..7768133 Binary files /dev/null and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe new file mode 100644 index 0000000..f373584 Binary files /dev/null and b/.gradle/file-system.probe differ diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..e58d3e4 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml new file mode 100644 index 0000000..8b57f45 --- /dev/null +++ b/.idea/google-java-format.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..d0dbce0 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..cdb1d4f --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jpa-buddy.xml b/.idea/jpa-buddy.xml new file mode 100644 index 0000000..966d5f5 --- /dev/null +++ b/.idea/jpa-buddy.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..1a227fb --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,16 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..288b36b --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..918b621 --- /dev/null +++ b/README.txt @@ -0,0 +1,12 @@ + +Juego del bien público + +- Varios jugadores. +- Reciben monedas al comienzo. +- Hay un bote central +- Cada turno se elige con cuántas monedas uno colabora al bote +- Entonces, el contenido del bote se multiplica por dos y se divide entre todos los jugadores. +- Pasadas N rondas, el jugador se queda con lo que ganó + monedas iniciales. + +Comprobar cómo de dispuesta está la gente a contribuir a un bien, que será compartido por todos por igual, +hayan contribuido o no. diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..2af1428 --- /dev/null +++ b/build.gradle @@ -0,0 +1,25 @@ +apply plugin: 'java' +apply plugin: 'idea' +apply plugin: 'application' + + +repositories { + mavenCentral() + mavenLocal() + maven { + url "https://repo.akka.io/maven" + } +} + +dependencies { + implementation 'com.typesafe.akka:akka-actor-typed_2.13:2.9.0' + implementation 'ch.qos.logback:logback-classic:1.2.3' + testImplementation 'com.typesafe.akka:akka-actor-testkit-typed_2.13:2.9.0' + testImplementation 'junit:junit:4.13.1' +} + +mainClassName = "com.example.AkkaQuickstart" + +run { + standardInput = System.in +} diff --git a/build.sbt b/build.sbt new file mode 100644 index 0000000..7826143 --- /dev/null +++ b/build.sbt @@ -0,0 +1,24 @@ +name := "akka-quickstart-java" + +version := "1.0" + +scalaVersion := "2.13.12" + +lazy val akkaVersion = "2.9.0" + +resolvers += "Akka library repository".at("https://repo.akka.io/maven") + +// Run in a separate JVM, to make sure sbt waits until all threads have +// finished before returning. +// If you want to keep the application running while executing other +// sbt tasks, consider https://github.com/spray/sbt-revolver/ +fork := true + +resolvers += "Akka library repository".at("https://repo.akka.io/maven") + +libraryDependencies ++= Seq( + "com.typesafe.akka" %% "akka-actor-typed" % akkaVersion, + "com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion, + "ch.qos.logback" % "logback-classic" % "1.2.3", + "junit" % "junit" % "4.13.1" % Test, + "com.novocode" % "junit-interface" % "0.11" % Test) diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatQuickStart$Main.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatQuickStart$Main.class new file mode 100644 index 0000000..c6fcb07 Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatQuickStart$Main.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatQuickStart.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatQuickStart.class new file mode 100644 index 0000000..0651672 Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatQuickStart.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$GetSession.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$GetSession.class new file mode 100644 index 0000000..2a37433 Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$GetSession.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$MessagePosted.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$MessagePosted.class new file mode 100644 index 0000000..5febfbb Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$MessagePosted.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$NotifyClient.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$NotifyClient.class new file mode 100644 index 0000000..777ceb1 Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$NotifyClient.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$PostMessage.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$PostMessage.class new file mode 100644 index 0000000..4342948 Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$PostMessage.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$PublishSessionMessage.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$PublishSessionMessage.class new file mode 100644 index 0000000..a474278 Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$PublishSessionMessage.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$RoomCommand.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$RoomCommand.class new file mode 100644 index 0000000..919c9a0 Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$RoomCommand.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$Session.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$Session.class new file mode 100644 index 0000000..605f13a Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$Session.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$SessionCommand.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$SessionCommand.class new file mode 100644 index 0000000..fe5bc26 Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$SessionCommand.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$SessionDenied.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$SessionDenied.class new file mode 100644 index 0000000..d1014c5 Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$SessionDenied.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$SessionEvent.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$SessionEvent.class new file mode 100644 index 0000000..255b807 Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$SessionEvent.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$SessionGranted.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$SessionGranted.class new file mode 100644 index 0000000..c3838cd Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom$SessionGranted.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom.class b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom.class new file mode 100644 index 0000000..b5457f1 Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/ChatRoom.class differ diff --git a/build/classes/java/main/dev/freireservices/social_altruism/Gabbler.class b/build/classes/java/main/dev/freireservices/social_altruism/Gabbler.class new file mode 100644 index 0000000..0f0ccd4 Binary files /dev/null and b/build/classes/java/main/dev/freireservices/social_altruism/Gabbler.class differ diff --git a/build/classes/java/test/dev/freireservices/social_altruism/ChatQuickStartTest.class b/build/classes/java/test/dev/freireservices/social_altruism/ChatQuickStartTest.class new file mode 100644 index 0000000..4e78a82 Binary files /dev/null and b/build/classes/java/test/dev/freireservices/social_altruism/ChatQuickStartTest.class differ diff --git a/build/reports/tests/test/classes/dev.freireservices.social_altruism.ChatQuickStartTest.html b/build/reports/tests/test/classes/dev.freireservices.social_altruism.ChatQuickStartTest.html new file mode 100644 index 0000000..fa1e4c8 --- /dev/null +++ b/build/reports/tests/test/classes/dev.freireservices.social_altruism.ChatQuickStartTest.html @@ -0,0 +1,146 @@ + + + + + +Test results - Class dev.freireservices.social_altruism.ChatQuickStartTest + + + + + +
+

Class dev.freireservices.social_altruism.ChatQuickStartTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
2
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.944s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + +
TestDurationResult
testActorGetsUserDenied0.856spassed
testGreeterActorSendingOfGreeting0.088spassed
+
+
+

Standard output

+ +
[2023-12-22 09:02:23,397] [INFO] [akka.event.slf4j.Slf4jLogger] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [] - Slf4jLogger started
+[2023-12-22 09:02:23,552] [ERROR] [akka.actor.testkit.typed.internal.ActorTestKitGuardian$$anonfun$handleSpawnException$1] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user] - Spawn failed, props [EmptyProps]
+akka.actor.InvalidActorNameException: actor name [chatRoom] is not unique!
+	at akka.actor.dungeon.ChildrenContainer$NormalChildrenContainer.reserve(ChildrenContainer.scala:134)
+	at akka.actor.dungeon.Children.reserveChild(Children.scala:147)
+	at akka.actor.dungeon.Children.reserveChild$(Children.scala:145)
+	at akka.actor.ActorCell.reserveChild(ActorCell.scala:410)
+	at akka.actor.dungeon.Children.makeChild(Children.scala:300)
+	at akka.actor.dungeon.Children.actorOf(Children.scala:49)
+	at akka.actor.dungeon.Children.actorOf$(Children.scala:48)
+	at akka.actor.ActorCell.actorOf(ActorCell.scala:410)
+	at akka.actor.typed.internal.adapter.ActorRefFactoryAdapter$.spawn(ActorRefFactoryAdapter.scala:55)
+	at akka.actor.typed.internal.adapter.ActorContextAdapter.spawn(ActorContextAdapter.scala:73)
+	at akka.actor.testkit.typed.internal.ActorTestKitGuardian$.$anonfun$testKitGuardian$1(TestKitUtils.scala:35)
+	at akka.actor.typed.internal.BehaviorImpl$ReceiveBehavior.receive(BehaviorImpl.scala:136)
+	at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
+	at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
+	at akka.actor.typed.internal.InterceptorImpl$$anon$2.apply(InterceptorImpl.scala:57)
+	at akka.actor.typed.internal.adapter.GuardianStopInterceptor.aroundReceive(GuardianStartupBehavior.scala:59)
+	at akka.actor.typed.internal.InterceptorImpl.receive(InterceptorImpl.scala:85)
+	at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
+	at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
+	at akka.actor.typed.internal.adapter.ActorAdapter.handleMessage(ActorAdapter.scala:133)
+	at akka.actor.typed.internal.adapter.ActorAdapter.aroundReceive(ActorAdapter.scala:109)
+	at akka.actor.ActorCell.receiveMessage(ActorCell.scala:579)
+	at akka.actor.ActorCell.invoke(ActorCell.scala:547)
+	at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:270)
+	at akka.dispatch.Mailbox.run(Mailbox.scala:231)
+	at akka.dispatch.Mailbox.exec(Mailbox.scala:243)
+	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
+	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1311)
+	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1840)
+	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1806)
+	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
+[2023-12-22 09:02:23,640] [INFO] [akka.actor.LocalActorRef] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/$a] - Message [dev.freireservices.social_altruism.ChatRoom$GetSession] to Actor[akka://ChatQuickStartTest/user/$a#-835521502] was not delivered. [1] dead letters encountered. If this is not an expected behavior then Actor[akka://ChatQuickStartTest/user/$a#-835521502] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
+[2023-12-22 09:02:23,665] [INFO] [akka.actor.CoordinatedShutdown] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [CoordinatedShutdown(akka://ChatQuickStartTest)] - Running CoordinatedShutdown with reason [ActorSystemTerminateReason]
+
+
+
+
+ +
+ + diff --git a/build/reports/tests/test/css/base-style.css b/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/build/reports/tests/test/css/style.css b/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/build/reports/tests/test/index.html b/build/reports/tests/test/index.html new file mode 100644 index 0000000..39cfb74 --- /dev/null +++ b/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
2
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.944s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+dev.freireservices.social_altruism +2000.944s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+dev.freireservices.social_altruism.ChatQuickStartTest +2000.944s100%
+
+
+ +
+ + diff --git a/build/reports/tests/test/js/report.js b/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/build/reports/tests/test/packages/dev.freireservices.social_altruism.html b/build/reports/tests/test/packages/dev.freireservices.social_altruism.html new file mode 100644 index 0000000..ca1a291 --- /dev/null +++ b/build/reports/tests/test/packages/dev.freireservices.social_altruism.html @@ -0,0 +1,103 @@ + + + + + +Test results - Package dev.freireservices.social_altruism + + + + + +
+

Package dev.freireservices.social_altruism

+ +
+ + + + + +
+
+ + + + + + + +
+
+
2
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.944s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+ChatQuickStartTest +2000.944s100%
+
+
+ +
+ + diff --git a/build/resources/main/logback.xml b/build/resources/main/logback.xml new file mode 100644 index 0000000..203596d --- /dev/null +++ b/build/resources/main/logback.xml @@ -0,0 +1,21 @@ + + + + + + [%date{ISO8601}] [%level] [%logger] [%thread] [%X{akkaSource}] - %msg%n + + + + + 1024 + true + + + + + + + + diff --git a/build/test-results/test/TEST-dev.freireservices.social_altruism.ChatQuickStartTest.xml b/build/test-results/test/TEST-dev.freireservices.social_altruism.ChatQuickStartTest.xml new file mode 100644 index 0000000..39910e7 --- /dev/null +++ b/build/test-results/test/TEST-dev.freireservices.social_altruism.ChatQuickStartTest.xml @@ -0,0 +1,44 @@ + + + + + + + + diff --git a/build/test-results/test/binary/output.bin b/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e4ba414 Binary files /dev/null and b/build/test-results/test/binary/output.bin differ diff --git a/build/test-results/test/binary/output.bin.idx b/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..480e221 Binary files /dev/null and b/build/test-results/test/binary/output.bin.idx differ diff --git a/build/test-results/test/binary/results.bin b/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..46f5c17 Binary files /dev/null and b/build/test-results/test/binary/results.bin differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatQuickStart$Main.class.uniqueId3 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatQuickStart$Main.class.uniqueId3 new file mode 100644 index 0000000..c6fcb07 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatQuickStart$Main.class.uniqueId3 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatQuickStart.class.uniqueId5 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatQuickStart.class.uniqueId5 new file mode 100644 index 0000000..0651672 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatQuickStart.class.uniqueId5 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$GetSession.class.uniqueId1 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$GetSession.class.uniqueId1 new file mode 100644 index 0000000..2a37433 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$GetSession.class.uniqueId1 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$MessagePosted.class.uniqueId2 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$MessagePosted.class.uniqueId2 new file mode 100644 index 0000000..def7f0e Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$MessagePosted.class.uniqueId2 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$NotifyClient.class.uniqueId11 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$NotifyClient.class.uniqueId11 new file mode 100644 index 0000000..dcab200 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$NotifyClient.class.uniqueId11 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$PostMessage.class.uniqueId9 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$PostMessage.class.uniqueId9 new file mode 100644 index 0000000..2739d8c Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$PostMessage.class.uniqueId9 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$PublishSessionMessage.class.uniqueId4 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$PublishSessionMessage.class.uniqueId4 new file mode 100644 index 0000000..a474278 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$PublishSessionMessage.class.uniqueId4 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$RoomCommand.class.uniqueId10 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$RoomCommand.class.uniqueId10 new file mode 100644 index 0000000..919c9a0 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$RoomCommand.class.uniqueId10 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$Session.class.uniqueId12 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$Session.class.uniqueId12 new file mode 100644 index 0000000..63ecff2 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$Session.class.uniqueId12 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$SessionCommand.class.uniqueId13 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$SessionCommand.class.uniqueId13 new file mode 100644 index 0000000..fe5bc26 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$SessionCommand.class.uniqueId13 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$SessionDenied.class.uniqueId14 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$SessionDenied.class.uniqueId14 new file mode 100644 index 0000000..fde18cd Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$SessionDenied.class.uniqueId14 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$SessionEvent.class.uniqueId8 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$SessionEvent.class.uniqueId8 new file mode 100644 index 0000000..255b807 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$SessionEvent.class.uniqueId8 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$SessionGranted.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$SessionGranted.class.uniqueId0 new file mode 100644 index 0000000..c3838cd Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom$SessionGranted.class.uniqueId0 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom.class.uniqueId6 b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom.class.uniqueId6 new file mode 100644 index 0000000..b5457f1 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ChatRoom.class.uniqueId6 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/Gabbler.class.uniqueId7 b/build/tmp/compileJava/compileTransaction/stash-dir/Gabbler.class.uniqueId7 new file mode 100644 index 0000000..0f0ccd4 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/Gabbler.class.uniqueId7 differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..437ae5b Binary files /dev/null and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/build/tmp/compileTestJava/compileTransaction/stash-dir/ChatQuickStartTest.class.uniqueId0 b/build/tmp/compileTestJava/compileTransaction/stash-dir/ChatQuickStartTest.class.uniqueId0 new file mode 100644 index 0000000..72a8bcd Binary files /dev/null and b/build/tmp/compileTestJava/compileTransaction/stash-dir/ChatQuickStartTest.class.uniqueId0 differ diff --git a/build/tmp/compileTestJava/previous-compilation-data.bin b/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..02c8f29 Binary files /dev/null and b/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..c1962a7 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..f398c33 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..aeb74cb --- /dev/null +++ b/gradlew @@ -0,0 +1,245 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..6689b85 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..e51e716 --- /dev/null +++ b/pom.xml @@ -0,0 +1,71 @@ + + + 4.0.0 + + hello-akka-java + app + 1.0 + + + 2.9.0 + + + + + akka-repository + Akka library repository + https://repo.akka.io/maven + + + + + + com.typesafe.akka + akka-actor-typed_2.13 + ${akka.version} + + + ch.qos.logback + logback-classic + 1.2.11 + + + com.typesafe.akka + akka-actor-testkit-typed_2.13 + ${akka.version} + test + + + junit + junit + 4.13.2 + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 17 + 17 + + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + java + + -classpath + + dev.freireservices.social_altruism.ChatQuickStart + + + + + + diff --git a/project/build.properties b/project/build.properties new file mode 100644 index 0000000..abbbce5 --- /dev/null +++ b/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.9.8 diff --git a/sbt b/sbt new file mode 100755 index 0000000..efdfda6 --- /dev/null +++ b/sbt @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +./sbt-dist/bin/sbt "$@" \ No newline at end of file diff --git a/sbt-dist/bin/sbt b/sbt-dist/bin/sbt new file mode 100755 index 0000000..a3f9443 --- /dev/null +++ b/sbt-dist/bin/sbt @@ -0,0 +1,605 @@ +#!/usr/bin/env bash + +set +e +declare -a residual_args +declare -a java_args +declare -a scalac_args +declare -a sbt_commands +declare -a sbt_options +declare -a print_version +declare -a print_sbt_version +declare -a print_sbt_script_version +declare java_cmd=java +declare java_version +declare init_sbt_version=_to_be_replaced +declare sbt_default_mem=1024 +declare -r default_sbt_opts="" +declare -r default_java_opts="-Dfile.encoding=UTF-8" +declare sbt_verbose= +declare sbt_debug= + +### ------------------------------- ### +### Helper methods for BASH scripts ### +### ------------------------------- ### + +# Bash reimplementation of realpath to return the absolute path +realpathish () { +( + TARGET_FILE="$1" + FIX_CYGPATH="$2" + + cd "$(dirname "$TARGET_FILE")" + TARGET_FILE=$(basename "$TARGET_FILE") + + COUNT=0 + while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ] + do + TARGET_FILE=$(readlink "$TARGET_FILE") + cd "$(dirname "$TARGET_FILE")" + TARGET_FILE=$(basename "$TARGET_FILE") + COUNT=$(($COUNT + 1)) + done + + # make sure we grab the actual windows path, instead of cygwin's path. + if [[ "x$FIX_CYGPATH" != "x" ]]; then + echo "$(cygwinpath "$(pwd -P)/$TARGET_FILE")" + else + echo "$(pwd -P)/$TARGET_FILE" + fi +) +} + +# Uses uname to detect if we're in the odd cygwin environment. +is_cygwin() { + local os=$(uname -s) + case "$os" in + CYGWIN*) return 0 ;; + MINGW*) return 0 ;; + MSYS*) return 0 ;; + *) return 1 ;; + esac +} + +# TODO - Use nicer bash-isms here. +CYGWIN_FLAG=$(if is_cygwin; then echo true; else echo false; fi) + +# This can fix cygwin style /cygdrive paths so we get the +# windows style paths. +cygwinpath() { + local file="$1" + if [[ "$CYGWIN_FLAG" == "true" ]]; then #" + echo $(cygpath -w $file) + else + echo $file + fi +} + + +declare -r sbt_bin_dir="$(dirname "$(realpathish "$0")")" +declare -r sbt_home="$(dirname "$sbt_bin_dir")" + +echoerr () { + echo 1>&2 "$@" +} +vlog () { + [[ $sbt_verbose || $sbt_debug ]] && echoerr "$@" +} +dlog () { + [[ $sbt_debug ]] && echoerr "$@" +} + +jar_file () { + echo "$(cygwinpath "${sbt_home}/bin/sbt-launch.jar")" +} + +acquire_sbt_jar () { + sbt_jar="$(jar_file)" + + if [[ ! -f "$sbt_jar" ]]; then + echoerr "Could not find launcher jar: $sbt_jar" + exit 2 + fi +} + +rt_export_file () { + echo "${sbt_bin_dir}/java9-rt-export.jar" +} + +# execRunner should be called only once to give up control to java +execRunner () { + # print the arguments one to a line, quoting any containing spaces + [[ $sbt_verbose || $sbt_debug ]] && echo "# Executing command line:" && { + for arg; do + if printf "%s\n" "$arg" | grep -q ' '; then + printf "\"%s\"\n" "$arg" + else + printf "%s\n" "$arg" + fi + done + echo "" + } + + if [[ "$CYGWIN_FLAG" == "true" ]]; then + # In cygwin we loose the ability to re-hook stty if exec is used + # https://github.com/sbt/sbt-launcher-package/issues/53 + "$@" + else + exec "$@" + fi +} + +addJava () { + dlog "[addJava] arg = '$1'" + java_args=( "${java_args[@]}" "$1" ) +} +addSbt () { + dlog "[addSbt] arg = '$1'" + sbt_commands=( "${sbt_commands[@]}" "$1" ) +} +addResidual () { + dlog "[residual] arg = '$1'" + residual_args=( "${residual_args[@]}" "$1" ) +} +addDebugger () { + addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$1" +} + +addMemory () { + dlog "[addMemory] arg = '$1'" + # evict memory related options + local xs=("${java_args[@]}") + java_args=() + for i in "${xs[@]}"; do + if ! [[ "${i}" == *-Xmx* ]] && ! [[ "${i}" == *-Xms* ]] && ! [[ "${i}" == *-XX:MaxPermSize* ]] && ! [[ "${i}" == *-XX:MaxMetaspaceSize* ]] && ! [[ "${i}" == *-XX:ReservedCodeCacheSize* ]]; then + java_args+=("${i}") + fi + done + local ys=("${sbt_options[@]}") + sbt_options=() + for i in "${ys[@]}"; do + if ! [[ "${i}" == *-Xmx* ]] && ! [[ "${i}" == *-Xms* ]] && ! [[ "${i}" == *-XX:MaxPermSize* ]] && ! [[ "${i}" == *-XX:MaxMetaspaceSize* ]] && ! [[ "${i}" == *-XX:ReservedCodeCacheSize* ]]; then + sbt_options+=("${i}") + fi + done + # a ham-fisted attempt to move some memory settings in concert + local mem=$1 + local codecache=$(( $mem / 8 )) + (( $codecache > 128 )) || codecache=128 + (( $codecache < 512 )) || codecache=512 + local class_metadata_size=$(( $codecache * 2 )) + if [[ -z $java_version ]]; then + java_version=$(jdk_version) + fi + + addJava "-Xms${mem}m" + addJava "-Xmx${mem}m" + addJava "-Xss4M" + addJava "-XX:ReservedCodeCacheSize=${codecache}m" + (( $java_version >= 8 )) || addJava "-XX:MaxPermSize=${class_metadata_size}m" +} + +addDefaultMemory() { + # if we detect any of these settings in ${JAVA_OPTS} or ${JAVA_TOOL_OPTIONS} we need to NOT output our settings. + # The reason is the Xms/Xmx, if they don't line up, cause errors. + if [[ "${java_args[@]}" == *-Xmx* ]] || \ + [[ "${java_args[@]}" == *-Xms* ]] || \ + [[ "${java_args[@]}" == *-XX:+UseCGroupMemoryLimitForHeap* ]] || \ + [[ "${java_args[@]}" == *-XX:MaxRAM* ]] || \ + [[ "${java_args[@]}" == *-XX:InitialRAMPercentage* ]] || \ + [[ "${java_args[@]}" == *-XX:MaxRAMPercentage* ]] || \ + [[ "${java_args[@]}" == *-XX:MinRAMPercentage* ]]; then + : + elif [[ "${JAVA_TOOL_OPTIONS}" == *-Xmx* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-Xms* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:+UseCGroupMemoryLimitForHeap* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxRAM* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:InitialRAMPercentage* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxRAMPercentage* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MinRAMPercentage* ]] ; then + : + elif [[ "${sbt_options[@]}" == *-Xmx* ]] || \ + [[ "${sbt_options[@]}" == *-Xms* ]] || \ + [[ "${sbt_options[@]}" == *-XX:+UseCGroupMemoryLimitForHeap* ]] || \ + [[ "${sbt_options[@]}" == *-XX:MaxRAM* ]] || \ + [[ "${sbt_options[@]}" == *-XX:InitialRAMPercentage* ]] || \ + [[ "${sbt_options[@]}" == *-XX:MaxRAMPercentage* ]] || \ + [[ "${sbt_options[@]}" == *-XX:MinRAMPercentage* ]] ; then + : + else + addMemory $sbt_default_mem + fi +} + +require_arg () { + local type="$1" + local opt="$2" + local arg="$3" + if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then + echo "$opt requires <$type> argument" + exit 1 + fi +} + +is_function_defined() { + declare -f "$1" > /dev/null +} + +# parses JDK version from the -version output line. +# 8 for 1.8.0_nn, 9 for 9-ea etc, and "no_java" for undetected +jdk_version() { + local result + local lines=$("$java_cmd" -Xms32M -Xmx32M -version 2>&1 | tr '\r' '\n') + local IFS=$'\n' + for line in $lines; do + if [[ (-z $result) && ($line = *"version \""*) ]] + then + local ver=$(echo $line | sed -e 's/.*version "\(.*\)"\(.*\)/\1/; 1q') + # on macOS sed doesn't support '?' + if [[ $ver = "1."* ]] + then + result=$(echo $ver | sed -e 's/1\.\([0-9]*\)\(.*\)/\1/; 1q') + else + result=$(echo $ver | sed -e 's/\([0-9]*\)\(.*\)/\1/; 1q') + fi + fi + done + if [[ -z $result ]] + then + result=no_java + fi + echo "$result" +} + +# Extracts the preloaded directory from either -Dsbt.preloaded or -Dsbt.global.base +# properties by looking at: +# - _JAVA_OPTIONS environment variable, +# - SBT_OPTS environment variable, +# - JAVA_OPTS environment variable and +# - properties set by command-line options +# in that order. The last one will be chosen such that `sbt.preloaded` is +# always preferred over `sbt.global.base`. +getPreloaded() { + local -a _java_options_array + local -a sbt_opts_array + local -a java_opts_array + read -a _java_options_array <<< "$_JAVA_OPTIONS" + read -a sbt_opts_array <<< "$SBT_OPTS" + read -a java_opts_array <<< "$JAVA_OPTS" + + local args_to_check=( + "${_java_options_array[@]}" + "${sbt_opts_array[@]}" + "${java_opts_array[@]}" + "${java_args[@]}") + local via_global_base="$HOME/.sbt/preloaded" + local via_explicit="" + + for opt in "${args_to_check[@]}"; do + if [[ "$opt" == -Dsbt.preloaded=* ]]; then + via_explicit="${opt#-Dsbt.preloaded=}" + elif [[ "$opt" == -Dsbt.global.base=* ]]; then + via_global_base="${opt#-Dsbt.global.base=}/preloaded" + fi + done + + echo "${via_explicit:-${via_global_base}}" +} + +syncPreloaded() { + local source_preloaded="$sbt_home/lib/local-preloaded/" + local target_preloaded="$(getPreloaded)" + if [[ "$init_sbt_version" == "" ]]; then + # FIXME: better $init_sbt_version detection + init_sbt_version="$(ls -1 "$source_preloaded/org/scala-sbt/sbt/")" + fi + [[ -f "$target_preloaded/org/scala-sbt/sbt/$init_sbt_version/" ]] || { + # lib/local-preloaded exists (This is optional) + [[ -d "$source_preloaded" ]] && { + command -v rsync >/dev/null 2>&1 && { + mkdir -p "$target_preloaded" + rsync --recursive --links --perms --times --ignore-existing "$source_preloaded" "$target_preloaded" || true + } + } + } +} + +# Detect that we have java installed. +checkJava() { + local required_version="$1" + # Now check to see if it's a good enough version + local good_enough="$(expr $java_version ">=" $required_version)" + if [[ "$java_version" == "" ]]; then + echo + echo "No Java Development Kit (JDK) installation was detected." + echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download. + echo + exit 1 + elif [[ "$good_enough" != "1" ]]; then + echo + echo "The Java Development Kit (JDK) installation you have is not up to date." + echo $script_name requires at least version $required_version+, you have + echo version $java_version + echo + echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download + echo a valid JDK and install before running $script_name. + echo + exit 1 + fi +} + +copyRt() { + local at_least_9="$(expr $java_version ">=" 9)" + if [[ "$at_least_9" == "1" ]]; then + rtexport=$(rt_export_file) + # The grep for java9-rt-ext- matches the filename prefix printed in Export.java + java9_ext=$("$java_cmd" "${sbt_options[@]}" "${java_args[@]}" \ + -jar "$rtexport" --rt-ext-dir | grep java9-rt-ext-) + java9_rt=$(echo "$java9_ext/rt.jar") + vlog "[copyRt] java9_rt = '$java9_rt'" + if [[ ! -f "$java9_rt" ]]; then + echo copying runtime jar... + mkdir -p "$java9_ext" + "$java_cmd" \ + "${sbt_options[@]}" \ + "${java_args[@]}" \ + -jar "$rtexport" \ + "${java9_rt}" + fi + addJava "-Dscala.ext.dirs=${java9_ext}" + fi +} + +run() { + java_args=($JAVA_OPTS) + sbt_options0=(${SBT_OPTS:-$default_sbt_opts}) + + # Split SBT_OPTS into options/commands + miniscript=$(map_args "${sbt_options0[@]}") && eval "${miniscript/options/sbt_options}" && \ + eval "${miniscript/commands/sbt_additional_commands}" + + # Combine command line options/commands and commands from SBT_OPTS + miniscript=$(map_args "$@") && eval "${miniscript/options/cli_options}" && eval "${miniscript/commands/cli_commands}" + args1=( "${cli_options[@]}" "${cli_commands[@]}" "${sbt_additional_commands[@]}" ) + + # process the combined args, then reset "$@" to the residuals + process_args "${args1[@]}" + vlog "[sbt_options] $(declare -p sbt_options)" + + addDefaultMemory + set -- "${residual_args[@]}" + argumentCount=$# + + # Copy preloaded repo to user's preloaded directory + syncPreloaded + + # no jar? download it. + [[ -f "$sbt_jar" ]] || acquire_sbt_jar "$sbt_version" || { + # still no jar? uh-oh. + echo "Download failed. Obtain the sbt-launch.jar manually and place it at $sbt_jar" + exit 1 + } + + # TODO - java check should be configurable... + checkJava "6" + + # Java 9 support + copyRt + + # If we're in cygwin, we should use the windows config, and terminal hacks + if [[ "$CYGWIN_FLAG" == "true" ]]; then #" + stty -icanon min 1 -echo > /dev/null 2>&1 + addJava "-Djline.terminal=jline.UnixTerminal" + addJava "-Dsbt.cygwin=true" + fi + + if [[ $print_sbt_version ]]; then + execRunner "$java_cmd" -jar "$sbt_jar" "sbtVersion" | tail -1 | sed -e 's/\[info\]//g' + elif [[ $print_sbt_script_version ]]; then + echo "$init_sbt_version" + elif [[ $print_version ]]; then + execRunner "$java_cmd" -jar "$sbt_jar" "sbtVersion" | tail -1 | sed -e 's/\[info\]/sbt version in this project:/g' + echo "sbt script version: $init_sbt_version" + else + # run sbt + execRunner "$java_cmd" \ + "${java_args[@]}" \ + "${sbt_options[@]}" \ + -jar "$sbt_jar" \ + "${sbt_commands[@]}" \ + "${residual_args[@]}" + fi + + exit_code=$? + + # Clean up the terminal from cygwin hacks. + if [[ "$CYGWIN_FLAG" == "true" ]]; then #" + stty icanon echo > /dev/null 2>&1 + fi + exit $exit_code +} + +declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" +declare -r sbt_opts_file=".sbtopts" +declare -r etc_sbt_opts_file="/etc/sbt/sbtopts" +# this allows /etc/sbt/sbtopts location to be changed +declare -r etc_file="${SBT_ETC_FILE:-$etc_sbt_opts_file}" +declare -r dist_sbt_opts_file="${sbt_home}/conf/sbtopts" +declare -r win_sbt_opts_file="${sbt_home}/conf/sbtconfig.txt" + +usage() { + cat < path to global settings/plugins directory (default: ~/.sbt) + --sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) + --ivy path to local Ivy repository (default: ~/.ivy2) + --mem set memory options (default: $sbt_default_mem) + --no-share use all local caches; no sharing + --no-global uses global caches, but does not use global ~/.sbt directory. + --jvm-debug Turn on JVM debugging, open at the given port. + --batch disable interactive mode + + # sbt version (default: from project/build.properties if present, else latest release) + --sbt-version use the specified version of sbt + --sbt-jar use the specified jar as the sbt launcher + + # java version (default: java from PATH, currently $(java -version 2>&1 | grep version)) + --java-home alternate JAVA_HOME + + # jvm options and output control + JAVA_OPTS environment variable, if unset uses "$default_java_opts" + .jvmopts if this file exists in the current directory, its contents + are appended to JAVA_OPTS + SBT_OPTS environment variable, if unset uses "$default_sbt_opts" + .sbtopts if this file exists in the current directory, its contents + are prepended to the runner args + /etc/sbt/sbtopts if this file exists, it is prepended to the runner args + -Dkey=val pass -Dkey=val directly to the java runtime + -J-X pass option -X directly to the java runtime + (-J is stripped) + -S-X add -X to sbt's scalacOptions (-S is stripped) + +In the case of duplicated or conflicting options, the order above +shows precedence: JAVA_OPTS lowest, command line options highest. +EOM +} + +process_my_args () { + while [[ $# -gt 0 ]]; do + case "$1" in + -batch|--batch) exec + + -sbt-create|--sbt-create) sbt_create=true && shift ;; + + new) sbt_new=true && addResidual "$1" && shift ;; + + *) addResidual "$1" && shift ;; + esac + done + + # Now, ensure sbt version is used. + [[ "${sbt_version}XXX" != "XXX" ]] && addJava "-Dsbt.version=$sbt_version" + + # Confirm a user's intent if the current directory does not look like an sbt + # top-level directory and neither the -sbt-create option nor the "new" + # command was given. + [[ -f ./build.sbt || -d ./project || -n "$sbt_create" || -n "$sbt_new" ]] || { + echo "[warn] Neither build.sbt nor a 'project' directory in the current directory: $(pwd)" + while true; do + echo 'c) continue' + echo 'q) quit' + + read -p '? ' || exit 1 + case "$REPLY" in + c|C) break ;; + q|Q) exit 1 ;; + esac + done + } +} + +## map over argument array. this is used to process both command line arguments and SBT_OPTS +map_args () { + local options=() + local commands=() + while [[ $# -gt 0 ]]; do + case "$1" in + -no-colors|--no-colors) options=( "${options[@]}" "-Dsbt.log.noformat=true" ) && shift ;; + -timings|--timings) options=( "${options[@]}" "-Dsbt.task.timings=true" "-Dsbt.task.timings.on.shutdown=true" ) && shift ;; + -traces|--traces) options=( "${options[@]}" "-Dsbt.traces=true" ) && shift ;; + --supershell=*) options=( "${options[@]}" "-Dsbt.supershell=${1:13}" ) && shift ;; + -supershell=*) options=( "${options[@]}" "-Dsbt.supershell=${1:12}" ) && shift ;; + --color=*) options=( "${options[@]}" "-Dsbt.color=${1:8}" ) && shift ;; + -color=*) options=( "${options[@]}" "-Dsbt.color=${1:7}" ) && shift ;; + -no-share|--no-share) options=( "${options[@]}" "$noshare_opts" ) && shift ;; + -no-global|--no-global) options=( "${options[@]}" "-Dsbt.global.base=$(pwd)/project/.sbtboot" ) && shift ;; + -sbt-boot|--sbt-boot) require_arg path "$1" "$2" && options=( "${options[@]}" "-Dsbt.boot.directory=$2" ) && shift 2 ;; + -sbt-dir|--sbt-dir) require_arg path "$1" "$2" && options=( "${options[@]}" "-Dsbt.global.base=$2" ) && shift 2 ;; + -debug|--debug) commands=( "${commands[@]}" "-debug" ) && shift ;; + -debug-inc|--debug-inc) options=( "${options[@]}" "-Dxsbt.inc.debug=true" ) && shift ;; + *) options=( "${options[@]}" "$1" ) && shift ;; + esac + done + declare -p options + declare -p commands +} + +process_args () { + while [[ $# -gt 0 ]]; do + case "$1" in + -h|-help|--help) usage; exit 1 ;; + -v|-verbose|--verbose) sbt_verbose=1 && shift ;; + -V|-version|--version) print_version=1 && shift ;; + --numeric-version) print_sbt_version=1 && shift ;; + --script-version) print_sbt_script_version=1 && shift ;; + -d|-debug|--debug) sbt_debug=1 && addSbt "-debug" && shift ;; + + -ivy|--ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; + -mem|--mem) require_arg integer "$1" "$2" && addMemory "$2" && shift 2 ;; + -jvm-debug|--jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; + -batch|--batch) exec nul >nul + if !JVM_DEBUG_PORT! EQU 0 ( + rem next argument wasn't a port, set a default and process next arg + set /A JVM_DEBUG_PORT=5005 + goto args_loop + ) else ( + shift + goto args_loop + ) + ) +) + +if "%~0" == "-java-home" set _java_home_arg=true +if "%~0" == "--java-home" set _java_home_arg=true + +if defined _java_home_arg ( + set _java_home_arg= + if not "%~1" == "" ( + if exist "%~1\bin\java.exe" ( + set "_JAVACMD=%~1\bin\java.exe" + set "JAVA_HOME=%~1" + set "JDK_HOME=%~1" + shift + goto args_loop + ) else ( + echo Directory "%~1" for JAVA_HOME is not valid + goto error + ) + ) else ( + echo Second argument for --java-home missing + goto error + ) +) + +if "%~0" == "new" ( + if not defined SBT_ARGS ( + set sbt_new=true + ) +) + +if "%g:~0,2%" == "-D" ( + rem special handling for -D since '=' gets parsed away + for /F "tokens=1 delims==" %%a in ("%g%") do ( + rem make sure it doesn't have the '=' already + if "%g%" == "%%a" ( + if not "%~1" == "" ( + call :dlog [args_loop] -D argument %~0=%~1 + set "SBT_ARGS=!SBT_ARGS! %~0=%~1" + shift + goto args_loop + ) else ( + echo %g% is missing a value + goto error + ) + ) else ( + call :dlog [args_loop] -D argument %~0 + set "SBT_ARGS=!SBT_ARGS! %~0" + goto args_loop + ) + ) +) + +if not "%g:~0,5%" == "-XX:+" if not "%g:~0,5%" == "-XX:-" if "%g:~0,3%" == "-XX" ( + rem special handling for -XX since '=' gets parsed away + for /F "tokens=1 delims==" %%a in ("%g%") do ( + rem make sure it doesn't have the '=' already + if "%g%" == "%%a" ( + if not "%~1" == "" ( + call :dlog [args_loop] -XX argument %~0=%~1 + set "SBT_ARGS=!SBT_ARGS! %~0=%~1" + shift + goto args_loop + ) else ( + echo %g% is missing a value + goto error + ) + ) else ( + call :dlog [args_loop] -XX argument %~0 + set "SBT_ARGS=!SBT_ARGS! %~0" + goto args_loop + ) + ) +) + +rem the %0 (instead of %~0) preserves original argument quoting +set SBT_ARGS=!SBT_ARGS! %0 + +goto args_loop +:args_end + +rem Confirm a user's intent if the current directory does not look like an sbt +rem top-level directory and the "new" command was not given. + +if not defined sbt_args_sbt_create if not defined sbt_args_print_version if not defined sbt_args_print_sbt_version if not defined sbt_args_print_sbt_script_version if not exist build.sbt ( + if not exist project\ ( + if not defined sbt_new ( + echo [warn] Neither build.sbt nor a 'project' directory in the current directory: "%CD%" + setlocal +:confirm + echo c^) continue + echo q^) quit + + set /P reply=^? + if /I "!reply!" == "c" ( + goto confirm_end + ) else if /I "!reply!" == "q" ( + exit /B 1 + ) + + goto confirm +:confirm_end + endlocal + ) + ) +) + +call :process + +rem avoid bootstrapping/java version check for script version + +if !sbt_args_print_sbt_script_version! equ 1 ( + echo !init_sbt_version! + goto :eof +) + +call :checkjava + +call :copyrt + +if defined JVM_DEBUG_PORT ( + set _JAVA_OPTS=!_JAVA_OPTS! -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=!JVM_DEBUG_PORT! +) + +call :sync_preloaded + +call :run !SBT_ARGS! + +if ERRORLEVEL 1 goto error +goto end + +:run + +rem set arguments + +if defined sbt_args_debug_inc ( + set _SBT_OPTS=-Dxsbt.inc.debug=true !_SBT_OPTS! +) + +if defined sbt_args_no_colors ( + set _SBT_OPTS=-Dsbt.log.noformat=true !_SBT_OPTS! +) + +if defined sbt_args_no_global ( + set _SBT_OPTS=-Dsbt.global.base=project/.sbtboot !_SBT_OPTS! +) + +if defined sbt_args_no_share ( + set _SBT_OPTS=-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy !_SBT_OPTS! +) + +if defined sbt_args_supershell ( + set _SBT_OPTS=-Dsbt.supershell=!sbt_args_supershell! !_SBT_OPTS! +) + +if defined sbt_args_sbt_version ( + set _SBT_OPTS=-Dsbt.version=!sbt_args_sbt_version! !_SBT_OPTS! +) + +if defined sbt_args_sbt_dir ( + set _SBT_OPTS=-Dsbt.global.base=!sbt_args_sbt_dir! !_SBT_OPTS! +) + +if defined sbt_args_sbt_boot ( + set _SBT_OPTS=-Dsbt.boot.directory=!sbt_args_sbt_boot! !_SBT_OPTS! +) + +if defined sbt_args_ivy ( + set _SBT_OPTS=-Dsbt.ivy.home=!sbt_args_ivy! !_SBT_OPTS! +) + +if defined sbt_args_color ( + set _SBT_OPTS=-Dsbt.color=!sbt_args_color! !_SBT_OPTS! +) + +if defined sbt_args_mem ( + call :addMemory !sbt_args_mem! +) else ( + call :addDefaultMemory +) + +if defined sbt_args_timings ( + set _SBT_OPTS=-Dsbt.task.timings=true -Dsbt.task.timings.on.shutdown=true !_SBT_OPTS! +) + +if defined sbt_args_traces ( + set _SBT_OPTS=-Dsbt.traces=true !_SBT_OPTS! +) + +if defined sbt_args_sbt_jar ( + set "sbt_jar=!sbt_args_sbt_jar!" +) else ( + set "sbt_jar=!SBT_HOME!\bin\sbt-launch.jar" +) + +set sbt_jar=!sbt_jar:"=! + +rem TODO: _SBT_OPTS needs to be processed as args and diffed against SBT_ARGS + +if !sbt_args_print_sbt_version! equ 1 ( + call :set_sbt_version + echo !sbt_version! + goto :eof +) + +if !sbt_args_print_version! equ 1 ( + call :set_sbt_version + echo sbt version in this project: !sbt_version! + echo sbt script version: !init_sbt_version! + goto :eof +) + +if defined sbt_args_verbose ( + echo # Executing command line: + echo "!_JAVACMD!" + if defined _JAVA_OPTS ( call :echolist !_JAVA_OPTS! ) + if defined _SBT_OPTS ( call :echolist !_SBT_OPTS! ) + echo -cp + echo "!sbt_jar!" + echo xsbt.boot.Boot + if not "%~1" == "" ( call :echolist %* ) + echo. +) + +"!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -cp "!sbt_jar!" xsbt.boot.Boot %* + +goto :eof + +rem for expression tries to interpret files, so simply loop over %* instead +rem fixes dealing with quotes after = args: -Dscala.ext.dirs="C:\Users\First Last\.sbt\0.13\java9-rt-ext-adoptopenjdk_11_0_3" +:echolist +rem call method is in first call of %0 +shift + +if "%~0" == "" goto echolist_end +set "p=%~0" + +if "%p:~0,2%" == "-D" ( + rem special handling for -D since '=' gets parsed away + for /F "tokens=1 delims==" %%a in ("%p%") do ( + rem make sure it doesn't have the '=' already + if "%p%" == "%%a" if not "%~1" == "" ( + echo %0=%1 + shift + goto echolist + ) + ) +) + +if not "%p:~0,5%" == "-XX:+" if not "%p:~0,5%" == "-XX:-" if "%p:~0,3%" == "-XX" ( + rem special handling for -XX since '=' gets parsed away + for /F "tokens=1 delims==" %%a in ("%p%") do ( + rem make sure it doesn't have the '=' already + if "%p%" == "%%a" if not "%~1" == "" ( + echo %0=%1 + shift + goto echolist + ) + ) +) + +if "%p:~0,14%" == "-agentlib:jdwp" ( + rem special handling for --jvm-debug since '=' and ',' gets parsed away + for /F "tokens=1 delims==" %%a in ("%p%") do ( + rem make sure it doesn't have the '=' already + if "%p%" == "%%a" if not "%~1" == "" if not "%~2" == "" if not "%~3" == "" if not "%~4" == "" if not "%~5" == "" if not "%~6" == "" if not "%~7" == "" if not "%~8" == "" ( + echo %0=%1=%2,%3=%4,%5=%6,%7=%8 + shift & shift & shift & shift & shift & shift & shift & shift + goto echolist + ) + ) +) + +echo %0 +goto echolist + +:echolist_end + +exit /B 0 + +:addJava + call :dlog [addJava] arg = '%*' + set "_JAVA_OPTS=!_JAVA_OPTS! %*" +exit /B 0 + +:addMemory + call :dlog [addMemory] arg = '%*' + + rem evict memory related options + set _new_java_opts= + set _old_java_opts=!_JAVA_OPTS! +:next_java_opt + if "!_old_java_opts!" == "" goto :done_java_opt + for /F "tokens=1,*" %%g in ("!_old_java_opts!") do ( + set "p=%%g" + if not "!p:~0,4!" == "-Xmx" if not "!p:~0,4!" == "-Xms" if not "!p:~0,15!" == "-XX:MaxPermSize" if not "!p:~0,20!" == "-XX:MaxMetaspaceSize" if not "!p:~0,25!" == "-XX:ReservedCodeCacheSize" ( + set _new_java_opts=!_new_java_opts! %%g + ) + set "_old_java_opts=%%h" + ) + goto :next_java_opt +:done_java_opt + set _JAVA_OPTS=!_new_java_opts! + + set _new_sbt_opts= + set _old_sbt_opts=!_SBT_OPTS! +:next_sbt_opt + if "!_old_sbt_opts!" == "" goto :done_sbt_opt + for /F "tokens=1,*" %%g in ("!_old_sbt_opts!") do ( + set "p=%%g" + if not "!p:~0,4!" == "-Xmx" if not "!p:~0,4!" == "-Xms" if not "!p:~0,15!" == "-XX:MaxPermSize" if not "!p:~0,20!" == "-XX:MaxMetaspaceSize" if not "!p:~0,25!" == "-XX:ReservedCodeCacheSize" ( + set _new_sbt_opts=!_new_sbt_opts! %%g + ) + set "_old_sbt_opts=%%h" + ) + goto :next_sbt_opt +:done_sbt_opt + set _SBT_OPTS=!_new_sbt_opts! + + rem a ham-fisted attempt to move some memory settings in concert + set mem=%1 + set /a codecache=!mem! / 8 + if !codecache! GEQ 512 set /a codecache=512 + if !codecache! LEQ 128 set /a codecache=128 + + set /a class_metadata_size=!codecache! * 2 + + call :addJava -Xms!mem!m + call :addJava -Xmx!mem!m + call :addJava -Xss4M + call :addJava -XX:ReservedCodeCacheSize=!codecache!m + + if /I !JAVA_VERSION! LSS 8 ( + call :addJava -XX:MaxPermSize=!class_metadata_size!m + ) + +exit /B 0 + +:addDefaultMemory + rem if we detect any of these settings in ${JAVA_OPTS} or ${JAVA_TOOL_OPTIONS} we need to NOT output our settings. + rem The reason is the Xms/Xmx, if they don't line up, cause errors. + + set _has_memory_args= + + if defined _JAVA_OPTS for /F %%g in ("!_JAVA_OPTS!") do ( + set "p=%%g" + if "!p:~0,4!" == "-Xmx" set _has_memory_args=1 + if "!p:~0,4!" == "-Xms" set _has_memory_args=1 + ) + + if defined JAVA_TOOL_OPTIONS for /F %%g in ("%JAVA_TOOL_OPTIONS%") do ( + set "p=%%g" + if "!p:~0,4!" == "-Xmx" set _has_memory_args=1 + if "!p:~0,4!" == "-Xms" set _has_memory_args=1 + ) + + if defined _SBT_OPTS for /F %%g in ("!_SBT_OPTS!") do ( + set "p=%%g" + if "!p:~0,4!" == "-Xmx" set _has_memory_args=1 + if "!p:~0,4!" == "-Xms" set _has_memory_args=1 + ) + + if not defined _has_memory_args ( + call :addMemory !sbt_default_mem! + ) +exit /B 0 + +:dlog + if defined sbt_args_debug ( + echo %* 1>&2 + ) +exit /B 0 + +:process +rem Parses x out of 1.x; for example 8 out of java version 1.8.0_xx +rem Otherwise, parses the major version; 9 out of java version 9-ea +set JAVA_VERSION=0 + +for /f "tokens=3 usebackq" %%g in (`CALL "!_JAVACMD!" -Xms32M -Xmx32M -version 2^>^&1 ^| findstr /i version`) do ( + set JAVA_VERSION=%%g +) + +rem removes all quotes from JAVA_VERSION +set JAVA_VERSION=!JAVA_VERSION:"=! + +for /f "delims=.-_ tokens=1-2" %%v in ("!JAVA_VERSION!") do ( + if /I "%%v" EQU "1" ( + set JAVA_VERSION=%%w + ) else ( + set JAVA_VERSION=%%v + ) +) + +exit /B 0 + +:checkjava +set /a required_version=6 +if /I !JAVA_VERSION! GEQ !required_version! ( + exit /B 0 +) +echo. +echo The Java Development Kit ^(JDK^) installation you have is not up to date. +echo sbt requires at least version !required_version!+, you have +echo version "!JAVA_VERSION!" +echo. +echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download +echo a valid JDK and install before running sbt. +echo. +exit /B 1 + +:copyrt +if /I !JAVA_VERSION! GEQ 9 ( + set "rtexport=!SBT_BIN_DIR!java9-rt-export.jar" + + "!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -jar "!rtexport!" --rt-ext-dir > "%TEMP%.\rtext.txt" + set /p java9_ext= < "%TEMP%.\rtext.txt" + set "java9_rt=!java9_ext!\rt.jar" + + if not exist "!java9_rt!" ( + mkdir "!java9_ext!" + "!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -jar "!rtexport!" "!java9_rt!" + ) + set _JAVA_OPTS=!_JAVA_OPTS! -Dscala.ext.dirs="!java9_ext!" +) +exit /B 0 + +:sync_preloaded +if not defined init_sbt_version ( + rem FIXME: better !init_sbt_version! detection + FOR /F "tokens=* usebackq" %%F IN (`dir /b "!SBT_HOME!\lib\local-preloaded\org\scala-sbt\sbt" /B`) DO ( + SET init_sbt_version=%%F + ) +) + +set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org\scala-sbt\sbt\!init_sbt_version!\" +if /I !JAVA_VERSION! GEQ 8 ( + where robocopy >nul 2>nul + if %ERRORLEVEL% EQU 0 ( + if not exist !PRELOAD_SBT_JAR! ( + if exist "!SBT_HOME!\lib\local-preloaded\" ( + robocopy "!SBT_HOME!\lib\local-preloaded" "%UserProfile%\.sbt\preloaded" /E >nul 2>nul + ) + ) + ) +) +exit /B 0 + +:usage + +for /f "tokens=3 usebackq" %%g in (`CALL "!_JAVACMD!" -Xms32M -Xmx32M -version 2^>^&1 ^| findstr /i version`) do ( + set FULL_JAVA_VERSION=%%g +) + +echo. +echo Usage: %~n0 [options] +echo. +echo -h ^| --help print this message +echo -v ^| --verbose this runner is chattier +echo -V ^| --version print sbt version information +echo --numeric-version print the numeric sbt version (sbt sbtVersion) +echo --script-version print the version of sbt script +echo -d ^| --debug set sbt log level to debug +echo -debug-inc ^| --debug-inc +echo enable extra debugging for the incremental debugger +echo --no-colors disable ANSI color codes +echo --color=auto^|always^|true^|false^|never +echo enable or disable ANSI color codes ^(sbt 1.3 and above^) +echo --supershell=auto^|always^|true^|false^|never +echo enable or disable supershell ^(sbt 1.3 and above^) +echo --traces generate Trace Event report on shutdown ^(sbt 1.3 and above^) +echo --timings display task timings report on shutdown +echo --sbt-create start sbt even if current directory contains no sbt project +echo --sbt-dir ^ path to global settings/plugins directory ^(default: ~/.sbt^) +echo --sbt-boot ^ path to shared boot directory ^(default: ~/.sbt/boot in 0.11 series^) +echo --ivy ^ path to local Ivy repository ^(default: ~/.ivy2^) +echo --mem ^ set memory options ^(default: %sbt_default_mem%^) +echo --no-share use all local caches; no sharing +echo --no-global uses global caches, but does not use global ~/.sbt directory. +echo --jvm-debug ^ enable on JVM debugging, open at the given port. +rem echo --batch disable interactive mode +echo. +echo # sbt version ^(default: from project/build.properties if present, else latest release^) +echo --sbt-version ^ use the specified version of sbt +echo --sbt-jar ^ use the specified jar as the sbt launcher +echo. +echo # java version ^(default: java from PATH, currently !FULL_JAVA_VERSION!^) +echo --java-home ^ alternate JAVA_HOME +echo. +echo # jvm options and output control +echo JAVA_OPTS environment variable, if unset uses "!default_java_opts!" +echo .jvmopts if this file exists in the current directory, its contents +echo are appended to JAVA_OPTS +echo SBT_OPTS environment variable, if unset uses "!default_sbt_opts!" +echo .sbtopts if this file exists in the current directory, its contents +echo are prepended to the runner args +echo !SBT_CONFIG! +echo if this file exists, it is prepended to the runner args +echo -Dkey=val pass -Dkey=val directly to the java runtime +rem echo -J-X pass option -X directly to the java runtime +rem echo ^(-J is stripped^) +rem echo -S-X add -X to sbt's scalacOptions ^(-S is stripped^) +echo. +echo In the case of duplicated or conflicting options, the order above +echo shows precedence: JAVA_OPTS lowest, command line options highest. +echo. + +@endlocal +exit /B 1 + +:set_sbt_version +rem set project sbtVersion +for /F "usebackq tokens=2" %%G in (`CALL "!_JAVACMD!" -jar "!sbt_jar!" "sbtVersion" 2^>^&1`) do set "sbt_version=%%G" +exit /B 0 + +:error +@endlocal +exit /B 1 + +:end +@endlocal +exit /B 0 diff --git a/sbt-dist/conf/sbtconfig.txt b/sbt-dist/conf/sbtconfig.txt new file mode 100644 index 0000000..a4da43e --- /dev/null +++ b/sbt-dist/conf/sbtconfig.txt @@ -0,0 +1,14 @@ +# Set the java args to high + +-Xmx512M + +-XX:MaxPermSize=256m + +-XX:ReservedCodeCacheSize=128m + + + +# Set the extra SBT options + +-Dsbt.log.format=true + diff --git a/sbt-dist/conf/sbtopts b/sbt-dist/conf/sbtopts new file mode 100644 index 0000000..f018465 --- /dev/null +++ b/sbt-dist/conf/sbtopts @@ -0,0 +1,49 @@ +# ------------------------------------------------ # +# The SBT Configuration file. # +# ------------------------------------------------ # + + +# Disable ANSI color codes +# +#-no-colors + +# Starts sbt even if the current directory contains no sbt project. +# +-sbt-create + +# Path to global settings/plugins directory (default: ~/.sbt) +# +#-sbt-dir /etc/sbt + +# Path to shared boot directory (default: ~/.sbt/boot in 0.11 series) +# +#-sbt-boot ~/.sbt/boot + +# Path to local Ivy repository (default: ~/.ivy2) +# +#-ivy ~/.ivy2 + +# set memory options +# +#-mem + +# Use local caches for projects, no sharing. +# +#-no-share + +# Put SBT in offline mode. +# +#-offline + +# Sets the SBT version to use. +#-sbt-version 0.11.3 + +# Scala version (default: latest release) +# +#-scala-home +#-scala-version + +# java version (default: java from PATH, currently $(java -version |& grep version)) +# +#-java-home + diff --git a/sbt.bat b/sbt.bat new file mode 100755 index 0000000..d199a1c --- /dev/null +++ b/sbt.bat @@ -0,0 +1,3 @@ +@REM SBT launcher script + +.\sbt-dist\bin\sbt.bat %* diff --git a/src/main/java/dev/freireservices/social_altruism/ChatQuickStart.java b/src/main/java/dev/freireservices/social_altruism/ChatQuickStart.java new file mode 100644 index 0000000..be1d3ef --- /dev/null +++ b/src/main/java/dev/freireservices/social_altruism/ChatQuickStart.java @@ -0,0 +1,31 @@ +package dev.freireservices.social_altruism; + +import akka.actor.typed.ActorRef; +import akka.actor.typed.ActorSystem; +import akka.actor.typed.Behavior; +import akka.actor.typed.Terminated; +import akka.actor.typed.javadsl.Behaviors; + +public class ChatQuickStart { + public static void main(String[] args) { + // #actor-system + ActorSystem.create(Main.create(), "ChatRoomDemo"); + } + + public static class Main { + public static Behavior create() { + return Behaviors.setup( + context -> { + ActorRef chatRoom = context.spawn(ChatRoom.create(), "chatRoom"); + ActorRef gabbler = context.spawn(Gabbler.create(), "gabbler"); + context.watch(gabbler); + chatRoom.tell(new ChatRoom.GetSession("ol’ Gabbler", gabbler)); + + return Behaviors.receive(Void.class) + .onSignal(Terminated.class, sig -> Behaviors.stopped()) + .build(); + }); + } + } + // #actor-system +} diff --git a/src/main/java/dev/freireservices/social_altruism/ChatRoom.java b/src/main/java/dev/freireservices/social_altruism/ChatRoom.java new file mode 100644 index 0000000..0e7d5e8 --- /dev/null +++ b/src/main/java/dev/freireservices/social_altruism/ChatRoom.java @@ -0,0 +1,212 @@ +package dev.freireservices.social_altruism; + +import akka.actor.typed.ActorRef; +import akka.actor.typed.Behavior; +import akka.actor.typed.javadsl.ActorContext; +import akka.actor.typed.javadsl.Behaviors; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class ChatRoom { + + private final ActorContext context; + + private ChatRoom(ActorContext context) { + this.context = context; + } + + interface RoomCommand {} + + public static final class GetSession implements RoomCommand { + public final String screenName; + public final ActorRef replyTo; + + + public GetSession(String screenName, ActorRef replyTo) { + this.screenName = screenName; + this.replyTo = replyTo; + } + } + // #chatroom-protocol + // #chatroom-behavior + private static final class PublishSessionMessage implements RoomCommand { + public final String screenName; + public final String message; + + + public PublishSessionMessage(String screenName, String message) { + this.screenName = screenName; + this.message = message; + } + } + // #chatroom-behavior + // #chatroom-protocol + + private Behavior onGetSession( + List> sessions, GetSession getSession) { + + if (sessions.stream().anyMatch(s -> s.path().name().equals(URLEncoder.encode(getSession.screenName, StandardCharsets.UTF_8)))) { + getSession.replyTo.tell(new SessionDenied("duplicate session name")); + return Behaviors.same(); + } + + ActorRef client = getSession.replyTo; + ActorRef ses = + context.spawn( + Session.create(context.getSelf(), getSession.screenName, client), + URLEncoder.encode(getSession.screenName, StandardCharsets.UTF_8)); + // narrow to only expose PostMessage + + client.tell(new SessionGranted(ses.narrow())); + + List> newSessions = new ArrayList<>(sessions); + newSessions.add(ses); + return chatRoom(newSessions); + } + + private Behavior onPublishSessionMessage( + List> sessions, PublishSessionMessage pub) { + NotifyClient notification = + new NotifyClient((new MessagePosted(pub.screenName, pub.message))); + sessions.forEach(s -> s.tell(notification)); + return Behaviors.same(); + } + + private Behavior chatRoom(List> sessions) { + return Behaviors.receive(RoomCommand.class) + .onMessage(GetSession.class, getSession -> onGetSession(sessions, getSession)) + .onMessage(PublishSessionMessage.class, pub -> onPublishSessionMessage(sessions, pub)) + .build(); + } + + + public static Behavior create() { + return Behaviors.setup( + ctx -> new ChatRoom(ctx).chatRoom(new ArrayList>())); + } + + public interface SessionEvent {} + + + public static final class SessionGranted implements SessionEvent { + public final ActorRef handle; + + + public SessionGranted(ActorRef handle) { + this.handle = handle; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SessionGranted that = (SessionGranted) o; + return Objects.equals(handle, that.handle); + } + + @Override + public int hashCode() { + return Objects.hash(handle); + } + + @Override + public String toString() { + return "SessionGranted{" + + "handle=" + handle + + '}'; + } + } + + + public static final class SessionDenied implements SessionEvent { + public final String reason; + + + public SessionDenied(String reason) { + this.reason = reason; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SessionDenied that = (SessionDenied) o; + return Objects.equals(reason, that.reason); + } + + @Override + public int hashCode() { + return Objects.hash(reason); + } + + @Override + public String toString() { + return "SessionDenied{" + + "reason='" + reason + '\'' + + '}'; + } + } + + + public static final class MessagePosted implements SessionEvent { + public final String screenName; + public final String message; + + + public MessagePosted(String screenName, String message) { + this.screenName = screenName; + this.message = message; + } + } + + + interface SessionCommand {} + + + public static final class PostMessage implements SessionCommand { + public final String message; + + + public PostMessage(String message) { + this.message = message; + } + } + + + private static final class NotifyClient implements SessionCommand { + final MessagePosted message; + + + NotifyClient(MessagePosted message) { + this.message = message; + } + } + + static class Session { + static Behavior create( + ActorRef room, String screenName, ActorRef client) { + return Behaviors.receive(ChatRoom.SessionCommand.class) + .onMessage(PostMessage.class, post -> onPostMessage(room, screenName, post)) + .onMessage(NotifyClient.class, notification -> onNotifyClient(client, notification)) + .build(); + } + + private static Behavior onPostMessage( + ActorRef room, String screenName, PostMessage post) { + // from client, publish to others via the room + room.tell(new PublishSessionMessage(screenName, post.message)); + return Behaviors.same(); + } + + private static Behavior onNotifyClient( + ActorRef client, NotifyClient notification) { + // published from the room + client.tell(notification.message); + return Behaviors.same(); + } + } +} diff --git a/src/main/java/dev/freireservices/social_altruism/Gabbler.java b/src/main/java/dev/freireservices/social_altruism/Gabbler.java new file mode 100644 index 0000000..972e2ba --- /dev/null +++ b/src/main/java/dev/freireservices/social_altruism/Gabbler.java @@ -0,0 +1,44 @@ +package dev.freireservices.social_altruism; + +import akka.actor.typed.Behavior; +import akka.actor.typed.javadsl.ActorContext; +import akka.actor.typed.javadsl.Behaviors; +import dev.freireservices.social_altruism.ChatRoom; + +public class Gabbler { + + public static Behavior create() { + return Behaviors.setup(ctx -> new Gabbler(ctx).behavior()); + } + + private final ActorContext context; + + private Gabbler(ActorContext context) { + this.context = context; + } + + private Behavior behavior() { + return Behaviors.receive(ChatRoom.SessionEvent.class) + .onMessage(ChatRoom.SessionDenied.class, this::onSessionDenied) + .onMessage(ChatRoom.SessionGranted.class, this::onSessionGranted) + .onMessage(ChatRoom.MessagePosted.class, this::onMessagePosted) + .build(); + } + + private Behavior onSessionDenied(ChatRoom.SessionDenied message) { + context.getLog().info("cannot start chat room session: {}", message.reason); + return Behaviors.stopped(); + } + + private Behavior onSessionGranted(ChatRoom.SessionGranted message) { + message.handle.tell(new ChatRoom.PostMessage("Hello World!")); + return Behaviors.same(); + } + + private Behavior onMessagePosted(ChatRoom.MessagePosted message) { + context + .getLog() + .info("message has been posted by '{}': {}", message.screenName, message.message); + return Behaviors.stopped(); + } +} \ No newline at end of file diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..203596d --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,21 @@ + + + + + + [%date{ISO8601}] [%level] [%logger] [%thread] [%X{akkaSource}] - %msg%n + + + + + 1024 + true + + + + + + + + diff --git a/src/test/java/dev/freireservices/social_altruism/ChatQuickStartTest.java b/src/test/java/dev/freireservices/social_altruism/ChatQuickStartTest.java new file mode 100644 index 0000000..63bbc6b --- /dev/null +++ b/src/test/java/dev/freireservices/social_altruism/ChatQuickStartTest.java @@ -0,0 +1,68 @@ +package dev.freireservices.social_altruism; + +import akka.actor.testkit.typed.javadsl.ActorTestKit; +import akka.actor.testkit.typed.javadsl.TestProbe; +import akka.actor.typed.ActorRef; +import java.time.Duration; +import org.junit.AfterClass; +import org.junit.Test; + +// #definition +public class ChatQuickStartTest { + + static final ActorTestKit testKit = ActorTestKit.create(); + + // #definition + + // #test + @Test + public void testGreeterActorSendingOfGreeting() { + + TestProbe testProbe = testKit.createTestProbe(); + + ActorRef chatRoomTest = testKit.spawn(ChatRoom.create(), "chatRoom"); + ActorRef gabblerTest = testKit.spawn(Gabbler.create(), "gabbler"); + + chatRoomTest.tell(new ChatRoom.GetSession("ol’ Gabbler", gabblerTest)); + + ChatRoom.SessionGranted sessionGranted = new ChatRoom.SessionGranted(testProbe.ref()); + gabblerTest.tell(sessionGranted); + + ChatRoom.PostMessage postMessage = new ChatRoom.PostMessage("Hello World!"); + sessionGranted.handle.tell(postMessage); + // #test + + // #assert + testProbe.expectMessage(postMessage); + // #assert + + testKit.stop(chatRoomTest); + testKit.stop(gabblerTest); + } + + @Test + public void testActorGetsUserDenied() { + + TestProbe testProbe = testKit.createTestProbe(); + + ActorRef chatRoomTest = testKit.spawn(ChatRoom.create(), "chatRoom"); + + chatRoomTest.tell(new ChatRoom.GetSession("ol’ Gabbler", testProbe.ref())); + + testProbe.expectMessageClass(ChatRoom.SessionGranted.class, Duration.ofSeconds(10)); + + chatRoomTest.tell(new ChatRoom.GetSession("ol’ Gabbler", testProbe.ref())); + + ChatRoom.SessionDenied sessionDenied = new ChatRoom.SessionDenied("duplicate session name"); + + testProbe.expectMessage(Duration.ofSeconds(10), sessionDenied); + + // #assert + } + + @AfterClass + public static void cleanup() { + testKit.system().terminate(); + testKit.shutdownTestKit(); + } +} diff --git a/target/app-1.0.jar b/target/app-1.0.jar new file mode 100644 index 0000000..83dea82 Binary files /dev/null and b/target/app-1.0.jar differ diff --git a/target/classes/com/example/AkkaQuickstart.class b/target/classes/com/example/AkkaQuickstart.class new file mode 100644 index 0000000..164722a Binary files /dev/null and b/target/classes/com/example/AkkaQuickstart.class differ diff --git a/target/classes/com/example/Greeter$Greet.class b/target/classes/com/example/Greeter$Greet.class new file mode 100644 index 0000000..e98192a Binary files /dev/null and b/target/classes/com/example/Greeter$Greet.class differ diff --git a/target/classes/com/example/Greeter$Greeted.class b/target/classes/com/example/Greeter$Greeted.class new file mode 100644 index 0000000..0df9671 Binary files /dev/null and b/target/classes/com/example/Greeter$Greeted.class differ diff --git a/target/classes/com/example/Greeter.class b/target/classes/com/example/Greeter.class new file mode 100644 index 0000000..31a9593 Binary files /dev/null and b/target/classes/com/example/Greeter.class differ diff --git a/target/classes/com/example/GreeterBot.class b/target/classes/com/example/GreeterBot.class new file mode 100644 index 0000000..67c4e29 Binary files /dev/null and b/target/classes/com/example/GreeterBot.class differ diff --git a/target/classes/com/example/GreeterMain$SayHello.class b/target/classes/com/example/GreeterMain$SayHello.class new file mode 100644 index 0000000..7539d97 Binary files /dev/null and b/target/classes/com/example/GreeterMain$SayHello.class differ diff --git a/target/classes/com/example/GreeterMain.class b/target/classes/com/example/GreeterMain.class new file mode 100644 index 0000000..1fe021c Binary files /dev/null and b/target/classes/com/example/GreeterMain.class differ diff --git a/target/classes/logback.xml b/target/classes/logback.xml new file mode 100644 index 0000000..203596d --- /dev/null +++ b/target/classes/logback.xml @@ -0,0 +1,21 @@ + + + + + + [%date{ISO8601}] [%level] [%logger] [%thread] [%X{akkaSource}] - %msg%n + + + + + 1024 + true + + + + + + + + diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..6667767 --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=app +groupId=hello-akka-java +version=1.0 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..37c6d50 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,7 @@ +com/example/Greeter$Greet.class +com/example/AkkaQuickstart.class +com/example/Greeter$Greeted.class +com/example/GreeterMain$SayHello.class +com/example/Greeter.class +com/example/GreeterMain.class +com/example/GreeterBot.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..5debb49 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,4 @@ +/Users/rdev/Source/social_altruism_akka/src/main/java/com/example/GreeterBot.java +/Users/rdev/Source/social_altruism_akka/src/main/java/com/example/AkkaQuickstart.java +/Users/rdev/Source/social_altruism_akka/src/main/java/com/example/Greeter.java +/Users/rdev/Source/social_altruism_akka/src/main/java/com/example/GreeterMain.java diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..5a25cb3 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1 @@ +com/example/AkkaQuickstartTest.class diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..3406626 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +/Users/rdev/Source/social_altruism_akka/src/test/java/com/example/AkkaQuickstartTest.java diff --git a/target/surefire-reports/TEST-com.example.AkkaQuickstartTest.xml b/target/surefire-reports/TEST-com.example.AkkaQuickstartTest.xml new file mode 100644 index 0000000..961ac4d --- /dev/null +++ b/target/surefire-reports/TEST-com.example.AkkaQuickstartTest.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/target/surefire-reports/com.example.AkkaQuickstartTest.txt b/target/surefire-reports/com.example.AkkaQuickstartTest.txt new file mode 100644 index 0000000..3bb9513 --- /dev/null +++ b/target/surefire-reports/com.example.AkkaQuickstartTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: dev.freireservices.social_altruism.ChatQuickStartTest +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.387 s -- in dev.freireservices.social_altruism.ChatQuickStartTest diff --git a/target/test-classes/com/example/AkkaQuickstartTest.class b/target/test-classes/com/example/AkkaQuickstartTest.class new file mode 100644 index 0000000..ea6320c Binary files /dev/null and b/target/test-classes/com/example/AkkaQuickstartTest.class differ