2011/09/26

一个scala编译错误

针对类似如下代码:
package e3.configuration


trait IConfigurationFactory[R] extends Disposable {
  /**
   * the load method will only responsible for the load strategy, but will not be responsible for the content manipulation works.
   */
  def load(): Option[R]
}

case class EromangaConfigurations(serverCfg: EromangaConfig, commonCfg: ErosaCommonConfiguration, channelsCfg: Array[ErosaChannelConfigurationWrapper])


class EromangaSpringContextConfigurationFactory[EromangaConfigurations](configLocation: File, fileFinder: IFileFinder = new XmlFileFinder) extends IConfigurationFactory[EromangaConfigurations] {
  require(configLocation != null && configLocation.isDirectory)
  require(fileFinder != null)

  var context: FileSystemXmlApplicationContext = _

  def load(): Option[EromangaConfigurations] = {
    val resources = fileFinder.findUnder(configLocation).map("file://" + _.getAbsolutePath)
    if (context != null) {
      return None
    }
    context = new FileSystemXmlApplicationContext(resources, true)
    val e3config = context.getBean(classOf[EromangaConfig])
    val erosaCommonCfg = context.getBean(classOf[ErosaCommonConfiguration])
    val buffer = new scala.collection.mutable.ArrayBuffer[ErosaChannelConfigurationWrapper]()
    context.getBeansOfType(classOf[ErosaChannelConfigurationWrapper]).values().foreach(buffer += _)
    val channelCfgs = buffer.toArray[ErosaChannelConfigurationWrapper]
    Some(EromangaConfigurations.apply(e3config, erosaCommonCfg, channelCfgs))
  }

  def dispose() {
    if (context != null) {
      context.close()
      context = null
    }
  }
}

碰到如下编译错误:

[error] /Users/fujohnwang/workspace/e3_filestore_branch/src/main/scala/Configuration.scala:70: type mismatch;
[error]  found   : e3.configuration.EromangaConfigurations
[error]  required: EromangaConfigurations
[error]     Some(EromangaConfigurations.apply(e3config, erosaCommonCfg, channelCfgs))
[error]                                      ^
[error] one error found

猜猜哪里出了问题,^_^

没有评论: