View Javadoc

1   /**
2    * Copyright (C) 2005-2009 Alfresco Software Limited.
3    *
4    * This file is part of the Spring Surf Extension project.
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   */
18  
19  package org.springframework.extensions.webscripts;
20  
21  import java.util.Map;
22  
23  
24  /**
25   * Web Script Processor
26   * 
27   * @author davidc
28   */
29  public interface ScriptProcessor
30  {
31  
32      /**
33       * Find a script at the specified path (within registered Web Script stores)
34       * 
35       * @param path   script path
36       * @return  script location (or null, if not found)
37       */
38      public ScriptContent findScript(String path);
39  
40      /**
41       * Execute script
42       * 
43       * @param path  script path
44       * @param model  model
45       * @return  script result
46       * @throws ScriptException
47       */
48      public Object executeScript(String path, Map<String, Object> model);
49  
50      /**
51       * Execute script
52       *  
53       * @param location  script location
54       * @param model  model
55       * @return  script result
56       */
57      public Object executeScript(ScriptContent location, Map<String, Object> model);
58  
59      /**
60       * Unwrap value returned by script
61       * 
62       * TODO: Remove this method when value conversion is truly hidden within script engine
63       * 
64       * @param path   the path to the file
65       * @param value  value to unwrap
66       * @return  unwrapped value
67       */
68      public Object unwrapValue(Object value);
69      
70      /**
71       * Reset script cache
72       */
73      public void reset();
74  
75  }