-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move boot code and pipeline factory to its own class. cleaned up example.
- Loading branch information
Showing
3 changed files
with
52 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/scala/com/something/lift/LiftPipelineFactory.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.something.lift | ||
|
||
import org.jboss.netty.handler.codec.http.{HttpResponseEncoder, HttpRequestDecoder} | ||
import net.liftweb.common.Box | ||
import net.liftweb.util.Helpers | ||
import net.liftweb.http.{LiftRules, LiftServlet} | ||
import org.jboss.netty.channel.{Channels, ChannelPipeline, ChannelPipelineFactory} | ||
|
||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: jordanrw | ||
* Date: 2/23/12 | ||
* Time: 9:55 PM | ||
*/ | ||
|
||
import MyTypes._ | ||
class LiftPipelineFactory extends ChannelPipelineFactory { | ||
|
||
// TODO make better, extensible, etc | ||
def getPipeline: ChannelPipeline = Channels.pipeline( | ||
new HttpRequestDecoder, | ||
new HttpResponseEncoder, | ||
handler | ||
) | ||
|
||
val transientVarProvider: VarProvider = | ||
findObject("net.liftweb.http.TransientRequestVarHandler").open_!.asInstanceOf[VarProvider] | ||
val reqVarProvider: VarProvider = | ||
findObject("net.liftweb.http.RequestVarHandler").open_!.asInstanceOf[VarProvider] | ||
|
||
val nettyContext = new HTTPNettyContext | ||
|
||
val liftLand = new LiftServlet(nettyContext) | ||
|
||
LiftRules.setContext(nettyContext) | ||
|
||
val handler = new LiftChannelHandler(nettyContext, transientVarProvider, reqVarProvider, liftLand) | ||
|
||
private def findObject(cls: String): Box[AnyRef] = | ||
Helpers.tryo[Class[_]](Nil)(Class.forName(cls + "$")).flatMap { | ||
c => | ||
Helpers.tryo { | ||
val field = c.getField("MODULE$") | ||
field.get(null) | ||
} | ||
} | ||
|
||
} |