-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add archetype for Akka microKernel application
- Loading branch information
Showing
10 changed files
with
124 additions
and
9 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/main/resources/com/typesafe/sbt/packager/archetypes/akka-bash-template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
declare AKKA_HOME="$(cd "$(cd "$(dirname "$0")"; pwd -P)"/..; pwd)" | ||
declare -r app_home="$0" | ||
declare -r lib_dir="${AKKA_HOME}/lib" | ||
|
||
${{template_declares}} | ||
|
||
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xms1024M -Xmx1024M -Xss1M -XX:MaxPermSize=256M -XX:+UseParallelGC" | ||
|
||
# we will use akka_classpath instead the app_classpath | ||
[ -n "$akka_classpath" ] || akka_classpath="$AKKA_HOME/lib/*:$AKKA_HOME/conf" | ||
|
||
java $JAVA_OPTS -cp "$akka_classpath" -Dakka.home="$AKKA_HOME" -Dakka.kernel.quiet=false akka.kernel.Main $app_mainclass |
11 changes: 11 additions & 0 deletions
11
src/main/resources/com/typesafe/sbt/packager/archetypes/akka-bat-template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
echo off | ||
|
||
set _JAVA_OPTS=%_JAVA_OPTS% %_JAVA_PARAMS% | ||
|
||
@@APP_DEFINES@@ | ||
|
||
set AKKA_HOME=%~dp0.. | ||
set JAVA_OPTS=-Xmx1024M -Xms1024M -Xss1M -XX:MaxPermSize=256M -XX:+UseParallelGC | ||
set AKKA_CLASSPATH=%AKKA_HOME%\lib\*;%AKKA_HOME%\config;%AKKA_HOME%\lib\akka\* | ||
|
||
java %JAVA_OPTS% -cp "%AKKA_CLASSPATH%" -Dakka.home="%AKKA_HOME%" akka.kernel.Main %APP_MAIN_CLASS% %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/scala/com/typesafe/sbt/packager/archetypes/AkkaApp.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.typesafe.sbt | ||
package packager | ||
package archetypes | ||
|
||
/** | ||
* Created by max.cai on 2014-09-27. | ||
*/ | ||
object AkkaApp extends JavaApp { | ||
val bashTemplate = "akka-bash-template" | ||
val batTemplate = "akka-bat-template" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import NativePackagerKeys._ | ||
|
||
packageArchetype.akka_application | ||
|
||
name := """test-akka""" | ||
|
||
mainClass in Compile := Some("HelloKernel") | ||
|
||
version := "1.0" | ||
|
||
libraryDependencies ++= Seq( | ||
"com.typesafe.akka" %% "akka-kernel" % "2.3.4", | ||
"com.typesafe.akka" %% "akka-actor" % "2.3.4", | ||
"com.typesafe.akka" %% "akka-testkit" % "2.3.4" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version")) |
32 changes: 32 additions & 0 deletions
32
src/sbt-test/universal/test-akka/src/main/scala/HelloKernel.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import akka.actor.{ Actor, ActorSystem, Props } | ||
import akka.kernel.Bootable | ||
|
||
case object Start | ||
|
||
class HelloActor extends Actor { | ||
val worldActor = context.actorOf(Props[WorldActor]) | ||
|
||
def receive = { | ||
case Start => worldActor ! "Hello" | ||
case message: String => | ||
println("Received message '%s'" format message) | ||
} | ||
} | ||
|
||
class WorldActor extends Actor { | ||
def receive = { | ||
case message: String => sender() ! (message.toUpperCase + " world!") | ||
} | ||
} | ||
|
||
class HelloKernel extends Bootable { | ||
val system = ActorSystem("hellokernel") | ||
|
||
def startup = { | ||
system.actorOf(Props[HelloActor]) ! Start | ||
} | ||
|
||
def shutdown = { | ||
system.shutdown() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# generate Akka startup script | ||
> stage | ||
$ exists target/universal/stage/bin/test-akka |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters