From do-not-reply at jboss.org Wed Jul 21 04:43:10 2010
Content-Type: multipart/mixed; boundary="===============4015773429716964336=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r2807 -
jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/ws.
Date: Wed, 21 Jul 2010 04:43:10 -0400
Message-ID: <201007210843.o6L8hAkI021899@svn01.web.mwc.hst.phx2.redhat.com>
--===============4015773429716964336==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: tolusha
Date: 2010-07-21 04:43:09 -0400 (Wed, 21 Jul 2010)
New Revision: 2807
Modified:
jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/ws/groovy-scr=
ipts-as-rest-services.xml
Log:
EXOJCR-807: Port the article Groovy Scripts as REST Services
Modified: jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/ws/gro=
ovy-scripts-as-rest-services.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/ws/groovy-sc=
ripts-as-rest-services.xml 2010-07-21 08:00:15 UTC (rev 2806)
+++ jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/ws/groovy-sc=
ripts-as-rest-services.xml 2010-07-21 08:43:09 UTC (rev 2807)
@@ -381,4 +381,102 @@
=
That is all.
+
+
+ Dependencies resolving
+
+ Since WS version 2.2.0-Beta01 and JCR version 1.14.0-Beta01 ther=
e is
+ support of script dependency resolving. If Groovy RESTful service use =
some
+ classes from other Groovy scripts they can be loaded when service will=
be
+ deployed. There is special
+ org.exoplatform.container.component.ComponentPlugin for this
+ (configuration example below).
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.jcr.ext.script.groo=
vy.GroovyScript2RestLoader</target-component>
+ <component-plugin>
+ <name>add groovy repo</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.jcr.ext.script.groovy.Groovy=
ScriptAddRepoPlugin</type>
+ <init-params>
+ <properties-param>
+ <name>repo1</name>
+ <property name=3D"repository" value=3D"repository"/>
+ <property name=3D"workspace" value=3D"production"/>
+ <property name=3D"path" value=3D"/dependencies"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+ It is possible to add more then one dependencies location, just =
one
+ more "properties-param" should be used.
+
+ When Groovy ClassLoader need load class in will try to load from
+ repository "repository", workspace "production" and from folder
+ "/dependencies/...". For example, we have simple Groovy RESTful service
+ :
+
+ package org.exoplatform.groovy.test
+
+import javax.ws.rs.GET
+import javax.ws.rs.Path
+
+import org.exoplatform.groovy.lib.Dependency1
+
+(a)Path("groovy-test-dependency")
+public class TestDependency {
+ =
+ @GET
+ def method() {
+ return new Dependency1().getName()
+ }
+ =
+}
+
+ and other script
+
+ package org.exoplatform.groovy.lib
+
+class Dependency1
+{
+ String name =3D getClass().getName()
+}
+
+ Script org.exoplatform.groovy.lib.Dependency1 MUST be located wi=
th
+ respect to package name. So if we make a decision to store dependencie=
s in
+ repository "repository", workspace "production" and in folder
+ "/dependencies" then full path to org.exoplatform.groovy.lib.Dependenc=
y1
+ must be /dependencies/org/exoplatform/groovy/lib/Dependency1.groovy. If
+ script located as described it will be found automatically when "main"
+ service will be deployed.
+
+
+
+ Security
+
+ Since WS version 2.2.0-Beta01 and JCR version 1.14.0-Beta01 it is
+ possible to configure permissions of Groovy based RESTful services by
+ using special codebase. Let's see how we allow a dynamic (possibly user
+ defined) services to execute with limited permissions.
+
+ Add in existed or create new policy file and add next lines in
+ it
+
+ grant codeBase "file:/groovy/script/jaxrs" {
+};
+
+ In this case groovy services have not any privileges. Detailed l=
ist
+ of JDK permissions available here http://java.sun.com/j2se/1.5.0/docs/guide/security/per=
missions.html#PropertyPermission
+ To give all permissions to Groovy services simply add next in policy
+ file
+
+ grant codeBase "file:/groovy/script/jaxrs" {
+ permission java.security.AllPermission;
+};
+
+ NOTE URL file:/groovy/script/jaxrs is virtual and not need be
+ present on file system.
+
--===============4015773429716964336==--