Permalink
Browse files

Update framework to new structure, lift-* suffix finally gone

  • Loading branch information...
1 parent 4baba92 commit f6296ec60001ecf4eeaba475a9fe69e1217e5b90 @indrajitr indrajitr committed Feb 5, 2011
Showing 750 changed files with 0 additions and 22,075 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ Copyright 2006-2010 WorldWide Conferencing, LLC
- ~
- ~ 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.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!--
- ~ The Basics
- -->
- <parent>
- <groupId>net.liftweb</groupId>
- <artifactId>lift-modules_2.8.1</artifactId>
- <version>2.3-SNAPSHOT</version>
- </parent>
- <artifactId>lift-amqp_2.8.1</artifactId>
-
- <!--
- ~ More Project Information
- -->
- <name>Lift AMQP</name>
- <description>AMQP (rabbitmq) integration helper</description>
-
- <!--
- ~ Environment Settings
- -->
- <!-- <properties/> -->
-
- <!--
- ~ Dependency Settings
- -->
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>lift-actor_${scala.version}</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-library</artifactId>
- </dependency>
- <dependency>
- <groupId>com.rabbitmq</groupId>
- <artifactId>amqp-client</artifactId>
- </dependency>
- </dependencies>
-
- <!--
- ~ Build Settings
- -->
- <!-- <build/> -->
-
- <!--
- ~ Reporting Settings
- -->
- <!-- <reporting/> -->
-
-</project>
@@ -1,163 +0,0 @@
-/*
- * Copyright 2007-2010 WorldWide Conferencing, LLC
- *
- * 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 net.liftweb {
-package amqp {
-
-import _root_.com.rabbitmq.client._
-import _root_.net.liftweb.actor._
-import _root_.java.io.ObjectInputStream
-import _root_.java.io.ByteArrayInputStream
-import _root_.java.util.Timer
-import _root_.java.util.TimerTask
-
-/**
- * @param a The actor to add as a Listener to this Dispatcher.
- */
-case class AMQPAddListener(a: LiftActor)
-
-/**
- * @param message A deserialized value received via AMQP.
- *
- * Messages received from AMQP are wrapped in this case class. When you
- * register a listener, this is the case class that you will be matching on.
- */
-case class AMQPMessage[T](message: T)
-
-
-/**
- * Reconnect to the AMQP Server after a delay of {@code delay} milliseconds.
- */
-case class AMQPReconnect(delay: Long)
-
-/**
- * An actor that serves as an endpoint for AMQP messages of serialized type T
- * coming into a specific queue/exchange.
- *
- * To listen for messages coming into that queue/exchange, send
- * this actor an AMQPAddListener message.
- *
- * For each message containing a value of type T, all listeners will be send
- * an AMQPMessage contaning that value.
- *
- * See also Enterprise Integration Patterns pp. 508-514
- *
- * @author Steve Jenson (stevej@pobox.com)
- */
-abstract class AMQPDispatcher[T](cf: ConnectionFactory, host: String, port: Int) extends LiftActor {
- var (conn, channel) = connect()
- private var as: List[LiftActor] = Nil
-
- private def connect(): (Connection, Channel) = {
- val conn = cf.newConnection(host, port)
- val channel = conn.createChannel()
- configure(channel)
- (conn, channel)
- }
-
- /**
- * Override this to configure the Channel and Consumer.
- */
- def configure(channel: Channel)
-
- private val reconnectTimer = new Timer("AMQPReconnectTimer")
-
- protected def messageHandler = {
- case AMQPAddListener(a) => as ::= a
- case msg@AMQPMessage(t) => as.foreach(_ ! msg)
- case AMQPReconnect(delay: Long) =>
- try {
- val details = connect()
- conn = details._1
- channel = details._2
- println("AMQPDispatcher: Successfully reconnected to AMQP Server")
- } catch {
- // Attempts to reconnect again using geometric back-off.
- case e: Exception => {
- val amqp = this
- println("AMQPDispatcher: Will attempt reconnect again in " + (delay * 2) + "ms.")
- reconnectTimer.schedule(new TimerTask(){
- override def run = {
- amqp ! AMQPReconnect(delay * 2)
- }
- }, delay)
- }
- }
- case _ =>
- }
-}
-
-/**
- * Example consumer on an AMQP channel.
- */
-class SerializedConsumer[T](channel: Channel, a: LiftActor) extends DefaultConsumer(channel) {
- override def handleDelivery(tag: String, env: Envelope, props: AMQP.BasicProperties, body: Array[Byte]) {
- val routingKey = env.getRoutingKey
- val contentType = props.getContentType
- val deliveryTag = env.getDeliveryTag
- val in = new ObjectInputStream(new ByteArrayInputStream(body))
- val t = in.readObject.asInstanceOf[T];
- // Send t to all registered listeners.
- a ! AMQPMessage(t)
- channel.basicAck(deliveryTag, false);
- }
-}
-
-/**
- * Example Dispatcher that listens on an example queue and exchange. Use this
- * as your guiding example for creating your own Dispatcher.
- *
- */
-class ExampleSerializedAMQPDispatcher[T](factory: ConnectionFactory, host: String, port: Int)
- extends AMQPDispatcher[T](factory, host, port) {
- override def configure(channel: Channel) {
- // Set up the exchange and queue
- channel.exchangeDeclare("mult", "direct")
- channel.queueDeclare("mult_queue")
- channel.queueBind("mult_queue", "mult", "routeroute")
- // Use the short version of the basicConsume method for convenience.
- channel.basicConsume("mult_queue", false, new SerializedConsumer(channel, this))
- }
-}
-
-/**
- * Example class that accepts Strings coming in from the
- * ExampleSerializedAMQPDispatcher.
- */
-class ExampleStringAMQPListener {
- val params = new ConnectionParameters
- params.setUsername("guest")
- params.setPassword("guest")
- params.setVirtualHost("/")
- params.setRequestedHeartbeat(0)
-
- val factory = new ConnectionFactory(params)
- // thor.local is a machine on your network with rabbitmq listening on port 5672
- val amqp = new ExampleSerializedAMQPDispatcher[String](factory, "thor.local", 5672)
-
- // Example Listener that just prints the String it receives.
-
- val stringListener = new LiftActor {
- protected def messageHandler = {
- case msg@AMQPMessage(contents: String) => println("received: " + msg)
- }
- }
-
- amqp ! AMQPAddListener(stringListener)
-}
-
-}
-}
@@ -1,139 +0,0 @@
-/*
- * Copyright 2007-2010 WorldWide Conferencing, LLC
- *
- * 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 net.liftweb {
-package amqp {
-
-import _root_.net.liftweb.actor._
-import _root_.com.rabbitmq.client._
-import _root_.java.io.ByteArrayOutputStream
-import _root_.java.io.ObjectOutputStream
-
-/**
- * An actor with a long-lived connection to an AMQP exchange/queue.
- *
- * @see ExampleStringAMQPSender for an example use.
- * @author Steve Jenson (stevej@pobox.com)
- */
-abstract class AMQPSender[T](cf: ConnectionFactory, host: String, port: Int, exchange: String, routingKey: String) extends LiftActor {
- val conn = cf.newConnection(host, port)
- val channel = conn.createChannel()
-
- /**
- * Override this to use your own AMQP queue/exchange with the given channel.
- */
- def configure(channel: Channel): AnyRef
-
- def send(msg: T) {
- // Now write an object to a byte array and shove it across the wire.
- val bytes = new ByteArrayOutputStream
- val store = new ObjectOutputStream(bytes)
- store.writeObject(msg)
- store.close
- channel.basicPublish(exchange, routingKey, null, bytes.toByteArray)
- }
-
- protected def messageHandler = {
- case AMQPMessage(msg: T) => send(msg)
- }
-}
-
-/**
- * An example subclass of AMQPSender[T]
- *
- * An example of how to send messages to an AMQP queue/exchange. Notice that this
- * is setup with the same params as StringAQMPExample. After making a new instance of
- * StringAMQPExample, just send ExampleAMQPSender ! "hi" to see the message "hi"
- * appear in the output log. Fun and Easy!
- *
- * If you are planning to send lots of messages to lots of different exchange/queues,
- * consider creating Actor-based Senders, that will help your application to scale.
- */
-class StringAMQPSender(cf: ConnectionFactory, host: String, port: Int, exchange: String, routingKey: String)
- extends AMQPSender[String](cf, host, port, exchange, routingKey){
- override def configure(channel: Channel) = {
- val conn = cf.newConnection(host, port)
- val channel = conn.createChannel()
- channel
- }
-}
-
-/**
- * An Example of how to use the Example subclass of AMQPSender[T]. Still following?
- */
-class ExampleStringAMQPSender {
- val params = new ConnectionParameters
- // All of the params, exchanges, and queues are all just example data.
- params.setUsername("guest")
- params.setPassword("guest")
- params.setVirtualHost("/")
- params.setRequestedHeartbeat(0)
- val factory = new ConnectionFactory(params)
-
- val amqp = new StringAMQPSender(factory, "localhost", 5672, "mult", "routeroute")
- amqp ! AMQPMessage("hi")
-}
-
-/**
- * An example of using AMQP in a short-lived manner, setting up and tearing down
- * the connection whenever you need it. The long-lived example above is more
- * efficient with resources.
- */
-object ExampleDirectAMQPSender {
- def send[T](msg: T) {
- val params = new ConnectionParameters
- // All of the params, exchanges, and queues are all just example data.
- params.setUsername("guest")
- params.setPassword("guest")
- params.setVirtualHost("/")
- params.setRequestedHeartbeat(0)
- send(msg, params, "localhost", 5672)
- }
-
- def send[T](msg: T, params: ConnectionParameters, host: String, port: Int) {
- val factory = new ConnectionFactory(params)
- val conn = factory.newConnection(host, port)
- val channel = conn.createChannel()
- // Now write an object to a byte array and shove it across the wire.
- val bytes = new ByteArrayOutputStream
- val store = new ObjectOutputStream(bytes)
- store.writeObject(msg)
- store.close
- channel.basicPublish("mult", "routeroute", null, bytes.toByteArray)
- }
-}
-
-/**
- * Just a few examples of how you might test this. Mostly useful snippets
- * for me to run from script/console to see the bits flying.
- */
-object AMQPExampleFunPack {
- def directExample {
- val recv = new ExampleStringAMQPListener()
- // You should see the message 'hi'
- val sender = new ExampleStringAMQPSender()
- sender
- }
- def actorExample {
- val recv = new ExampleStringAMQPListener()
- // You probably know what message you are going to see. 'hello!'
- val sender = ExampleDirectAMQPSender.send("hello!")
- sender
- }
-}
-
-}
-}
@@ -1,4 +0,0 @@
-net.liftweb.common=${vscaladoc.links.liftweb.baseurl}/lift-base/lift-common/${vscaladoc.links.liftweb.pathsufix}
-net.liftweb.actor=${vscaladoc.links.liftweb.baseurl}/lift-base/lift-actor/${vscaladoc.links.liftweb.pathsufix}
-net.liftweb.util=${vscaladoc.links.liftweb.baseurl}/lift-base/lift-util/${vscaladoc.links.liftweb.pathsufix}
-com.rabbitmq.client=http://www.rabbitmq.com/releases/rabbitmq-java-client/v1.7.0/rabbitmq-java-client-javadoc-1.7.0/
Oops, something went wrong.

0 comments on commit f6296ec

Please sign in to comment.