2010-10-20 89 views
1

問候scala舉起演員,錯誤:類型不匹配;

我使用Scala的2.8.0版和提升的2.1版編譯我的項目使用Maven我標記以下錯誤:

 
error: type mismatch; 

[INFO] required: **scala.actors.Actor** 
[INFO]  Auctioneer !? AddListener(**this**, this.itemId) match { 
[INFO]        ^

error: type mismatch; 

[INFO] required: **scala.actors.Actor** 
[INFO]  Auctioneer ! RemoveListener(**this**, this.itemId) 
[INFO]        ^

該文件是:

package org.developerworks.comet 

import net.liftweb.http._ 
import net.liftweb.common.Full 
import net.liftweb.http.S._ 
import net.liftweb.http.SHtml._ 
import net.liftweb.http.js.JsCmd 
import net.liftweb.http.js.JsCmds._ 
import net.liftweb.http.js.JE._ 
import net.liftweb.util.Helpers._ 
import net.liftweb.util._ 
import scala.xml.NodeSeq 
import org.developerworks.model._ 
import org.developerworks.actor._ 
import java.lang.Long 


class AuctionActor extends CometActor { 


    var highBid : TheCurrentHighBid = null 

    override def defaultPrefix = Full("auction") 

    val itemId = S.param("itemId").map(Long.parseLong(_)).openOr(0L) 


    def render = { 

    def itemView: NodeSeq = { 

     val item = if (itemId > 0) 
     ItemMetaData.findByKey(itemId).openOr(ItemMetaData.create) 
     else ItemMetaData.create 
     val currBid = item.highBid 
     val bidAmt = if (currBid.user.isEmpty) 0L else currBid.amount.is 
     highBid = TheCurrentHighBid(bidAmt, currBid.user.obj.openOr(User.currentUser.open_!)) 
     val minNewBid = highBid.amount + 1L 
     val button = <button type="button">{S.?("Bid Now!")}</button> % 
     ("onclick" -> ajaxCall(JsRaw("$('#newBid').attr('value')"), bid _)) 
     (<div> 
      <strong>{item.name}</strong> 
      <br/> 
      <div> 
      Current Bid: ${highBid.amount} by {highBid.user.niceName} 
      </div> 
      <div> 
      New Bid (min: ${minNewBid}) : 
      <input type="text" id="newBid"/> 
      {button} 
      </div> 
      {item.description}<br/> 
     </div>) 
    } 

    bind("foo" -> <div>{itemView}</div>) 

    } 


    def bid(s:String): JsCmd = { 

    val user = User.currentUser.open_! 
    Auctioneer ! BidOnItem(itemId, Long.parseLong(s), user) 
    Noop 

    } 


    override def localSetup { 

    Auctioneer !? AddListener(this, this.itemId) match { 

     case Success(true) => println("Listener added") 
     case _ => println("Other ls") 

    } 

    } 


    override def localShutdown { 

    Auctioneer ! RemoveListener(this, this.itemId) 

    } 


    override def lowPriority : PartialFunction[Any, Unit] = { 

    case TheCurrentHighBid(a,u) => { 
     highBid = TheCurrentHighBid(a,u) 
     reRender(false) 
     } 
    case _ => println("Other lp") 

    } 


} 

任何人都可以告訴我我失蹤或我做錯了

我在2.7.3版中編譯過這個項目,並且沒有問題

請幫忙!!!

回答

3

電梯的演員不再是斯卡拉演員。有可能是他們互操作的一種方式,但我建議首先嚐試改變所有演員,以便他們是電梯演員。

1

您可以在同一個項目中使用Scala Actor和Lift Actor,但不能將它們替換爲另一個項目。他們使用Actor系統的完全不同的實現,所以他們不能據我所知發送消息給對方。

在Lift項目中,我通常使用LiftActors作爲我的單身人士,名爲演員將接收明確發送給它的消息。爲了便於閱讀,我將使用Scala actors來執行後臺任務,例如將日誌寫入數據庫:

actor { mapper.save }