0,0 → 1,114 |
package net.outlyer.plugins; |
|
/* |
* Copyright (c) 2008, Toni Corvera. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are met: |
* |
* * Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* * Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
|
// $Id$ |
|
import java.lang.reflect.Method; |
import java.util.Map; |
import javax.script.ScriptEngine; |
|
/** |
* Public methods provided by the sandbox. |
*/ |
// Note that all methods defined directly in this interface imply a call to {@link #execute}. |
public interface Sandbox extends RuntimeHooks, SandboxProperties, Sandbox_R1 { |
/** |
* Creates an implementation of an interface from a JS object |
* containing the interface's methods. |
* <br /> |
* <b>Note</b>: Implies a call to {@link #execute()}. |
* @param interfaceClass Interface to implement |
* @param objectName Name of the JS object implementing the interface |
* @return The implementation |
* @throws net.outlyer.plugins.PluginExecutionException |
* @see #createDelayedImplementation(Class,Map) |
* @see #execute() |
*/ |
<T> T createDelayedImplementation(final Class<T> interfaceClass, |
final String objectName) |
throws PluginExecutionException; |
|
/** |
* Creates an implementation of an interface from inline JS code. |
* This variant allows more flexibility (e.g. the implementation might |
* be split among objects, map to global functions or fallback to other |
* object if unimplemented). |
* Note the mapped code should be evaluable as a JS function AND |
* it shouldn't end in a semicolon, e.g.: |
* <br /> |
* Valid: |
* <pre> |
* function() { return SomeValue; } |
* </pre> |
* <pre> |
* // myFunc() is a function defined somewhere in the code |
* myFunc |
* </pre> |
* <br /> |
* Not valid: |
* <pre> |
* function() { return SomeValue; }; |
* </pre> |
* <pre> |
* SomeValue |
* </pre> |
* <br /> |
* Where possible {@link #createDelayedImplementation(Class,String)} is |
* a much cleaner option. |
* <br /> |
* <b>Note</b>: Implies a call to {@link #execute()}. |
* @param interfaceClass |
* @param methodToCodeMap |
* @return |
* @throws net.outlyer.plugins.PluginExecutionException |
* @see #createDelayedImplementation(Class,String) |
*/ |
<T> T createDelayedImplementation(final Class<T> interfaceClass, |
final Map<Method, String> methodToCodeMap) |
throws PluginExecutionException; |
|
/** |
* Run the script |
*/ |
void execute() throws PluginExecutionException; |
|
/** |
* Obtains a reference to the engine currently in use, if any. |
* If called during an execution it will return the current engine, from calling |
* outside will return null. |
* @return Current ScriptEngine |
*/ |
ScriptEngine getCurrentEngine(); |
|
/** |
* Obtains object containing the plugin object |
* <br /> |
* <b>Note</b>: Implies a call to {@link #execute()}. |
* @see #getPluginName |
* @return Plugin object associated to this sandbox |
*/ |
BasePluginObject getPluginObject() throws PluginExecutionException; |
} |
Property changes: |
Added: svn:keywords |
+Rev Id Date |
\ No newline at end of property |