Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding new files

  • Loading branch information...
commit c9631931cff3243c12d6630d770e83662f2dc4c8 1 parent ebb6bc5
@write2munish authored
View
47 ClientServerExample/pom.xml
@@ -0,0 +1,47 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.akka.essentials.clientserver.sample</groupId>
+ <artifactId>org-akka-essentials-clientserver-sample</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>org-akka-essentials-clientserver-sample</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-actor</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-remote</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-kernel</artifactId>
+ <version>2.0</version>
+ </dependency>
+ </dependencies>
+ <repositories>
+ <repository>
+ <id>typesafe</id>
+ <name>Typesafe Repository</name>
+ <url>http://repo.typesafe.com/typesafe/releases/</url>
+ </repository>
+ </repositories>
+</project>
View
28 ClientServerExample/src/main/java/org/akka/essentials/clientserver/sample/ClientActor.java
@@ -0,0 +1,28 @@
+package org.akka.essentials.clientserver.sample;
+
+import akka.actor.ActorRef;
+import akka.actor.UntypedActor;
+
+public class ClientActor extends UntypedActor {
+
+ private ActorRef remote;
+
+ public ClientActor(ActorRef inActor) {
+ remote = inActor;
+ }
+
+ @Override
+ public void onReceive(Object arg0) throws Exception {
+
+ if (arg0 instanceof String) {
+ if (((String) arg0).compareTo("Start") == 0) {
+ remote.tell("Hi there", getSelf());
+ } else {
+ System.out.println(arg0);
+ getContext().system().shutdown();
+ }
+ }
+
+ }
+
+}
View
48 ...erverExample/src/main/java/org/akka/essentials/clientserver/sample/ClientActorSystem.java
@@ -0,0 +1,48 @@
+package org.akka.essentials.clientserver.sample;
+
+import akka.actor.ActorRef;
+import akka.actor.ActorSystem;
+import akka.actor.Props;
+import akka.actor.UntypedActor;
+import akka.actor.UntypedActorFactory;
+import akka.kernel.Bootable;
+
+import com.typesafe.config.ConfigFactory;
+
+public class ClientActorSystem implements Bootable {
+
+ private ActorSystem system;
+ private ActorRef actor;
+ private ActorRef remoteActor;
+
+ public ClientActorSystem(){
+ system = ActorSystem.create("LookupApplication", ConfigFactory.load().getConfig("ClientActor"));
+
+ remoteActor = system.actorFor("akka://HelloWorldApplication@127.0.0.1:2552/user/serverActor");
+
+ actor = system.actorOf(new Props(new UntypedActorFactory() {
+ public UntypedActor create() {
+ return new ClientActor(remoteActor);
+ }
+ }));
+
+ actor.tell("Start");
+ }
+
+ public void shutdown() {
+ // TODO Auto-generated method stub
+ system.shutdown();
+ }
+
+
+ public void startup() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public static void main(String[] args) {
+
+ new ClientActorSystem();
+ }
+
+}
View
15 ClientServerExample/src/main/java/org/akka/essentials/clientserver/sample/ServerActor.java
@@ -0,0 +1,15 @@
+package org.akka.essentials.clientserver.sample;
+
+import akka.actor.UntypedActor;
+
+public class ServerActor extends UntypedActor {
+
+ @Override
+ public void onReceive(Object arg0) throws Exception {
+ if(arg0 instanceof String){
+ getSender().tell(arg0 + " got something");
+ }
+
+ }
+
+}
View
37 ...erverExample/src/main/java/org/akka/essentials/clientserver/sample/ServerActorSystem.java
@@ -0,0 +1,37 @@
+package org.akka.essentials.clientserver.sample;
+
+import akka.actor.ActorRef;
+import akka.actor.ActorSystem;
+import akka.actor.Props;
+import akka.kernel.Bootable;
+
+import com.typesafe.config.ConfigFactory;
+
+public class ServerActorSystem implements Bootable {
+
+ private ActorSystem system;
+
+ public ServerActorSystem() {
+ system = ActorSystem.create("HelloWorldApplication", ConfigFactory
+ .load().getConfig("ServerActor"));
+ ActorRef actor = system.actorOf(new Props(ServerActor.class),
+ "serverActor");
+ }
+
+ public void shutdown() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void startup() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public static void main(String[] args) {
+
+ new ServerActorSystem();
+
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.