From 5422f9b89284e06c2ffd382a76ae5896cf91c418 Mon Sep 17 00:00:00 2001 From: Crossing-Tech Date: Mon, 14 Jan 2013 00:57:20 -0800 Subject: [PATCH 1/7] Initial commit --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000..30b9df2b35 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +akka-osgi-sample +================ \ No newline at end of file From 70637b6ae9f30eb51ce9e750a5987822f4c6c3f0 Mon Sep 17 00:00:00 2001 From: Christophe Pache Date: Tue, 5 Feb 2013 20:58:22 +0100 Subject: [PATCH 2/7] DinningHakkers with automatic Karaf runners\n current error: No configuration setting found for key 'akka.cluster' Fix indentation in application.conf (Done by Raman Gupta) Change default IP address to localhost (Done by Raman Gupta) ServiceRegistration is typed in OSGi 4.3 Add a wildcard type for the ServiceRegistration declaration. (Done by Raman Gupta) Fix spelling errors in Dining Hakker and Hacker (Done by Raman Gupta) removing protobuf as bundlelized through the maven karaf feature --- README.md | 43 ++++- api/pom.xml | 80 ++++++++ .../sample/api/DiningHakkersService.scala | 22 +++ command/pom.xml | 95 ++++++++++ .../akka/osgi/sample/command/Activator.scala | 41 ++++ core/pom.xml | 174 +++++++++++++++++ core/src/main/resources/application.conf | 21 +++ .../osgi/sample/activation/Activator.scala | 69 +++++++ .../akka/osgi/sample/internal/Hakker.scala | 175 ++++++++++++++++++ .../akka/osgi/sample/internal/Table.scala | 26 +++ .../service/DiningHakkersServiceImpl.scala | 26 +++ karaf.sh | 24 +++ osgi-run.sh | 2 + pom.xml | 65 +++++++ project/Build.scala | 144 ++++++++++++++ protobuf/pom.xml | 81 ++++++++ uncommons/pom.xml | 91 +++++++++ 17 files changed, 1177 insertions(+), 2 deletions(-) create mode 100644 api/pom.xml create mode 100644 api/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala create mode 100644 command/pom.xml create mode 100644 command/src/main/scala/akka/osgi/sample/command/Activator.scala create mode 100644 core/pom.xml create mode 100644 core/src/main/resources/application.conf create mode 100644 core/src/main/scala/akka/osgi/sample/activation/Activator.scala create mode 100644 core/src/main/scala/akka/osgi/sample/internal/Hakker.scala create mode 100644 core/src/main/scala/akka/osgi/sample/internal/Table.scala create mode 100644 core/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala create mode 100755 karaf.sh create mode 100755 osgi-run.sh create mode 100644 pom.xml create mode 100644 project/Build.scala create mode 100644 protobuf/pom.xml create mode 100644 uncommons/pom.xml diff --git a/README.md b/README.md index 30b9df2b35..8aa90d2094 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,41 @@ -akka-osgi-sample -================ \ No newline at end of file +akka-osgi-sample : Clustered DiningHakker +================ +This project may be used to test akka bundles in OSGi Frameworks. The build tool (sbt for the moment) provide scripts to run in an OSGi Framework (Karaf only for the moment) a version of the DiningHakkers that runs on several nodes unsing the akka-cluster module. + +## Bundle overview + +This project provides three Osgi Bundles + - api providing an API for the Service exposed by the core and used by the command + - core implementing the whole logic: clustered connections, Hakkers, ChopSticks. It finally provide an ActorRef of one created Hakker + - command use a service to get a Hakker (ActorRef) with its position around the table + +## How to use it + +### Setup with sbt +just run: +```bash +sbt clean +sbt package +sbt osgi-bundle +sbt osgi-prepare +``` + +### Setup with Maven +```bash +mvn clean package +``` + +### Personalize and run +From this point, you may change the created bundles if you want to test other bundles. Afterwards, launch the OSGi Framework using +``./osgi-run.sh`` + + +Then try to restart some bundles, to test the stability of the bundles: + +``list`` to get the list of the bundles +``restart #bundle_number`` to restart the bundle using its ID +``exit`` or CTRL-D to exit the Karaf console + +Depending on the akka version you're using, you may need to modify the core bundle when deploying on a second machine, to set it's akka.remote.netty.hostname in the application.conf. + +The configuration is set to start the fist node on one machine and to start other nodes on vm running on the same machine for tests (with vmware, ip of the host : 192.168.229.1 and first vm ip would be 192.168.229.128, but it may differ according to your configuration. diff --git a/api/pom.xml b/api/pom.xml new file mode 100644 index 0000000000..8afbe834a9 --- /dev/null +++ b/api/pom.xml @@ -0,0 +1,80 @@ + + + + osgi-sample + com.typesafe.akka + 2.2.0-SNAPSHOT + + 4.0.0 + + api + Dining Hakker :: Service API + bundle + + + + + com.typesafe.akka + akka-actor_2.10 + 2.1.0 + + + + + src/main/scala + + + + + bundle-manifest + process-classes + + manifest + + + + org.apache.felix + maven-bundle-plugin + 2.3.7 + true + + + ${project.name} + ${project.artifactId} + akka.osgi.sample.api + !sun.misc, * + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-artifact + package + + copy + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + ${project.packaging} + + + ../bundles + + + + + + + diff --git a/api/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala b/api/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala new file mode 100644 index 0000000000..9801d8f9c4 --- /dev/null +++ b/api/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala @@ -0,0 +1,22 @@ +/* +Copyright 2013 Crossing-Tech + +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 + +http://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. + */ +package akka.osgi.sample.api + +import akka.actor.ActorRef + +trait DiningHakkersService { + def getHakker(name: String, chairNumber: Int): ActorRef +} diff --git a/command/pom.xml b/command/pom.xml new file mode 100644 index 0000000000..656f434cd8 --- /dev/null +++ b/command/pom.xml @@ -0,0 +1,95 @@ + + + + osgi-sample + com.typesafe.akka + 2.2.0-SNAPSHOT + + 4.0.0 + + command + Dining Hakker :: Service consumer + bundle + + + + org.osgi + org.osgi.core + 4.3.0 + + + org.osgi + org.osgi.compendium + 4.3.0 + + + ${project.groupId} + api + ${version} + + + com.typesafe.akka + akka-osgi_2.10 + 2.1.0 + + + + + src/main/scala + + + + + bundle-manifest + process-classes + + manifest + + + + org.apache.felix + maven-bundle-plugin + 2.3.7 + true + + + ${project.name} + ${project.artifactId} + akka.osgi.sample.command + !sun.misc, * + + + + akka.osgi.sample.command.Activator + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-artifact + package + + copy + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + ${project.packaging} + + + ../bundles + + + + + + + diff --git a/command/src/main/scala/akka/osgi/sample/command/Activator.scala b/command/src/main/scala/akka/osgi/sample/command/Activator.scala new file mode 100644 index 0000000000..7e7c78c695 --- /dev/null +++ b/command/src/main/scala/akka/osgi/sample/command/Activator.scala @@ -0,0 +1,41 @@ +/* +Copyright 2013 Crossing-Tech + +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 + +http://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. + */ +package akka.osgi.sample.command + +import org.osgi.framework.{ServiceEvent, BundleContext, BundleActivator} +import akka.osgi.sample.api.DiningHakkersService +import akka.actor.{ActorRef, PoisonPill} +import org.osgi.util.tracker.ServiceTracker + +class Activator extends BundleActivator { + println("Command Activator created") + var hakker : Option[ActorRef] = None + + def start(context: BundleContext) { + val logServiceTracker = new ServiceTracker(context, classOf[DiningHakkersService].getName, null) + logServiceTracker.open() + val service = Option(logServiceTracker.getService.asInstanceOf[DiningHakkersService]) + service.foreach(startHakker(_, context.getBundle.getSymbolicName + ":" + context.getBundle.getBundleId)) + } + + def startHakker(service: DiningHakkersService, name: String){ + hakker = Some(service.getHakker(name, (math.floor(math.random * 5)).toInt)) + } + + def stop(context: BundleContext) { + hakker.foreach(_ ! PoisonPill) + } +} diff --git a/core/pom.xml b/core/pom.xml new file mode 100644 index 0000000000..b6cb3b93e9 --- /dev/null +++ b/core/pom.xml @@ -0,0 +1,174 @@ + + + + osgi-sample + com.typesafe.akka + 2.2.0-SNAPSHOT + + 4.0.0 + + core + Dining Hakker :: Core + bundle + + + + org.osgi + org.osgi.core + 4.2.0 + + + org.osgi + org.osgi.compendium + 4.2.0 + + + com.typesafe.akka + akka-actor_2.10 + 2.1.0 + + + com.typesafe.akka + akka-remote_2.10 + 2.1.0 + + + com.typesafe + config + 1.0.0 + + + ${project.groupId} + api + ${version} + + + + + + + + org.jboss.netty + netty + 3.2.7.Final + + + com.google.protobuf + protobuf-java + 2.4.1 + + + com.typesafe.akka + akka-cluster-experimental_2.10 + 2.1.0 + + + org.hyperic + sigar + 1.6.4 + + + + com.typesafe.akka + akka-osgi_2.10 + 2.1.0 + + + + + src/main/scala + + + + + bundle-manifest + process-classes + + manifest + + + + org.apache.felix + maven-bundle-plugin + 2.3.7 + true + + + ${project.name} + ${project.artifactId} + akka.osgi.sample.activation + !sun.misc, * + + akka.osgi.sample.internal, akka.osgi.sample.service + + akka.osgi.sample.activation.Activator + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-artifact + package + + copy + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + ${project.packaging} + + + ../bundles + + + + + + + exec-maven-plugin + org.codehaus.mojo + + + osgi-prepare + package + + exec + + + ../karaf.sh + + + + + + org.apache.maven.plugins + maven-clean-plugin + 2.4.1 + + + + ../apache-karaf-2.3.0 + + **/* + + false + + + + + + + diff --git a/core/src/main/resources/application.conf b/core/src/main/resources/application.conf new file mode 100644 index 0000000000..1b4600d742 --- /dev/null +++ b/core/src/main/resources/application.conf @@ -0,0 +1,21 @@ +akka { + + actor { + provider = "akka.cluster.ClusterActorRefProvider" + } + + remote { + transport = "akka.remote.netty.NettyRemoteTransport" + log-remote-lifecycle-events = off + netty { + hostname = "localhost" + port = 2552 + } + } + + cluster { + seed-nodes = ["akka://akka-osgi-sample@localhost:2552"] + auto-down = on + } + +} diff --git a/core/src/main/scala/akka/osgi/sample/activation/Activator.scala b/core/src/main/scala/akka/osgi/sample/activation/Activator.scala new file mode 100644 index 0000000000..0bfa765ff7 --- /dev/null +++ b/core/src/main/scala/akka/osgi/sample/activation/Activator.scala @@ -0,0 +1,69 @@ +/* +Copyright 2013 Crossing-Tech + +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 + +http://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. + */ +package akka.osgi.sample.activation + +import akka.osgi.ActorSystemActivator +import org.osgi.framework.{ServiceRegistration, BundleContext} +import akka.actor.{Props, ActorSystem} +import java.util.{Dictionary, Properties} +import akka.osgi.sample.internal.Table +import akka.osgi.sample.service.DiningHakkersServiceImpl +import akka.osgi.sample.api.DiningHakkersService +import akka.event.{LogSource, Logging} + +class Activator extends ActorSystemActivator { + + import Activator._ + + var service: Option[ServiceRegistration[_]] = None + + def configure(context: BundleContext, system: ActorSystem) { + val log = Logging(system, this) + log.info("Core bundle configured") + system.actorOf(Props[Table], "table") + registerHakkersService(context, system) + log.info("Hakker service registred") + } + + def registerHakkersService(context: BundleContext, system: ActorSystem) { + + val hakkersService = new DiningHakkersServiceImpl(system) + + service.foreach(_.unregister()) //Cleanup //TODO required?? + service = Some(context.registerService(classOf[DiningHakkersService].getName, hakkersService, (new Properties()).asInstanceOf[Dictionary[String, Any]])) + + } + + + override def stop(context: BundleContext) { + unregisterHakkersService(context) + println("Hakker service unregistred") + super.stop(context) + } + + def unregisterHakkersService(context: BundleContext) { + service foreach (_.unregister()) + } + + override def getActorSystemName(context: BundleContext): String = "akka-osgi-sample" +} + +object Activator { + implicit val logSource: LogSource[AnyRef] = new LogSource[AnyRef] { + def genString(o: AnyRef): String = o.getClass.getName + override def getClazz(o: AnyRef): Class[_] = o.getClass + } +} diff --git a/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala b/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala new file mode 100644 index 0000000000..dc6e0de9e3 --- /dev/null +++ b/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala @@ -0,0 +1,175 @@ +/** + * Copyright (C) 2009-2010 Typesafe Inc. . + */ +package akka.osgi.sample.internal + +import language.postfixOps +import akka.cluster.Cluster +import akka.cluster.ClusterEvent.{CurrentClusterState, LeaderChanged} +import akka.event.Logging + +//Akka adaptation of +//http://www.dalnefre.com/wp/2010/08/dining-philosophers-in-humus/ + +import akka.actor._ +import scala.concurrent.duration._ + +/* +* First we define our messages, they basically speak for themselves +*/ +sealed trait DiningHakkerMessage + +case class Busy(chopstick: ActorRef) extends DiningHakkerMessage + +case class Put(hakker: ActorRef) extends DiningHakkerMessage + +case class Take(hakker: ActorRef) extends DiningHakkerMessage + +case class Taken(chopstick: ActorRef) extends DiningHakkerMessage + +object Eat extends DiningHakkerMessage + +object Think extends DiningHakkerMessage + +/* +* A Chopstick is an actor, it can be taken, and put back +*/ +class Chopstick extends Actor { + + val log = Logging(context.system, this) + + import context._ + + //When a Chopstick is taken by a hakker + //It will refuse to be taken by other hakkers + //But the owning hakker can put it back + def takenBy(hakker: ActorRef): Receive = { + case Take(otherHakker) ⇒ + otherHakker ! Busy(self) + case Put(`hakker`) ⇒ + become(available) + } + + //When a Chopstick is available, it can be taken by a hakker + def available: Receive = { + case Take(hakker) ⇒ + log.info(self.path +" is taken by "+hakker) + become(takenBy(hakker)) + hakker ! Taken(self) + } + + //A Chopstick begins its existence as available + def receive = available +} + +/* +* A hakker is an awesome dude or dudett who either thinks about hacking or has to eat ;-) +*/ +class Hakker(name: String, chair: Int) extends Actor { + + val log = Logging(context.system, this) + + log.info("Created Hakker at" +self.path) + + import context._ + + val cluster = Cluster(context.system) + + override def preStart(){ + log.info(s"Hakker ($name) takes position($chair)") + cluster.subscribe(self, classOf[LeaderChanged]) + } + + override def postStop(){ + log.info(s"Hakker ($name) leaves position($chair)") + cluster.unsubscribe(self) + } + + //When a hakker is thinking it can become hungry + //and try to pick up its chopsticks and eat + def thinking(left: ActorRef, right: ActorRef): Receive = { + case Eat ⇒ + become(hungry(left, right) orElse (clusterEvents)) + left ! Take(self) + right ! Take(self) + } + + //When a hakker is hungry it tries to pick up its chopsticks and eat + //When it picks one up, it goes into wait for the other + //If the hakkers first attempt at grabbing a chopstick fails, + //it starts to wait for the response of the other grab + def hungry(left: ActorRef, right: ActorRef): Receive = { + case Taken(`left`) ⇒ + become(waiting_for(left, right, false) orElse (clusterEvents)) + case Taken(`right`) ⇒ + become(waiting_for(left, right, true) orElse (clusterEvents)) + case Busy(chopstick) ⇒ + become(denied_a_chopstick(left, right) orElse (clusterEvents)) + } + + //When a hakker is waiting for the last chopstick it can either obtain it + //and start eating, or the other chopstick was busy, and the hakker goes + //back to think about how he should obtain his chopsticks :-) + def waiting_for(left: ActorRef, right: ActorRef, waitingForLeft: Boolean): Receive = { + case Taken(`left`) if waitingForLeft ⇒ + log.info("%s has picked up %s and %s and starts to eat".format(name, left.path.name, right.path.name)) + become(eating(left, right) orElse (clusterEvents)) + system.scheduler.scheduleOnce(5 seconds, self, Think) + case Taken(`right`) if !waitingForLeft => + log.info("%s has picked up %s and %s and starts to eat".format(name, left.path.name, right.path.name)) + become(eating(left, right) orElse (clusterEvents)) + system.scheduler.scheduleOnce(5 seconds, self, Think) + case Busy(chopstick) ⇒ + become(thinking(left, right) orElse (clusterEvents)) + if (waitingForLeft) { + right ! Put(self) + } else { + left ! Put(self) + } + self ! Eat + } + + //When the results of the other grab comes back, + //he needs to put it back if he got the other one. + //Then go back and think and try to grab the chopsticks again + def denied_a_chopstick(left: ActorRef, right: ActorRef): Receive = { + case Taken(chopstick) ⇒ + become(thinking(left, right) orElse (clusterEvents)) + chopstick ! Put(self) + self ! Eat + case Busy(chopstick) ⇒ + become(thinking(left, right) orElse (clusterEvents)) + self ! Eat + } + + //When a hakker is eating, he can decide to start to think, + //then he puts down his chopsticks and starts to think + def eating(left: ActorRef, right: ActorRef): Receive = { + case Think ⇒ + become(thinking(left, right) orElse (clusterEvents)) + left ! Put(self) + right ! Put(self) + log.info("%s puts down his chopsticks and starts to think".format(name)) + system.scheduler.scheduleOnce(5 seconds, self, Eat) + } + + def waitForChopsticks: Receive = { + case (left: ActorRef, right: ActorRef) => + become(thinking(left, right) orElse (clusterEvents)) + system.scheduler.scheduleOnce(5 seconds, self, Eat) + } + + def clusterEvents: Receive = { + case state: CurrentClusterState ⇒ state.leader foreach updateTable + case LeaderChanged(Some(leaderAddress)) ⇒ updateTable(leaderAddress) + } + + def updateTable(leaderAdress: Address) { + become(waitForChopsticks) + context.actorFor(RootActorPath(leaderAdress) / "user" / "table") ! chair + } + + //All hakkers start in a non-eating state + def receive = clusterEvents + +} \ No newline at end of file diff --git a/core/src/main/scala/akka/osgi/sample/internal/Table.scala b/core/src/main/scala/akka/osgi/sample/internal/Table.scala new file mode 100644 index 0000000000..0111408f3e --- /dev/null +++ b/core/src/main/scala/akka/osgi/sample/internal/Table.scala @@ -0,0 +1,26 @@ +/* +Copyright 2013 Crossing-Tech + +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 + +http://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. + */ +package akka.osgi.sample.internal + +import akka.actor.{Props, Actor} + +class Table extends Actor { + val chopsticks = for (i ← 1 to 5) yield context.actorOf(Props[Chopstick], "Chopstick" + i) + + def receive = { + case x: Int => sender !(chopsticks(x), chopsticks((x + 1) % 5)) + } +} diff --git a/core/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala b/core/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala new file mode 100644 index 0000000000..5bdb667527 --- /dev/null +++ b/core/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala @@ -0,0 +1,26 @@ +/* +Copyright 2013 Crossing-Tech + +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 + +http://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. + */ +package akka.osgi.sample.service + +import akka.osgi.sample.api.DiningHakkersService +import akka.actor.{Props, ActorSystem} +import akka.osgi.sample.internal.Hakker + +class DiningHakkersServiceImpl(system: ActorSystem) extends DiningHakkersService { + def getHakker(name: String, chairNumber: Int) = { + system.actorOf(Props(new Hakker(name, chairNumber))) + } +} diff --git a/karaf.sh b/karaf.sh new file mode 100755 index 0000000000..b15c2599c7 --- /dev/null +++ b/karaf.sh @@ -0,0 +1,24 @@ +#!/bin/bash +cd .. +#Karaf download +if [ ! -f apache-karaf-2.3.0 ]; +then +echo "karaf download" +wget -q http://mirror.switch.ch/mirror/apache/dist/karaf/2.3.0/apache-karaf-2.3.0.tar.gz -O karaf.tar.gz +echo "karaf untar" +tar xf karaf.tar.gz +rm karaf.tar.gz +fi +deploy_directory=apache-karaf-2.3.0/deploy +#Bundles download +wget -q "http://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.10/2.1.0/akka-actor_2.10-2.1.0.jar" -O $deploy_directory/akka-actor-2.1.jar +wget -q "http://repo1.maven.org/maven2/com/typesafe/akka/akka-osgi_2.10/2.1.0/akka-osgi_2.10-2.1.0.jar" -O $deploy_directory/akka-osgi-2.1.jar +wget -q "http://repo1.maven.org/maven2/com/typesafe/akka/akka-remote_2.10/2.1.0/akka-remote_2.10-2.1.0.jar" -O $deploy_directory/akka-remote-2.1.jar +wget -q "http://repo1.maven.org/maven2/io/netty/netty/3.5.7.Final/netty-3.5.7.Final.jar" -O $deploy_directory/netty-3.5.7.jar +wget -q "http://repo1.maven.org/maven2/com/typesafe/akka/akka-cluster-experimental_2.10/2.1.0/akka-cluster-experimental_2.10-2.1.0.jar" -O $deploy_directory/akka-cluster-2.1.jar +wget -q "http://repo1.maven.org/maven2/com/typesafe/config/1.0.0/config-1.0.0.jar" -O $deploy_directory/config-1.0.jar +wget -q "http://repo1.maven.org/maven2/org/scala-lang/scala-library/2.10.0/scala-library-2.10.0.jar" -O $deploy_directory/scala-library-2.10.jar +echo $PWD +cp bundles/*.jar $deploy_directory + +echo please run apache-karaf-2.3.0/bin/karaf after having replace, in $deploy_directory, legacy bundles by the bundles you wand to test diff --git a/osgi-run.sh b/osgi-run.sh new file mode 100755 index 0000000000..6423e4a835 --- /dev/null +++ b/osgi-run.sh @@ -0,0 +1,2 @@ +#!/bin/bash +./apache-karaf-2.3.0/bin/karaf \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000..852c8ef8d7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + com.typesafe.akka + osgi-sample + 2.2.0-SNAPSHOT + + api + command + uncommons + protobuf + core + + pom + com.typesafe.akka.akka-osgi.sample + + + org.scala-lang + scala-compiler + 2.10.0 + + + + + oss-sonatype-releases + https://oss.sonatype.org/content/repositories/releases + + + + + + + org.scala-tools + maven-scala-plugin + 2.15.2 + + + + compile + + + + + + + org.apache.maven.plugins + maven-clean-plugin + 2.4.1 + + + + bundles + + **/* + + false + + + + + + + diff --git a/project/Build.scala b/project/Build.scala new file mode 100644 index 0000000000..f44af586e9 --- /dev/null +++ b/project/Build.scala @@ -0,0 +1,144 @@ +/* +Copyright 2013 Crossing-Tech + +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 + +http://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. + */ +import sbt._ +import Keys._ +import com.typesafe.sbtosgi.OsgiPlugin.{OsgiKeys, osgiSettings} + + +object OsgiSampleBuild extends Build { + + override lazy val settings = + super.settings ++ + buildSettings ++ + Seq( + shellPrompt := { + s => Project.extract(s).currentProject.id + " > " + } + ) + + lazy val buildSettings = Seq( + scalaVersion := "2.10.0", + resolvers ++= Seq("oss-sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases", + "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"), + version := "2.1.0-SNAPSHOT" + ) + + + val ActorReferenceCopyTask = TaskKey[Int]("osgi-prepare", "Prepare an Osgi framework and required bundles") + + val ActorReferenceCopyAction = ActorReferenceCopyTask:={ + new File("bundles").mkdir() + projects.map(_.base).filter(p => (new File(p+"/target/scala-2.10")).exists).foreach(p => { + List("sh", "-c", "cp "+p+"/target/scala-2.10/*.jar bundles") !; + }) + List("sh", "-c", "cd core; bash ../karaf.sh") !; + } + + lazy val root = Project(id = "osgi-sample", + base = file("."), + settings = Project.defaultSettings ++ Seq( + ActorReferenceCopyAction, + cleanFiles <+= baseDirectory { base => base / "bundles" }, + cleanFiles <+= baseDirectory { base => base / "apache-karaf-2.3.0" }, + libraryDependencies ++= Seq() + ) + ) aggregate(api, command, core, uncommons, protobuf) + + lazy val api = Project(id = "api", + base = file("./api"), + settings = Project.defaultSettings ++ exports(Seq("akka.osgi.sample.api")) ++ Seq(libraryDependencies ++= Seq(Dependencies.akka_actor)) + ) + + lazy val command = Project(id = "command", + base = file("./command"), + settings = Project.defaultSettings ++ exports(Seq("akka.osgi.sample.command"), Seq("akka.osgi.sample.api", "org.osgi.framework")) ++ Seq( + libraryDependencies ++= Dependencies.command, + OsgiKeys.bundleActivator := Option("akka.osgi.sample.command.Activator") + ) + ) dependsOn (api) + + + lazy val core = Project(id = "core", + base = file("./core"), + settings = Project.defaultSettings ++ exports(Seq("akka.osgi.sample.service", "akka.osgi.sample.activation"), defaultImports, Seq("akka.osgi.sample.internal")) ++ Seq( + libraryDependencies ++= Dependencies.core, + OsgiKeys.bundleActivator := Option("akka.osgi.sample.activation.Activator") + ) + ) dependsOn (api) + + lazy val uncommons = Project(id = "uncommons", + base = file("./uncommons"), + settings = Project.defaultSettings ++ exports(Seq("org.uncommons.maths.random"), privates = Seq("org.uncommons.maths.binary", "org.uncommons.maths", "org.uncommons.maths.number")) ++ Seq( + libraryDependencies ++= Dependencies.uncommons, + version := "1.2.2" + ) + ) + + lazy val protobuf = Project(id = "protobuf", + base = file("./protobuf"), + settings = Project.defaultSettings ++ exports(Seq("com.google.protobuf")) ++ Seq( + libraryDependencies ++= Seq(Dependencies.protobuf), + version := "2.4.1" + ) + ) + + def exports(packages: Seq[String] = Seq(), imports: Seq[String] = Nil, privates: Seq[String] = Nil) = osgiSettings ++ Seq( + OsgiKeys.importPackage := imports ++ Seq("*"), + OsgiKeys.privatePackage := privates, + OsgiKeys.exportPackage := packages + ) + + def copyFile(source: String, sink: String){ + val src = new java.io.File(source) + val dest = new java.io.File(sink) + new java.io.FileOutputStream(dest) getChannel() transferFrom( + new java.io.FileInputStream(src) getChannel, 0, Long.MaxValue ) + } + + + def defaultImports = Seq("!sun.misc", akkaImport(), configImport(), scalaImport()) + + def akkaImport(packageName: String = "akka.*") = "%s;version=\"[2.1,2.3)\"".format(packageName) + + def configImport(packageName: String = "com.typesafe.config.*") = "%s;version=\"[0.4.1,1.1.0)\"".format(packageName) + + def protobufImport(packageName: String = "com.google.protobuf.*") = "%s;version=\"[2.4.0,2.5.0)\"".format(packageName) + + def scalaImport(packageName: String = "scala.*") = "%s;version=\"[2.10,2.11)\"".format(packageName) + +} + +object Dependencies { + val akka_actor = "com.typesafe.akka" % "akka-actor_2.10" % "2.2-SNAPSHOT" changing() + val akka_osgi = "com.typesafe.akka" % "akka-osgi_2.10" % "2.2-SNAPSHOT" exclude("org.osgi.core", "org.osgi.compendium") changing() + val akka_remote = "com.typesafe.akka" % "akka-remote_2.10" % "2.2-SNAPSHOT" changing() + val akka_cluster = "com.typesafe.akka" % "akka-cluster-experimental_2.10" % "2.2-SNAPSHOT" changing() + val config = "com.typesafe" % "config" % "1.0.0" + + val osgiCore = "org.osgi" % "org.osgi.core" % "4.3.0" + val osgiCompendium = "org.osgi" % "org.osgi.compendium" % "4.3.0" + val core = Seq(akka_actor, akka_osgi, akka_remote, akka_cluster, config, osgiCore, osgiCompendium) + val command = Seq(akka_actor, osgiCore, osgiCompendium) + + val uncommons_math = "org.uncommons.maths" % "uncommons-maths" % "1.2.2" + val jcommon = "jfree" % "jcommon" % "1.0.16" + val jfreechart = "jfree" % "jfreechart" % "1.0.13" + val uncommons = Seq(uncommons_math, jcommon, jfreechart) + + val protobuf = "com.google.protobuf" % "protobuf-java" % "2.4.1" + +} + diff --git a/protobuf/pom.xml b/protobuf/pom.xml new file mode 100644 index 0000000000..0d27390b05 --- /dev/null +++ b/protobuf/pom.xml @@ -0,0 +1,81 @@ + + + + osgi-sample + com.typesafe.akka + 2.2.0-SNAPSHOT + + 4.0.0 + + protobuf + com.google.protobuf + 2.4.1 + bundle + + + + + com.google.protobuf + protobuf-java + 2.4.1 + + + + + + + + + + bundle-manifest + process-classes + + manifest + + + + org.apache.felix + maven-bundle-plugin + 2.3.7 + true + + + ${project.name} + ${project.artifactId} + com.google.protobuf + !sun.misc, * + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-artifact + package + + copy + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + ${project.packaging} + + + ../bundles + + + + + + + diff --git a/uncommons/pom.xml b/uncommons/pom.xml new file mode 100644 index 0000000000..86c276d105 --- /dev/null +++ b/uncommons/pom.xml @@ -0,0 +1,91 @@ + + + + osgi-sample + com.typesafe.akka + 2.2.0-SNAPSHOT + + 4.0.0 + + uncommons + org.uncommons.maths.random + 1.2.2 + bundle + + + + + org.uncommons.maths + uncommons-maths + 1.2.2 + + + jfree + jfreechart + 1.0.13 + + + jfree + jcommon + 1.0.16 + + + + + + + + + + bundle-manifest + process-classes + + manifest + + + + org.apache.felix + maven-bundle-plugin + 2.3.7 + true + + + ${project.name} + ${project.artifactId} + org.uncommons.maths.random + !sun.misc, * + + org.uncommons.maths.binary, org.uncommons.maths, org.uncommons.maths.number + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-artifact + package + + copy + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + ${project.packaging} + + + ../bundles + + + + + + + From 0b7b9ed093268a3a5b788947124d60cf9806041f Mon Sep 17 00:00:00 2001 From: Raman Gupta Date: Tue, 29 Jan 2013 13:36:53 -0500 Subject: [PATCH 3/7] Maven optimization and Karf Feature Simplify maven deps by using inheritance Define dependency versions once in dependencyManagement and inherit in child modules, to avoid defining the version and scope of modules more than once. Use version properties to make things even clearer. Move the maven-bundle-plugin to the root of the project to avoid repeating the same config. Move the src/main/scala source configuration into the root by using the build-helper-plugin. Add a note in uncommons-maths OSGi build POM about v1.2.3 Resolve maven warnings about deprecations and missing versions Use maven-accessible sigar dependency Provision Karaf via maven and features Created assembly-features to define the project features for Karaf provisioning. Created assembly-dist containing the build instructions necessary to build an archive of a pre-configured Karaf instance. Update the Netty version. Use the pre-bundled Protobuf from the servicemix project -- see the features.xml created for Karaf -- and remove the manual protobuf bundling. --- README.md | 21 ++- api/pom.xml | 58 +------ assembly-dist/pom.xml | 140 +++++++++++++++++ assembly-dist/src/main/descriptors/bin.xml | 92 +++++++++++ assembly-dist/src/main/distribution/README | 47 ++++++ assembly-dist/src/main/distribution/VERSION | 1 + .../main/distribution/etc/custom.properties | 31 ++++ .../etc/org.apache.karaf.features.cfg | 8 + .../src/main/distribution/etc/readme.txt | 7 + .../src/main/distribution/lib/readme.txt | 2 + .../src/main/resources/etc/readme.txt | 3 + assembly-features/pom.xml | 75 +++++++++ .../src/main/resources/features.xml | 48 ++++++ command/pom.xml | 50 +----- core/pom.xml | 102 ++----------- karaf.sh | 36 ++--- pom.xml | 144 +++++++++++++++--- protobuf/pom.xml | 81 ---------- uncommons/pom.xml | 42 +---- 19 files changed, 626 insertions(+), 362 deletions(-) create mode 100644 assembly-dist/pom.xml create mode 100644 assembly-dist/src/main/descriptors/bin.xml create mode 100644 assembly-dist/src/main/distribution/README create mode 100644 assembly-dist/src/main/distribution/VERSION create mode 100644 assembly-dist/src/main/distribution/etc/custom.properties create mode 100644 assembly-dist/src/main/distribution/etc/org.apache.karaf.features.cfg create mode 100644 assembly-dist/src/main/distribution/etc/readme.txt create mode 100644 assembly-dist/src/main/distribution/lib/readme.txt create mode 100644 assembly-dist/src/main/resources/etc/readme.txt create mode 100644 assembly-features/pom.xml create mode 100644 assembly-features/src/main/resources/features.xml delete mode 100644 protobuf/pom.xml diff --git a/README.md b/README.md index 8aa90d2094..52e4baa08b 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,13 @@ This project provides three Osgi Bundles - core implementing the whole logic: clustered connections, Hakkers, ChopSticks. It finally provide an ActorRef of one created Hakker - command use a service to get a Hakker (ActorRef) with its position around the table +Two modules that provision the project into the Karaf OSGi container for experimentation and integration testing: + - assembly-features defines the karaf "feature" that allows Karaf to provision the bundles + - assembly-dist creates a distribution tar.gz and zip file containing the configured Karaf runtime + ## How to use it -### Setup with sbt +### Setup with sbt -- TODO update this for latest Karaf provisioning changes and other Maven build changes just run: ```bash sbt clean @@ -22,13 +26,17 @@ sbt osgi-prepare ### Setup with Maven ```bash -mvn clean package +mvn clean install ``` -### Personalize and run -From this point, you may change the created bundles if you want to test other bundles. Afterwards, launch the OSGi Framework using -``./osgi-run.sh`` +The assembly-dist/target/ directory will now contain a tar.gz file that contains a pre-configured Karaf runtime. +This can be extracted to any location, and bin/karaf executed. The provided karaf.sh script automates this. +### Run +Extract the OSGi Framework from the tar.gz described above into any location, or run: +``./karaf.sh`` + +Execute the framework by running bin ``/karaf`` from inside the extracted directory. Then try to restart some bundles, to test the stability of the bundles: @@ -38,4 +46,5 @@ Then try to restart some bundles, to test the stability of the bundles: Depending on the akka version you're using, you may need to modify the core bundle when deploying on a second machine, to set it's akka.remote.netty.hostname in the application.conf. -The configuration is set to start the fist node on one machine and to start other nodes on vm running on the same machine for tests (with vmware, ip of the host : 192.168.229.1 and first vm ip would be 192.168.229.128, but it may differ according to your configuration. +# TODO: The VM ips below are specific to one environment, make this more general +The configuration is set to start the fist node on localhost, and to start other nodes on vm running on the same machine for tests (localhost and first vm ip would be 192.168.229.128, but it may differ according to your configuration. diff --git a/api/pom.xml b/api/pom.xml index 8afbe834a9..6cde31766e 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -17,64 +17,8 @@ com.typesafe.akka - akka-actor_2.10 - 2.1.0 + akka-actor_${scala.dep.version} - - src/main/scala - - - - - bundle-manifest - process-classes - - manifest - - - - org.apache.felix - maven-bundle-plugin - 2.3.7 - true - - - ${project.name} - ${project.artifactId} - akka.osgi.sample.api - !sun.misc, * - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-artifact - package - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - - - ../bundles - - - - - - diff --git a/assembly-dist/pom.xml b/assembly-dist/pom.xml new file mode 100644 index 0000000000..d64a144d9b --- /dev/null +++ b/assembly-dist/pom.xml @@ -0,0 +1,140 @@ + + + 4.0.0 + + + com.typesafe.akka + osgi-sample + 2.2.0-SNAPSHOT + + + com.typesafe.akka + assembly-dist + Dining Hakkers :: Distribution + + + + ${project.groupId} + api + + + ${project.groupId} + core + + + ${project.groupId} + command + + + + + + + ${basedir}/src/main/resources + true + + **/* + + + + + + org.apache.karaf.tooling + features-maven-plugin + ${karaf.version} + + + add-features-to-repo + prepare-package + + add-features-to-repo + + + + mvn:org.apache.karaf.assemblies.features/standard/${karaf.version}/xml/features + mvn:org.apache.karaf.assemblies.features/enterprise/${karaf.version}/xml/features + mvn:com.typesafe.akka/assembly-features/${project.version}/xml/features + + target/generated-features-repo + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.6 + + + copy-cli-dependencies + prepare-package + + copy-dependencies + + + true + target/generated-features-repo + + + + + + unpack + prepare-package + + unpack + + + + + org.apache.karaf + apache-karaf + tar.gz + target/dependencies + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.4 + + + bin + package + + single + + + + src/main/descriptors/bin.xml + + false + gnu + + + + + + + + diff --git a/assembly-dist/src/main/descriptors/bin.xml b/assembly-dist/src/main/descriptors/bin.xml new file mode 100644 index 0000000000..ef595a1b4d --- /dev/null +++ b/assembly-dist/src/main/descriptors/bin.xml @@ -0,0 +1,92 @@ + + + bin + + + tar.gz + + + true + akka-osgi-sample-${project.version} + + + + + ${project.build.directory}/dependencies + + *.jar + + /lib/ + + + + ${project.basedir}/src/main/distribution + / + 0755 + 0644 + true + + lib/readme.txt + + + + + ${project.basedir}/src/main/bin + /bin + 0755 + 0755 + + + + ${project.build.directory}/classes/etc + /etc/ + unix + 0755 + 0644 + + + + ${project.build.directory}/generated-features-repo + /system + 0755 + 0644 + + + + + ${project.build.directory}/dependencies/apache-karaf-${karaf.version} + / + + **/demos/** + bin/** + etc/custom.properties + etc/org.apache.karaf.features.cfg + README + RELEASE-NOTES + karaf-manual*.html + karaf-manual*.pdf + + + + + + ${project.build.directory}/dependencies/apache-karaf-${karaf.version} + / + + bin/** + + 0755 + + + + + diff --git a/assembly-dist/src/main/distribution/README b/assembly-dist/src/main/distribution/README new file mode 100644 index 0000000000..750b5a9c9e --- /dev/null +++ b/assembly-dist/src/main/distribution/README @@ -0,0 +1,47 @@ +============================================================================== + + ZZ: + ZZZZ + ZZZZZZ + ZZZ' ZZZ + ~7 7ZZ' ZZZ + :ZZZ: IZZ' ZZZ + ,OZZZZ.~ZZ? ZZZ + ZZZZ' 'ZZZ$ ZZZ + . $ZZZ ~ZZ$ ZZZ + .=Z?. .ZZZO ~ZZ7 OZZ + .ZZZZ7..:ZZZ~ 7ZZZ ZZZ~ + .$ZZZ$Z+.ZZZZ ZZZ: ZZZ$ + .,ZZZZ?' =ZZO= .OZZ 'ZZZ + .$ZZZZ+ .ZZZZ IZZZ ZZZ$ + .ZZZZZ' .ZZZZ' .ZZZ$ ?ZZZ + .ZZZZZZ' .OZZZ? ?ZZZ 'ZZZ$ + .?ZZZZZZ' .ZZZZ? .ZZZ? 'ZZZO + .+ZZZZZZ?' .7ZZZZ' .ZZZZ :ZZZZ + .ZZZZZZ$' .?ZZZZZ' .~ZZZZ 'ZZZZ. + + + NNNNN $NNNN+ + NNNNN $NNNN+ + NNNNN $NNNN+ + NNNNN $NNNN+ + NNNNN $NNNN+ + =NNNNNNNNND$ NNNNN DDDDDD: $NNNN+ DDDDDN NDDNNNNNNNN, + NNNNNNNNNNNNND NNNNN DNNNNN $NNNN+ 8NNNNN= :NNNNNNNNNNNNNN + NNNNN$ DNNNNN NNNNN $NNNNN~ $NNNN+ NNNNNN NNNNN, :NNNNN+ + ?DN~ NNNNN NNNNN MNNNNN $NNNN+:NNNNN7 $ND =NNNNN + DNNNNN NNNNNDNNNN$ $NNNNDNNNNN :DNNNNN + ZNDNNNNNNNNND NNNNNNNNNND, $NNNNNNNNNNN DNDNNNNNNNNNN + NNNNNNNDDINNNNN NNNNNNNNNNND $NNNNNNNNNNND ONNNNNNND8+NNNNN + :NNNND NNNNN NNNNNN DNNNN, $NNNNNO 7NNNND NNNNNO :NNNNN + DNNNN NNNNN NNNNN DNNNN $NNNN+ 8NNNNN NNNNN $NNNNN + DNNNNO NNNNNN NNNNN NNNNN $NNNN+ NNNNN$ NNNND, ,NNNNND + NNNNNNDDNNNNNNNN NNNNN =NNNNN $NNNN+ DNNNN? DNNNNNNDNNNNNNNND + NNNNNNNNN NNNN$ NNNNN 8NNNND $NNNN+ NNNNN= ,DNNNNNNND NNNNN$ + +============================================================================== + +Welcome to the Akka ${project.version} OSGi sample. + +The sample runs inside a Karaf environment, but the concepts are easily +applicable to any OSGi environment. diff --git a/assembly-dist/src/main/distribution/VERSION b/assembly-dist/src/main/distribution/VERSION new file mode 100644 index 0000000000..df6498b0f5 --- /dev/null +++ b/assembly-dist/src/main/distribution/VERSION @@ -0,0 +1 @@ +Akka ${project.version} diff --git a/assembly-dist/src/main/distribution/etc/custom.properties b/assembly-dist/src/main/distribution/etc/custom.properties new file mode 100644 index 0000000000..83e10d70cf --- /dev/null +++ b/assembly-dist/src/main/distribution/etc/custom.properties @@ -0,0 +1,31 @@ +################################################################################ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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 +# +# http://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. +# +################################################################################ + +# +# All the values specified here will override the default values given +# in config.properties. +# + +karaf.systemBundlesStartLevel=50 + +# Use Equinox +karaf.framework=equinox + +# Poll etc every 5s (default = 1s) +felix.fileinstall.poll=5000 diff --git a/assembly-dist/src/main/distribution/etc/org.apache.karaf.features.cfg b/assembly-dist/src/main/distribution/etc/org.apache.karaf.features.cfg new file mode 100644 index 0000000000..b97bdfbf07 --- /dev/null +++ b/assembly-dist/src/main/distribution/etc/org.apache.karaf.features.cfg @@ -0,0 +1,8 @@ +# +# Comma separated list of features repositories to register by default +# Default list + Dining Hakkers feature +# +featuresRepositories=mvn:org.apache.karaf.assemblies.features/standard/${karaf.version}/xml/features,mvn:org.apache.karaf.assemblies.features/enterprise/${karaf.version}/xml/features,mvn:com.typesafe.akka/assembly-features/${project.version}/xml/features + +# Comma separated list of features to install at startup. Features definitions are looked up from repositories above. +featuresBoot=config,ssh,management,dining-hakker diff --git a/assembly-dist/src/main/distribution/etc/readme.txt b/assembly-dist/src/main/distribution/etc/readme.txt new file mode 100644 index 0000000000..ba59520b8e --- /dev/null +++ b/assembly-dist/src/main/distribution/etc/readme.txt @@ -0,0 +1,7 @@ +Place files like custom.properties and jre.properties here. Files +placed here will be copied to the Karaf etc/ directory. + +Exclude the Karaf default version of the file in bin.xml. + +Additional configuration files for etc should be placed into +src/main/resources/etc. diff --git a/assembly-dist/src/main/distribution/lib/readme.txt b/assembly-dist/src/main/distribution/lib/readme.txt new file mode 100644 index 0000000000..e900b3cdc0 --- /dev/null +++ b/assembly-dist/src/main/distribution/lib/readme.txt @@ -0,0 +1,2 @@ +Jars targeted to the ${app.home}/lib directory should be placed here. +See lib/README in the distribution package for more details. diff --git a/assembly-dist/src/main/resources/etc/readme.txt b/assembly-dist/src/main/resources/etc/readme.txt new file mode 100644 index 0000000000..f0e22d6db4 --- /dev/null +++ b/assembly-dist/src/main/resources/etc/readme.txt @@ -0,0 +1,3 @@ +Configuration files for the Karaf etc/ directory. + +Place Karaf ConfigAdmin files here. diff --git a/assembly-features/pom.xml b/assembly-features/pom.xml new file mode 100644 index 0000000000..fe08a18165 --- /dev/null +++ b/assembly-features/pom.xml @@ -0,0 +1,75 @@ + + + 4.0.0 + + + com.typesafe.akka + osgi-sample + 2.2.0-SNAPSHOT + + + com.typesafe.akka + assembly-features + Dining Hakkers :: Features + pom + + + + + src/main/resources + true + + **/* + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.6 + + false + + + ${*} + + + + + filter + generate-resources + + resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.7 + + + attach-artifact + package + + attach-artifact + + + + + target/classes/features.xml + xml + features + + + + + + + + + diff --git a/assembly-features/src/main/resources/features.xml b/assembly-features/src/main/resources/features.xml new file mode 100644 index 0000000000..79e96f0261 --- /dev/null +++ b/assembly-features/src/main/resources/features.xml @@ -0,0 +1,48 @@ + + + + + mvn:org.osgi/org.osgi.compendium/${osgi.version} + + + + mvn:org.scala-lang/scala-library/${scala.version} + + + + + mvn:com.typesafe.akka/uncommons/1.2.2 + + + + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.protobuf-java/${protobuf.version}_1 + + + + mvn:io.netty/netty/${netty.version} + + + + scala + mvn:com.typesafe/config/${typesafe.config.version} + + + + scala + netty + uncommons-maths + protobuf + typesafe-config + mvn:com.typesafe.akka/akka-actor_${scala.dep.version}/${akka.version} + mvn:com.typesafe.akka/akka-cluster-experimental_${scala.dep.version}/${akka.version} + mvn:com.typesafe.akka/akka-remote_${scala.dep.version}/${akka.version} + mvn:com.typesafe.akka/akka-osgi_${scala.dep.version}/${akka.version} + + + + akka + mvn:com.typesafe.akka/api/${project.version} + mvn:com.typesafe.akka/core/${project.version} + mvn:com.typesafe.akka/command/${project.version} + + diff --git a/command/pom.xml b/command/pom.xml index 656f434cd8..42c5a4b963 100644 --- a/command/pom.xml +++ b/command/pom.xml @@ -17,79 +17,31 @@ org.osgi org.osgi.core - 4.3.0 org.osgi org.osgi.compendium - 4.3.0 ${project.groupId} api - ${version} com.typesafe.akka - akka-osgi_2.10 - 2.1.0 + akka-osgi_${scala.dep.version} - - src/main/scala - - - bundle-manifest - process-classes - - manifest - - - org.apache.felix maven-bundle-plugin - 2.3.7 - true - ${project.name} - ${project.artifactId} - akka.osgi.sample.command - !sun.misc, * - - - akka.osgi.sample.command.Activator - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-artifact - package - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - - - ../bundles - - - - diff --git a/core/pom.xml b/core/pom.xml index b6cb3b93e9..6bd0243067 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -17,158 +17,74 @@ org.osgi org.osgi.core - 4.2.0 org.osgi org.osgi.compendium - 4.2.0 com.typesafe.akka - akka-actor_2.10 - 2.1.0 + akka-actor_${scala.dep.version} com.typesafe.akka - akka-remote_2.10 - 2.1.0 + akka-remote_${scala.dep.version} com.typesafe config - 1.0.0 ${project.groupId} api - ${version} - org.jboss.netty + io.netty netty - 3.2.7.Final com.google.protobuf protobuf-java - 2.4.1 com.typesafe.akka - akka-cluster-experimental_2.10 - 2.1.0 + akka-cluster-experimental_${scala.dep.version} - org.hyperic + org.fusesource sigar 1.6.4 com.typesafe.akka - akka-osgi_2.10 - 2.1.0 + akka-osgi_${scala.dep.version} - - src/main/scala - - - bundle-manifest - process-classes - - manifest - - - org.apache.felix maven-bundle-plugin - 2.3.7 - true - ${project.name} - ${project.artifactId} - akka.osgi.sample.activation - !sun.misc, * - + + !sun.misc, akka.remote.netty;version="[2.1.0,3.0.0)", * akka.osgi.sample.internal, akka.osgi.sample.service - akka.osgi.sample.activation.Activator - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-artifact - package - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - - - ../bundles - - - - - - - exec-maven-plugin - org.codehaus.mojo - - - osgi-prepare - package - - exec - - - ../karaf.sh - - - - - - org.apache.maven.plugins - maven-clean-plugin - 2.4.1 - - - - ../apache-karaf-2.3.0 - - **/* - - false - - - - diff --git a/karaf.sh b/karaf.sh index b15c2599c7..502d9cdbb3 100755 --- a/karaf.sh +++ b/karaf.sh @@ -1,24 +1,16 @@ #!/bin/bash -cd .. -#Karaf download -if [ ! -f apache-karaf-2.3.0 ]; -then -echo "karaf download" -wget -q http://mirror.switch.ch/mirror/apache/dist/karaf/2.3.0/apache-karaf-2.3.0.tar.gz -O karaf.tar.gz -echo "karaf untar" -tar xf karaf.tar.gz -rm karaf.tar.gz -fi -deploy_directory=apache-karaf-2.3.0/deploy -#Bundles download -wget -q "http://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.10/2.1.0/akka-actor_2.10-2.1.0.jar" -O $deploy_directory/akka-actor-2.1.jar -wget -q "http://repo1.maven.org/maven2/com/typesafe/akka/akka-osgi_2.10/2.1.0/akka-osgi_2.10-2.1.0.jar" -O $deploy_directory/akka-osgi-2.1.jar -wget -q "http://repo1.maven.org/maven2/com/typesafe/akka/akka-remote_2.10/2.1.0/akka-remote_2.10-2.1.0.jar" -O $deploy_directory/akka-remote-2.1.jar -wget -q "http://repo1.maven.org/maven2/io/netty/netty/3.5.7.Final/netty-3.5.7.Final.jar" -O $deploy_directory/netty-3.5.7.jar -wget -q "http://repo1.maven.org/maven2/com/typesafe/akka/akka-cluster-experimental_2.10/2.1.0/akka-cluster-experimental_2.10-2.1.0.jar" -O $deploy_directory/akka-cluster-2.1.jar -wget -q "http://repo1.maven.org/maven2/com/typesafe/config/1.0.0/config-1.0.0.jar" -O $deploy_directory/config-1.0.jar -wget -q "http://repo1.maven.org/maven2/org/scala-lang/scala-library/2.10.0/scala-library-2.10.0.jar" -O $deploy_directory/scala-library-2.10.jar -echo $PWD -cp bundles/*.jar $deploy_directory -echo please run apache-karaf-2.3.0/bin/karaf after having replace, in $deploy_directory, legacy bundles by the bundles you wand to test +projdir=$(cd $(dirname $0); pwd) +version=2.2.0-SNAPSHOT + +# This directory is specified in the build as the root of the tar +# Use tar --strip-components=1 to ignore the root +outputdir="$projdir/akka-osgi-sample-$version" + +if [[ -d "$outputdir" ]]; then + echo Deleting existing $outputdir... + rm -fr "$outputdir" +fi +echo Extracting configured container into $outputdir... +tar -C $projdir -zxf assembly-dist/target/assembly-dist-$version.tar.gz +echo Extract complete, please run $outputdir/bin/karaf diff --git a/pom.xml b/pom.xml index 852c8ef8d7..8e28644dd1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,20 +6,123 @@ com.typesafe.akka osgi-sample 2.2.0-SNAPSHOT + + + 2.1.0 + 2.3.0 + 3.5.8.Final + 4.3.0 + 2.6.0 + 2.4.1 + 2.10.0 + 2.10 + 1.0.0 + + api command uncommons - protobuf core + + assembly-features + assembly-dist pom com.typesafe.akka.akka-osgi.sample + + + + + org.osgi + org.osgi.core + ${osgi.version} + + + org.osgi + org.osgi.compendium + ${osgi.version} + + + + ${project.groupId} + api + ${project.version} + + + ${project.groupId} + core + ${project.version} + + + ${project.groupId} + command + ${project.version} + + + + com.typesafe.akka + akka-actor_${scala.dep.version} + ${akka.version} + + + com.typesafe.akka + akka-osgi_${scala.dep.version} + ${akka.version} + + + com.typesafe.akka + akka-cluster-experimental_${scala.dep.version} + ${akka.version} + + + com.typesafe.akka + akka-remote_${scala.dep.version} + ${akka.version} + + + com.typesafe + config + ${typesafe.config.version} + + + com.google.protobuf + protobuf-java + ${protobuf.version} + + + io.netty + netty + ${netty.version} + + + + org.apache.karaf + apache-karaf + ${karaf.version} + tar.gz + + + + org.scala-lang scala-compiler - 2.10.0 + ${scala.version} + + + + org.apache.karaf.tooling.exam + org.apache.karaf.tooling.exam.container + ${karaf.version} + test + + + org.ops4j.pax.exam + pax-exam-junit4 + ${paxexam.version} + test @@ -31,6 +134,24 @@ + + org.codehaus.mojo + build-helper-maven-plugin + 1.7 + + + generate-sources + + add-source + + + + src/main/scala + + + + + org.scala-tools maven-scala-plugin @@ -43,22 +164,11 @@ - - org.apache.maven.plugins - maven-clean-plugin - 2.4.1 - - - - bundles - - **/* - - false - - - + org.apache.felix + maven-bundle-plugin + 2.3.7 + true diff --git a/protobuf/pom.xml b/protobuf/pom.xml deleted file mode 100644 index 0d27390b05..0000000000 --- a/protobuf/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - osgi-sample - com.typesafe.akka - 2.2.0-SNAPSHOT - - 4.0.0 - - protobuf - com.google.protobuf - 2.4.1 - bundle - - - - - com.google.protobuf - protobuf-java - 2.4.1 - - - - - - - - - - bundle-manifest - process-classes - - manifest - - - - org.apache.felix - maven-bundle-plugin - 2.3.7 - true - - - ${project.name} - ${project.artifactId} - com.google.protobuf - !sun.misc, * - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-artifact - package - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - - - ../bundles - - - - - - - diff --git a/uncommons/pom.xml b/uncommons/pom.xml index 86c276d105..d6c01f6baa 100644 --- a/uncommons/pom.xml +++ b/uncommons/pom.xml @@ -9,6 +9,11 @@ 4.0.0 + + uncommons org.uncommons.maths.random 1.2.2 @@ -37,55 +42,18 @@ - - - bundle-manifest - process-classes - - manifest - - - org.apache.felix maven-bundle-plugin - 2.3.7 - true ${project.name} ${project.artifactId} org.uncommons.maths.random !sun.misc, * - org.uncommons.maths.binary, org.uncommons.maths, org.uncommons.maths.number - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-artifact - package - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - - - ../bundles - - - - From c02c071170006c97f6d0d017c6a35e73e8589cbe Mon Sep 17 00:00:00 2001 From: Raman Gupta Date: Tue, 5 Feb 2013 20:59:03 +0100 Subject: [PATCH 4/7] Added Pax Exam based in-container integration test New module integration-test that contains integration tests. Created an initial test that obtains a reference to the DiningHakkerService, creates a dining Hakker, and then interrogates its name and current state. The dining Hakker messages were moved to the API bundle, so that the integration test has access to them without seeing the implementation classes in core. The test is run via the standard "mvn install" command. Update Maven scala plugin to 3.1.2 Update to Akka 2.2-SNAPSHOT (failing integration test) - Netty was updated to 3.6.2.Final (at least 3.6.0 is required by akka-remote) - Removed the temporary import on akka.remote.netty in core - Removed the temporary settings in application.conf - Changed references to akka-actor to akka-osgi Conflicts: core/src/main/resources/application.conf Add karaf tar.gz/zip as deps to avoid pax exam download Add an example of a Karaf cfg to only access jars locally Conflicts: project/Build.scala --- README.md | 11 +- api/pom.xml | 2 +- .../sample/api/DiningHakkersMessages.scala | 24 +++ .../etc/org.ops4j.pax.url.mvn.cfg.onlylocal | 92 ++++++++++ .../src/main/resources/features.xml | 13 +- core/pom.xml | 4 +- .../osgi/sample/activation/Activator.scala | 17 +- .../akka/osgi/sample/internal/Hakker.scala | 28 ++-- integration-test/pom.xml | 157 ++++++++++++++++++ .../osgi/sample/test/HakkerStatusTest.scala | 100 +++++++++++ .../akka/osgi/sample/test/TestOptions.scala | 60 +++++++ pom.xml | 90 +++++++--- project/Build.scala | 38 +---- project/plugins.sbt | 2 +- 14 files changed, 544 insertions(+), 94 deletions(-) create mode 100644 api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala create mode 100644 assembly-dist/src/main/distribution/etc/org.ops4j.pax.url.mvn.cfg.onlylocal create mode 100644 integration-test/pom.xml create mode 100644 integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala create mode 100644 integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala diff --git a/README.md b/README.md index 52e4baa08b..f3d2b6e231 100644 --- a/README.md +++ b/README.md @@ -9,21 +9,23 @@ This project provides three Osgi Bundles - core implementing the whole logic: clustered connections, Hakkers, ChopSticks. It finally provide an ActorRef of one created Hakker - command use a service to get a Hakker (ActorRef) with its position around the table +An integration testing module is provided to verify OSGi functionality: + - integration-test + Two modules that provision the project into the Karaf OSGi container for experimentation and integration testing: - assembly-features defines the karaf "feature" that allows Karaf to provision the bundles - assembly-dist creates a distribution tar.gz and zip file containing the configured Karaf runtime ## How to use it -### Setup with sbt -- TODO update this for latest Karaf provisioning changes and other Maven build changes +### Setup with sbt just run: ```bash sbt clean sbt package sbt osgi-bundle -sbt osgi-prepare ``` - +sbt will creates the bundles in each subproject (api, command, core)/target/scala-2.10 directories. To have integration tests and OSGi environment loaded, please use the Maven build (at least for the moment) ### Setup with Maven ```bash mvn clean install @@ -45,6 +47,3 @@ Then try to restart some bundles, to test the stability of the bundles: ``exit`` or CTRL-D to exit the Karaf console Depending on the akka version you're using, you may need to modify the core bundle when deploying on a second machine, to set it's akka.remote.netty.hostname in the application.conf. - -# TODO: The VM ips below are specific to one environment, make this more general -The configuration is set to start the fist node on localhost, and to start other nodes on vm running on the same machine for tests (localhost and first vm ip would be 192.168.229.128, but it may differ according to your configuration. diff --git a/api/pom.xml b/api/pom.xml index 6cde31766e..5f01624123 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -17,7 +17,7 @@ com.typesafe.akka - akka-actor_${scala.dep.version} + akka-osgi_${scala.dep.version} diff --git a/api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala b/api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala new file mode 100644 index 0000000000..c83ccac228 --- /dev/null +++ b/api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala @@ -0,0 +1,24 @@ +package akka.osgi.sample.api + +import akka.actor.ActorRef + +/* + * Define our messages, they basically speak for themselves + */ +sealed trait DiningHakkerMessage + +case class Busy(chopstick: ActorRef) extends DiningHakkerMessage + +case class Put(hakker: ActorRef) extends DiningHakkerMessage + +case class Take(hakker: ActorRef) extends DiningHakkerMessage + +case class Taken(chopstick: ActorRef) extends DiningHakkerMessage + +object Eat extends DiningHakkerMessage + +object Think extends DiningHakkerMessage + +object Identify extends DiningHakkerMessage + +case class Identification(name: String, busyWith: String) extends DiningHakkerMessage diff --git a/assembly-dist/src/main/distribution/etc/org.ops4j.pax.url.mvn.cfg.onlylocal b/assembly-dist/src/main/distribution/etc/org.ops4j.pax.url.mvn.cfg.onlylocal new file mode 100644 index 0000000000..02dac64fde --- /dev/null +++ b/assembly-dist/src/main/distribution/etc/org.ops4j.pax.url.mvn.cfg.onlylocal @@ -0,0 +1,92 @@ +################################################################################ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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 +# +# http://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. +# +################################################################################ + +# +# If set to true, the following property will not allow any certificate to be used +# when accessing Maven repositories through SSL +# +#org.ops4j.pax.url.mvn.certificateCheck= + +# +# Path to the local Maven settings file. +# The repositories defined in this file will be automatically added to the list +# of default repositories if the 'org.ops4j.pax.url.mvn.repositories' property +# below is not set. +# The following locations are checked for the existence of the settings.xml file +# * 1. looks for the specified url +# * 2. if not found looks for ${user.home}/.m2/settings.xml +# * 3. if not found looks for ${maven.home}/conf/settings.xml +# * 4. if not found looks for ${M2_HOME}/conf/settings.xml +# +#org.ops4j.pax.url.mvn.settings= + +# +# Path to the local Maven repository which is used to avoid downloading +# artifacts when they already exist locally. +# The value of this property will be extracted from the settings.xml file +# above, or defaulted to: +# System.getProperty( "user.home" ) + "/.m2/repository" +# +org.ops4j.pax.url.mvn.localRepository=file:${karaf.home}/${karaf.default.repository} + +# +# Default this to false. It's just weird to use undocumented repos +# +org.ops4j.pax.url.mvn.useFallbackRepositories=false + +# +# Uncomment if you don't wanna use the proxy settings +# from the Maven conf/settings.xml file +# +# org.ops4j.pax.url.mvn.proxySupport=false + +# +# Disable aether support by default. This ensure that the defaultRepositories +# below will be used +# +org.ops4j.pax.url.mvn.disableAether=true + +# +# Comma separated list of repositories scanned when resolving an artifact. +# Those repositories will be checked before iterating through the +# below list of repositories and even before the local repository +# A repository url can be appended with zero or more of the following flags: +# @snapshots : the repository contains snaphots +# @noreleases : the repository does not contain any released artifacts +# +# The following property value will add the system folder as a repo. +# +org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}/${karaf.default.repository}@snapshots,\ + file:${karaf.home}/local-repo@snapshots + +# +# Comma separated list of repositories scanned when resolving an artifact. +# The default list includes the following repositories: +# http://repo1.maven.org/maven2 +# http://repository.apache.org/content/groups/snapshots-group +# http://svn.apache.org/repos/asf/servicemix/m2-repo +# http://repository.springsource.com/maven/bundles/release +# http://repository.springsource.com/maven/bundles/external +# To add repositories to the default ones, prepend '+' to the list of repositories +# to add. +# A repository url can be appended with zero or more of the following flags: +# @snapshots : the repository contains snaphots +# @noreleases : the repository does not contain any released artifacts +# +org.ops4j.pax.url.mvn.repositories=file:${karaf.home}/${karaf.default.repository} diff --git a/assembly-features/src/main/resources/features.xml b/assembly-features/src/main/resources/features.xml index 79e96f0261..ea31066b21 100644 --- a/assembly-features/src/main/resources/features.xml +++ b/assembly-features/src/main/resources/features.xml @@ -23,24 +23,23 @@ - scala + scala mvn:com.typesafe/config/${typesafe.config.version} - scala - netty + scala + netty uncommons-maths - protobuf - typesafe-config - mvn:com.typesafe.akka/akka-actor_${scala.dep.version}/${akka.version} + protobuf + typesafe-config mvn:com.typesafe.akka/akka-cluster-experimental_${scala.dep.version}/${akka.version} mvn:com.typesafe.akka/akka-remote_${scala.dep.version}/${akka.version} mvn:com.typesafe.akka/akka-osgi_${scala.dep.version}/${akka.version} - akka + akka mvn:com.typesafe.akka/api/${project.version} mvn:com.typesafe.akka/core/${project.version} mvn:com.typesafe.akka/command/${project.version} diff --git a/core/pom.xml b/core/pom.xml index 6bd0243067..4e49595a39 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -24,7 +24,7 @@ com.typesafe.akka - akka-actor_${scala.dep.version} + akka-osgi_${scala.dep.version} com.typesafe.akka @@ -78,8 +78,6 @@ maven-bundle-plugin - - !sun.misc, akka.remote.netty;version="[2.1.0,3.0.0)", * akka.osgi.sample.internal, akka.osgi.sample.service akka.osgi.sample.activation.Activator diff --git a/core/src/main/scala/akka/osgi/sample/activation/Activator.scala b/core/src/main/scala/akka/osgi/sample/activation/Activator.scala index 0bfa765ff7..5de4746eac 100644 --- a/core/src/main/scala/akka/osgi/sample/activation/Activator.scala +++ b/core/src/main/scala/akka/osgi/sample/activation/Activator.scala @@ -16,19 +16,19 @@ See the License for the specific language governing permissions and package akka.osgi.sample.activation import akka.osgi.ActorSystemActivator -import org.osgi.framework.{ServiceRegistration, BundleContext} import akka.actor.{Props, ActorSystem} -import java.util.{Dictionary, Properties} import akka.osgi.sample.internal.Table import akka.osgi.sample.service.DiningHakkersServiceImpl import akka.osgi.sample.api.DiningHakkersService import akka.event.{LogSource, Logging} +import org.osgi.framework.{ServiceRegistration, BundleContext} +import scala.collection.mutable.ListBuffer class Activator extends ActorSystemActivator { import Activator._ - var service: Option[ServiceRegistration[_]] = None + val services: ListBuffer[ServiceRegistration[_]] = ListBuffer() def configure(context: BundleContext, system: ActorSystem) { val log = Logging(system, this) @@ -42,20 +42,19 @@ class Activator extends ActorSystemActivator { val hakkersService = new DiningHakkersServiceImpl(system) - service.foreach(_.unregister()) //Cleanup //TODO required?? - service = Some(context.registerService(classOf[DiningHakkersService].getName, hakkersService, (new Properties()).asInstanceOf[Dictionary[String, Any]])) + services += context.registerService(classOf[DiningHakkersService], hakkersService, null) + services += context.registerService(classOf[ActorSystem], system, null) } - override def stop(context: BundleContext) { - unregisterHakkersService(context) + unregisterServices(context) println("Hakker service unregistred") super.stop(context) } - def unregisterHakkersService(context: BundleContext) { - service foreach (_.unregister()) + def unregisterServices(context: BundleContext) { + services foreach (_.unregister()) } override def getActorSystemName(context: BundleContext): String = "akka-osgi-sample" diff --git a/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala b/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala index dc6e0de9e3..3fcad7a30e 100644 --- a/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala +++ b/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala @@ -14,22 +14,7 @@ import akka.event.Logging import akka.actor._ import scala.concurrent.duration._ -/* -* First we define our messages, they basically speak for themselves -*/ -sealed trait DiningHakkerMessage - -case class Busy(chopstick: ActorRef) extends DiningHakkerMessage - -case class Put(hakker: ActorRef) extends DiningHakkerMessage - -case class Take(hakker: ActorRef) extends DiningHakkerMessage - -case class Taken(chopstick: ActorRef) extends DiningHakkerMessage - -object Eat extends DiningHakkerMessage - -object Think extends DiningHakkerMessage +import akka.osgi.sample.api._ /* * A Chopstick is an actor, it can be taken, and put back @@ -92,6 +77,7 @@ class Hakker(name: String, chair: Int) extends Actor { become(hungry(left, right) orElse (clusterEvents)) left ! Take(self) right ! Take(self) + case Identify ⇒ identify("Thinking") } //When a hakker is hungry it tries to pick up its chopsticks and eat @@ -105,6 +91,7 @@ class Hakker(name: String, chair: Int) extends Actor { become(waiting_for(left, right, true) orElse (clusterEvents)) case Busy(chopstick) ⇒ become(denied_a_chopstick(left, right) orElse (clusterEvents)) + case Identify ⇒ identify("Hungry") } //When a hakker is waiting for the last chopstick it can either obtain it @@ -127,6 +114,7 @@ class Hakker(name: String, chair: Int) extends Actor { left ! Put(self) } self ! Eat + case Identify ⇒ identify("Waiting for Chopstick") } //When the results of the other grab comes back, @@ -140,6 +128,7 @@ class Hakker(name: String, chair: Int) extends Actor { case Busy(chopstick) ⇒ become(thinking(left, right) orElse (clusterEvents)) self ! Eat + case Identify ⇒ identify("Denied a Chopstick") } //When a hakker is eating, he can decide to start to think, @@ -151,6 +140,7 @@ class Hakker(name: String, chair: Int) extends Actor { right ! Put(self) log.info("%s puts down his chopsticks and starts to think".format(name)) system.scheduler.scheduleOnce(5 seconds, self, Eat) + case Identify ⇒ identify("Eating") } def waitForChopsticks: Receive = { @@ -164,6 +154,10 @@ class Hakker(name: String, chair: Int) extends Actor { case LeaderChanged(Some(leaderAddress)) ⇒ updateTable(leaderAddress) } + def identify(busyWith: String) { + sender ! Identification(name, busyWith) + } + def updateTable(leaderAdress: Address) { become(waitForChopsticks) context.actorFor(RootActorPath(leaderAdress) / "user" / "table") ! chair @@ -172,4 +166,4 @@ class Hakker(name: String, chair: Int) extends Actor { //All hakkers start in a non-eating state def receive = clusterEvents -} \ No newline at end of file +} diff --git a/integration-test/pom.xml b/integration-test/pom.xml new file mode 100644 index 0000000000..6e795793f6 --- /dev/null +++ b/integration-test/pom.xml @@ -0,0 +1,157 @@ + + + + osgi-sample + com.typesafe.akka + 2.2.0-SNAPSHOT + + 4.0.0 + + integration-test + Dining Hakker :: Integration Test + jar + + + + ${project.groupId} + api + + + org.apache.karaf.tooling.exam + org.apache.karaf.tooling.exam.container + + + org.ops4j.pax.exam + pax-exam-junit4 + + + com.typesafe.akka + akka-testkit_${scala.dep.version} + + + org.scalatest + scalatest_${scala.dep.version} + + + + org.scala-lang + scala-actors + ${scala.version} + + + junit + junit + + + + + org.ops4j.pax.exam + pax-exam + ${paxexam.version} + test + + + org.ops4j.pax.exam + pax-exam-container-remote + ${paxexam.version} + test + + + org.ops4j.pax.exam + pax-exam-invoker-junit + ${paxexam.version} + test + + + org.ops4j.pax.exam + pax-exam-container-rbc + ${paxexam.version} + test + + + org.ops4j.pax.exam + pax-exam-container-rbc-client + ${paxexam.version} + test + + + org.ops4j.pax.exam + pax-exam-extender-service + ${paxexam.version} + test + + + org.ops4j.pax.exam + pax-exam-inject + ${paxexam.version} + test + + + org.ops4j.pax.swissbox + pax-swissbox-core + ${paxswissbox.version} + test + + + org.ops4j.pax.swissbox + pax-swissbox-extender + ${paxswissbox.version} + test + + + org.ops4j.pax.swissbox + pax-swissbox-lifecycle + ${paxswissbox.version} + test + + + org.ops4j.pax.swissbox + pax-swissbox-framework + ${paxswissbox.version} + test + + + + + + + + + org.ops4j.pax.exam + maven-paxexam-plugin + 1.2.4 + + + generate-config + + generate-depends-file + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12.4 + + + 30000 + ${karaf.version} + ${project.version} + + ${scala.dep.version} + + + + + + diff --git a/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala b/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala new file mode 100644 index 0000000000..f9b0786899 --- /dev/null +++ b/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala @@ -0,0 +1,100 @@ +package akka.osgi.sample.test + +import akka.actor._ +import akka.osgi.sample.api.{Identification, Identify, DiningHakkersService} +import akka.osgi.sample.test.TestOptions._ +import org.junit.runner.RunWith +import org.junit.{Before, Test} +import org.ops4j.pax.exam.{Option => PaxOption} +import org.ops4j.pax.exam.junit.{Configuration, JUnit4TestRunner} +import org.ops4j.pax.exam.util.Filter +import org.scalatest.junit.JUnitSuite +import org.scalatest.junit.ShouldMatchersForJUnit +import javax.inject.Inject +import java.util.concurrent.{TimeUnit, SynchronousQueue} +import akka.testkit.TestProbe +import scala.Some + +/** + * This is a ScalaTest based integration test. Pax-Exam, which is responsible for loading the test class into + * the OSGi environment and executing it, currently does not support ScalaTest directly. However, ScalaTest + * provides a JUnit-compatible runner, so the test is defined to use that runner. Pax-Exam can then invoke + * it as a normal JUnit test. Because Pax Exam is using the JUnitRunner and not one of the ScalaTest traits such + * as FunSuite, the test must be defined using the JUnit @Test annotation. + * + * This is a simple test demonstrating in-container integration testing. + * + * One thing to note is that we only depend on the API bundle, not the implementation in core. The implementation + * is injected into the test at runtime via an OSGi service lookup performed by Pax Exam. + * + * TODO attempt to use the Akka test probe + */ +@RunWith(classOf[JUnit4TestRunner]) +class HakkerStatusTest extends JUnitSuite with ShouldMatchersForJUnit { + + @Inject @Filter(timeout = 30000) + var actorSystem: ActorSystem = _ + + @Inject @Filter(timeout = 30000) + var service: DiningHakkersService = _ + + var testProbe: TestProbe = _ + + @Configuration + def config: Array[PaxOption] = Array[PaxOption]( + karafOptionsWithTestBundles(), + featureDiningHakkers() + //,debugOptions() + ) + + // Junit @Before and @After can be used as well +/* + @Before + def setupAkkaTestkit() { + testProbe = new TestProbe(actorSystem) + } +*/ + + @Test + def verifyObtainingAHakkerViaTheTheDiningHakkersService() { + + val name = "TestHakker" + val hakker = Some(service.getHakker(name, (math.floor(math.random * 5)).toInt)) + .getOrElse(throw new IllegalStateException("No Hakker was created via DiningHakkerService")) + + hakker should not be (null) + +/* TODO Getting some weird config error with TestProbe, is it a TestProbe inside OSGi issue? +java.io.EOFException + at java.io.ObjectInputStream$BlockDataInputStream.readUnsignedByte(ObjectInputStream.java:2747) + at java.io.ObjectInputStream.readUnsignedByte(ObjectInputStream.java:924) + at com.typesafe.config.impl.SerializedConfigValue.readCode(SerializedConfigValue.java:412) + at com.typesafe.config.impl.SerializedConfigValue.readOrigin(SerializedConfigValue.java:218) + ... + + testProbe.send(hakker, Identify) + val identification = testProbe.expectMsgClass(classOf[Identification]) + val (fromHakker, busyWith) = (identification.name, identification.busyWith) +*/ + + // create an "Interrogator" actor that receives a Hakker's identification + // this is to work around the TestProbe Exception above + val response = new SynchronousQueue[(String, String)]() + class Interrogator extends Actor { + def receive = { + case msg: Identification ⇒ { + response.put((msg.name, msg.busyWith)) + } + } + } + + hakker.tell(Identify, actorSystem.actorOf(Props(new Interrogator()), "Interrogator")) + val (fromHakker, busyWith) = response.poll(5, TimeUnit.SECONDS) + + println("---------------> %s is busy with %s.".format(fromHakker, busyWith)) + fromHakker should be ("TestHakker") + busyWith should not be (null) + + } + +} diff --git a/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala b/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala new file mode 100644 index 0000000000..b3e7880fbd --- /dev/null +++ b/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala @@ -0,0 +1,60 @@ +package akka.osgi.sample.test + +import org.ops4j.pax.exam.CoreOptions._ +import org.ops4j.pax.exam.options.DefaultCompositeOption +import org.ops4j.pax.exam.{Option => PaxOption} +import org.apache.karaf.tooling.exam.options.LogLevelOption +import org.apache.karaf.tooling.exam.options.KarafDistributionOption._ + +/** + * Re-usable PAX Exam option groups. + */ +object TestOptions { + + val scalaDepVersion = System.getProperty("scala.dep.version") + + def karafOptions(useDeployFolder: Boolean = false): PaxOption = { + new DefaultCompositeOption( + karafDistributionConfiguration.frameworkUrl( + maven.groupId("org.apache.karaf").artifactId("apache-karaf").`type`("zip").version(System.getProperty("karaf.version"))) + .karafVersion(System.getProperty("karaf.version")).name("Apache Karaf").useDeployFolder(useDeployFolder), + editConfigurationFilePut("etc/config.properties", "karaf.framework", "equinox") + ) + } + + def testBundles(): PaxOption = { + new DefaultCompositeOption( + mavenBundle("com.typesafe.akka", "akka-testkit_%s".format(scalaDepVersion)).versionAsInProject, + mavenBundle("org.scalatest", "scalatest_%s".format(scalaDepVersion)).versionAsInProject, + // This is needed for the scalatest osgi bundle, it has a non-optional import on a scala-actors package + mavenBundle("org.scala-lang", "scala-actors").versionAsInProject, + junitBundles + ) + } + + def debugOptions(level: LogLevelOption.LogLevel = LogLevelOption.LogLevel.INFO, debugPort: Int= 5005): PaxOption = { + new DefaultCompositeOption( + logLevel(level), + debugConfiguration(String.valueOf(debugPort), true), + configureConsole().startLocalConsole(), + configureConsole().startRemoteShell() + ) + } + + def karafOptionsWithTestBundles(useDeployFolder: Boolean = false): PaxOption = { + new DefaultCompositeOption( + karafOptions(useDeployFolder), + testBundles() + ) + } + + def featureDiningHakkers(): PaxOption = { + akkaFeature("dining-hakker") + } + + def akkaFeature(feature: String): PaxOption = { + scanFeatures(maven.groupId("com.typesafe.akka").artifactId("assembly-features").`type`("xml").classifier("features") + .version(System.getProperty("project.version")), feature) + } + +} diff --git a/pom.xml b/pom.xml index 8e28644dd1..a2a425baeb 100644 --- a/pom.xml +++ b/pom.xml @@ -8,14 +8,17 @@ 2.2.0-SNAPSHOT - 2.1.0 + 2.2-SNAPSHOT 2.3.0 - 3.5.8.Final + ${karaf.version} + 3.6.2.Final 4.3.0 2.6.0 + 1.6.0 2.4.1 2.10.0 2.10 + 1.9.1 1.0.0 @@ -27,6 +30,7 @@ assembly-features assembly-dist + integration-test pom com.typesafe.akka.akka-osgi.sample @@ -60,11 +64,6 @@ ${project.version} - - com.typesafe.akka - akka-actor_${scala.dep.version} - ${akka.version} - com.typesafe.akka akka-osgi_${scala.dep.version} @@ -97,10 +96,34 @@ - org.apache.karaf - apache-karaf - ${karaf.version} - tar.gz + org.apache.karaf.tooling.exam + org.apache.karaf.tooling.exam.container + ${karaf.tooling.exam.version} + test + + + org.ops4j.pax.exam + pax-exam-junit4 + ${paxexam.version} + test + + + com.typesafe.akka + akka-testkit_${scala.dep.version} + ${akka.version} + test + + + org.scalatest + scalatest_${scala.dep.version} + ${scalatest.version} + test + + + junit + junit + 4.9 + test @@ -112,17 +135,18 @@ ${scala.version} + - org.apache.karaf.tooling.exam - org.apache.karaf.tooling.exam.container + org.apache.karaf + apache-karaf ${karaf.version} - test + tar.gz - org.ops4j.pax.exam - pax-exam-junit4 - ${paxexam.version} - test + org.apache.karaf + apache-karaf + ${karaf.version} + zip @@ -130,6 +154,10 @@ oss-sonatype-releases https://oss.sonatype.org/content/repositories/releases + + typesafe-snapshots + http://repo.typesafe.com/typesafe/snapshots/ + @@ -153,16 +181,36 @@ - org.scala-tools - maven-scala-plugin - 2.15.2 + net.alchim31.maven + scala-maven-plugin + 3.1.2 + scala-compile-first + process-resources + add-source compile + + scala-test-compile + process-test-resources + + testCompile + + + + + -deprecation + -feature + -encoding + UTF-8 + + + + org.apache.felix diff --git a/project/Build.scala b/project/Build.scala index f44af586e9..1dc9c52e4e 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and */ import sbt._ import Keys._ -import com.typesafe.sbtosgi.OsgiPlugin.{OsgiKeys, osgiSettings} +import com.typesafe.sbt.osgi.SbtOsgi.{OsgiKeys, osgiSettings} object OsgiSampleBuild extends Build { @@ -32,30 +32,18 @@ object OsgiSampleBuild extends Build { lazy val buildSettings = Seq( scalaVersion := "2.10.0", resolvers ++= Seq("oss-sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases", + "JBoss Repo" at "http://repository.jboss.org/nexus/content/groups/public/", "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"), - version := "2.1.0-SNAPSHOT" + version := "2.2.0-SNAPSHOT" ) - val ActorReferenceCopyTask = TaskKey[Int]("osgi-prepare", "Prepare an Osgi framework and required bundles") - - val ActorReferenceCopyAction = ActorReferenceCopyTask:={ - new File("bundles").mkdir() - projects.map(_.base).filter(p => (new File(p+"/target/scala-2.10")).exists).foreach(p => { - List("sh", "-c", "cp "+p+"/target/scala-2.10/*.jar bundles") !; - }) - List("sh", "-c", "cd core; bash ../karaf.sh") !; - } - lazy val root = Project(id = "osgi-sample", base = file("."), settings = Project.defaultSettings ++ Seq( - ActorReferenceCopyAction, - cleanFiles <+= baseDirectory { base => base / "bundles" }, - cleanFiles <+= baseDirectory { base => base / "apache-karaf-2.3.0" }, libraryDependencies ++= Seq() ) - ) aggregate(api, command, core, uncommons, protobuf) + ) aggregate(api, command, core, uncommons) lazy val api = Project(id = "api", base = file("./api"), @@ -87,14 +75,6 @@ object OsgiSampleBuild extends Build { ) ) - lazy val protobuf = Project(id = "protobuf", - base = file("./protobuf"), - settings = Project.defaultSettings ++ exports(Seq("com.google.protobuf")) ++ Seq( - libraryDependencies ++= Seq(Dependencies.protobuf), - version := "2.4.1" - ) - ) - def exports(packages: Seq[String] = Seq(), imports: Seq[String] = Nil, privates: Seq[String] = Nil) = osgiSettings ++ Seq( OsgiKeys.importPackage := imports ++ Seq("*"), OsgiKeys.privatePackage := privates, @@ -111,7 +91,7 @@ object OsgiSampleBuild extends Build { def defaultImports = Seq("!sun.misc", akkaImport(), configImport(), scalaImport()) - def akkaImport(packageName: String = "akka.*") = "%s;version=\"[2.1,2.3)\"".format(packageName) + def akkaImport(packageName: String = "akka.*") = "%s;version=\"[2.2,2.3)\"".format(packageName) def configImport(packageName: String = "com.typesafe.config.*") = "%s;version=\"[0.4.1,1.1.0)\"".format(packageName) @@ -122,10 +102,10 @@ object OsgiSampleBuild extends Build { } object Dependencies { - val akka_actor = "com.typesafe.akka" % "akka-actor_2.10" % "2.2-SNAPSHOT" changing() - val akka_osgi = "com.typesafe.akka" % "akka-osgi_2.10" % "2.2-SNAPSHOT" exclude("org.osgi.core", "org.osgi.compendium") changing() - val akka_remote = "com.typesafe.akka" % "akka-remote_2.10" % "2.2-SNAPSHOT" changing() - val akka_cluster = "com.typesafe.akka" % "akka-cluster-experimental_2.10" % "2.2-SNAPSHOT" changing() + val akka_actor = "com.typesafe.akka" % "akka-actor_2.10" % "2.2-SNAPSHOT" + val akka_osgi = "com.typesafe.akka" % "akka-osgi_2.10" % "2.2-SNAPSHOT" exclude("org.osgi.core", "org.osgi.compendium") + val akka_remote = "com.typesafe.akka" % "akka-remote_2.10" % "2.2-SNAPSHOT" + val akka_cluster = "com.typesafe.akka" % "akka-cluster-experimental_2.10" % "2.2-SNAPSHOT" val config = "com.typesafe" % "config" % "1.0.0" val osgiCore = "org.osgi" % "org.osgi.core" % "4.3.0" diff --git a/project/plugins.sbt b/project/plugins.sbt index ba3f4b7f33..72e24c5b2c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -8,7 +8,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-multi-jvm" % "0.3.5") addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.0.0") -addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.6.2") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.7.0-M1") addSbtPlugin("com.typesafe.sbtosgi" % "sbtosgi" % "0.3.0") From 39cd23977b8702f0636780c97a2ff5a9b0ee5d28 Mon Sep 17 00:00:00 2001 From: Christophe Pache Date: Wed, 6 Feb 2013 15:54:58 +0100 Subject: [PATCH 5/7] akka-sample-osgi : fix on sript running maven integration test --- README.md | 12 +- .../akka/osgi/ActorSystemActivator.scala | 3 +- api/pom.xml | 4 +- .../sample/api/DiningHakkersMessages.scala | 5 +- assembly-dist/pom.xml | 21 +-- assembly-dist/src/main/descriptors/bin.xml | 9 +- assembly-features/pom.xml | 5 +- .../src/main/resources/features.xml | 8 +- command/pom.xml | 7 +- core/pom.xml | 4 +- core/src/main/resources/application.conf | 8 +- .../osgi/sample/activation/Activator.scala | 16 ++- .../akka/osgi/sample/internal/Hakker.scala | 2 +- integration-test/pom.xml | 4 +- .../osgi/sample/test/HakkerStatusTest.scala | 17 ++- .../akka/osgi/sample/test/TestOptions.scala | 2 +- pom.xml | 6 +- project/AkkaBuild.scala | 61 ++++++++- project/Build.scala | 124 ------------------ project/plugins.sbt | 2 +- uncommons/pom.xml | 5 +- 21 files changed, 123 insertions(+), 202 deletions(-) delete mode 100644 project/Build.scala diff --git a/README.md b/README.md index f3d2b6e231..303b611346 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -akka-osgi-sample : Clustered DiningHakker +akka-osgi-sample : Clustered DiningHakkers ================ -This project may be used to test akka bundles in OSGi Frameworks. The build tool (sbt for the moment) provide scripts to run in an OSGi Framework (Karaf only for the moment) a version of the DiningHakkers that runs on several nodes unsing the akka-cluster module. +This project may be used to test akka bundles in OSGi Frameworks. The build tool (sbt for the moment) provide scripts to run in an OSGi Framework (Karaf only for the moment) a version of the DiningHakkers that runs on several nodes using the akka-cluster module. ## Bundle overview This project provides three Osgi Bundles - api providing an API for the Service exposed by the core and used by the command - - core implementing the whole logic: clustered connections, Hakkers, ChopSticks. It finally provide an ActorRef of one created Hakker + - core implementing the whole logic: clustered connections, Hakkers, ChopSticks. Finally it provides an ActorRef of one created Hakker - command use a service to get a Hakker (ActorRef) with its position around the table An integration testing module is provided to verify OSGi functionality: @@ -25,7 +25,7 @@ sbt clean sbt package sbt osgi-bundle ``` -sbt will creates the bundles in each subproject (api, command, core)/target/scala-2.10 directories. To have integration tests and OSGi environment loaded, please use the Maven build (at least for the moment) +sbt will creates the bundles in each subproject akka-sample/akka-sample-osgi-dining-hakkers/(api, command, core)/target directories. To have integration tests and OSGi environment loaded, please use the Maven build (at least for the moment) ### Setup with Maven ```bash mvn clean install @@ -38,7 +38,7 @@ This can be extracted to any location, and bin/karaf executed. The provided kara Extract the OSGi Framework from the tar.gz described above into any location, or run: ``./karaf.sh`` -Execute the framework by running bin ``/karaf`` from inside the extracted directory. +Execute the framework by running ``bin/karaf`` from inside the extracted directory. Then try to restart some bundles, to test the stability of the bundles: @@ -46,4 +46,4 @@ Then try to restart some bundles, to test the stability of the bundles: ``restart #bundle_number`` to restart the bundle using its ID ``exit`` or CTRL-D to exit the Karaf console -Depending on the akka version you're using, you may need to modify the core bundle when deploying on a second machine, to set it's akka.remote.netty.hostname in the application.conf. +Depending on the akka version you're using, you may need to modify the core bundle when deploying on a second machine, to set its akka.remote.netty.hostname in the application.conf. diff --git a/akka-osgi/src/main/scala/akka/osgi/ActorSystemActivator.scala b/akka-osgi/src/main/scala/akka/osgi/ActorSystemActivator.scala index dfe55728aa..37fa8293e2 100644 --- a/akka-osgi/src/main/scala/akka/osgi/ActorSystemActivator.scala +++ b/akka-osgi/src/main/scala/akka/osgi/ActorSystemActivator.scala @@ -54,7 +54,8 @@ abstract class ActorSystemActivator extends BundleActivator { val logServiceListner = new ServiceListener { def serviceChanged(event: ServiceEvent) { event.getType match { - case ServiceEvent.REGISTERED ⇒ system.eventStream.publish(serviceForReference[LogService](context, event.getServiceReference)) + case ServiceEvent.REGISTERED ⇒ + system.eventStream.publish(serviceForReference[LogService](context, event.getServiceReference)) case ServiceEvent.UNREGISTERING ⇒ system.eventStream.publish(UnregisteringLogService) } } diff --git a/api/pom.xml b/api/pom.xml index 5f01624123..ead1a955ad 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -3,8 +3,8 @@ 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"> - osgi-sample - com.typesafe.akka + parent + com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers 2.2.0-SNAPSHOT 4.0.0 diff --git a/api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala b/api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala index c83ccac228..2fb5625f42 100644 --- a/api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala +++ b/api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala @@ -1,4 +1,7 @@ -package akka.osgi.sample.api +/** + * Copyright (C) 2009-2013 Typesafe Inc. . + */ +package akka.sample.osgi.api import akka.actor.ActorRef diff --git a/assembly-dist/pom.xml b/assembly-dist/pom.xml index d64a144d9b..8927186364 100644 --- a/assembly-dist/pom.xml +++ b/assembly-dist/pom.xml @@ -5,12 +5,11 @@ 4.0.0 - com.typesafe.akka - osgi-sample + com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers + parent 2.2.0-SNAPSHOT - com.typesafe.akka assembly-dist Dining Hakkers :: Distribution @@ -55,7 +54,7 @@ mvn:org.apache.karaf.assemblies.features/standard/${karaf.version}/xml/features mvn:org.apache.karaf.assemblies.features/enterprise/${karaf.version}/xml/features - mvn:com.typesafe.akka/assembly-features/${project.version}/xml/features + mvn:com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers/assembly-features/${project.version}/xml/features target/generated-features-repo @@ -79,20 +78,6 @@ target/generated-features-repo - unpack diff --git a/assembly-dist/src/main/descriptors/bin.xml b/assembly-dist/src/main/descriptors/bin.xml index ef595a1b4d..cb15aa8e91 100644 --- a/assembly-dist/src/main/descriptors/bin.xml +++ b/assembly-dist/src/main/descriptors/bin.xml @@ -77,16 +77,9 @@ bin/** + unix 0755 - diff --git a/assembly-features/pom.xml b/assembly-features/pom.xml index fe08a18165..8501daca1b 100644 --- a/assembly-features/pom.xml +++ b/assembly-features/pom.xml @@ -5,12 +5,11 @@ 4.0.0 - com.typesafe.akka - osgi-sample + com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers + parent 2.2.0-SNAPSHOT - com.typesafe.akka assembly-features Dining Hakkers :: Features pom diff --git a/assembly-features/src/main/resources/features.xml b/assembly-features/src/main/resources/features.xml index ea31066b21..3799c1d421 100644 --- a/assembly-features/src/main/resources/features.xml +++ b/assembly-features/src/main/resources/features.xml @@ -11,7 +11,7 @@ - mvn:com.typesafe.akka/uncommons/1.2.2 + mvn:com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers/uncommons/1.2.2 @@ -40,8 +40,8 @@ akka - mvn:com.typesafe.akka/api/${project.version} - mvn:com.typesafe.akka/core/${project.version} - mvn:com.typesafe.akka/command/${project.version} + mvn:com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers/api/${project.version} + mvn:com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers/core/${project.version} + mvn:com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers/command/${project.version} diff --git a/command/pom.xml b/command/pom.xml index 42c5a4b963..d8de23a7c1 100644 --- a/command/pom.xml +++ b/command/pom.xml @@ -3,8 +3,8 @@ 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"> - osgi-sample - com.typesafe.akka + parent + com.typesafe.akka.akka-sample.akka-sample-osgi 2.2.0-SNAPSHOT 4.0.0 @@ -38,7 +38,8 @@ maven-bundle-plugin - akka.osgi.sample.command.Activator + akka.sample.osgi.command.Activator + * diff --git a/core/pom.xml b/core/pom.xml index 4e49595a39..daebda5b32 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -3,8 +3,8 @@ 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"> - osgi-sample - com.typesafe.akka + parent + com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers 2.2.0-SNAPSHOT 4.0.0 diff --git a/core/src/main/resources/application.conf b/core/src/main/resources/application.conf index 1b4600d742..1db639fc76 100644 --- a/core/src/main/resources/application.conf +++ b/core/src/main/resources/application.conf @@ -5,16 +5,14 @@ akka { } remote { - transport = "akka.remote.netty.NettyRemoteTransport" - log-remote-lifecycle-events = off - netty { + netty.tcp { hostname = "localhost" - port = 2552 + port = 4242 } } cluster { - seed-nodes = ["akka://akka-osgi-sample@localhost:2552"] + seed-nodes = ["akka.tcp://akka-osgi-sample@localhost:4242"] auto-down = on } diff --git a/core/src/main/scala/akka/osgi/sample/activation/Activator.scala b/core/src/main/scala/akka/osgi/sample/activation/Activator.scala index 5de4746eac..a9102d3283 100644 --- a/core/src/main/scala/akka/osgi/sample/activation/Activator.scala +++ b/core/src/main/scala/akka/osgi/sample/activation/Activator.scala @@ -28,22 +28,28 @@ class Activator extends ActorSystemActivator { import Activator._ - val services: ListBuffer[ServiceRegistration[_]] = ListBuffer() + var diningHakkerService: Option[ServiceRegistration[_]] = None def configure(context: BundleContext, system: ActorSystem) { val log = Logging(system, this) log.info("Core bundle configured") system.actorOf(Props[Table], "table") + registerService(context, system) registerHakkersService(context, system) - log.info("Hakker service registred") + log.info("Hakker service registered") } + /** + * registers the DinningHakkerService as a Service to be tracked and find by other OSGi bundles. + * in other words, this instance may be used in other bundles which listen or track the OSGi Service + * @param context OSGi BundleContext + * @param system ActorSystem + */ def registerHakkersService(context: BundleContext, system: ActorSystem) { val hakkersService = new DiningHakkersServiceImpl(system) - services += context.registerService(classOf[DiningHakkersService], hakkersService, null) - services += context.registerService(classOf[ActorSystem], system, null) + diningHakkerService = Some(context.registerService(classOf[DiningHakkersService], hakkersService, null)) } @@ -54,7 +60,7 @@ class Activator extends ActorSystemActivator { } def unregisterServices(context: BundleContext) { - services foreach (_.unregister()) + diningHakkerService foreach (_.unregister()) } override def getActorSystemName(context: BundleContext): String = "akka-osgi-sample" diff --git a/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala b/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala index 3fcad7a30e..6362951184 100644 --- a/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala +++ b/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala @@ -1,5 +1,5 @@ /** - * Copyright (C) 2009-2010 Typesafe Inc. . + * Copyright (C) 2009-2013 Typesafe Inc. . */ package akka.osgi.sample.internal diff --git a/integration-test/pom.xml b/integration-test/pom.xml index 6e795793f6..48b910f017 100644 --- a/integration-test/pom.xml +++ b/integration-test/pom.xml @@ -3,8 +3,8 @@ 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"> - osgi-sample - com.typesafe.akka + parent + com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers 2.2.0-SNAPSHOT 4.0.0 diff --git a/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala b/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala index f9b0786899..28f3ed9d44 100644 --- a/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala +++ b/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala @@ -48,12 +48,12 @@ class HakkerStatusTest extends JUnitSuite with ShouldMatchersForJUnit { ) // Junit @Before and @After can be used as well -/* - @Before + +/* @Before def setupAkkaTestkit() { testProbe = new TestProbe(actorSystem) - } -*/ + }*/ + @Test def verifyObtainingAHakkerViaTheTheDiningHakkersService() { @@ -65,17 +65,22 @@ class HakkerStatusTest extends JUnitSuite with ShouldMatchersForJUnit { hakker should not be (null) /* TODO Getting some weird config error with TestProbe, is it a TestProbe inside OSGi issue? + Exception in thread "RMI TCP Connection(idle)" java.lang.NullPointerException + at com.typesafe.config.impl.SerializedConfigValue.writeOrigin(SerializedConfigValue.java:202) + at com.typesafe.config.impl.ConfigImplUtil.writeOrigin(ConfigImplUtil.java:224) + at com.typesafe.config.ConfigException.writeObject(ConfigException.java:58) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + java.io.EOFException at java.io.ObjectInputStream$BlockDataInputStream.readUnsignedByte(ObjectInputStream.java:2747) at java.io.ObjectInputStream.readUnsignedByte(ObjectInputStream.java:924) at com.typesafe.config.impl.SerializedConfigValue.readCode(SerializedConfigValue.java:412) at com.typesafe.config.impl.SerializedConfigValue.readOrigin(SerializedConfigValue.java:218) ... - testProbe.send(hakker, Identify) val identification = testProbe.expectMsgClass(classOf[Identification]) val (fromHakker, busyWith) = (identification.name, identification.busyWith) -*/ + */ // create an "Interrogator" actor that receives a Hakker's identification // this is to work around the TestProbe Exception above diff --git a/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala b/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala index b3e7880fbd..669bb33ec9 100644 --- a/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala +++ b/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala @@ -53,7 +53,7 @@ object TestOptions { } def akkaFeature(feature: String): PaxOption = { - scanFeatures(maven.groupId("com.typesafe.akka").artifactId("assembly-features").`type`("xml").classifier("features") + scanFeatures(maven.groupId("com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers").artifactId("assembly-features").`type`("xml").classifier("features") .version(System.getProperty("project.version")), feature) } diff --git a/pom.xml b/pom.xml index a2a425baeb..37be7303a8 100644 --- a/pom.xml +++ b/pom.xml @@ -3,8 +3,8 @@ 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"> 4.0.0 - com.typesafe.akka - osgi-sample + com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers + parent 2.2.0-SNAPSHOT @@ -33,7 +33,7 @@ integration-test pom - com.typesafe.akka.akka-osgi.sample + com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers.sample diff --git a/project/AkkaBuild.scala b/project/AkkaBuild.scala index 14e77d1ed1..1716d7c213 100644 --- a/project/AkkaBuild.scala +++ b/project/AkkaBuild.scala @@ -357,7 +357,7 @@ object AkkaBuild extends Build { id = "akka-samples", base = file("akka-samples"), settings = parentSettings, - aggregate = Seq(camelSample, fsmSample, helloSample, helloKernelSample, remoteSample, clusterSample, multiNodeSample) + aggregate = Seq(camelSample, fsmSample, helloSample, helloKernelSample, remoteSample, clusterSample, multiNodeSample, osgiDiningHakkersSample) ) lazy val camelSample = Project( @@ -427,6 +427,45 @@ object AkkaBuild extends Build { ) ) configs (MultiJvm) + lazy val osgiDiningHakkersSample = Project(id = "akka-sample-osgi-dining-hakkers", + base = file("akka-samples/akka-sample-osgi-dining-hakkers"), + settings = sampleSettings ++ Seq( + test in Test ~= { x => { + if({List("sh", "-c", "which mvn") !} != 0 ) {throw new Exception("Maven is not installed or not in the $PATH")} + if({List("sh", "-c", "cd akka-samples/akka-sample-osgi-dining-hakkers; mvn clean install") !} != 0 ) {throw new Exception("Osgi sample Dining hakkers failed")} + } } + ) + ) aggregate(osgiDiningHakkersSampleApi, osgiDiningHakkersSampleCommand, osgiDiningHakkersSampleCore, uncommons) + + lazy val osgiDiningHakkersSampleApi = Project(id = "akka-sample-osgi-dining-hakkers-api", + base = file("akka-samples/akka-sample-osgi-dining-hakkers/api"), + settings = sampleSettings ++ OSGi.osgiDiningHakkersSampleApi + )dependsOn(actor) + + lazy val osgiDiningHakkersSampleCommand = Project(id = "akka-sample-osgi-dining-hakkers-command", + base = file("akka-samples/akka-sample-osgi-dining-hakkers/command"), + settings = sampleSettings ++ OSGi.osgiDiningHakkersSampleCommand ++ Seq( + libraryDependencies ++= Dependencies.osgiDiningHakkerSampleCommand + ) + ) dependsOn (osgiDiningHakkersSampleApi, actor) + + + lazy val osgiDiningHakkersSampleCore = Project(id = "akka-sample-osgi-dining-hakkers-core", + base = file("akka-samples/akka-sample-osgi-dining-hakkers/core"), + settings = sampleSettings ++ OSGi.osgiDiningHakkersSampleCore ++ Seq( + libraryDependencies ++= Dependencies.osgiDiningHakkerSampleCore + ) + ) dependsOn (osgiDiningHakkersSampleApi, actor, remote, cluster, osgi) + + //TODO to remove it as soon as the uncommons gets OSGified, see ticket #2990 + lazy val uncommons = Project(id = "akka-sample-osgi-dining-hakkers-uncommons", + base = file("akka-samples/akka-sample-osgi-dining-hakkers//uncommons"), + settings = sampleSettings ++ OSGi.osgiDiningHakkersSampleUncommons ++ Seq( + libraryDependencies ++= Dependencies.uncommons, + version := "1.2.2" + ) + ) + lazy val docs = Project( id = "akka-docs", base = file("akka-docs"), @@ -800,6 +839,14 @@ object AkkaBuild extends Build { OsgiKeys.importPackage := (osgiOptionalImports map optionalResolution) ++ Seq("!sun.misc", scalaImport(),configImport(), "*") ) + val osgiDiningHakkersSampleApi = exports(Seq("akka.sample.osgi.api")) + + val osgiDiningHakkersSampleCommand = osgiSettings ++ Seq(OsgiKeys.bundleActivator := Option("akka.sample.osgi.command.Activator"), OsgiKeys.privatePackage := Seq("akka.sample.osgi.command")) + + val osgiDiningHakkersSampleCore = exports(Seq("")) ++ Seq(OsgiKeys.bundleActivator := Option("akka.sample.osgi.activation.Activator"), OsgiKeys.privatePackage := Seq("akka.sample.osgi.internal", "akka.sample.osgi.activation", "akka.sample.osgi.service")) + + val osgiDiningHakkersSampleUncommons = exports(Seq("org.uncommons.maths.random")) ++ Seq(OsgiKeys.privatePackage := Seq("org.uncommons.maths.binary", "org.uncommons.maths", "org.uncommons.maths.number")) + val osgiAries = exports() ++ Seq(OsgiKeys.privatePackage := Seq("akka.osgi.aries.*")) val remote = exports(Seq("akka.remote.*"), imports = Seq(protobufImport())) @@ -870,8 +917,8 @@ object Dependencies { // Camel Sample val camelJetty = "org.apache.camel" % "camel-jetty" % camelCore.revision // ApacheV2 - // Cluster Sample - val sigar = "org.fusesource" % "sigar" % "1.6.4" // ApacheV2 + // Cluster Sample //TODO check for fusesource + val sigar = "org.hyperic" % "sigar" % "1.6.4" // ApacheV2 // Test @@ -925,7 +972,13 @@ object Dependencies { val osgi = Seq(osgiCore, osgiCompendium, Test.logback, Test.commonsIo, Test.pojosr, Test.tinybundles, Test.scalatest, Test.junit) - val osgiAries = Seq(osgiCore, ariesBlueprint, Test.ariesProxy) + val osgiDiningHakkerSampleCore = Seq(config, osgiCore, osgiCompendium) + + val osgiDiningHakkerSampleCommand = Seq(osgiCore, osgiCompendium) + + val uncommons = Seq(uncommonsMath) + + val osgiAries = Seq(osgiCore, osgiCompendium, ariesBlueprint, Test.ariesProxy) val docs = Seq(Test.scalatest, Test.junit, Test.junitIntf) diff --git a/project/Build.scala b/project/Build.scala deleted file mode 100644 index 1dc9c52e4e..0000000000 --- a/project/Build.scala +++ /dev/null @@ -1,124 +0,0 @@ -/* -Copyright 2013 Crossing-Tech - -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 - -http://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. - */ -import sbt._ -import Keys._ -import com.typesafe.sbt.osgi.SbtOsgi.{OsgiKeys, osgiSettings} - - -object OsgiSampleBuild extends Build { - - override lazy val settings = - super.settings ++ - buildSettings ++ - Seq( - shellPrompt := { - s => Project.extract(s).currentProject.id + " > " - } - ) - - lazy val buildSettings = Seq( - scalaVersion := "2.10.0", - resolvers ++= Seq("oss-sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases", - "JBoss Repo" at "http://repository.jboss.org/nexus/content/groups/public/", - "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"), - version := "2.2.0-SNAPSHOT" - ) - - - lazy val root = Project(id = "osgi-sample", - base = file("."), - settings = Project.defaultSettings ++ Seq( - libraryDependencies ++= Seq() - ) - ) aggregate(api, command, core, uncommons) - - lazy val api = Project(id = "api", - base = file("./api"), - settings = Project.defaultSettings ++ exports(Seq("akka.osgi.sample.api")) ++ Seq(libraryDependencies ++= Seq(Dependencies.akka_actor)) - ) - - lazy val command = Project(id = "command", - base = file("./command"), - settings = Project.defaultSettings ++ exports(Seq("akka.osgi.sample.command"), Seq("akka.osgi.sample.api", "org.osgi.framework")) ++ Seq( - libraryDependencies ++= Dependencies.command, - OsgiKeys.bundleActivator := Option("akka.osgi.sample.command.Activator") - ) - ) dependsOn (api) - - - lazy val core = Project(id = "core", - base = file("./core"), - settings = Project.defaultSettings ++ exports(Seq("akka.osgi.sample.service", "akka.osgi.sample.activation"), defaultImports, Seq("akka.osgi.sample.internal")) ++ Seq( - libraryDependencies ++= Dependencies.core, - OsgiKeys.bundleActivator := Option("akka.osgi.sample.activation.Activator") - ) - ) dependsOn (api) - - lazy val uncommons = Project(id = "uncommons", - base = file("./uncommons"), - settings = Project.defaultSettings ++ exports(Seq("org.uncommons.maths.random"), privates = Seq("org.uncommons.maths.binary", "org.uncommons.maths", "org.uncommons.maths.number")) ++ Seq( - libraryDependencies ++= Dependencies.uncommons, - version := "1.2.2" - ) - ) - - def exports(packages: Seq[String] = Seq(), imports: Seq[String] = Nil, privates: Seq[String] = Nil) = osgiSettings ++ Seq( - OsgiKeys.importPackage := imports ++ Seq("*"), - OsgiKeys.privatePackage := privates, - OsgiKeys.exportPackage := packages - ) - - def copyFile(source: String, sink: String){ - val src = new java.io.File(source) - val dest = new java.io.File(sink) - new java.io.FileOutputStream(dest) getChannel() transferFrom( - new java.io.FileInputStream(src) getChannel, 0, Long.MaxValue ) - } - - - def defaultImports = Seq("!sun.misc", akkaImport(), configImport(), scalaImport()) - - def akkaImport(packageName: String = "akka.*") = "%s;version=\"[2.2,2.3)\"".format(packageName) - - def configImport(packageName: String = "com.typesafe.config.*") = "%s;version=\"[0.4.1,1.1.0)\"".format(packageName) - - def protobufImport(packageName: String = "com.google.protobuf.*") = "%s;version=\"[2.4.0,2.5.0)\"".format(packageName) - - def scalaImport(packageName: String = "scala.*") = "%s;version=\"[2.10,2.11)\"".format(packageName) - -} - -object Dependencies { - val akka_actor = "com.typesafe.akka" % "akka-actor_2.10" % "2.2-SNAPSHOT" - val akka_osgi = "com.typesafe.akka" % "akka-osgi_2.10" % "2.2-SNAPSHOT" exclude("org.osgi.core", "org.osgi.compendium") - val akka_remote = "com.typesafe.akka" % "akka-remote_2.10" % "2.2-SNAPSHOT" - val akka_cluster = "com.typesafe.akka" % "akka-cluster-experimental_2.10" % "2.2-SNAPSHOT" - val config = "com.typesafe" % "config" % "1.0.0" - - val osgiCore = "org.osgi" % "org.osgi.core" % "4.3.0" - val osgiCompendium = "org.osgi" % "org.osgi.compendium" % "4.3.0" - val core = Seq(akka_actor, akka_osgi, akka_remote, akka_cluster, config, osgiCore, osgiCompendium) - val command = Seq(akka_actor, osgiCore, osgiCompendium) - - val uncommons_math = "org.uncommons.maths" % "uncommons-maths" % "1.2.2" - val jcommon = "jfree" % "jcommon" % "1.0.16" - val jfreechart = "jfree" % "jfreechart" % "1.0.13" - val uncommons = Seq(uncommons_math, jcommon, jfreechart) - - val protobuf = "com.google.protobuf" % "protobuf-java" % "2.4.1" - -} - diff --git a/project/plugins.sbt b/project/plugins.sbt index 72e24c5b2c..ba3f4b7f33 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -8,7 +8,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-multi-jvm" % "0.3.5") addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.0.0") -addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.7.0-M1") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.6.2") addSbtPlugin("com.typesafe.sbtosgi" % "sbtosgi" % "0.3.0") diff --git a/uncommons/pom.xml b/uncommons/pom.xml index d6c01f6baa..959cbe1e1d 100644 --- a/uncommons/pom.xml +++ b/uncommons/pom.xml @@ -3,8 +3,8 @@ 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"> - osgi-sample - com.typesafe.akka + parent + com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers 2.2.0-SNAPSHOT 4.0.0 @@ -12,6 +12,7 @@ uncommons From f8243a928d39035e3bacf434afe83c37e0bef8e6 Mon Sep 17 00:00:00 2001 From: Christophe Pache Date: Fri, 1 Mar 2013 21:29:22 +0100 Subject: [PATCH 6/7] akka.sample.osgi.dining-hakkers integration test --- .../akka-sample-osgi-dining-hakkers/README.md | 0 .../api}/pom.xml | 2 +- .../sample/api/DiningHakkersMessages.scala | 0 .../sample/api/DiningHakkersService.scala | 2 +- .../assembly-dist}/pom.xml | 2 +- .../src/main/descriptors/bin.xml | 0 .../src/main/distribution/README | 0 .../src/main/distribution/VERSION | 0 .../main/distribution/etc/custom.properties | 0 .../etc/org.apache.karaf.features.cfg | 0 .../etc/org.ops4j.pax.url.mvn.cfg.onlylocal | 0 .../src/main/distribution/etc/readme.txt | 0 .../src/main/distribution/lib/readme.txt | 0 .../src/main/resources/etc/readme.txt | 0 .../assembly-features}/pom.xml | 2 +- .../src/main/resources/features.xml | 8 +++---- .../command}/pom.xml | 2 +- .../akka/osgi/sample/command/Activator.scala | 18 ++++++++-------- .../core}/pom.xml | 2 +- .../core}/src/main/resources/application.conf | 0 .../osgi/sample/activation/Activator.scala | 18 ++++++++-------- .../akka/osgi/sample/internal/Hakker.scala | 21 ++++++++++--------- .../akka/osgi/sample/internal/Table.scala | 6 +++--- .../service/DiningHakkersServiceImpl.scala | 8 +++---- .../integration-test}/pom.xml | 2 +- .../osgi/sample/test/HakkerStatusTest.scala | 6 +++--- .../akka/osgi/sample/test/TestOptions.scala | 2 +- .../akka-sample-osgi-dining-hakkers/pom.xml | 4 ++-- .../uncommons}/pom.xml | 2 +- project/AkkaBuild.scala | 5 ++--- 30 files changed, 56 insertions(+), 56 deletions(-) rename README.md => akka-samples/akka-sample-osgi-dining-hakkers/README.md (100%) rename {api => akka-samples/akka-sample-osgi-dining-hakkers/api}/pom.xml (89%) rename {api => akka-samples/akka-sample-osgi-dining-hakkers/api}/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala (100%) rename {api => akka-samples/akka-sample-osgi-dining-hakkers/api}/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala (95%) rename {assembly-dist => akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist}/pom.xml (98%) rename {assembly-dist => akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist}/src/main/descriptors/bin.xml (100%) rename {assembly-dist => akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist}/src/main/distribution/README (100%) rename {assembly-dist => akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist}/src/main/distribution/VERSION (100%) rename {assembly-dist => akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist}/src/main/distribution/etc/custom.properties (100%) rename {assembly-dist => akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist}/src/main/distribution/etc/org.apache.karaf.features.cfg (100%) rename {assembly-dist => akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist}/src/main/distribution/etc/org.ops4j.pax.url.mvn.cfg.onlylocal (100%) rename {assembly-dist => akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist}/src/main/distribution/etc/readme.txt (100%) rename {assembly-dist => akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist}/src/main/distribution/lib/readme.txt (100%) rename {assembly-dist => akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist}/src/main/resources/etc/readme.txt (100%) rename {assembly-features => akka-samples/akka-sample-osgi-dining-hakkers/assembly-features}/pom.xml (96%) rename {assembly-features => akka-samples/akka-sample-osgi-dining-hakkers/assembly-features}/src/main/resources/features.xml (91%) rename {command => akka-samples/akka-sample-osgi-dining-hakkers/command}/pom.xml (95%) rename {command => akka-samples/akka-sample-osgi-dining-hakkers/command}/src/main/scala/akka/osgi/sample/command/Activator.scala (66%) rename {core => akka-samples/akka-sample-osgi-dining-hakkers/core}/pom.xml (97%) rename {core => akka-samples/akka-sample-osgi-dining-hakkers/core}/src/main/resources/application.conf (100%) rename {core => akka-samples/akka-sample-osgi-dining-hakkers/core}/src/main/scala/akka/osgi/sample/activation/Activator.scala (82%) rename {core => akka-samples/akka-sample-osgi-dining-hakkers/core}/src/main/scala/akka/osgi/sample/internal/Hakker.scala (91%) rename {core => akka-samples/akka-sample-osgi-dining-hakkers/core}/src/main/scala/akka/osgi/sample/internal/Table.scala (83%) rename {core => akka-samples/akka-sample-osgi-dining-hakkers/core}/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala (82%) rename {integration-test => akka-samples/akka-sample-osgi-dining-hakkers/integration-test}/pom.xml (98%) rename {integration-test => akka-samples/akka-sample-osgi-dining-hakkers/integration-test}/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala (96%) rename {integration-test => akka-samples/akka-sample-osgi-dining-hakkers/integration-test}/src/test/scala/akka/osgi/sample/test/TestOptions.scala (98%) rename pom.xml => akka-samples/akka-sample-osgi-dining-hakkers/pom.xml (98%) rename {uncommons => akka-samples/akka-sample-osgi-dining-hakkers/uncommons}/pom.xml (95%) diff --git a/README.md b/akka-samples/akka-sample-osgi-dining-hakkers/README.md similarity index 100% rename from README.md rename to akka-samples/akka-sample-osgi-dining-hakkers/README.md diff --git a/api/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/api/pom.xml similarity index 89% rename from api/pom.xml rename to akka-samples/akka-sample-osgi-dining-hakkers/api/pom.xml index ead1a955ad..bb5f13bbf9 100644 --- a/api/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/api/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> parent - com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers + com.typesafe.akka.akka-sample.dining-hakkers 2.2.0-SNAPSHOT 4.0.0 diff --git a/api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala b/akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala similarity index 100% rename from api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala diff --git a/api/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala b/akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala similarity index 95% rename from api/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala index 9801d8f9c4..2b61699f66 100644 --- a/api/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala +++ b/akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala @@ -13,7 +13,7 @@ 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. */ -package akka.osgi.sample.api +package akka.sample.osgi.api import akka.actor.ActorRef diff --git a/assembly-dist/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/pom.xml similarity index 98% rename from assembly-dist/pom.xml rename to akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/pom.xml index 8927186364..7a371ad0e4 100644 --- a/assembly-dist/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/pom.xml @@ -5,7 +5,7 @@ 4.0.0 - com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers + com.typesafe.akka.akka-sample.dining-hakkers parent 2.2.0-SNAPSHOT diff --git a/assembly-dist/src/main/descriptors/bin.xml b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/descriptors/bin.xml similarity index 100% rename from assembly-dist/src/main/descriptors/bin.xml rename to akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/descriptors/bin.xml diff --git a/assembly-dist/src/main/distribution/README b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/README similarity index 100% rename from assembly-dist/src/main/distribution/README rename to akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/README diff --git a/assembly-dist/src/main/distribution/VERSION b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/VERSION similarity index 100% rename from assembly-dist/src/main/distribution/VERSION rename to akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/VERSION diff --git a/assembly-dist/src/main/distribution/etc/custom.properties b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/etc/custom.properties similarity index 100% rename from assembly-dist/src/main/distribution/etc/custom.properties rename to akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/etc/custom.properties diff --git a/assembly-dist/src/main/distribution/etc/org.apache.karaf.features.cfg b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/etc/org.apache.karaf.features.cfg similarity index 100% rename from assembly-dist/src/main/distribution/etc/org.apache.karaf.features.cfg rename to akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/etc/org.apache.karaf.features.cfg diff --git a/assembly-dist/src/main/distribution/etc/org.ops4j.pax.url.mvn.cfg.onlylocal b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/etc/org.ops4j.pax.url.mvn.cfg.onlylocal similarity index 100% rename from assembly-dist/src/main/distribution/etc/org.ops4j.pax.url.mvn.cfg.onlylocal rename to akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/etc/org.ops4j.pax.url.mvn.cfg.onlylocal diff --git a/assembly-dist/src/main/distribution/etc/readme.txt b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/etc/readme.txt similarity index 100% rename from assembly-dist/src/main/distribution/etc/readme.txt rename to akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/etc/readme.txt diff --git a/assembly-dist/src/main/distribution/lib/readme.txt b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/lib/readme.txt similarity index 100% rename from assembly-dist/src/main/distribution/lib/readme.txt rename to akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/lib/readme.txt diff --git a/assembly-dist/src/main/resources/etc/readme.txt b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/resources/etc/readme.txt similarity index 100% rename from assembly-dist/src/main/resources/etc/readme.txt rename to akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/resources/etc/readme.txt diff --git a/assembly-features/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/pom.xml similarity index 96% rename from assembly-features/pom.xml rename to akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/pom.xml index 8501daca1b..48c3777037 100644 --- a/assembly-features/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/pom.xml @@ -5,7 +5,7 @@ 4.0.0 - com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers + com.typesafe.akka.akka-sample.dining-hakkers parent 2.2.0-SNAPSHOT diff --git a/assembly-features/src/main/resources/features.xml b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/src/main/resources/features.xml similarity index 91% rename from assembly-features/src/main/resources/features.xml rename to akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/src/main/resources/features.xml index 3799c1d421..948c186263 100644 --- a/assembly-features/src/main/resources/features.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/src/main/resources/features.xml @@ -11,7 +11,7 @@ - mvn:com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers/uncommons/1.2.2 + mvn:com.typesafe.akka.akka-sample.dining-hakkers/uncommons/1.2.2 @@ -40,8 +40,8 @@ akka - mvn:com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers/api/${project.version} - mvn:com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers/core/${project.version} - mvn:com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers/command/${project.version} + mvn:com.typesafe.akka.akka-sample.dining-hakkers/api/${project.version} + mvn:com.typesafe.akka.akka-sample.dining-hakkers/core/${project.version} + mvn:com.typesafe.akka.akka-sample.dining-hakkers/command/${project.version} diff --git a/command/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/command/pom.xml similarity index 95% rename from command/pom.xml rename to akka-samples/akka-sample-osgi-dining-hakkers/command/pom.xml index d8de23a7c1..f7f14f2fb5 100644 --- a/command/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/command/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> parent - com.typesafe.akka.akka-sample.akka-sample-osgi + com.typesafe.akka.akka-sample.dining-hakkers 2.2.0-SNAPSHOT 4.0.0 diff --git a/command/src/main/scala/akka/osgi/sample/command/Activator.scala b/akka-samples/akka-sample-osgi-dining-hakkers/command/src/main/scala/akka/osgi/sample/command/Activator.scala similarity index 66% rename from command/src/main/scala/akka/osgi/sample/command/Activator.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/command/src/main/scala/akka/osgi/sample/command/Activator.scala index 7e7c78c695..1b6e7c9887 100644 --- a/command/src/main/scala/akka/osgi/sample/command/Activator.scala +++ b/akka-samples/akka-sample-osgi-dining-hakkers/command/src/main/scala/akka/osgi/sample/command/Activator.scala @@ -13,25 +13,25 @@ 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. */ -package akka.osgi.sample.command +package akka.sample.osgi.command -import org.osgi.framework.{ServiceEvent, BundleContext, BundleActivator} -import akka.osgi.sample.api.DiningHakkersService -import akka.actor.{ActorRef, PoisonPill} +import org.osgi.framework.{ ServiceEvent, BundleContext, BundleActivator } +import akka.sample.osgi.api.DiningHakkersService +import akka.actor.{ ActorRef, PoisonPill } import org.osgi.util.tracker.ServiceTracker class Activator extends BundleActivator { println("Command Activator created") - var hakker : Option[ActorRef] = None + var hakker: Option[ActorRef] = None def start(context: BundleContext) { val logServiceTracker = new ServiceTracker(context, classOf[DiningHakkersService].getName, null) logServiceTracker.open() - val service = Option(logServiceTracker.getService.asInstanceOf[DiningHakkersService]) - service.foreach(startHakker(_, context.getBundle.getSymbolicName + ":" + context.getBundle.getBundleId)) - } + val service = Option(logServiceTracker.getService.asInstanceOf[DiningHakkersService]) + service.foreach(startHakker(_, context.getBundle.getSymbolicName + ":" + context.getBundle.getBundleId)) + } - def startHakker(service: DiningHakkersService, name: String){ + def startHakker(service: DiningHakkersService, name: String) { hakker = Some(service.getHakker(name, (math.floor(math.random * 5)).toInt)) } diff --git a/core/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/core/pom.xml similarity index 97% rename from core/pom.xml rename to akka-samples/akka-sample-osgi-dining-hakkers/core/pom.xml index daebda5b32..988234f5bf 100644 --- a/core/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/core/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> parent - com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers + com.typesafe.akka.akka-sample.dining-hakkers 2.2.0-SNAPSHOT 4.0.0 diff --git a/core/src/main/resources/application.conf b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/resources/application.conf similarity index 100% rename from core/src/main/resources/application.conf rename to akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/resources/application.conf diff --git a/core/src/main/scala/akka/osgi/sample/activation/Activator.scala b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/activation/Activator.scala similarity index 82% rename from core/src/main/scala/akka/osgi/sample/activation/Activator.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/activation/Activator.scala index a9102d3283..4fc009eba7 100644 --- a/core/src/main/scala/akka/osgi/sample/activation/Activator.scala +++ b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/activation/Activator.scala @@ -13,22 +13,22 @@ 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. */ -package akka.osgi.sample.activation +package akka.sample.osgi.activation import akka.osgi.ActorSystemActivator -import akka.actor.{Props, ActorSystem} -import akka.osgi.sample.internal.Table -import akka.osgi.sample.service.DiningHakkersServiceImpl -import akka.osgi.sample.api.DiningHakkersService -import akka.event.{LogSource, Logging} -import org.osgi.framework.{ServiceRegistration, BundleContext} +import akka.actor.{ Props, ActorSystem } +import akka.sample.osgi.internal.Table +import akka.sample.osgi.service.DiningHakkersServiceImpl +import akka.sample.osgi.api.DiningHakkersService +import akka.event.{ LogSource, Logging } +import org.osgi.framework.{ ServiceRegistration, BundleContext } import scala.collection.mutable.ListBuffer class Activator extends ActorSystemActivator { import Activator._ - var diningHakkerService: Option[ServiceRegistration[_]] = None + var diningHakkerService: Option[ServiceRegistration] = None def configure(context: BundleContext, system: ActorSystem) { val log = Logging(system, this) @@ -49,7 +49,7 @@ class Activator extends ActorSystemActivator { val hakkersService = new DiningHakkersServiceImpl(system) - diningHakkerService = Some(context.registerService(classOf[DiningHakkersService], hakkersService, null)) + diningHakkerService = Some(context.registerService(classOf[DiningHakkersService].getName(), hakkersService, null)) } diff --git a/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala similarity index 91% rename from core/src/main/scala/akka/osgi/sample/internal/Hakker.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala index 6362951184..88672277f2 100644 --- a/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala +++ b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala @@ -1,12 +1,13 @@ /** * Copyright (C) 2009-2013 Typesafe Inc. . */ -package akka.osgi.sample.internal +package akka.sample.osgi.internal import language.postfixOps import akka.cluster.Cluster -import akka.cluster.ClusterEvent.{CurrentClusterState, LeaderChanged} +import akka.cluster.ClusterEvent.{ CurrentClusterState, LeaderChanged } import akka.event.Logging +import akka.sample.osgi.api._ //Akka adaptation of //http://www.dalnefre.com/wp/2010/08/dining-philosophers-in-humus/ @@ -14,7 +15,7 @@ import akka.event.Logging import akka.actor._ import scala.concurrent.duration._ -import akka.osgi.sample.api._ +import akka.sample.osgi.api._ /* * A Chopstick is an actor, it can be taken, and put back @@ -38,7 +39,7 @@ class Chopstick extends Actor { //When a Chopstick is available, it can be taken by a hakker def available: Receive = { case Take(hakker) ⇒ - log.info(self.path +" is taken by "+hakker) + log.info(self.path + " is taken by " + hakker) become(takenBy(hakker)) hakker ! Taken(self) } @@ -54,18 +55,18 @@ class Hakker(name: String, chair: Int) extends Actor { val log = Logging(context.system, this) - log.info("Created Hakker at" +self.path) + log.info("Created Hakker at" + self.path) import context._ val cluster = Cluster(context.system) - override def preStart(){ + override def preStart() { log.info(s"Hakker ($name) takes position($chair)") cluster.subscribe(self, classOf[LeaderChanged]) } - override def postStop(){ + override def postStop() { log.info(s"Hakker ($name) leaves position($chair)") cluster.unsubscribe(self) } @@ -102,7 +103,7 @@ class Hakker(name: String, chair: Int) extends Actor { log.info("%s has picked up %s and %s and starts to eat".format(name, left.path.name, right.path.name)) become(eating(left, right) orElse (clusterEvents)) system.scheduler.scheduleOnce(5 seconds, self, Think) - case Taken(`right`) if !waitingForLeft => + case Taken(`right`) if !waitingForLeft ⇒ log.info("%s has picked up %s and %s and starts to eat".format(name, left.path.name, right.path.name)) become(eating(left, right) orElse (clusterEvents)) system.scheduler.scheduleOnce(5 seconds, self, Think) @@ -144,13 +145,13 @@ class Hakker(name: String, chair: Int) extends Actor { } def waitForChopsticks: Receive = { - case (left: ActorRef, right: ActorRef) => + case (left: ActorRef, right: ActorRef) ⇒ become(thinking(left, right) orElse (clusterEvents)) system.scheduler.scheduleOnce(5 seconds, self, Eat) } def clusterEvents: Receive = { - case state: CurrentClusterState ⇒ state.leader foreach updateTable + case state: CurrentClusterState ⇒ state.leader foreach updateTable case LeaderChanged(Some(leaderAddress)) ⇒ updateTable(leaderAddress) } diff --git a/core/src/main/scala/akka/osgi/sample/internal/Table.scala b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/internal/Table.scala similarity index 83% rename from core/src/main/scala/akka/osgi/sample/internal/Table.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/internal/Table.scala index 0111408f3e..8d5d325a10 100644 --- a/core/src/main/scala/akka/osgi/sample/internal/Table.scala +++ b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/internal/Table.scala @@ -13,14 +13,14 @@ 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. */ -package akka.osgi.sample.internal +package akka.sample.osgi.internal -import akka.actor.{Props, Actor} +import akka.actor.{ Props, Actor } class Table extends Actor { val chopsticks = for (i ← 1 to 5) yield context.actorOf(Props[Chopstick], "Chopstick" + i) def receive = { - case x: Int => sender !(chopsticks(x), chopsticks((x + 1) % 5)) + case x: Int ⇒ sender ! (chopsticks(x), chopsticks((x + 1) % 5)) } } diff --git a/core/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala similarity index 82% rename from core/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala index 5bdb667527..2f29e8b659 100644 --- a/core/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala +++ b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala @@ -13,11 +13,11 @@ 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. */ -package akka.osgi.sample.service +package akka.sample.osgi.service -import akka.osgi.sample.api.DiningHakkersService -import akka.actor.{Props, ActorSystem} -import akka.osgi.sample.internal.Hakker +import akka.sample.osgi.api.DiningHakkersService +import akka.actor.{ Props, ActorSystem } +import akka.sample.osgi.internal.Hakker class DiningHakkersServiceImpl(system: ActorSystem) extends DiningHakkersService { def getHakker(name: String, chairNumber: Int) = { diff --git a/integration-test/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/pom.xml similarity index 98% rename from integration-test/pom.xml rename to akka-samples/akka-sample-osgi-dining-hakkers/integration-test/pom.xml index 48b910f017..df7642b988 100644 --- a/integration-test/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> parent - com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers + com.typesafe.akka.akka-sample.dining-hakkers 2.2.0-SNAPSHOT 4.0.0 diff --git a/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala b/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala similarity index 96% rename from integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala index 28f3ed9d44..0d61d98d49 100644 --- a/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala +++ b/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala @@ -1,8 +1,8 @@ -package akka.osgi.sample.test +package akka.sample.osgi.test import akka.actor._ -import akka.osgi.sample.api.{Identification, Identify, DiningHakkersService} -import akka.osgi.sample.test.TestOptions._ +import akka.sample.osgi.api.{DiningHakkersService, Identify, Identification} +import akka.sample.osgi.test.TestOptions._ import org.junit.runner.RunWith import org.junit.{Before, Test} import org.ops4j.pax.exam.{Option => PaxOption} diff --git a/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala b/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala similarity index 98% rename from integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala index 669bb33ec9..c4ceca7c03 100644 --- a/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala +++ b/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala @@ -1,4 +1,4 @@ -package akka.osgi.sample.test +package akka.sample.osgi.test import org.ops4j.pax.exam.CoreOptions._ import org.ops4j.pax.exam.options.DefaultCompositeOption diff --git a/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/pom.xml similarity index 98% rename from pom.xml rename to akka-samples/akka-sample-osgi-dining-hakkers/pom.xml index 37be7303a8..e520ab05fe 100644 --- a/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/pom.xml @@ -3,7 +3,7 @@ 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"> 4.0.0 - com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers + com.typesafe.akka.akka-sample.dining-hakkers parent 2.2.0-SNAPSHOT @@ -12,7 +12,7 @@ 2.3.0 ${karaf.version} 3.6.2.Final - 4.3.0 + 4.2.0 2.6.0 1.6.0 2.4.1 diff --git a/uncommons/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/uncommons/pom.xml similarity index 95% rename from uncommons/pom.xml rename to akka-samples/akka-sample-osgi-dining-hakkers/uncommons/pom.xml index 959cbe1e1d..b11d35b352 100644 --- a/uncommons/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/uncommons/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> parent - com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers + com.typesafe.akka.akka-sample.dining-hakkers 2.2.0-SNAPSHOT 4.0.0 diff --git a/project/AkkaBuild.scala b/project/AkkaBuild.scala index 1716d7c213..c13d7d1571 100644 --- a/project/AkkaBuild.scala +++ b/project/AkkaBuild.scala @@ -431,7 +431,6 @@ object AkkaBuild extends Build { base = file("akka-samples/akka-sample-osgi-dining-hakkers"), settings = sampleSettings ++ Seq( test in Test ~= { x => { - if({List("sh", "-c", "which mvn") !} != 0 ) {throw new Exception("Maven is not installed or not in the $PATH")} if({List("sh", "-c", "cd akka-samples/akka-sample-osgi-dining-hakkers; mvn clean install") !} != 0 ) {throw new Exception("Osgi sample Dining hakkers failed")} } } ) @@ -917,8 +916,8 @@ object Dependencies { // Camel Sample val camelJetty = "org.apache.camel" % "camel-jetty" % camelCore.revision // ApacheV2 - // Cluster Sample //TODO check for fusesource - val sigar = "org.hyperic" % "sigar" % "1.6.4" // ApacheV2 + // Cluster Sample + val sigar = "org.fusesource" % "sigar" % "1.6.4" // ApacheV2 // Test From 0c4b375f61b85033212f6cf9969616ecc310d3b9 Mon Sep 17 00:00:00 2001 From: Raman Gupta Date: Sun, 7 Apr 2013 14:10:52 -0400 Subject: [PATCH 7/7] Resolve naming/packaging problems --- .../akka-sample-osgi-dining-hakkers/api/pom.xml | 4 ++-- .../osgi}/api/DiningHakkersMessages.scala | 0 .../osgi}/api/DiningHakkersService.scala | 0 .../assembly-dist/pom.xml | 13 +++++++++---- .../assembly-dist/src/main/descriptors/bin.xml | 2 +- .../etc/org.apache.karaf.features.cfg | 2 +- .../assembly-features/pom.xml | 6 +++--- .../src/main/resources/features.xml | 8 ++++---- .../command/pom.xml | 4 ++-- .../osgi}/command/Activator.scala | 0 .../akka-sample-osgi-dining-hakkers/core/pom.xml | 13 ++++--------- .../osgi}/activation/Activator.scala | 0 .../sample => sample/osgi}/internal/Hakker.scala | 0 .../sample => sample/osgi}/internal/Table.scala | 0 .../osgi}/service/DiningHakkersServiceImpl.scala | 0 .../integration-test/pom.xml | 4 ++-- .../osgi}/test/HakkerStatusTest.scala | 0 .../sample => sample/osgi}/test/TestOptions.scala | 3 ++- .../akka-sample-osgi-dining-hakkers/karaf.sh | 0 .../akka-sample-osgi-dining-hakkers/osgi-run.sh | 0 .../akka-sample-osgi-dining-hakkers/pom.xml | 15 +++++++++++---- .../uncommons/pom.xml | 4 ++-- 22 files changed, 43 insertions(+), 35 deletions(-) rename akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/{osgi/sample => sample/osgi}/api/DiningHakkersMessages.scala (100%) rename akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/{osgi/sample => sample/osgi}/api/DiningHakkersService.scala (100%) rename akka-samples/akka-sample-osgi-dining-hakkers/command/src/main/scala/akka/{osgi/sample => sample/osgi}/command/Activator.scala (100%) rename akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/{osgi/sample => sample/osgi}/activation/Activator.scala (100%) rename akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/{osgi/sample => sample/osgi}/internal/Hakker.scala (100%) rename akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/{osgi/sample => sample/osgi}/internal/Table.scala (100%) rename akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/{osgi/sample => sample/osgi}/service/DiningHakkersServiceImpl.scala (100%) rename akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/{osgi/sample => sample/osgi}/test/HakkerStatusTest.scala (100%) rename akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/{osgi/sample => sample/osgi}/test/TestOptions.scala (92%) rename karaf.sh => akka-samples/akka-sample-osgi-dining-hakkers/karaf.sh (100%) rename osgi-run.sh => akka-samples/akka-sample-osgi-dining-hakkers/osgi-run.sh (100%) diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/api/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/api/pom.xml index bb5f13bbf9..0d34113d53 100644 --- a/akka-samples/akka-sample-osgi-dining-hakkers/api/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/api/pom.xml @@ -3,8 +3,8 @@ 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"> - parent - com.typesafe.akka.akka-sample.dining-hakkers + com.typesafe.akka.akka-sample-osgi-dining-hakkers + project 2.2.0-SNAPSHOT 4.0.0 diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala b/akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/sample/osgi/api/DiningHakkersMessages.scala similarity index 100% rename from akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/osgi/sample/api/DiningHakkersMessages.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/sample/osgi/api/DiningHakkersMessages.scala diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala b/akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/sample/osgi/api/DiningHakkersService.scala similarity index 100% rename from akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/osgi/sample/api/DiningHakkersService.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/api/src/main/scala/akka/sample/osgi/api/DiningHakkersService.scala diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/pom.xml index 7a371ad0e4..846db0fde1 100644 --- a/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/pom.xml @@ -5,15 +5,20 @@ 4.0.0 - com.typesafe.akka.akka-sample.dining-hakkers - parent + com.typesafe.akka.akka-sample-osgi-dining-hakkers + project 2.2.0-SNAPSHOT - assembly-dist + akka-sample-osgi-dining-hakkers-dist Dining Hakkers :: Distribution + + ${project.groupId} + akka-sample-osgi-dining-hakkers + pom + ${project.groupId} api @@ -54,7 +59,7 @@ mvn:org.apache.karaf.assemblies.features/standard/${karaf.version}/xml/features mvn:org.apache.karaf.assemblies.features/enterprise/${karaf.version}/xml/features - mvn:com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers/assembly-features/${project.version}/xml/features + mvn:com.typesafe.akka.akka-sample-osgi-dining-hakkers/akka-sample-osgi-dining-hakkers/${project.version}/xml/features target/generated-features-repo diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/descriptors/bin.xml b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/descriptors/bin.xml index cb15aa8e91..d3f72a43de 100644 --- a/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/descriptors/bin.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/descriptors/bin.xml @@ -9,7 +9,7 @@ true - akka-osgi-sample-${project.version} + akka-sample-osgi-dining-hakkers-${project.version} diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/etc/org.apache.karaf.features.cfg b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/etc/org.apache.karaf.features.cfg index b97bdfbf07..63da8af40c 100644 --- a/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/etc/org.apache.karaf.features.cfg +++ b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-dist/src/main/distribution/etc/org.apache.karaf.features.cfg @@ -2,7 +2,7 @@ # Comma separated list of features repositories to register by default # Default list + Dining Hakkers feature # -featuresRepositories=mvn:org.apache.karaf.assemblies.features/standard/${karaf.version}/xml/features,mvn:org.apache.karaf.assemblies.features/enterprise/${karaf.version}/xml/features,mvn:com.typesafe.akka/assembly-features/${project.version}/xml/features +featuresRepositories=mvn:org.apache.karaf.assemblies.features/standard/${karaf.version}/xml/features,mvn:org.apache.karaf.assemblies.features/enterprise/${karaf.version}/xml/features,mvn:com.typesafe.akka.akka-sample-osgi-dining-hakkers/akka-sample-osgi-dining-hakkers/${project.version}/xml/features # Comma separated list of features to install at startup. Features definitions are looked up from repositories above. featuresBoot=config,ssh,management,dining-hakker diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/pom.xml index 48c3777037..617fac5bb5 100644 --- a/akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/pom.xml @@ -5,12 +5,12 @@ 4.0.0 - com.typesafe.akka.akka-sample.dining-hakkers - parent + com.typesafe.akka.akka-sample-osgi-dining-hakkers + project 2.2.0-SNAPSHOT - assembly-features + akka-sample-osgi-dining-hakkers Dining Hakkers :: Features pom diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/src/main/resources/features.xml b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/src/main/resources/features.xml index 948c186263..18056fa180 100644 --- a/akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/src/main/resources/features.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/assembly-features/src/main/resources/features.xml @@ -11,7 +11,7 @@ - mvn:com.typesafe.akka.akka-sample.dining-hakkers/uncommons/1.2.2 + mvn:com.typesafe.akka.akka-sample-osgi-dining-hakkers/uncommons/1.2.2 @@ -40,8 +40,8 @@ akka - mvn:com.typesafe.akka.akka-sample.dining-hakkers/api/${project.version} - mvn:com.typesafe.akka.akka-sample.dining-hakkers/core/${project.version} - mvn:com.typesafe.akka.akka-sample.dining-hakkers/command/${project.version} + mvn:com.typesafe.akka.akka-sample-osgi-dining-hakkers/api/${project.version} + mvn:com.typesafe.akka.akka-sample-osgi-dining-hakkers/core/${project.version} + mvn:com.typesafe.akka.akka-sample-osgi-dining-hakkers/command/${project.version} diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/command/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/command/pom.xml index f7f14f2fb5..913c9ffb8c 100644 --- a/akka-samples/akka-sample-osgi-dining-hakkers/command/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/command/pom.xml @@ -3,8 +3,8 @@ 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"> - parent - com.typesafe.akka.akka-sample.dining-hakkers + com.typesafe.akka.akka-sample-osgi-dining-hakkers + project 2.2.0-SNAPSHOT 4.0.0 diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/command/src/main/scala/akka/osgi/sample/command/Activator.scala b/akka-samples/akka-sample-osgi-dining-hakkers/command/src/main/scala/akka/sample/osgi/command/Activator.scala similarity index 100% rename from akka-samples/akka-sample-osgi-dining-hakkers/command/src/main/scala/akka/osgi/sample/command/Activator.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/command/src/main/scala/akka/sample/osgi/command/Activator.scala diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/core/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/core/pom.xml index 988234f5bf..978507b7a7 100644 --- a/akka-samples/akka-sample-osgi-dining-hakkers/core/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/core/pom.xml @@ -3,8 +3,8 @@ 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"> - parent - com.typesafe.akka.akka-sample.dining-hakkers + com.typesafe.akka.akka-sample-osgi-dining-hakkers + project 2.2.0-SNAPSHOT 4.0.0 @@ -65,11 +65,6 @@ sigar 1.6.4 - - - com.typesafe.akka - akka-osgi_${scala.dep.version} - @@ -78,8 +73,8 @@ maven-bundle-plugin - akka.osgi.sample.internal, akka.osgi.sample.service - akka.osgi.sample.activation.Activator + akka.sample.osgi.internal, akka.sample.osgi.service + akka.sample.osgi.activation.Activator diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/activation/Activator.scala b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/sample/osgi/activation/Activator.scala similarity index 100% rename from akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/activation/Activator.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/sample/osgi/activation/Activator.scala diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/sample/osgi/internal/Hakker.scala similarity index 100% rename from akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/internal/Hakker.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/sample/osgi/internal/Hakker.scala diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/internal/Table.scala b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/sample/osgi/internal/Table.scala similarity index 100% rename from akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/internal/Table.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/sample/osgi/internal/Table.scala diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala b/akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/sample/osgi/service/DiningHakkersServiceImpl.scala similarity index 100% rename from akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/osgi/sample/service/DiningHakkersServiceImpl.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/core/src/main/scala/akka/sample/osgi/service/DiningHakkersServiceImpl.scala diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/pom.xml index df7642b988..a4b1e4a9f9 100644 --- a/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/pom.xml @@ -3,8 +3,8 @@ 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"> - parent - com.typesafe.akka.akka-sample.dining-hakkers + com.typesafe.akka.akka-sample-osgi-dining-hakkers + project 2.2.0-SNAPSHOT 4.0.0 diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala b/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/sample/osgi/test/HakkerStatusTest.scala similarity index 100% rename from akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/osgi/sample/test/HakkerStatusTest.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/sample/osgi/test/HakkerStatusTest.scala diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala b/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/sample/osgi/test/TestOptions.scala similarity index 92% rename from akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala rename to akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/sample/osgi/test/TestOptions.scala index c4ceca7c03..267ebcf928 100644 --- a/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/osgi/sample/test/TestOptions.scala +++ b/akka-samples/akka-sample-osgi-dining-hakkers/integration-test/src/test/scala/akka/sample/osgi/test/TestOptions.scala @@ -53,7 +53,8 @@ object TestOptions { } def akkaFeature(feature: String): PaxOption = { - scanFeatures(maven.groupId("com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers").artifactId("assembly-features").`type`("xml").classifier("features") + scanFeatures(maven.groupId("com.typesafe.akka.akka-sample-osgi-dining-hakkers") + .artifactId("akka-sample-osgi-dining-hakkers") .`type`("xml").classifier("features") .version(System.getProperty("project.version")), feature) } diff --git a/karaf.sh b/akka-samples/akka-sample-osgi-dining-hakkers/karaf.sh similarity index 100% rename from karaf.sh rename to akka-samples/akka-sample-osgi-dining-hakkers/karaf.sh diff --git a/osgi-run.sh b/akka-samples/akka-sample-osgi-dining-hakkers/osgi-run.sh similarity index 100% rename from osgi-run.sh rename to akka-samples/akka-sample-osgi-dining-hakkers/osgi-run.sh diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/pom.xml index e520ab05fe..a032d6e796 100644 --- a/akka-samples/akka-sample-osgi-dining-hakkers/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/pom.xml @@ -3,11 +3,12 @@ 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"> 4.0.0 - com.typesafe.akka.akka-sample.dining-hakkers - parent + com.typesafe.akka.akka-sample-osgi-dining-hakkers + project 2.2.0-SNAPSHOT + UTF-8 2.2-SNAPSHOT 2.3.0 ${karaf.version} @@ -16,7 +17,7 @@ 2.6.0 1.6.0 2.4.1 - 2.10.0 + 2.10.1 2.10 1.9.1 1.0.0 @@ -33,7 +34,7 @@ integration-test pom - com.typesafe.akka.akka-sample.akka-sample-osgi-dining-hakkers.sample + akka-sample-osgi-dining-hakkers @@ -63,6 +64,12 @@ command ${project.version} + + ${project.groupId} + akka-sample-osgi-dining-hakkers + ${project.version} + pom + com.typesafe.akka diff --git a/akka-samples/akka-sample-osgi-dining-hakkers/uncommons/pom.xml b/akka-samples/akka-sample-osgi-dining-hakkers/uncommons/pom.xml index b11d35b352..6d00a830e7 100644 --- a/akka-samples/akka-sample-osgi-dining-hakkers/uncommons/pom.xml +++ b/akka-samples/akka-sample-osgi-dining-hakkers/uncommons/pom.xml @@ -3,8 +3,8 @@ 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"> - parent - com.typesafe.akka.akka-sample.dining-hakkers + com.typesafe.akka.akka-sample-osgi-dining-hakkers + project 2.2.0-SNAPSHOT 4.0.0