Skip to content

Commit 83da5eb

Browse files
committed
* greeting actors system
1 parent d1777dd commit 83da5eb

24 files changed

+918
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
target

app.iml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
4+
<output url="file://$MODULE_DIR$/target/classes" />
5+
<output-test url="file://$MODULE_DIR$/target/test-classes" />
6+
<content url="file://$MODULE_DIR$">
7+
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
9+
<excludeFolder url="file://$MODULE_DIR$/target" />
10+
</content>
11+
<orderEntry type="inheritedJdk" />
12+
<orderEntry type="sourceFolder" forTests="false" />
13+
<orderEntry type="library" name="Maven: com.typesafe.akka:akka-actor_2.12:2.5.12" level="project" />
14+
<orderEntry type="library" name="Maven: org.scala-lang:scala-library:2.12.5" level="project" />
15+
<orderEntry type="library" name="Maven: com.typesafe:config:1.3.2" level="project" />
16+
<orderEntry type="library" name="Maven: org.scala-lang.modules:scala-java8-compat_2.12:0.8.0" level="project" />
17+
<orderEntry type="library" name="Maven: com.typesafe.akka:akka-testkit_2.12:2.5.12" level="project" />
18+
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
19+
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
20+
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.5" level="project" />
21+
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
22+
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.5" level="project" />
23+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.16.8" level="project" />
24+
<orderEntry type="library" name="Maven: com.rabbitmq:amqp-client:5.2.0" level="project" />
25+
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
26+
</component>
27+
</module>

build.gradle

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apply plugin: 'java'
2+
apply plugin: 'idea'
3+
apply plugin: 'application'
4+
5+
6+
repositories {
7+
mavenCentral()
8+
mavenLocal()
9+
}
10+
11+
dependencies {
12+
compile 'com.typesafe.akka:akka-actor_2.12:2.5.3'
13+
testCompile 'com.typesafe.akka:akka-testkit_2.12:2.5.3'
14+
testCompile 'junit:junit:4.12'
15+
}
16+
17+
mainClassName = "com.lightbend.akka.sample.AkkaQuickstart"
18+
19+
run {
20+
standardInput = System.in
21+
}

build.sbt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name := "akka-quickstart-java"
2+
3+
version := "1.0"
4+
5+
scalaVersion := "2.12.2"
6+
7+
lazy val akkaVersion = "2.5.12"
8+
9+
libraryDependencies ++= Seq(
10+
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
11+
"com.typesafe.akka" %% "akka-testkit" % akkaVersion,
12+
"junit" % "junit" % "4.12")

pom.xml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!-- #build-sample -->
2+
<project>
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>hello-akka-java</groupId>
6+
<artifactId>app</artifactId>
7+
<version>1.0</version>
8+
9+
<dependencies>
10+
<dependency>
11+
<groupId>com.typesafe.akka</groupId>
12+
<artifactId>akka-actor_2.12</artifactId>
13+
<version>2.5.12</version>
14+
</dependency>
15+
<dependency>
16+
<groupId>com.typesafe.akka</groupId>
17+
<artifactId>akka-testkit_2.12</artifactId>
18+
<version>2.5.12</version>
19+
</dependency>
20+
<dependency>
21+
<groupId>junit</groupId>
22+
<artifactId>junit</artifactId>
23+
<version>4.12</version>
24+
</dependency>
25+
<dependency>
26+
<groupId>com.fasterxml.jackson.core</groupId>
27+
<artifactId>jackson-databind</artifactId>
28+
<version>2.9.5</version>
29+
</dependency>
30+
31+
<!-- LOMBOK -->
32+
<dependency>
33+
<groupId>org.projectlombok</groupId>
34+
<artifactId>lombok</artifactId>
35+
<version>1.16.8</version>
36+
<scope>provided</scope>
37+
</dependency>
38+
39+
<!-- RABBITMQ -->
40+
<dependency>
41+
<groupId>com.rabbitmq</groupId>
42+
<artifactId>amqp-client</artifactId>
43+
<version>5.2.0</version>
44+
</dependency>
45+
</dependencies>
46+
<build>
47+
<plugins>
48+
<plugin>
49+
<groupId>org.apache.maven.plugins</groupId>
50+
<artifactId>maven-compiler-plugin</artifactId>
51+
<version>3.5.1</version>
52+
<configuration>
53+
<source>1.8</source>
54+
<target>1.8</target>
55+
</configuration>
56+
</plugin>
57+
<plugin>
58+
<groupId>org.codehaus.mojo</groupId>
59+
<artifactId>exec-maven-plugin</artifactId>
60+
<version>1.6.0</version>
61+
<configuration>
62+
<executable>java</executable>
63+
<arguments>
64+
<argument>-classpath</argument>
65+
<classpath/>
66+
<argument>com.lightbend.akka.sample.AkkaQuickstart</argument>
67+
</arguments>
68+
</configuration>
69+
</plugin>
70+
</plugins>
71+
</build>
72+
</project>

project/build.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=0.13.15

sbt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
./sbt-dist/bin/sbt "$@"

sbt-dist/bin/sbt

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#!/usr/bin/env bash
2+
3+
4+
### ------------------------------- ###
5+
### Helper methods for BASH scripts ###
6+
### ------------------------------- ###
7+
8+
realpath () {
9+
(
10+
TARGET_FILE="$1"
11+
FIX_CYGPATH="$2"
12+
13+
cd "$(dirname "$TARGET_FILE")"
14+
TARGET_FILE=$(basename "$TARGET_FILE")
15+
16+
COUNT=0
17+
while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ]
18+
do
19+
TARGET_FILE=$(readlink "$TARGET_FILE")
20+
cd "$(dirname "$TARGET_FILE")"
21+
TARGET_FILE=$(basename "$TARGET_FILE")
22+
COUNT=$(($COUNT + 1))
23+
done
24+
25+
# make sure we grab the actual windows path, instead of cygwin's path.
26+
if [[ "x$FIX_CYGPATH" != "x" ]]; then
27+
echo "$(cygwinpath "$(pwd -P)/$TARGET_FILE")"
28+
else
29+
echo "$(pwd -P)/$TARGET_FILE"
30+
fi
31+
)
32+
}
33+
34+
35+
# Uses uname to detect if we're in the odd cygwin environment.
36+
is_cygwin() {
37+
local os=$(uname -s)
38+
case "$os" in
39+
CYGWIN*) return 0 ;;
40+
*) return 1 ;;
41+
esac
42+
}
43+
44+
# TODO - Use nicer bash-isms here.
45+
CYGWIN_FLAG=$(if is_cygwin; then echo true; else echo false; fi)
46+
47+
48+
# This can fix cygwin style /cygdrive paths so we get the
49+
# windows style paths.
50+
cygwinpath() {
51+
local file="$1"
52+
if [[ "$CYGWIN_FLAG" == "true" ]]; then
53+
echo $(cygpath -w $file)
54+
else
55+
echo $file
56+
fi
57+
}
58+
59+
. "$(dirname "$(realpath "$0")")/sbt-launch-lib.bash"
60+
61+
62+
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
63+
declare -r sbt_opts_file=".sbtopts"
64+
declare -r etc_sbt_opts_file="${sbt_home}/conf/sbtopts"
65+
declare -r win_sbt_opts_file="${sbt_home}/conf/sbtconfig.txt"
66+
67+
usage() {
68+
cat <<EOM
69+
Usage: $script_name [options]
70+
71+
-h | -help print this message
72+
-v | -verbose this runner is chattier
73+
-d | -debug set sbt log level to debug
74+
-no-colors disable ANSI color codes
75+
-sbt-create start sbt even if current directory contains no sbt project
76+
-sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
77+
-sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
78+
-ivy <path> path to local Ivy repository (default: ~/.ivy2)
79+
-mem <integer> set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem))
80+
-no-share use all local caches; no sharing
81+
-no-global uses global caches, but does not use global ~/.sbt directory.
82+
-jvm-debug <port> Turn on JVM debugging, open at the given port.
83+
-batch Disable interactive mode
84+
85+
# sbt version (default: from project/build.properties if present, else latest release)
86+
-sbt-version <version> use the specified version of sbt
87+
-sbt-jar <path> use the specified jar as the sbt launcher
88+
-sbt-rc use an RC version of sbt
89+
-sbt-snapshot use a snapshot version of sbt
90+
91+
# java version (default: java from PATH, currently $(java -version 2>&1 | grep version))
92+
-java-home <path> alternate JAVA_HOME
93+
94+
# jvm options and output control
95+
JAVA_OPTS environment variable, if unset uses "$java_opts"
96+
SBT_OPTS environment variable, if unset uses "$default_sbt_opts"
97+
.sbtopts if this file exists in the current directory, it is
98+
prepended to the runner args
99+
/etc/sbt/sbtopts if this file exists, it is prepended to the runner args
100+
-Dkey=val pass -Dkey=val directly to the java runtime
101+
-J-X pass option -X directly to the java runtime
102+
(-J is stripped)
103+
-S-X add -X to sbt's scalacOptions (-S is stripped)
104+
105+
In the case of duplicated or conflicting options, the order above
106+
shows precedence: JAVA_OPTS lowest, command line options highest.
107+
EOM
108+
}
109+
110+
111+
112+
process_my_args () {
113+
while [[ $# -gt 0 ]]; do
114+
case "$1" in
115+
-no-colors) addJava "-Dsbt.log.noformat=true" && shift ;;
116+
-no-share) addJava "$noshare_opts" && shift ;;
117+
-no-global) addJava "-Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;;
118+
-sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;;
119+
-sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;;
120+
-debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;;
121+
-batch) exec </dev/null && shift ;;
122+
123+
-sbt-create) sbt_create=true && shift ;;
124+
125+
*) addResidual "$1" && shift ;;
126+
esac
127+
done
128+
129+
# Now, ensure sbt version is used.
130+
[[ "${sbt_version}XXX" != "XXX" ]] && addJava "-Dsbt.version=$sbt_version"
131+
}
132+
133+
loadConfigFile() {
134+
cat "$1" | sed '/^\#/d' | while read line; do
135+
eval echo $line
136+
done
137+
}
138+
139+
# TODO - Pull in config based on operating system... (MSYS + cygwin should pull in txt file).
140+
# Here we pull in the global settings configuration.
141+
[[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@"
142+
# -- Windows behavior stub'd
143+
# JAVA_OPTS=$(cat "$WDIR/sbtconfig.txt" | sed -e 's/\r//g' -e 's/^#.*$//g' | sed ':a;N;$!ba;s/\n/ /g')
144+
145+
146+
# Pull in the project-level config file, if it exists.
147+
[[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@"
148+
149+
150+
run "$@"
151+

0 commit comments

Comments
 (0)