home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Lift Framework example source code file (SimpleActor.scala)

This example Lift Framework source code file (SimpleActor.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Lift Framework tags/keywords

box, forwardableactor, genericactor, long, r, r, simpleactor, t, t, to, to, typedactor, typedactor, unit

The Lift Framework SimpleActor.scala source code

/*
 * Copyright 2009-2011 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 common 

/**
 * The simple definition of an actor.  Something that
 * can receive a message of type T.
 */
trait SimpleActor[-T] {
  /**
   * Send a message to the Actor
   *
   * @param param the message to send
   */
  def !(param: T): Unit
}

/**
 * An Actor that can receive a message of any type
 */
trait SimplestActor extends SimpleActor[Any]

/**
 * An Actor that can receive messsages of type T and
 * return responses of type R.
 */
trait TypedActor[-T, +R] extends SimpleActor[T] {
  def !?(param: T): R

  /**
   * Compatible with Scala Actors' !? method
   */
  def !?(timeout: Long, message: Any): Box[R]


  /**
   * Asynchronous message send. Send-and-receive eventually. Waits on a Future for the reply message.
   * If recevied within the Actor default timeout interval then it returns Some(result) and if a timeout
   * has occured None.
   */
  def !!(message: T): Box[R]

  /**
   * Asynchronous message send. Send-and-receive eventually. Waits on a Future for the reply message.
   * If recevied within timout interval that is specified then it returns Some(result) and if a timeout
   * has occured None.
   */
  def !!(message: T, timeout: Long): Box[R]

}

/**
 * Generic Actor interface. Can receive any type of message.
 * Can return (via !! and !?) messages of type R.
 */
trait GenericActor[+R] extends TypedActor[Any, R]

/**
 * Generic Actor interface. Can receive any type of message.
 * Can return (via !! and !?) messages of any type.
 */
trait SimplestGenericActor extends GenericActor[Any]


trait ForwardableActor[From, To] {
  self: TypedActor[From, To] =>

  protected def forwardMessageTo(msg: From,
                                 forwardTo: TypedActor[From, To]): Unit

  protected def reply(msg: To): Unit
}

Other Lift Framework examples (source code examples)

Here is a short list of links related to this Lift Framework SimpleActor.scala source code file:



my book on functional programming

 

new blog posts

 

Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.