added support for running akka as part of Lift app in Jetty, made akka web app aware, added sample module
This commit is contained in:
parent
720736d405
commit
b0e70ab775
15 changed files with 642 additions and 0 deletions
98
samples-lift/akka-samples-lift.iml
Normal file
98
samples-lift/akka-samples-lift.iml
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="Scala" name="Scala">
|
||||
<configuration />
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/scala" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/config" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/scala" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.codehaus.aspectwerkz:aspectwerkz-nodeps-jdk5:2.1" level="project" />
|
||||
<orderEntry type="module" module-name="akka-kernel" exported="" />
|
||||
<orderEntry type="module" module-name="akka-util-java" exported="" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.guiceyfruit:guice-core:2.0-beta-4" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.guiceyfruit:guice-jsr250:2.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: javax.annotation:jsr250-api:1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.google.protobuf:protobuf-java:2.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.scala-lang:scala-library:2.7.5" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: net.lag:configgy:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.scala-lang:scala-compiler:2.7.5" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.scala-tools:vscaladoc:1.1-md-3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: markdownj:markdownj:1.0.2b4-0.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: junit:junit:4.5" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.scala-tools.testing:specs:1.4.4" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.guiceyfruit:guiceyfruit-core:2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.guiceyfruit:guice-all:2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: javax.annotation:com.springsource.javax.annotation:1.0.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.aopalliance:com.springsource.org.aopalliance:1.0.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.google.code.google-collections:google-collect:snapshot-20080530" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: cglib:cglib:2.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: asm:asm:3.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: aopalliance:aopalliance:1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.apache.camel:camel-core:2.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: commons-logging:commons-logging-api:1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: javax.xml.bind:jaxb-api:2.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: javax.xml.stream:stax-api:1.0-2" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: javax.activation:activation:1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.xml.bind:jaxb-impl:2.1.6" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.jboss.netty:netty:3.1.0.CR1" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.apache:zookeeper:3.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.codehaus.jackson:jackson-core-asl:1.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.codehaus.jackson:jackson-mapper-asl:1.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: sbinary:sbinary:0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.twitter:scala-json:1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.apache.cassandra:cassandra:0.4.0-dev" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.facebook:thrift:1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.facebook:fb303:1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: high-scale-lib:high-scale-lib:1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: commons-lang:commons-lang:2.4" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: se.foldleft:cassidy:0.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-comet-webserver:1.8.6.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-servlet-webserver:1.8.6.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-http:1.8.6.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-framework:1.8.6.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-http-utils:1.8.6.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-rcm:1.8.6.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-portunif:1.8.6.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-http-servlet:1.8.6.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.servlet:servlet-api:2.5" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-comet:1.8.6.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.jersey:jersey-server:1.1.1-ea" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.jersey:jersey-core:1.1.1-ea" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: javax.ws.rs:jsr311-api:1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.jersey:jersey-json:1.1.1-ea" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.codehaus.jettison:jettison:1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: stax:stax-api:1.0.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.codehaus.jackson:jackson-asl:0.9.4" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.jersey.contribs:jersey-scala:1.1.2-ea-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.atmosphere:atmosphere-core:0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.atmosphere:atmosphere-portable-runtime:0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.atmosphere:atmosphere-compat:0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.slf4j:slf4j-log4j12:1.4.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: org.slf4j:slf4j-api:1.4.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: log4j:log4j:1.2.13" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: commons-logging:commons-logging:1.0.4" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: com.sun.jersey:jersey-client:1.1.0-ea" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: net.liftweb:lift-util:1.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: javax.mail:mail:1.4" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: commons-codec:commons-codec:1.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: commons-fileupload:commons-fileupload:1.2.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: net.liftweb:lift-webkit:1.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" exported="" name="Maven: net.liftweb:lift-actor:1.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mortbay.jetty:jetty:7.0.0.pre5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mortbay.jetty:servlet-api:3.0.pre4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mortbay.jetty:jetty-util:7.0.0.pre5" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
64
samples-lift/config/akka.conf
Normal file
64
samples-lift/config/akka.conf
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#####################
|
||||
# Akka Config File #
|
||||
###################
|
||||
|
||||
# This file has all the default settings, so all these could be remove with no visible effect.
|
||||
# Modify as needed.
|
||||
|
||||
<log>
|
||||
filename = "./logs/akka.log"
|
||||
roll = "daily" # Options: never, hourly, daily, sunday/monday/...
|
||||
level = "debug" # Options: fatal, critical, error, warning, info, debug, trace
|
||||
console = on
|
||||
# syslog_host = ""
|
||||
# syslog_server_name = ""
|
||||
</log>
|
||||
|
||||
<akka>
|
||||
version = "v0.5"
|
||||
|
||||
<actor>
|
||||
timeout = 5000 # default timeout for future based invocations
|
||||
concurrent-mode = off # if turned on, then the same actor instance is allowed to execute concurrently -
|
||||
# e.g. departing from the actor model for better performance
|
||||
serialize-messages = on # does a deep clone of (non-primitive) messages to ensure immutability
|
||||
</actor>
|
||||
|
||||
<stm>
|
||||
service = on
|
||||
restart-on-collision = off # (not implemented yet) if 'on' then it reschedules the transaction,
|
||||
# if 'off' then throws an exception or rollback for user to handle
|
||||
wait-for-completion = 100 # how long time in millis a transaction should be given time to complete when a collision is detected
|
||||
wait-nr-of-times = 3 # the number of times it should check for completion of a pending transaction upon collision
|
||||
distributed = off # not implemented yet
|
||||
</stm>
|
||||
|
||||
<remote>
|
||||
service = on
|
||||
hostname = "localhost"
|
||||
port = 9999
|
||||
connection-timeout = 1000 # in millis
|
||||
</remote>
|
||||
|
||||
<rest>
|
||||
service = on
|
||||
hostname = "localhost"
|
||||
port = 9998
|
||||
</rest>
|
||||
|
||||
<storage>
|
||||
system = "cassandra" # Options: cassandra (coming: terracotta, redis, tokyo-cabinet, tokyo-tyrant, voldemort, memcached, hazelcast)
|
||||
|
||||
<cassandra>
|
||||
service = on
|
||||
storage-format = "java" # Options: java, scala-json, java-json
|
||||
blocking = false # inserts and queries should be blocking or not
|
||||
|
||||
<thrift-server>
|
||||
service = on
|
||||
pidfile = "akka.pid"
|
||||
</thrift-server>
|
||||
</cassandra>
|
||||
</rest>
|
||||
</akka>
|
||||
|
||||
236
samples-lift/pom.xml
Normal file
236
samples-lift/pom.xml
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
|
||||
<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>
|
||||
|
||||
<artifactId>akka-samples-lift</artifactId>
|
||||
<name>Akka Lift Samples Module</name>
|
||||
|
||||
<packaging>war</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.5</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<lift.version>1.1-SNAPSHOT</lift.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>repo1.maven</id>
|
||||
<name>Maven Main Repository</name>
|
||||
<url>http://repo1.maven.org/maven2</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>project.embedded.module</id>
|
||||
<name>Project Embedded Repository</name>
|
||||
<url>file://${basedir}/../embedded-repo</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>scala-tools-snapshots</id>
|
||||
<name>Scala-Tools Maven2 Snapshot Repository</name>
|
||||
<url>http://scala-tools.org/repo-snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>scala-tools</id>
|
||||
<name>Scala-Tools Maven2 Repository</name>
|
||||
<url>http://scala-tools.org/repo-releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>lag</id>
|
||||
<name>Configgy's' Repository</name>
|
||||
<url>http://www.lag.net/repo</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>maven2-repository.dev.java.net</id>
|
||||
<name>Java.net Repository for Maven</name>
|
||||
<url>http://download.java.net/maven/2</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>java.net</id>
|
||||
<name>Java.net Legacy Repository for Maven</name>
|
||||
<url>http://download.java.net/maven/1</url>
|
||||
<layout>legacy</layout>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>guiceyfruit.release</id>
|
||||
<name>GuiceyFruit Release Repository</name>
|
||||
<url>http://guiceyfruit.googlecode.com/svn/repo/releases/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>guiceyfruit.snapshot</id>
|
||||
<name>GuiceyFruit Snapshot Repository</name>
|
||||
<url>http://guiceyfruit.googlecode.com/svn/repo/snapshots/</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>google-maven-repository</id>
|
||||
<name>Google Maven Repository</name>
|
||||
<url>http://google-maven-repository.googlecode.com/svn/repository/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>repository.codehaus.org</id>
|
||||
<name>Codehaus Maven Repository</name>
|
||||
<url>http://repository.codehaus.org</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>repository.jboss.org</id>
|
||||
<name>JBoss Repository for Maven</name>
|
||||
<url>http://repository.jboss.org/maven2</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>scala-tools.org</id>
|
||||
<name>Scala-Tools Maven2 Repository</name>
|
||||
<url>http://scala-tools.org/repo-releases</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.aspectwerkz</groupId>
|
||||
<artifactId>aspectwerkz-nodeps-jdk5</artifactId>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<artifactId>akka-kernel</artifactId>
|
||||
<version>0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<artifactId>akka-util-java</artifactId>
|
||||
<version>0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scala-lang</groupId>
|
||||
<artifactId>scala-library</artifactId>
|
||||
<version>${scala.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.liftweb</groupId>
|
||||
<artifactId>lift-util</artifactId>
|
||||
<version>${lift.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.liftweb</groupId>
|
||||
<artifactId>lift-webkit</artifactId>
|
||||
<version>${lift.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty</artifactId>
|
||||
<version>[6.1.6,)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- for LiftConsole -->
|
||||
<dependency>
|
||||
<groupId>org.scala-lang</groupId>
|
||||
<artifactId>scala-compiler</artifactId>
|
||||
<version>${scala.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/scala</sourceDirectory>
|
||||
<testSourceDirectory>src/test/scala</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.scala-tools</groupId>
|
||||
<artifactId>maven-scala-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<scalaVersion>${scala.version}</scalaVersion>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>maven-jetty-plugin</artifactId>
|
||||
<configuration>
|
||||
<contextPath>/</contextPath>
|
||||
<scanIntervalSeconds>5</scanIntervalSeconds>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>net.sf.alchim</groupId>
|
||||
<artifactId>yuicompressor-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compress</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<nosuffix>true</nosuffix>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>false</filtering>
|
||||
<directory>config</directory>
|
||||
<includes>
|
||||
<include>akka.conf</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.scala-tools</groupId>
|
||||
<artifactId>maven-scala-plugin</artifactId>
|
||||
<configuration>
|
||||
<scalaVersion>${scala.version}</scalaVersion>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
</project>
|
||||
58
samples-lift/src/main/scala/bootstrap/liftweb/Boot.scala
Normal file
58
samples-lift/src/main/scala/bootstrap/liftweb/Boot.scala
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package bootstrap.liftweb
|
||||
|
||||
import _root_.net.liftweb.util._
|
||||
import _root_.net.liftweb.http._
|
||||
import _root_.net.liftweb.sitemap._
|
||||
import _root_.net.liftweb.sitemap.Loc._
|
||||
import Helpers._
|
||||
import _root_.net.liftweb.http.auth._
|
||||
|
||||
import se.scalablesolutions.akka.kernel.state.{TransactionalState, CassandraStorageConfig}
|
||||
import se.scalablesolutions.akka.kernel.actor.{SupervisorFactory, Actor}
|
||||
import se.scalablesolutions.akka.kernel.config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.kernel.util.Logging
|
||||
import sample.lift.SimpleService
|
||||
|
||||
/**
|
||||
* A class that's instantiated early and run. It allows the application
|
||||
* to modify lift's environment
|
||||
*/
|
||||
class Boot {
|
||||
def boot {
|
||||
// where to search snippet
|
||||
LiftRules.addToPackages("sample.lift")
|
||||
|
||||
LiftRules.httpAuthProtectedResource.prepend {
|
||||
case (ParsePath("secure-basic" :: Nil, _, _, _)) => Full(AuthRole("admin"))
|
||||
}
|
||||
|
||||
LiftRules.authentication = HttpBasicAuthentication("lift") {
|
||||
case ("someuser", "1234", req) => {
|
||||
Log.info("You are now authenticated !")
|
||||
userRoles(AuthRole("admin"))
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
LiftRules.passNotFoundToChain = true
|
||||
|
||||
object factory extends SupervisorFactory {
|
||||
override def getSupervisorConfig: SupervisorConfig = {
|
||||
SupervisorConfig(
|
||||
RestartStrategy(OneForOne, 3, 100),
|
||||
Supervise(
|
||||
new SimpleService,
|
||||
LifeCycle(Permanent, 100)
|
||||
)
|
||||
:: Nil)
|
||||
}
|
||||
}
|
||||
val supervisor = factory.newSupervisor
|
||||
supervisor.startSupervisor
|
||||
|
||||
// Build SiteMap
|
||||
// val entries = Menu(Loc("Home", List("index"), "Home")) :: Nil
|
||||
// LiftRules.setSiteMap(SiteMap(entries:_*))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package sample.lift
|
||||
|
||||
import se.scalablesolutions.akka.kernel.state.{TransactionalState, CassandraStorageConfig}
|
||||
import se.scalablesolutions.akka.kernel.actor.{SupervisorFactory, Actor}
|
||||
import se.scalablesolutions.akka.kernel.config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.kernel.util.Logging
|
||||
|
||||
import javax.ws.rs.core.MultivaluedMap
|
||||
import javax.ws.rs.{GET, POST, Path, Produces, WebApplicationException, Consumes}
|
||||
|
||||
/**
|
||||
* Try service out by invoking (multiple times):
|
||||
* <pre>
|
||||
* curl http://localhost:9998/liftcount
|
||||
* </pre>
|
||||
* Or browse to the URL from a web browser.
|
||||
*/
|
||||
@Path("/liftcount")
|
||||
class SimpleService extends Actor {
|
||||
makeTransactionRequired
|
||||
|
||||
case object Tick
|
||||
private val KEY = "COUNTER";
|
||||
private var hasStartedTicking = false;
|
||||
private val storage = TransactionalState.newPersistentMap(CassandraStorageConfig())
|
||||
|
||||
@GET
|
||||
@Produces(Array("text/html"))
|
||||
def count = (this !! Tick).getOrElse(<h1>Error in counter</h1>)
|
||||
|
||||
override def receive: PartialFunction[Any, Unit] = {
|
||||
case Tick => if (hasStartedTicking) {
|
||||
val counter = storage.get(KEY).get.asInstanceOf[Integer].intValue
|
||||
storage.put(KEY, new Integer(counter + 1))
|
||||
reply(<h1>Tick: {counter + 1}</h1>)
|
||||
} else {
|
||||
storage.put(KEY, new Integer(0))
|
||||
hasStartedTicking = true
|
||||
reply(<h1>Tick: 0</h1>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package eu.getintheloop.example.snippet
|
||||
|
||||
class HelloWorld {
|
||||
def howdy = <span>Welcome to lift-akka at {new _root_.java.util.Date}</span>
|
||||
}
|
||||
|
||||
5
samples-lift/src/main/webapp/index.html
Normal file
5
samples-lift/src/main/webapp/index.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<lift:surround with="default" at="content">
|
||||
<h2>Welcome to your project!</h2>
|
||||
<p><lift:helloWorld.howdy /></p>
|
||||
</lift:surround>
|
||||
|
||||
15
samples-lift/src/main/webapp/templates-hidden/default.html
Normal file
15
samples-lift/src/main/webapp/templates-hidden/default.html
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:lift="http://liftweb.net/">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<meta name="description" content="" />
|
||||
<meta name="keywords" content="" />
|
||||
|
||||
<title>eu.getintheloop.example:lift-akka:1.0-SNAPSHOT</title>
|
||||
<script id="jquery" src="/classpath/jquery.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<lift:bind name="content" />
|
||||
<lift:Menu.builder />
|
||||
<lift:msgs/>
|
||||
</body>
|
||||
</html>
|
||||
15
samples-lift/src/test/scala/LiftConsole.scala
Normal file
15
samples-lift/src/test/scala/LiftConsole.scala
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import _root_.bootstrap.liftweb.Boot
|
||||
import _root_.scala.tools.nsc.MainGenericRunner
|
||||
|
||||
object LiftConsole {
|
||||
def main(args : Array[String]) {
|
||||
// Instantiate your project's Boot file
|
||||
val b = new Boot()
|
||||
// Boot your project
|
||||
b.boot
|
||||
// Now run the MainGenericRunner to get your repl
|
||||
MainGenericRunner.main(args)
|
||||
// After the repl exits, then exit the scala script
|
||||
exit(0)
|
||||
}
|
||||
}
|
||||
28
samples-lift/src/test/scala/RunWebApp.scala
Normal file
28
samples-lift/src/test/scala/RunWebApp.scala
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import _root_.org.mortbay.jetty.Connector
|
||||
import _root_.org.mortbay.jetty.Server
|
||||
import _root_.org.mortbay.jetty.webapp.WebAppContext
|
||||
|
||||
object RunWebApp extends Application {
|
||||
val server = new Server(8080)
|
||||
val context = new WebAppContext()
|
||||
context.setServer(server)
|
||||
context.setContextPath("/")
|
||||
context.setWar("src/main/webapp")
|
||||
|
||||
server.addHandler(context)
|
||||
|
||||
try {
|
||||
println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP")
|
||||
server.start()
|
||||
while (System.in.available() == 0) {
|
||||
Thread.sleep(5000)
|
||||
}
|
||||
server.stop()
|
||||
server.join()
|
||||
} catch {
|
||||
case exc : Exception => {
|
||||
exc.printStackTrace()
|
||||
System.exit(100)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
package eu.getintheloop.example
|
||||
|
||||
import _root_.java.io.File
|
||||
import _root_.junit.framework._
|
||||
import Assert._
|
||||
import _root_.scala.xml.XML
|
||||
import _root_.net.liftweb.util._
|
||||
|
||||
object AppTest {
|
||||
def suite: Test = {
|
||||
val suite = new TestSuite(classOf[AppTest])
|
||||
suite
|
||||
}
|
||||
|
||||
def main(args : Array[String]) {
|
||||
_root_.junit.textui.TestRunner.run(suite)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
class AppTest extends TestCase("app") {
|
||||
|
||||
/**
|
||||
* Rigourous Tests :-)
|
||||
*/
|
||||
def testOK() = assertTrue(true)
|
||||
// def testKO() = assertTrue(false);
|
||||
|
||||
/**
|
||||
* Tests to make sure the project's XML files are well-formed.
|
||||
*
|
||||
* Finds every *.html and *.xml file in src/main/webapp (and its
|
||||
* subdirectories) and tests to make sure they are well-formed.
|
||||
*/
|
||||
def testXml() = {
|
||||
var failed: List[File] = Nil
|
||||
|
||||
def handledXml(file: String) =
|
||||
file.endsWith(".xml")
|
||||
|
||||
def handledXHtml(file: String) =
|
||||
file.endsWith(".html") || file.endsWith(".htm") || file.endsWith(".xhtml")
|
||||
|
||||
def wellFormed(file: File) {
|
||||
if (file.isDirectory)
|
||||
for (f <- file.listFiles) wellFormed(f)
|
||||
|
||||
if (file.isFile && handledXml(file.getName)) {
|
||||
try {
|
||||
XML.loadFile(file)
|
||||
} catch {
|
||||
case e: _root_.org.xml.sax.SAXParseException => failed = file :: failed
|
||||
}
|
||||
}
|
||||
if (file.isFile && handledXHtml(file.getName)) {
|
||||
PCDataXmlParser(new java.io.FileInputStream(file.getAbsolutePath)) match {
|
||||
case Full(_) => // file is ok
|
||||
case _ => failed = file :: failed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wellFormed(new File("src/main/webapp"))
|
||||
|
||||
val numFails = failed.size
|
||||
if (numFails > 0) {
|
||||
val fileStr = if (numFails == 1) "file" else "files"
|
||||
val msg = "Malformed XML in " + numFails + " " + fileStr + ": " + failed.mkString(", ")
|
||||
println(msg)
|
||||
fail(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue