Fixed: Akka kernel now loads all jars wrapped up in the jars in the ./deploy dir

This commit is contained in:
Jonas Bonér 2010-04-07 14:23:58 +02:00
parent e4e96f61c8
commit 0d60400790
3 changed files with 39 additions and 16 deletions

View file

@ -1,11 +1,12 @@
/**
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
*/
package se.scalablesolutions.akka.actor
import java.io.File
import java.net.URLClassLoader
import java.net.{URL, URLClassLoader}
import java.util.jar.JarFile
import se.scalablesolutions.akka.util.{Bootable, Logging}
import se.scalablesolutions.akka.config.Config._
@ -17,7 +18,7 @@ trait BootableActorLoaderService extends Bootable with Logging {
val BOOT_CLASSES = config.getList("akka.boot")
lazy val applicationLoader: Option[ClassLoader] = createApplicationClassLoader
protected def createApplicationClassLoader : Option[ClassLoader] = {
Some(
if (HOME.isDefined) {
@ -28,9 +29,21 @@ trait BootableActorLoaderService extends Bootable with Logging {
log.error("Could not find a deploy directory at [%s]", DEPLOY)
System.exit(-1)
}
val toDeploy = for (f <- DEPLOY_DIR.listFiles().toArray.toList.asInstanceOf[List[File]]) yield f.toURI.toURL
log.info("Deploying applications from [%s]: [%s]", DEPLOY, toDeploy.toArray.toList)
new URLClassLoader(toDeploy.toArray, getClass.getClassLoader)
val filesToDeploy = DEPLOY_DIR.listFiles.toArray.toList.asInstanceOf[List[File]].filter(_.getName.endsWith(".jar"))
var dependencyJars: List[URL] = Nil
filesToDeploy.map { file =>
val jarFile = new JarFile(file)
val en = jarFile.entries
while (en.hasMoreElements) {
val name = en.nextElement.getName
if (name.endsWith(".jar")) dependencyJars ::= new File(String.format("jar:file:%s!/%s", jarFile.getName, name)).toURI.toURL
}
}
val toDeploy = filesToDeploy.map(_.toURI.toURL)
log.info("Deploying applications from [%s]: [%s]", DEPLOY, toDeploy)
log.debug("Loading dependencies [%s]", dependencyJars)
val allJars = toDeploy ::: dependencyJars
new URLClassLoader(allJars.toArray.asInstanceOf[Array[URL]] , getClass.getClassLoader)
} else getClass.getClassLoader)
}
@ -41,6 +54,6 @@ trait BootableActorLoaderService extends Bootable with Logging {
}
super.onLoad
}
abstract override def onUnload = ActorRegistry.shutdownAll
}

View file

@ -1,6 +1,5 @@
package se.scalablesolutions.akka.actor
import se.scalablesolutions.akka.stm.Transaction.Local._
import se.scalablesolutions.akka.stm._
import org.scalatest.Spec
@ -11,13 +10,14 @@ import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
@RunWith(classOf[JUnitRunner])
class StmSpec extends
Spec with
ShouldMatchers with
class StmSpec extends
Spec with
ShouldMatchers with
BeforeAndAfterAll {
describe("STM outside actors") {
describe("Transaction.Local") {
it("should be able to do multiple consecutive atomic {..} statements") {
import Transaction.Local._
lazy val ref = TransactionalState.newRef[Int]
@ -36,6 +36,7 @@ class StmSpec extends
}
it("should be able to do nested atomic {..} statements") {
import Transaction.Local._
lazy val ref = TransactionalState.newRef[Int]
@ -45,10 +46,10 @@ class StmSpec extends
def total: Int = atomic {
ref.get.getOrElse(0)
}
atomic {
increment
increment
increment
}
atomic {
increment
@ -57,6 +58,7 @@ class StmSpec extends
}
it("should roll back failing nested atomic {..} statements") {
import Transaction.Local._
lazy val ref = TransactionalState.newRef[Int]
@ -71,7 +73,7 @@ class StmSpec extends
increment
increment
throw new Exception
}
}
} catch {
case e => {}
}

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.redis</groupId>
<artifactId>redisclient</artifactId>
<version>2.8.0.Beta1-1.3-SNAPSHOT</version>
<packaging>jar</packaging>
</project>