Checkpoint for the Rhino Script engine integration

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2720 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-04-27 09:39:25 +00:00
parent 71f59c540e
commit 1757cec4f8
9 changed files with 214 additions and 15 deletions

View File

@@ -0,0 +1,61 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.repository;
import org.alfresco.error.AlfrescoRuntimeException;
/**
* @author Kevin Roast
*/
public class ScriptException extends AlfrescoRuntimeException
{
/**
* @param msgId
*/
public ScriptException(String msgId)
{
super(msgId);
}
/**
* @param msgId
* @param cause
*/
public ScriptException(String msgId, Throwable cause)
{
super(msgId, cause);
}
/**
* @param msgId
* @param params
*/
public ScriptException(String msgId, Object[] params)
{
super(msgId, params);
}
/**
* @param msgId
* @param msgParams
* @param cause
*/
public ScriptException(String msgId, Object[] msgParams, Throwable cause)
{
super(msgId, msgParams, cause);
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.repository;
import java.io.Writer;
import java.util.Map;
/**
* Script Service.
* <p>
* Provides an interface to services for executing the JavaScript engine against a script file
* against a Java object based scripting data model.
* <p>
* The template file can either be in the repository (passed as NodeRef string) or on the classpath.
* Also a script String can be passed directly to the service via the executeScriptString() methods.
* Java objects are passed into the scripting engine and methods can be accessed directly from the script.
* <p>
* A script is executed within a single transaction, any modifications to nodes or properties that fail
* and cause a rollback will rollback the entire script transaction.
*
* @author Kevin Roast
*/
public interface ScriptService
{
/**
* Process a script against the supplied data model.
*
* @param scriptClasspath Script location as qualified classpath name
* @param model Object model to process script against
*
* @return output of the script (may be null or any valid wrapped JavaScript object)
*
* @throws ScriptException
*/
public Object executeScript(String scriptClasspath, Map<String, Object> model)
throws ScriptException;
/**
* Process a script against the supplied data model.
*
* @param scriptRef Script NodeRef location
* @param model Object model to process script against
*
* @return output of the script (may be null or any valid wrapped JavaScript object)
*
* @throws ScriptException
*/
public Object executeScript(NodeRef scriptRef, Map<String, Object> model)
throws ScriptException;
/**
* Process a script against the supplied data model.
*
* @param script Script content as a String.
* @param model Object model to process script against
*
* @return output of the script (may be null or any valid wrapped JavaScript object)
*
* @throws ScriptException
*/
public Object executeScriptString(String script, Map<String, Object> model)
throws ScriptException;
}

View File

@@ -91,8 +91,7 @@ public final class TemplateNode implements Serializable
private Long size = null;
private TemplateImageResolver imageResolver = null;
private TemplateNode parent = null;
private ChildAssociationRef primaryParentAssoc;
private ChildAssociationRef primaryParentAssoc = null;
/**
@@ -494,8 +493,7 @@ public final class TemplateNode implements Serializable
}
/**
*
* @return the primary parent association so we can get at the association QName and the association type QName.
* @return the primary parent association so we can access the association QName and association type QName.
*/
public ChildAssociationRef getPrimaryParentAssoc()
{

View File

@@ -25,8 +25,10 @@ import java.io.Writer;
* and data model.
* <p>
* The service provides a configured list of available template engines. The template file
* can either be in the repository (passed as NodeRef string) or on the classpath. The data
* model is specified to the template engine. The FreeMarker template engine is used by default.
* can either be in the repository (passed as NodeRef string) or on the classpath. Also a template
* can be passed directly as a String using the processTemplateString() methods.
* <p>
* The data model is specified to the template engine. The FreeMarker template engine is used by default.
*
* @author Kevin Roast
*/
@@ -67,7 +69,7 @@ public interface TemplateService
* @throws TemplateException
*/
public String processTemplateString(String engine, String template, Object model)
throws TemplateException;
throws TemplateException;
/**
* Process a given template, provided as a string, against the supplied data model and report the
@@ -81,7 +83,7 @@ public interface TemplateService
* @throws TemplateException
*/
public void processTemplateString(String engine, String template, Object model, Writer out)
throws TemplateException;
throws TemplateException;
/**
* Return a TemplateProcessor instance for the specified engine name.