PageRenderTime 41ms CodeModel.GetById 29ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/scalate-camel/src/main/scala/org/fusesource/scalate/camel/ScalateComponent.scala

http://github.com/scalate/scalate
Scala | 50 lines | 22 code | 8 blank | 20 comment | 0 complexity | d787ed2dabbe9826617c6b5f364a3716 MD5 | raw file
 1/**
 2 * Copyright (C) 2009-2011 the original author or authors.
 3 * See the notice.md file distributed with this work for additional
 4 * information regarding copyright ownership.
 5 *
 6 * Licensed under the Apache License, Version 2.0 (the "License");
 7 * you may not use this file except in compliance with the License.
 8 * You may obtain a copy of the License at
 9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18package org.fusesource.scalate
19package camel
20
21import java.io.File
22import java.util.Map
23
24import org.apache.camel.Endpoint
25import org.apache.camel.impl.DefaultComponent
26import org.springframework.core.io.DefaultResourceLoader
27import org.fusesource.scalate.util.FileResourceLoader
28
29/**
30 * @version $Revision : 1.1 $
31 */
32
33@deprecated("because Apache Camel-Scala has become deprecated", since = "1.9.4")
34class ScalateComponent() extends DefaultComponent {
35
36  var defaultTemplateExtension: String = "ssp"
37  var templateEngine: TemplateEngine = new TemplateEngine()
38
39  var resourceLoader = new DefaultResourceLoader()
40
41  templateEngine.resourceLoader = new FileResourceLoader() {
42
43    override protected def toFile(uri: String): File = {
44      resourceLoader.getResource(uri).getFile
45    }
46  }
47  def createEndpoint(uri: String, remaining: String, parameters: Map[String, Object]): Endpoint = {
48    new ScalateEndpoint(this, uri, remaining, defaultTemplateExtension)
49  }
50}