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

@@ -16,6 +16,7 @@
<import resource="classpath:alfresco/hibernate-context.xml" />
<import resource="classpath:alfresco/ownable-services-context.xml" />
<import resource="classpath:alfresco/template-services-context.xml" />
<import resource="classpath:alfresco/script-services-context.xml" />
<import resource="classpath:alfresco/index-recovery-context.xml" />
<import resource="classpath:alfresco/authority-services-context.xml" />
<import resource="classpath:alfresco/authentication-services-context.xml" />

View File

@@ -784,7 +784,6 @@
</bean>
<!-- Authentication Service -->
<bean id="AuthenticationService" class="org.springframework.aop.framework.ProxyFactoryBean">
@@ -822,7 +821,9 @@
</property>
</bean>
<!-- Template Service -->
<bean id="TemplateService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>org.alfresco.service.cmr.repository.TemplateService</value>
@@ -858,7 +859,47 @@
</property>
</bean>
<!-- Script Service -->
<bean id="ScriptService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>org.alfresco.service.cmr.repository.ScriptService</value>
</property>
<property name="target"><ref bean="scriptService"/></property>
<property name="interceptorNames">
<list>
<idref local="ScriptService_transaction" />
<idref local="exceptionTranslator" />
<idref bean="ScriptService_security" />
<idref local="ScriptService_descriptor" />
</list>
</property>
</bean>
<bean id="ScriptService_transaction" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">${server.transaction.mode.default}</prop>
</props>
</property>
</bean>
<bean id="ScriptService_descriptor" parent="AlfrescoServiceDescriptor">
<property name="interface">
<value>org.alfresco.service.cmr.repository.ScriptService</value>
</property>
<property name="description">
<value>ScriptService Service</value>
</property>
</bean>
<!-- File/Folder Service -->
<bean id="FileFolderService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>org.alfresco.service.cmr.model.FileFolderService</value>

View File

@@ -675,4 +675,12 @@
<bean id="TemplateService_security" class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
<!-- ==================== -->
<!-- The Script Service -->
<!-- ==================== -->
<!-- This service currently has no restrictions. -->
<bean id="ScriptService_security" class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
</beans>

View File

@@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="scriptService" class="org.alfresco.repo.jscript.RhinoScriptService">
<property name="nodeService">
<ref bean="NodeService"/>
</property>
<property name="contentService">
<ref bean="ContentService"/>
</property>
</bean>
</beans>

View File

@@ -146,7 +146,6 @@ public class TemplateServiceImpl implements TemplateService, ApplicationContextA
}
}
public String processTemplateString(String engine, String template, Object model)
throws TemplateException
{
@@ -156,7 +155,6 @@ public class TemplateServiceImpl implements TemplateService, ApplicationContextA
}
/**
* Return the TemplateProcessor implementation for the named template engine
*

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
*/