exo-jcr SVN: r2656 - in kernel/trunk/exo.kernel.commons.test: src/main/java/org/exoplatform/commons/test and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-17 11:10:15 -0400 (Thu, 17 Jun 2010)
New Revision: 2656
Modified:
kernel/trunk/exo.kernel.commons.test/pom.xml
kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java
Log:
EXOJCR-756: add log.error()
Modified: kernel/trunk/exo.kernel.commons.test/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.commons.test/pom.xml 2010-06-17 15:00:16 UTC (rev 2655)
+++ kernel/trunk/exo.kernel.commons.test/pom.xml 2010-06-17 15:10:15 UTC (rev 2656)
@@ -24,6 +24,13 @@
<name>eXo Kernel :: Commons :: Test Util</name>
<description>eXo Commons Test Util</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.commons</artifactId>
+ </dependency>
+ </dependencies>
<build>
<plugins>
Modified: kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java
===================================================================
--- kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java 2010-06-17 15:00:16 UTC (rev 2655)
+++ kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java 2010-06-17 15:10:15 UTC (rev 2656)
@@ -18,6 +18,9 @@
*/
package org.exoplatform.commons.test;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
import java.security.Permission;
/**
@@ -29,6 +32,11 @@
{
/**
+ * The logger
+ */
+ private static final Log LOG = ExoLogger.getLogger("org.exoplatform.commons.test.TestSecurityManager");
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -107,8 +115,7 @@
return;
}
- System.out.println("#################");
- se.printStackTrace();
+ LOG.error(se);
throw se;
}
}
13 years, 11 months
exo-jcr SVN: r2655 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-17 11:00:16 -0400 (Thu, 17 Jun 2010)
New Revision: 2655
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
Log:
EXOJCR-756: replace operations on privileged operations for TrasactionManager
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-06-17 14:59:05 UTC (rev 2654)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-06-17 15:00:16 UTC (rev 2655)
@@ -25,6 +25,8 @@
import org.exoplatform.services.transaction.TransactionService;
import org.jboss.cache.transaction.TransactionManagerLookup;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
@@ -346,8 +348,40 @@
LOG.warn("Cannot set the transaction timeout", e);
}
}
+
// Start the transaction
- tm.begin();
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ tm.begin();
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof NotSupportedException)
+ {
+ throw (NotSupportedException)cause;
+ }
+ else if (cause instanceof SystemException)
+ {
+ throw (SystemException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
/**
@@ -356,7 +390,54 @@
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
SecurityException, IllegalStateException, SystemException
{
- tm.commit();
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ tm.commit();
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof RollbackException)
+ {
+ throw (RollbackException)cause;
+ }
+ else if (cause instanceof HeuristicMixedException)
+ {
+ throw (HeuristicMixedException)cause;
+ }
+ else if (cause instanceof HeuristicRollbackException)
+ {
+ throw (HeuristicRollbackException)cause;
+ }
+ else if (cause instanceof SecurityException)
+ {
+ throw (SecurityException)cause;
+ }
+ else if (cause instanceof IllegalStateException)
+ {
+ throw (IllegalStateException)cause;
+ }
+ else if (cause instanceof SystemException)
+ {
+ throw (SystemException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
/**
@@ -378,9 +459,45 @@
/**
* {@inheritDoc}
*/
- public void resume(Transaction tx) throws InvalidTransactionException, IllegalStateException, SystemException
+ public void resume(final Transaction tx) throws InvalidTransactionException, IllegalStateException,
+ SystemException
{
- tm.resume(tx);
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ tm.resume(tx);
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof InvalidTransactionException)
+ {
+ throw (InvalidTransactionException)cause;
+ }
+ else if (cause instanceof IllegalStateException)
+ {
+ throw (IllegalStateException)cause;
+ }
+ else if (cause instanceof SystemException)
+ {
+ throw (SystemException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
/**
@@ -388,7 +505,42 @@
*/
public void rollback() throws IllegalStateException, SecurityException, SystemException
{
- tm.rollback();
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ tm.rollback();
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof IllegalStateException)
+ {
+ throw (IllegalStateException)cause;
+ }
+ else if (cause instanceof SecurityException)
+ {
+ throw (SecurityException)cause;
+ }
+ else if (cause instanceof SystemException)
+ {
+ throw (SystemException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
/**
@@ -413,7 +565,33 @@
*/
public Transaction suspend() throws SystemException
{
- return tm.suspend();
+ PrivilegedExceptionAction<Transaction> action = new PrivilegedExceptionAction<Transaction>()
+ {
+ public Transaction run() throws Exception
+ {
+ return tm.suspend();
+ }
+ };
+ try
+ {
+ return AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof SystemException)
+ {
+ throw (SystemException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
}
}
13 years, 11 months
exo-jcr SVN: r2654 - kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-17 10:59:05 -0400 (Thu, 17 Jun 2010)
New Revision: 2654
Modified:
kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java
Log:
EXOJCR-756: temporary added printStackTrace() for SecurityException
Modified: kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java
===================================================================
--- kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java 2010-06-17 14:34:37 UTC (rev 2653)
+++ kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java 2010-06-17 14:59:05 UTC (rev 2654)
@@ -91,7 +91,8 @@
testCode = true;
}
}
- else if (className.startsWith("org.slf4j.impl.Log4jLoggerFactory"))
+ else if (className.startsWith("org.slf4j.impl.Log4jLoggerFactory")
+ || className.startsWith("com.arjuna.ats.jta.logging.jtaLogger"))
{
return;
}
@@ -106,6 +107,8 @@
return;
}
+ System.out.println("#################");
+ se.printStackTrace();
throw se;
}
}
13 years, 11 months
exo-jcr SVN: r2653 - jcr/trunk/exo.jcr.component.ext.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-06-17 10:34:37 -0400 (Thu, 17 Jun 2010)
New Revision: 2653
Modified:
jcr/trunk/exo.jcr.component.ext/pom.xml
Log:
EXOJCR-751 ext tests enabled
Modified: jcr/trunk/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/pom.xml 2010-06-17 09:44:43 UTC (rev 2652)
+++ jcr/trunk/exo.jcr.component.ext/pom.xml 2010-06-17 14:34:37 UTC (rev 2653)
@@ -166,9 +166,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
- <include>**/**/MetaDataActionTest.java</include>
-
- <!-- include>**/actions/*Test.java</include>
+ <include>**/actions/*Test.java</include>
<include>**/metadata/*Test.java</include>
<include>**/owner/*Test.java</include>
<include>**/registry/*Test.java</include>
@@ -177,7 +175,7 @@
<include>**/groovy/*Test.java</include>
<include>**/replication/*.java</include>
<include>**/replication/external/*.java</include>
- <include>**/replication/async/**/*.java</include -->
+ <include>**/replication/async/**/*.java</include>
</includes>
<excludes>
<exclude>**/BaseStandaloneTest.java</exclude>
13 years, 11 months
exo-jcr SVN: r2652 - in jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules: jcr and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-06-17 05:44:43 -0400 (Thu, 17 Jun 2010)
New Revision: 2652
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/data-container-howto.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/data-container.xml
Modified:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr.xml
Log:
=EXOJCR-742: adding doc about data container
Added: jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/data-container-howto.xml
===================================================================
--- jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/data-container-howto.xml (rev 0)
+++ jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/data-container-howto.xml 2010-06-17 09:44:43 UTC (rev 2652)
@@ -0,0 +1,111 @@
+<?xml version='1.0' ?><!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+ <chapter id="HowtoimplementWorkspaceDataContainer">
+ <title>How-to implement Workspace Data Container</title>
+ <section id="ShortintrointoWorkspacedatacontainerimplementationpractices">
+ <title>Short intro into Workspace data container implementation practices:</title>
+ <orderedlist>
+ <listitem>
+ <para>Read a bit about the <link linkend="JCRWorkspaceDataContainerarchitecturecontract">contract</link>.</para>
+ </listitem>
+ <listitem>
+ <para>Start new implementation project pom.xml with org.exoplatform.jcr parent. (optional, but will makes the development easy)</para>
+ </listitem>
+ <listitem>
+ <para>Update sources of JCR Core and read JavaDoc on
+ <emphasis role="bold">org.exoplatform.services.jcr.storage.WorkspaceDataContainer</emphasis> and
+ <emphasis role="bold">org.exoplatform.services.jcr.storage.WorkspaceStorageConnection</emphasis> interfaces. This two are main part for the implemenation.
+ </para>
+ </listitem>
+ <listitem>
+ <para>Look at
+ <emphasis role="bold">org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager</emphasis> sourcecode, check how data meneger uses container and its connections (see in save() method)
+ </para>
+ </listitem>
+ <listitem>
+ <para>Create
+ <emphasis role="bold">WorkspaceStorageConnection</emphasis> dummy implementation class. It's freeform class, but to be close to the eXo JCR, check how implemented JDBC or SimpleDB containers (
+ <emphasis role="bold">org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection</emphasis> and
+ <emphasis role="bold">org.exoplatform.services.jcr.aws.storage.sdb.SDBWorkspaceStorageConnection</emphasis>). Take in account usage of
+ <emphasis role="bold">ValueStoragePluginProvider</emphasis> in both implementations.Value storage is an useful option for production versions. But leave it to the end of implementation work.
+ </para>
+ </listitem>
+ <listitem>
+ <para>Create the connection implementation unit tests to play TTD. (optional, but takes many benefits for the process)</para>
+ </listitem>
+ <listitem>
+ <para>Implement CRUD starting from the read to write etc. Test the methods using external to the implementation ways of data read/write in your backend.</para>
+ </listitem>
+ <listitem>
+ <para>When all methods of the connection done start
+ <emphasis role="bold">WorkspaceDataContainer</emphasis>. Container class very simple, it's like a factory for the connections only.
+ </para>
+ </listitem>
+ <listitem>
+ <para>Care about container reuseConnection(WorkspaceStorageConnection) method logic. For some backends it cab be same as openConnection(), but for some others it's important to reuse physical backend connection, e.g. to be in same transaction - see JDBC container.</para>
+ </listitem>
+ <listitem>
+ <para>It's almost ready for use in data manager. Start another test and go on.</para>
+ </listitem>
+ </orderedlist>
+ <para>When the container will be ready for run as JCR persistence storage (e.g. for this level testing) it should be configured in Repository configuration.</para>
+ <para>Assuming that our new implementation class name is
+ <emphasis role="bold">org.project.jcr.impl.storage.MyWorkspaceDataContainer</emphasis>.
+ </para>
+ <programlisting> <repository-service default-repository="repository">
+ <repositories>
+ <repository name="repository" system-workspace="production" default-workspace="production">
+ .............
+ <workspaces>
+ <workspace name="production">
+ <container class="org.project.jcr.impl.storage.MyWorkspaceDataContainer">
+ <properties>
+ <property name="propertyName1" value="propertyValue1" />
+ <property name="propertyName2" value="propertyValue2" />
+ .......
+ <property name="propertyNameN" value="propertyValueN" />
+ </properties>
+ <value-storages>
+ .......
+ </value-storages>
+ </container>
+
+</programlisting>
+ <para>Container can be configured using set properties.</para>
+ </section>
+ <section id="Valuestorageusagenotes">
+ <title>Value storage usage notes:</title>
+ <para>Value storages pluggable to the container but if it used the container implementation should respect set of interfaces and external storage usage principles.</para>
+ <para>If the container have
+ <emphasis role="bold">ValueStoragePluginProvider</emphasis> (e.g. via constructor) it's just few methods to manipulate external Values data.
+ </para>
+ <programlisting>// get channel for ValueData write (add or update)
+ValueIOChannel channel = valueStorageProvider.getApplicableChannel(data, i);
+if (channel == null) {
+ // write
+ channel.write(data.getIdentifier(), vd);
+ // obtain storage id, id can be used for linkage of external ValueData and PropertyData in main backend
+ String storageId = channel.getStorageId();
+}
+
+....
+
+// delete all Property Values in external storage
+ValueIOChannel channel = valueStorageProvider.getChannel(storageId);
+channel.delete(propertyData.getIdentifier());
+
+....
+
+// read ValueData from external storage
+ValueIOChannel channel = valueStorageProvider.getChannel(storageId);
+ValueData vdata = channel.read(propertyData.getIdentifier(), orderNumber, maxBufferSize);
+
+</programlisting>
+ <important>
+ <title>Important</title>
+ <para>After a sequence of write and/or delete operations on the storage channel, the channel should be committed (or rolled back on an error). See
+ <emphasis role="bold">ValueIOChannel.commit()</emphasis> and
+ <emphasis role="bold">ValueIOChannel.rollback()</emphasis> and how those methods used in JDBC container.
+ </para>
+ </important>
+ </section>
+ </chapter>
Added: jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/data-container.xml
===================================================================
--- jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/data-container.xml (rev 0)
+++ jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/data-container.xml 2010-06-17 09:44:43 UTC (rev 2652)
@@ -0,0 +1,391 @@
+<?xml version='1.0' ?><!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="JCRWorkspaceDataContainerarchitecturecontract">
+ <title>JCR Workspace Data Container (architecture contract)</title>
+ <section id="Goals">
+ <title>Goals</title>
+ <itemizedlist>
+ <listitem>
+ <para>Cover Workspace Data Container implementation requirements</para>
+ </listitem>
+ <listitem>
+ <para>Describe container life cycle</para>
+ </listitem>
+ <listitem>
+ <para>Describe relations between container and high-level DataManagers</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section id="Concepts">
+ <title>Concepts</title>
+ <section id="Containerandconnection">
+ <title>Container and connection</title>
+ <para>Workspace Data Container (container) serves Repository Workspace persistent storage.
+ WorkspacePersistentDataManager (data manager) uses container to perform CRUD operation on the persistent
+ storage.
+ Access to the storage in data manager makes via storage connection obtained from the container (WorkspaceDataContainer
+ interface implemenatiton). Each connection represents a transaction on the storage. Storage Connection
+ (connection) should be an implementation of WorkspaceStorageConnection.</para>
+ <itemizedlist>
+ <listitem>
+ <para>Container acts as a factory of a new storage connections. Usually this method is designed to be
+ synchronized, to avoid possible concurrent issues.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>WorkspaceStorageConnection openConnection() throws RepositoryException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Open read-only WorkspaceStorageConnection. Read-only connections can be potentially a bit faster in
+ some cases.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException;
+</programlisting>
+ <note>
+ <title>*EXPERIMENTAL*</title>
+ <para>Read-only WorkspaceStorageConnection is experimental feature and not currently handled in JCR.
+ Actually such connections didn't prove their performance, so JCR Core doesn't use them.</para>
+ </note>
+ <itemizedlist>
+ <listitem>
+ <para>Storage connection might be reused also. Reuse of the connection means reuse of physical resource
+ (e.g. JDBC Connection) allocated by one connection in another. This feature used in data manager for
+ saving ordinary and system changes on the system Workspace. But the reuse is an optional feature and
+ it works only if possible, otherwise the new connection opens.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original) throws RepositoryException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>When checking Same-Name Siblings (SNS) existence, JCR Core can use new connection or not. This is
+ defined via Workspace Data Container configuration and retrieved using special method.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>boolean isCheckSNSNewConnection();
+</programlisting>
+ <important>
+ <title>New connection for SNS</title>
+ <para> Sometimes there is a need of checking if there are some nodes with equal names. Usually new Workspace
+ Storage Connection is used for purpose. The improvement came from JDBC Workspace Data Container, which
+ shows better performance on Oracle RDBMS when using new connection for checking SNS existence. But later
+ this led to deadlocks on Sybase RDBMS, so feature was made as an optional and configurable.</para>
+ </important>
+ <para>Container initialization based on a configuration only. After the container created it's not possible to
+ change parameters. Configuration consists of implementation class and set of properties and Value Storages
+ configuration.</para>
+ </section>
+ <section id="Valuestorages">
+ <title>Value storages</title>
+ <para>Container provides optional special mechanism for Value storing. It's possible to configure external
+ Value Storages via container configuration (available only via configuration).
+ Value Storage works as fully independent pluggable storage. All required parameters storage obtains from its
+ configuration. Some storages are possible for one container.
+ Configuration describes such parameters as ValueStoragePluginimplementation class, set of implementation specific properties and
+ filters. The filters declares criteria for Value matching to the storage. Only matched Property Values will
+ be stored. So, in common case, the storage might contains only the part of the Workspace content.
+ Value Storages are very useful for BLOB storing. E.g. storing on the File System instead of a database.</para>
+ <para>Container obtains Values Storages from ValueStoragePluginProvider component. Provider acts as a factory
+ of Value channels (ValueIOChannel). Channel provides all CRUD operation for Value Storage respecting the
+ transaction manner of work (how it can be possible due to implementation specifics of the storages).</para>
+ </section>
+ <section id="Lifecycle">
+ <title>Lifecycle</title>
+ <para>Container used by data manager for read and write operations.
+ Read operations (getters) uses connection once and close it on the finally.
+ Write operations performs in commit method as a sequence of create/update calls and final commit (or rollback on error).
+ Writes uses one connection (or two - another for system workspace) per commit call. One connection
+ guaranties transaction support for write operations.
+ Commit or rollback should free/clean all resources consumed by the container (connection).</para>
+ </section>
+ <section id="Valuestoragelifecycle">
+ <title>Value storage lifecycle</title>
+ <para>Value storage used from the container inside. Reads are related to a container reads. Writes are commit
+ related.
+ Container (connection) implementation should use transaction capabilities of the storages in same way as for other
+ operations.</para>
+ </section>
+ </section>
+ <section id="Requirements">
+ <title>Requirements</title>
+ <para>Connection create and reuse should be a thread safe operation.
+ Connection provides CRUD operations support on the storage.</para>
+ <section id="Readoperations">
+ <title>Read operations</title>
+ <itemizedlist>
+ <listitem>
+ <para>Reads ItemData from the storage by item identifier.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Reads ItemData from the storage using item's parent and name relative the parent location.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException,IllegalStateException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Reads List of NodeData from the storage using item's parent location.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Reads List of PropertyData from the storage using item's parent location</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Reads List of PropertyData with empty ValueData from the storage using item's parent location.</para>
+ </listitem>
+ </itemizedlist>
+ <para>This methiod specially dedicated for non-content modification operations (e.g. Items delete).</para>
+ <programlisting>List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Reads List of PropertyData from the storage using item's parent location.</para>
+ </listitem>
+ </itemizedlist>
+ <para>It's REFERENCE type Properties referencing Node with given nodeIdentifier. See more in javax.jcr.Node.getReferences()</para>
+ <programlisting>List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException,IllegalStateException,UnsupportedOperationException;
+</programlisting>
+ </section>
+ <section id="Writeoperations">
+ <title>Write operations</title>
+ <itemizedlist>
+ <listitem>
+ <para>Adds single NodeData.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void add(NodeData data) throws RepositoryException,UnsupportedOperationException,InvalidItemStateException,IllegalStateException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Adds single PropertyData.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void add(PropertyData data) throws RepositoryException,UnsupportedOperationException,InvalidItemStateException,IllegalStateException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Updates NodeData.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void update(NodeData data) throws RepositoryException,UnsupportedOperationException,InvalidItemStateException,IllegalStateException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Updates PropertyData.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void update(PropertyData data) throws RepositoryException,UnsupportedOperationException,InvalidItemStateException,IllegalStateException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Renames NodeData using Node identifier and new name and index from the data.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void rename(NodeData data) throws RepositoryException,UnsupportedOperationException,InvalidItemStateException,IllegalStateException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Deletes NodeData.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void delete(NodeData data) throws RepositoryException,UnsupportedOperationException,InvalidItemStateException,IllegalStateException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Deletes PropertyData.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void delete(PropertyData data) throws RepositoryException,UnsupportedOperationException,InvalidItemStateException,IllegalStateException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Persist changes and closes connection. It can be database transaction commit for instance etc.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void commit() throws IllegalStateException, RepositoryException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Refuses persistent changes and closes connection. It can be database transaction rollback for instance etc.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void rollback() throws IllegalStateException, RepositoryException;
+</programlisting>
+ <para>All methods throws IllegalStateException if connection is closed.
+ UnsupportedOperationException if the method is not supported (e.g. JCR Level 1 implementation etc).
+ RepositoryException if some error occurs during preparation, validation or persistence.</para>
+ </section>
+ <section id="Stateoperations">
+ <title>State operations</title>
+ <itemizedlist>
+ <listitem>
+ <para>Returns true if connection can be used.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>boolean isOpened();
+</programlisting>
+ </section>
+ <section id="Validationofwriteoperations">
+ <title>Validation of write operations</title>
+ <para>Container have to care about storage consistency (JCR constraints) on write operations:
+ (InvalidItemStateException should be thrown according the spec)
+ At least following checks should be performed:</para>
+ <itemizedlist>
+ <listitem>
+ <para>On ADD errors</para>
+ <itemizedlist>
+ <listitem>
+ <para>Parent not found. Condition: Parent ID (Item with ID is not exists).</para>
+ </listitem>
+ <listitem>
+ <para>Item already exists. Condition: ID (Item with ID already exists).</para>
+ </listitem>
+ <listitem>
+ <para>Item already exists. Condition: Parent ID, Name, Index (Item with parent ID, name and index already exists).</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ <itemizedlist>
+ <listitem>
+ <para>On DELETE errors</para>
+ <itemizedlist>
+ <listitem>
+ <para>Item not found. Condition ID.</para>
+ </listitem>
+ <listitem>
+ <para>Can not delete parent till children exists.</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ <itemizedlist>
+ <listitem>
+ <para>On UPDATE errors</para>
+ <itemizedlist>
+ <listitem>
+ <para>Item not found. Condition ID.</para>
+ </listitem>
+ <listitem>
+ <para>Item already exists with higher Version. Condition: ID, Version (Some Session had updated Item with ID prior this update).</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section id="Consistencyofsave">
+ <title>Consistency of save</title>
+ <para>The container (connection) should implement consistency of Commit (Rollback) in
+ <emphasis role="bold">transaction manner</emphasis>.
+ I.e. if set of operations were performed
+ <emphasis role="bold">before</emphasis> the future
+ <emphasis role="bold">Commit</emphasis> and another next operation
+ <emphasis role="bold">fails</emphasis>.
+ <emphasis role="bold">It should be possible to</emphasis> rollback applied changes using
+ <emphasis role="bold">Rollback</emphasis> command.
+ </para>
+ </section>
+ </section>
+ <section id="ValuestoragesAPI">
+ <title>Value storages API</title>
+ <section id="Storagesprovider">
+ <title>Storages provider:</title>
+ <para>Container implementation obtains Values Storages option via ValueStoragePluginProvider component. Provider acts as a factory of Value channels (ValueIOChannel) and has two methods for this purpose:</para>
+ <itemizedlist>
+ <listitem>
+ <para>Return ValueIOChannel matched this property and valueOrderNumer. Null will be returned if no channel matches.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>ValueIOChannel getApplicableChannel(PropertyData property, int valueOrderNumer) throws IOException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Return ValueIOChannel associated with given storageId.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>ValueIOChannel getChannel(String storageId) throws IOException, ValueStorageNotFoundException;
+</programlisting>
+ <para>There is also method for consistency check, but this method doesn't used anywhere and storage implementations has it empty.</para>
+ </section>
+ <section id="Valuestorageplugin">
+ <title>Value storage plugin</title>
+ <para>Provider implementation should use ValueStoragePlugin abstract class as a base for all storage implementations.
+ Plugin provides support for provider implementation methods. Plugin's methods should be implemented:</para>
+ <itemizedlist>
+ <listitem>
+ <para>Initialize this plugin. Used at start time in ValueStoragePluginProvider.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>public abstract void init(Properties props, ValueDataResourceHolder resources) throws RepositoryConfigurationException, IOException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Open ValueIOChannel.Used in ValueStoragePluginProvider.getApplicableChannel(PropertyData, int) and getChannel(String)</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>public abstract ValueIOChannel openIOChannel() throws IOException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Return true if this storage has same storageId.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>public abstract boolean isSame(String valueDataDescriptor);
+</programlisting>
+ </section>
+ <section id="ValueIOchannel">
+ <title>Value I/O channel</title>
+ <para>Channel should implement ValueIOChannel interface. CRUD operation for Value Storage:</para>
+ <itemizedlist>
+ <listitem>
+ <para>Read Property value.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>ValueData read(String propertyId, int orderNumber, int maxBufferSize) throws IOException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Add or update Property value.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void write(String propertyId, ValueData data) throws IOException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Delete Property all values.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void delete(String propertyId) throws IOException;
+</programlisting>
+ </section>
+ <section id="Transactionsupportviachannel">
+ <title>Transaction support via channel</title>
+ <para>Modification operations should be applied only on commit. Rollback is required for data created cleanup.</para>
+ <itemizedlist>
+ <listitem>
+ <para>Commit channel changes.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void commit() throws IOException;
+</programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>Rollback channel changes.</para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>void rollback() throws IOException;
+</programlisting>
+ </section>
+ </section>
+ </chapter>
Modified: jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr.xml
===================================================================
--- jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr.xml 2010-06-17 09:29:12 UTC (rev 2651)
+++ jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr.xml 2010-06-17 09:44:43 UTC (rev 2652)
@@ -55,5 +55,14 @@
<!-- statistics configs -->
<xi:include href="jcr/statistics.xml"
- xmlns:xi="http://www.w3.org/2001/XInclude" />
+ xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+ <!-- data container configs -->
+
+ <xi:include href="jcr/data-container.xml"
+ xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+ <xi:include href="jcr/data-container-howto.xml"
+ xmlns:xi="http://www.w3.org/2001/XInclude" />
+
</part>
13 years, 11 months
exo-jcr SVN: r2651 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services: jcr/impl/dataflow/persistent and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-17 05:29:12 -0400 (Thu, 17 Jun 2010)
New Revision: 2651
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
Log:
EXOJCR-756: replace operations on privileged operations
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java 2010-06-17 09:24:40 UTC (rev 2650)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java 2010-06-17 09:29:12 UTC (rev 2651)
@@ -29,6 +29,9 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.List;
import java.util.Map;
@@ -55,17 +58,17 @@
* The nested cache loader
*/
private final CacheLoader cl;
-
+
/**
* The related cache
*/
private CacheSPI cache;
-
+
/**
* The configuration of the current cache loader
*/
private IndividualCacheLoaderConfig config;
-
+
/**
* The default constructor
* @param cl the cache loader that will be managed by the controller
@@ -73,14 +76,38 @@
public ControllerCacheLoader(CacheLoader cl)
{
this.cl = cl;
- }
+ }
/**
* @see org.jboss.cache.loader.CacheLoader#commit(java.lang.Object)
*/
- public void commit(Object tx) throws Exception
+ public void commit(final Object tx) throws Exception
{
- cl.commit(tx);
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ cl.commit(tx);
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+
+ if (cause instanceof Exception)
+ {
+ throw (Exception)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
/**
@@ -96,13 +123,13 @@
if (node != null)
{
// The node already exists in the local cache, so we return true
- return true;
+ return true;
}
else
{
// The node doesn't exist in the local cache, so we need to check through the nested
// cache loader
- return cl.exists(name);
+ return cl.exists(name);
}
}
// All the data is loaded at startup, so no need to call the nested cache loader for another
@@ -123,13 +150,13 @@
if (node != null)
{
// The node already exists in the local cache, so we return the corresponding data
- return node.getDataDirect();
+ return node.getDataDirect();
}
else
{
// The node doesn't exist in the local cache, so we need to check through the nested
// cache loader
- return cl.get(name);
+ return cl.get(name);
}
}
// All the data is loaded at startup, so no need to call the nested cache loader for another
@@ -145,11 +172,11 @@
if (cache.getCacheStatus() == CacheStatus.STARTING)
{
// Try to get the list of children name from the nested cache loader
- return cl.getChildrenNames(fqn);
+ return cl.getChildrenNames(fqn);
}
// All the data is loaded at startup, so no need to call the nested cache loader for another
// cache status other than CacheStatus.STARTING
- return null;
+ return null;
}
/**
@@ -179,9 +206,34 @@
/**
* @see org.jboss.cache.loader.CacheLoader#prepare(java.lang.Object, java.util.List, boolean)
*/
- public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
+ public void prepare(final Object tx, final List<Modification> modifications, final boolean onePhase)
+ throws Exception
{
- cl.prepare(tx, modifications, onePhase);
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ cl.prepare(tx, modifications, onePhase);
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+
+ if (cause instanceof Exception)
+ {
+ throw (Exception)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
/**
@@ -205,14 +257,14 @@
*/
public Object put(final Fqn name, final Object key, final Object value) throws Exception
{
-
+
return SecurityHelper.doPriviledgedIOExceptionAction(new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
{
- public Object run() throws Exception
- {
- return cl.put(name, key, value);
- }
- });
+ return cl.put(name, key, value);
+ }
+ });
}
/**
@@ -242,9 +294,17 @@
/**
* @see org.jboss.cache.loader.CacheLoader#rollback(java.lang.Object)
*/
- public void rollback(Object tx)
+ public void rollback(final Object tx)
{
- cl.rollback(tx);
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ cl.rollback(tx);
+ return null;
+ }
+ };
+ AccessController.doPrivileged(action);
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java 2010-06-17 09:24:40 UTC (rev 2650)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java 2010-06-17 09:29:12 UTC (rev 2651)
@@ -4,6 +4,10 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
import javax.jcr.InvalidItemStateException;
import javax.jcr.ItemExistsException;
import javax.jcr.RepositoryException;
@@ -49,12 +53,94 @@
protected void commitTx() throws SecurityException, IllegalStateException, RollbackException,
HeuristicMixedException, HeuristicRollbackException, SystemException
{
- txManager.commit(); // commit global tx
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ txManager.commit(); // commit global tx
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof RollbackException)
+ {
+ throw (RollbackException)cause;
+ }
+ else if (cause instanceof HeuristicMixedException)
+ {
+ throw (HeuristicMixedException)cause;
+ }
+ else if (cause instanceof HeuristicRollbackException)
+ {
+ throw (HeuristicRollbackException)cause;
+ }
+ else if (cause instanceof SecurityException)
+ {
+ throw (SecurityException)cause;
+ }
+ else if (cause instanceof IllegalStateException)
+ {
+ throw (IllegalStateException)cause;
+ }
+ else if (cause instanceof SystemException)
+ {
+ throw (SystemException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
protected void rollbackTx() throws NotSupportedException, SystemException
{
- txManager.rollback(); // rollback global tx
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ txManager.rollback(); // rollback global tx
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof SecurityException)
+ {
+ throw (SecurityException)cause;
+ }
+ else if (cause instanceof IllegalStateException)
+ {
+ throw (IllegalStateException)cause;
+ }
+ else if (cause instanceof SystemException)
+ {
+ throw (SystemException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-06-17 09:24:40 UTC (rev 2650)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-06-17 09:29:12 UTC (rev 2651)
@@ -356,54 +356,7 @@
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
SecurityException, IllegalStateException, SystemException
{
- PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- tm.commit();
- return null;
- }
- };
- try
- {
- AccessController.doPrivileged(action);
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof RollbackException)
- {
- throw (RollbackException)cause;
- }
- else if (cause instanceof HeuristicMixedException)
- {
- throw (HeuristicMixedException)cause;
- }
- else if (cause instanceof HeuristicRollbackException)
- {
- throw (HeuristicRollbackException)cause;
- }
- else if (cause instanceof SecurityException)
- {
- throw (SecurityException)cause;
- }
- else if (cause instanceof IllegalStateException)
- {
- throw (IllegalStateException)cause;
- }
- else if (cause instanceof SystemException)
- {
- throw (SystemException)cause;
- }
- else if (cause instanceof RuntimeException)
- {
- throw (RuntimeException)cause;
- }
- else
- {
- throw new RuntimeException(cause);
- }
- }
+ tm.commit();
}
/**
@@ -435,42 +388,7 @@
*/
public void rollback() throws IllegalStateException, SecurityException, SystemException
{
- PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- tm.rollback();
- return null;
- }
- };
- try
- {
- AccessController.doPrivileged(action);
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof SecurityException)
- {
- throw (SecurityException)cause;
- }
- else if (cause instanceof IllegalStateException)
- {
- throw (IllegalStateException)cause;
- }
- else if (cause instanceof SystemException)
- {
- throw (SystemException)cause;
- }
- else if (cause instanceof RuntimeException)
- {
- throw (RuntimeException)cause;
- }
- else
- {
- throw new RuntimeException(cause);
- }
- }
+ tm.rollback();
}
/**
13 years, 11 months
exo-jcr SVN: r2650 - in kernel/trunk/exo.kernel.container/src: main/java/org/exoplatform/container/definition and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-06-17 05:24:40 -0400 (Thu, 17 Jun 2010)
New Revision: 2650
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
Log:
EXOJCR-795: Unexpected behavior of the method PortalContainer.isScopeValid()
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java 2010-06-17 09:03:54 UTC (rev 2649)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java 2010-06-17 09:24:40 UTC (rev 2650)
@@ -77,7 +77,7 @@
return Collections.unmodifiableSet(profiles);
}
- Log log = ExoLogger.getLogger("exo.kernel.container.ExoContainer");
+ static Log log = ExoLogger.getLogger("exo.kernel.container.ExoContainer");
private Map<String, ComponentLifecyclePlugin> componentLifecylePlugin_ =
new HashMap<String, ComponentLifecyclePlugin>();
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2010-06-17 09:03:54 UTC (rev 2649)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2010-06-17 09:24:40 UTC (rev 2650)
@@ -428,6 +428,12 @@
return null;
}
String portalContainerName = CONFIG.getPortalContainerName(context.getServletContextName());
+ if (portalContainerName == null)
+ {
+ log.warn("The Servlet Context '" + context.getServletContextName() + "' has not been registered"
+ + " has a dependency of any PortalContainerDefinitions.");
+ return null;
+ }
RootContainer root = RootContainer.getInstance();
return root.getPortalContainer(portalContainerName);
}
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-06-17 09:03:54 UTC (rev 2649)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-06-17 09:24:40 UTC (rev 2650)
@@ -397,14 +397,24 @@
{
throw new IllegalArgumentException("The context name cannot be null");
}
- final List<String> result = scopes.get(contextName);
- if (result == null || result.isEmpty())
+ if (scopes.isEmpty())
{
- // we assume the old behavior is expected
+ // we assume that the old behavior is expected
final String portalContainerName =
portalContainerNames.contains(contextName) ? contextName : defaultDefinition.getName();
return Collections.singletonList(portalContainerName);
}
+ final List<String> result = scopes.get(contextName);
+ if (result == null || result.isEmpty())
+ {
+ // This context has not been added as dependency of any portal containers
+ if (portalContainerNames.contains(contextName))
+ {
+ // The given context is a portal container
+ return Collections.singletonList(contextName);
+ }
+ return Collections.emptyList();
+ }
return result;
}
@@ -425,11 +435,16 @@
// The given context name is a context name of a portal container
return contextName;
}
+ else if (scopes.isEmpty())
+ {
+ // we assume that the old behavior is expected
+ return defaultDefinition.getName();
+ }
final List<String> result = scopes.get(contextName);
if (result == null || result.isEmpty())
{
- // we assume the old behavior is expected
- return defaultDefinition.getName();
+ // This context has not been added as dependency of any portal containers
+ return null;
}
return result.get(0);
}
@@ -524,16 +539,11 @@
*/
public boolean isScopeValid(String portalContainerName, String contextName)
{
- final List<String> result = scopes.get(contextName);
- if (result == null || result.isEmpty())
+ if (portalContainerName == null)
{
- // we assume the old behavior is expected
- return true;
- }
- else
- {
- return result.contains(portalContainerName);
- }
+ throw new IllegalArgumentException("The portal container name cannot be null");
+ }
+ return getPortalContainerNames(contextName).contains(portalContainerName);
}
/**
Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-06-17 09:03:54 UTC (rev 2649)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-06-17 09:24:40 UTC (rev 2650)
@@ -206,9 +206,10 @@
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
// Needed for backward compatibility
- assertTrue(config.isScopeValid("foo", "foo"));
- assertTrue(config.isScopeValid("myPortal", "foo"));
- assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
+ assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
+ assertFalse(config.isScopeValid("foo", "foo"));
+ assertFalse(config.isScopeValid("myPortal", "foo"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
assertFalse(config.hasDefinition());
// Empty with AddDependencies, AddDependenciesBefore and AddDependenciesAfter
@@ -233,15 +234,12 @@
assertTrue(names != null && !names.isEmpty());
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
- assertTrue(names != null && !names.isEmpty());
- assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
+ assertTrue(names != null && names.isEmpty());
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
- assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal"));
- assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config
- .getPortalContainerName("myPortal-pcdef"));
+ assertNull(config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("foo"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal-pcdef"));
@@ -287,9 +285,11 @@
assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
// Needed for backward compatibility
- assertTrue(config.isScopeValid("foo", "foo"));
+ assertFalse(config.isScopeValid("foo", "foo"));
assertTrue(config.isScopeValid("myPortal", "foo"));
- assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
+ assertTrue(config.isScopeValid("myPortal", "myPortal"));
+ assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertTrue(config.hasDefinition());
// Without dependencies and with no portal container name
@@ -348,9 +348,11 @@
assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
// Needed for backward compatibility
- assertTrue(config.isScopeValid("foo", "foo"));
+ assertFalse(config.isScopeValid("foo", "foo"));
assertTrue(config.isScopeValid("myPortal", "foo"));
- assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
+ assertTrue(config.isScopeValid("myPortal", "myPortal"));
+ assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertTrue(config.hasDefinition());
// Without dependencies and with default portal container definition
@@ -369,17 +371,14 @@
assertTrue(names.contains("myPortal-dpcdef"));
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
- assertTrue(names != null && !names.isEmpty());
- assertEquals(1, names.size());
- assertEquals("myPortal-dpcdef", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal-dpcdef", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
- assertEquals("myPortal-dpcdef", config.getPortalContainerName("foo"));
- assertEquals("myPortal-dpcdef", config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest-dpcdef", config.getRestContextName("foo"));
assertEquals("myRest-dpcdef", config.getRestContextName("myPortal"));
@@ -434,13 +433,12 @@
assertEquals(1, names.size());
assertEquals("myPortal-dpcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal-dpcdef", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-dpcdef", config.getPortalContainerName("foo"));
- assertEquals("myPortal-dpcdef", config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest-dpcdef", config.getRestContextName("foo"));
assertEquals("myRest-dpcdef", config.getRestContextName("myPortal"));
@@ -488,6 +486,8 @@
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "fooY"));
assertTrue(config.hasDefinition());
for (String profile : profiles)
13 years, 11 months
exo-jcr SVN: r2649 - in kernel/branches/2.2.x/exo.kernel.container/src: test/java/org/exoplatform/container/definition and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-06-17 05:03:54 -0400 (Thu, 17 Jun 2010)
New Revision: 2649
Modified:
kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
Log:
EXOJCR-795: Inconsistency issue between the methods getPortalContainerNames and isScopeValid has been fixed
Modified: kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-06-17 08:55:48 UTC (rev 2648)
+++ kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-06-17 09:03:54 UTC (rev 2649)
@@ -539,26 +539,11 @@
*/
public boolean isScopeValid(String portalContainerName, String contextName)
{
- if (portalContainerNames.contains(contextName))
+ if (portalContainerName == null)
{
- // The given context name is a context name of a portal container
- return true;
- }
- else if (scopes.isEmpty())
- {
- // we assume that the old behavior is expected
- return defaultDefinition.getName().equals(portalContainerName);
+ throw new IllegalArgumentException("The portal container name cannot be null");
}
- final List<String> result = scopes.get(contextName);
- if (result == null || result.isEmpty())
- {
- // This context has not been added as dependency of any portal containers
- return false;
- }
- else
- {
- return result.contains(portalContainerName);
- }
+ return getPortalContainerNames(contextName).contains(portalContainerName);
}
/**
Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-06-17 08:55:48 UTC (rev 2648)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-06-17 09:03:54 UTC (rev 2649)
@@ -486,6 +486,7 @@
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal"));
assertFalse(config.isScopeValid("myPortal-pcdef", "fooY"));
assertTrue(config.hasDefinition());
13 years, 11 months
exo-jcr SVN: r2648 - kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-17 04:55:48 -0400 (Thu, 17 Jun 2010)
New Revision: 2648
Modified:
kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java
Log:
EXOJCR-756: add RequestHandlerImpl in exclude for check permission
Modified: kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java
===================================================================
--- kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java 2010-06-17 08:39:29 UTC (rev 2647)
+++ kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java 2010-06-17 08:55:48 UTC (rev 2648)
@@ -27,6 +27,7 @@
*/
public class TestSecurityManager extends SecurityManager
{
+
/**
* {@inheritDoc}
*/
@@ -60,6 +61,12 @@
return;
}
+ // workaround for tests
+ if (fileName.equals("RequestHandlerImpl.java"))
+ {
+ return;
+ }
+
if (fileName.startsWith("Test") || fileName.endsWith("Test.java")
|| fileName.endsWith("TestBase.java") || fileName.equals("Probe.java")
|| fileName.equals("ExportBase.java"))
13 years, 11 months
exo-jcr SVN: r2647 - in ws/trunk: exo.ws.rest.ext and 7 other directories.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-06-17 04:39:29 -0400 (Thu, 17 Jun 2010)
New Revision: 2647
Added:
ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/
ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/GroovyJaxrsPublisher.java
ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/BaseTest.java
ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/
ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyContextParamTest.java
ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyExoComponentTest.java
ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySimpleTest.java
ws/trunk/exo.ws.rest.ext/src/test/resources/conf/
ws/trunk/exo.ws.rest.ext/src/test/resources/conf/standalone/
ws/trunk/exo.ws.rest.ext/src/test/resources/groovy1.groovy
ws/trunk/exo.ws.rest.ext/src/test/resources/groovy2.groovy
Removed:
ws/trunk/exo.ws.rest.ext/src/test/resources/standalone/
Modified:
ws/trunk/exo.ws.rest.ext/pom.xml
ws/trunk/exo.ws.rest.ext/src/test/resources/conf/standalone/test-configuration.xml
ws/trunk/pom.xml
Log:
EXOJCR-793 : support for groovy based services
Modified: ws/trunk/exo.ws.rest.ext/pom.xml
===================================================================
--- ws/trunk/exo.ws.rest.ext/pom.xml 2010-06-17 08:34:18 UTC (rev 2646)
+++ ws/trunk/exo.ws.rest.ext/pom.xml 2010-06-17 08:39:29 UTC (rev 2647)
@@ -46,6 +46,10 @@
<artifactId>exo.core.component.xml-processing</artifactId>
</dependency>
<dependency>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.script.groovy</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.exoplatform.ws</groupId>
<artifactId>exo.ws.commons</artifactId>
</dependency>
@@ -54,6 +58,11 @@
<artifactId>exo.ws.rest.core</artifactId>
</dependency>
<dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.testframework</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
</dependency>
@@ -81,6 +90,10 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
</dependency>
</dependencies>
</project>
Added: ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/GroovyJaxrsPublisher.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/GroovyJaxrsPublisher.java (rev 0)
+++ ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/GroovyJaxrsPublisher.java 2010-06-17 08:39:29 UTC (rev 2647)
@@ -0,0 +1,217 @@
+/**
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.rest.ext.groovy;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyCodeSource;
+
+import org.exoplatform.services.rest.PerRequestObjectFactory;
+import org.exoplatform.services.rest.impl.ResourceBinder;
+import org.exoplatform.services.script.groovy.GroovyScriptInstantiator;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+/**
+ * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class GroovyJaxrsPublisher
+{
+
+ /** Default character set name. */
+ static final String DEFAULT_CHARSET_NAME = "UTF-8";
+
+ /** Default character set. */
+ static final Charset DEFAULT_CHARSET = Charset.forName(DEFAULT_CHARSET_NAME);
+
+ protected final ResourceBinder binder;
+
+ protected final GroovyScriptInstantiator instantiator;
+
+ protected GroovyClassLoader gcl;
+
+ /**
+ * Create GroovyJaxrsPublisher which is able publish per-request and
+ * singleton resources. Any required dependencies for per-request resource
+ * injected by {@link PerRequestObjectFactory}, instance of singleton
+ * resources will be created by {@link GroovyScriptInstantiator}.
+ *
+ * @param binder resource binder
+ * @param instantiator instantiate java object from given groovy source
+ */
+ public GroovyJaxrsPublisher(ResourceBinder binder, GroovyScriptInstantiator instantiator)
+ {
+ this.binder = binder;
+ this.instantiator = instantiator;
+ ClassLoader cl = getClass().getClassLoader();
+ this.gcl = new GroovyClassLoader(cl);
+ }
+
+ /**
+ * Create GroovyJaxrsPublisher which is able public per-request resources
+ * only. This is default behavior for RESTful services. Any required
+ * dependencies for resource injected by {@link PerRequestObjectFactory} in
+ * runtime.
+ *
+ * @param binder resource binder
+ */
+ public GroovyJaxrsPublisher(ResourceBinder binder)
+ {
+ ClassLoader cl = getClass().getClassLoader();
+ this.gcl = new GroovyClassLoader(cl);
+ this.binder = binder;
+ this.instantiator = null;
+ }
+
+ /**
+ * Parse given stream and publish result as per-request RESTful service.
+ *
+ * @param in stream which contains groovy source code of RESTful service
+ * @param name name of resource
+ * @return <code>true</code> if resource was published and <code>false</code>
+ * otherwise
+ */
+ public boolean publishPerRequest(InputStream in, String name)
+ {
+ return publishPerRequest(createCodeSource(in, name));
+ }
+
+ /**
+ * Parse given <code>source</code> and publish result as per-request RESTful
+ * service.
+ *
+ * @param source groovy source code of RESTful service
+ * @param name name of resource
+ * @return <code>true</code> if resource was published and <code>false</code>
+ * otherwise
+ */
+ public boolean publishPerRequest(String source, String name)
+ {
+ byte[] bytes = source.getBytes(DEFAULT_CHARSET);
+ return publishPerRequest(new ByteArrayInputStream(bytes), name);
+ }
+
+ /**
+ * Parse given {@link GroovyCodeSource} and publish result as per-request
+ * RESTful service.
+ *
+ * @param gcs groovy code source which contains source code of RESTful
+ * service
+ * @return <code>true</code> if resource was published and <code>false</code>
+ * otherwise
+ */
+ public boolean publishPerRequest(GroovyCodeSource gcs)
+ {
+ Class<?> rc = gcl.parseClass(gcs);
+ return binder.bind(rc);
+ }
+
+ /**
+ * Parse given stream and publish result as singleton RESTful service.
+ *
+ * @param in stream which contains groovy source code of RESTful service
+ * @param name name of resource
+ * @return <code>true</code> if resource was published and <code>false</code>
+ * otherwise
+ * @throws UnsupportedOperationException if publisher was created without
+ * support of singleton resource, see
+ * {@link #GroovyJaxrsPublisher(ResourceBinder)}
+ */
+ public boolean publishSingleton(InputStream in, String name)
+ {
+ if (instantiator == null)
+ throw new UnsupportedOperationException(
+ "Can't instantiate groovy script. GroovyScriptInstantiator is not set.");
+ return publishSingleton(createCodeSource(in, name));
+ }
+
+ /**
+ * Parse given <code>source</code> and publish result as singleton RESTful
+ * service.
+ *
+ * @param source groovy source code of RESTful service
+ * @param name name of resource
+ * @return <code>true</code> if resource was published and <code>false</code>
+ * otherwise
+ * @throws UnsupportedOperationException if publisher was created without
+ * support of singleton resource, see
+ * {@link #GroovyJaxrsPublisher(ResourceBinder)}
+ */
+ public boolean publishSingleton(String source, String name)
+ {
+ if (instantiator == null)
+ throw new UnsupportedOperationException(
+ "Can't instantiate groovy script. GroovyScriptInstantiator is not set.");
+ byte[] bytes = source.getBytes(DEFAULT_CHARSET);
+ return publishSingleton(new ByteArrayInputStream(bytes), name);
+ }
+
+ /**
+ * Parse given {@link GroovyCodeSource} and publish result as singleton
+ * RESTful service.
+ *
+ * @param gcs groovy code source which contains source code of RESTful
+ * service
+ * @return <code>true</code> if resource was published and <code>false</code>
+ * otherwise
+ * @throws UnsupportedOperationException if publisher was created without
+ * support of singleton resource, see
+ * {@link #GroovyJaxrsPublisher(ResourceBinder)}
+ */
+ public boolean publishSingleton(GroovyCodeSource gcs)
+ {
+ if (instantiator == null)
+ throw new UnsupportedOperationException(
+ "Can't instantiate groovy script. GroovyScriptInstantiator is not set.");
+ Object r = instantiator.instantiateScript(gcs, gcl);
+ return binder.bind(r);
+ }
+
+ /**
+ * Set groovy class loader.
+ *
+ * @param gcl groovy class loader
+ * @throws NullPointerException if <code>gcl == null</code>
+ */
+ public void setGroovyClassLoader(GroovyClassLoader gcl)
+ {
+ if (gcl == null)
+ throw new NullPointerException("GroovyClassLoader may not be null.");
+ this.gcl = gcl;
+ }
+
+ /**
+ * Create {@link GroovyCodeSource} from given stream and name. Code base
+ * 'file:/groovy/script/jaxrs' will be used.
+ *
+ * @param in groovy source code stream
+ * @param name code source name
+ * @return GroovyCodeSource
+ */
+ protected GroovyCodeSource createCodeSource(InputStream in, String name)
+ {
+ GroovyCodeSource gcs =
+ new GroovyCodeSource(in, name == null ? gcl.generateScriptName() : name, "/groovy/script/jaxrs");
+ gcs.setCachable(false);
+ return gcs;
+ }
+}
Property changes on: ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/GroovyJaxrsPublisher.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/BaseTest.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/BaseTest.java (rev 0)
+++ ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/BaseTest.java 2010-06-17 08:39:29 UTC (rev 2647)
@@ -0,0 +1,111 @@
+/**
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.rest.ext;
+
+import junit.framework.TestCase;
+
+import org.exoplatform.container.StandaloneContainer;
+import org.exoplatform.services.rest.ContainerResponseWriter;
+import org.exoplatform.services.rest.ext.groovy.GroovyJaxrsPublisher;
+import org.exoplatform.services.rest.impl.ApplicationContextImpl;
+import org.exoplatform.services.rest.impl.ContainerRequest;
+import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.impl.EnvironmentContext;
+import org.exoplatform.services.rest.impl.InputHeadersMap;
+import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
+import org.exoplatform.services.rest.impl.ProviderBinder;
+import org.exoplatform.services.rest.impl.RequestHandlerImpl;
+import org.exoplatform.services.rest.impl.ResourceBinder;
+import org.exoplatform.services.rest.tools.DummyContainerResponseWriter;
+import org.exoplatform.services.test.mock.MockHttpServletRequest;
+
+import java.io.ByteArrayInputStream;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.MultivaluedMap;
+
+/**
+ * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public abstract class BaseTest extends TestCase
+{
+ protected StandaloneContainer container;
+
+ protected ProviderBinder providers;
+
+ protected ResourceBinder binder;
+
+ protected RequestHandlerImpl requestHandler;
+
+ protected GroovyJaxrsPublisher groovyPublisher;
+
+ public void setUp() throws Exception
+ {
+ StandaloneContainer.setConfigurationPath("src/test/resources/conf/standalone/test-configuration.xml");
+ container = StandaloneContainer.getInstance();
+ binder = (ResourceBinder)container.getComponentInstanceOfType(ResourceBinder.class);
+ requestHandler = (RequestHandlerImpl)container.getComponentInstanceOfType(RequestHandlerImpl.class);
+ // reset providers to be sure it is clean
+ ProviderBinder.setInstance(new ProviderBinder());
+ providers = ProviderBinder.getInstance();
+ ApplicationContextImpl.setCurrent(new ApplicationContextImpl(null, null, providers));
+ binder.clear();
+ groovyPublisher = (GroovyJaxrsPublisher)container.getComponentInstanceOfType(GroovyJaxrsPublisher.class);
+ }
+
+ public void tearDown() throws Exception
+ {
+ }
+
+ public ContainerResponse service(String method, String requestURI, String baseURI,
+ Map<String, List<String>> headers, byte[] data, ContainerResponseWriter writer) throws Exception
+ {
+
+ if (headers == null)
+ headers = new MultivaluedMapImpl();
+
+ ByteArrayInputStream in = null;
+ if (data != null)
+ in = new ByteArrayInputStream(data);
+
+ EnvironmentContext envctx = new EnvironmentContext();
+ HttpServletRequest httpRequest =
+ new MockHttpServletRequest(requestURI, in, in != null ? in.available() : 0, method, headers);
+ envctx.put(HttpServletRequest.class, httpRequest);
+ EnvironmentContext.setCurrent(envctx);
+ ContainerRequest request =
+ new ContainerRequest(method, new URI(requestURI), new URI(baseURI), in, new InputHeadersMap(headers));
+ ContainerResponse response = new ContainerResponse(writer);
+ requestHandler.handleRequest(request, response);
+ return response;
+ }
+
+ public ContainerResponse service(String method, String requestURI, String baseURI,
+ MultivaluedMap<String, String> headers, byte[] data) throws Exception
+ {
+ return service(method, requestURI, baseURI, headers, data, new DummyContainerResponseWriter());
+
+ }
+
+}
Property changes on: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/BaseTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyContextParamTest.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyContextParamTest.java (rev 0)
+++ ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyContextParamTest.java 2010-06-17 08:39:29 UTC (rev 2647)
@@ -0,0 +1,56 @@
+/**
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.rest.ext.groovy;
+
+import org.exoplatform.services.rest.ext.BaseTest;
+import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter;
+
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class GroovyContextParamTest extends BaseTest
+{
+
+ private InputStream script;
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ script = Thread.currentThread().getContextClassLoader().getResourceAsStream("groovy1.groovy");
+ assertNotNull(script);
+ }
+
+ public void testPerRequest() throws Exception
+ {
+ assertEquals(0, binder.getSize());
+ groovyPublisher.publishPerRequest(script, "g1");
+ assertEquals(1, binder.getSize());
+ ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
+ ContainerResponse resp =
+ service("GET", "http://localhost:8080/context/a/b", "http://localhost:8080/context", null, null, writer);
+ assertEquals(200, resp.getStatus());
+ assertEquals("GET\n/context/a/b", new String(writer.getBody()));
+ }
+
+}
Property changes on: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyContextParamTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyExoComponentTest.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyExoComponentTest.java (rev 0)
+++ ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyExoComponentTest.java 2010-06-17 08:39:29 UTC (rev 2647)
@@ -0,0 +1,85 @@
+/**
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.rest.ext.groovy;
+
+import org.exoplatform.services.rest.ext.BaseTest;
+import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter;
+
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class GroovyExoComponentTest extends BaseTest
+{
+
+ private InputStream script;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ container.registerComponentInstance(Component1.class.getName(), new Component1());
+ script = Thread.currentThread().getContextClassLoader().getResourceAsStream("groovy2.groovy");
+ assertNotNull(script);
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ container.unregisterComponent(Component1.class.getName());
+ super.tearDown();
+ }
+
+ public void testExoComponentPerRequest() throws Exception
+ {
+ containerComponentTest(false, "g1");
+ }
+
+ public void testExoComponentSingleton() throws Exception
+ {
+ containerComponentTest(true, "g1");
+ }
+
+ private void containerComponentTest(boolean singleton, String name) throws Exception
+ {
+ assertEquals(0, binder.getSize());
+ if (singleton)
+ groovyPublisher.publishSingleton(script, name);
+ else
+ groovyPublisher.publishPerRequest(script, name);
+ assertEquals(1, binder.getSize());
+ ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
+ ContainerResponse resp = service("GET", "/a/b", "", null, null, writer);
+ assertEquals(200, resp.getStatus());
+ assertEquals("exo container's component", new String(writer.getBody()));
+ }
+
+ public static class Component1
+ {
+ public String getName()
+ {
+ return "exo container's component";
+ }
+ }
+
+}
Property changes on: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyExoComponentTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySimpleTest.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySimpleTest.java (rev 0)
+++ ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySimpleTest.java 2010-06-17 08:39:29 UTC (rev 2647)
@@ -0,0 +1,74 @@
+/**
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.rest.ext.groovy;
+
+import org.exoplatform.services.rest.ext.BaseTest;
+import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter;
+
+import java.io.ByteArrayInputStream;
+
+/**
+ * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class GroovySimpleTest extends BaseTest
+{
+
+ public void testPerRequest() throws Exception
+ {
+ publicationTest(false, "g1");
+ }
+
+ public void testSingleton() throws Exception
+ {
+ publicationTest(true, "g2");
+ }
+
+ private void publicationTest(boolean singleton, String name) throws Exception
+ {
+ String script = //
+ "@javax.ws.rs.Path(\"a\")" //
+ + "class GroovyResource {" //
+ + "@javax.ws.rs.GET @javax.ws.rs.Path(\"{who}\")" //
+ + "def m0((a)javax.ws.rs.PathParam(\"who\") String who) { return (\"hello \" + who)}" //
+ + "}";
+
+ assertEquals(0, binder.getSize());
+
+ if (singleton)
+ groovyPublisher.publishSingleton(new ByteArrayInputStream(script.getBytes()), name);
+ else
+ groovyPublisher.publishPerRequest(new ByteArrayInputStream(script.getBytes()), name);
+
+ assertEquals(1, binder.getSize());
+
+ String cs =
+ binder.getResources().get(0).getObjectModel().getObjectClass().getProtectionDomain().getCodeSource()
+ .getLocation().toString();
+ assertEquals("file:/groovy/script/jaxrs", cs);
+
+ ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
+ ContainerResponse resp = service("GET", "/a/groovy", "", null, null, writer);
+ assertEquals(200, resp.getStatus());
+ assertEquals("hello groovy", new String(writer.getBody()));
+ }
+
+}
Property changes on: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySimpleTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: ws/trunk/exo.ws.rest.ext/src/test/resources/conf/standalone (from rev 2528, ws/trunk/exo.ws.rest.ext/src/test/resources/standalone)
Modified: ws/trunk/exo.ws.rest.ext/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/resources/standalone/test-configuration.xml 2010-06-09 14:10:00 UTC (rev 2528)
+++ ws/trunk/exo.ws.rest.ext/src/test/resources/conf/standalone/test-configuration.xml 2010-06-17 08:39:29 UTC (rev 2647)
@@ -1,111 +1,103 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
+ <!--
- Copyright (C) 2009 eXo Platform SAS.
+ Copyright (C) 2009 eXo Platform SAS. This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at
+ your option) any later version. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details. You should have received a copy of the GNU Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ site: http://www.fsf.org.
+ -->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd" xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+ <component>
+ <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
+ <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <init-params>
+ <value-param>
+ <name>logger</name>
+ <value>org.slf4j.Logger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>Log4J properties</description>
+ <property name="log4j.rootLogger" value="INFO, stdout" />
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
+ <property name="log4j.appender.stdout" value="org.apache.log4j.ConsoleAppender" />
+ <property name="log4j.appender.stdout.threshold" value="DEBUG" />
+ <property name="log4j.appender.stdout.layout" value="org.apache.log4j.PatternLayout" />
+ <property name="log4j.appender.stdout.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+ <property name="log4j.appender.file" value="org.apache.log4j.FileAppender" />
+ <property name="log4j.appender.file.File" value="target/container.log" />
+ <property name="log4j.appender.file.layout" value="org.apache.log4j.PatternLayout" />
+ <property name="log4j.appender.file.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
+ </properties-param>
+ </init-params>
+ </component>
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ <component>
+ <type>org.exoplatform.services.rest.impl.RequestHandlerImpl</type>
+ </component>
+ <component>
+ <type>org.exoplatform.services.rest.impl.RequestDispatcher</type>
+ </component>
+ <component>
+ <type>org.exoplatform.services.rest.impl.ResourceBinder</type>
+ </component>
+ <component>
+ <type>org.exoplatform.services.rest.impl.provider.JAXBContextResolver</type>
+ </component>
+ <component>
+ <type>org.exoplatform.services.rest.ext.groovy.GroovyJaxrsPublisher</type>
+ </component>
+ <component>
+ <type>org.exoplatform.services.script.groovy.GroovyScriptInstantiator</type>
+ </component>
--->
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
- <component>
- <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
- <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
- <init-params>
- <value-param>
- <name>logger</name>
- <value>org.slf4j.Logger</value>
- </value-param>
- <value-param>
- <name>configurator</name>
- <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>Log4J properties</description>
- <property name="log4j.rootLogger" value="INFO, stdout" />
-
- <property name="log4j.appender.stdout" value="org.apache.log4j.ConsoleAppender" />
- <property name="log4j.appender.stdout.threshold" value="DEBUG" />
- <property name="log4j.appender.stdout.layout" value="org.apache.log4j.PatternLayout" />
- <property name="log4j.appender.stdout.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
- <property name="log4j.appender.file" value="org.apache.log4j.FileAppender" />
- <property name="log4j.appender.file.File" value="target/container.log" />
- <property name="log4j.appender.file.layout" value="org.apache.log4j.PatternLayout" />
- <property name="log4j.appender.file.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
-
- </properties-param>
- </init-params>
- </component>
-
- <component>
- <type>org.exoplatform.services.rest.impl.RequestHandlerImpl</type>
- </component>
- <component>
- <type>org.exoplatform.services.rest.impl.RequestDispatcher</type>
- </component>
- <component>
- <type>org.exoplatform.services.rest.impl.ResourceBinder</type>
- </component>
- <component>
- <type>org.exoplatform.services.rest.impl.provider.JAXBContextResolver</type>
- </component>
-
- <external-component-plugins>
- <target-component>org.exoplatform.services.rest.impl.provider.JAXBContextResolver</target-component>
- <component-plugin>
- <name>ws.rs.jaxb.context</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.rest.impl.provider.JAXBContextComponentPlugin</type>
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.rest.impl.provider.JAXBContextResolver</target-component>
+ <component-plugin>
+ <name>ws.rs.jaxb.context</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.rest.impl.provider.JAXBContextComponentPlugin</type>
+ <init-params>
+ <!-- ======== example ======= -->
+ <value-param>
+ <name>book</name>
+ <value>org.exoplatform.services.rest.generated.Book</value>
+ </value-param>
+ <!-- ======================== -->
+ <value-param>
+ <name>wadl.application</name>
+ <value>org.exoplatform.services.rest.wadl.research.Application</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.rest.impl.RequestHandlerImpl</target-component>
+ <component-plugin>
+ <name>ws.rs.entity.provider</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.rest.impl.provider.EntityProviderComponentPlugin</type>
+ <!-- NOTE it is just example of configuration. -->
+ <!-- StringEntityProvider is part of REST framework, not needs to add it from configuration -->
+ <!--
<init-params>
- <!-- ======== example ======= -->
<value-param>
- <name>book</name>
- <value>org.exoplatform.services.rest.generated.Book</value>
- </value-param>
- <!-- ======================== -->
- <value-param>
- <name>wadl.application</name>
- <value>org.exoplatform.services.rest.wadl.research.Application</value>
- </value-param>
- </init-params>
- </component-plugin>
- </external-component-plugins>
- <external-component-plugins>
- <target-component>org.exoplatform.services.rest.impl.RequestHandlerImpl</target-component>
- <component-plugin>
- <name>ws.rs.entity.provider</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.rest.impl.provider.EntityProviderComponentPlugin</type>
- <!-- NOTE it is just example of configuration. -->
- <!-- StringEntityProvider is part of REST framework, not needs to add it from configuration -->
- <!--
- <init-params>
- <value-param>
<name>strings</name>
<value>org.exoplatform.services.rest.impl.provider.StringEntityProvider</value>
</value-param>
</init-params>
-->
- </component-plugin>
- <component-plugin>
- <name>ws.rs.method.filter</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.rest.impl.method.MethodInvokerFilterComponentPlugin</type>
- <!--
+ </component-plugin>
+ <component-plugin>
+ <name>ws.rs.method.filter</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.rest.impl.method.MethodInvokerFilterComponentPlugin</type>
+ <!--
<init-params>
<value-param>
<name>name</name>
@@ -113,12 +105,12 @@
</value-param>
</init-params>
-->
- </component-plugin>
- <component-plugin>
- <name>ws.rs.request.filter</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.rest.impl.RequestFilterComponentPlugin</type>
- <!--
+ </component-plugin>
+ <component-plugin>
+ <name>ws.rs.request.filter</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.rest.impl.RequestFilterComponentPlugin</type>
+ <!--
<init-params>
<value-param>
<name>name</name>
@@ -126,12 +118,12 @@
</value-param>
</init-params>
-->
- </component-plugin>
- <component-plugin>
- <name>ws.rs.response.filter</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.rest.impl.ResponseFilterComponentPlugin</type>
- <!--
+ </component-plugin>
+ <component-plugin>
+ <name>ws.rs.response.filter</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.rest.impl.ResponseFilterComponentPlugin</type>
+ <!--
<init-params>
<value-param>
<name>name</name>
@@ -139,6 +131,6 @@
</value-param>
</init-params>
-->
- </component-plugin>
- </external-component-plugins>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
Added: ws/trunk/exo.ws.rest.ext/src/test/resources/groovy1.groovy
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/resources/groovy1.groovy (rev 0)
+++ ws/trunk/exo.ws.rest.ext/src/test/resources/groovy1.groovy 2010-06-17 08:39:29 UTC (rev 2647)
@@ -0,0 +1,27 @@
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+
+@Path("a")
+class CroovyResource1
+{
+
+ CroovyResource1(@Context HttpServletRequest req1)
+ {
+ this.req1 = req1;
+ }
+
+ @Context
+ private HttpServletRequest req
+
+ private HttpServletRequest req1
+
+ @GET
+ @Path("b")
+ def m0()
+ {
+ return req.getMethod() + "\n" +req.getRequestURI().toString()
+ }
+
+}
\ No newline at end of file
Added: ws/trunk/exo.ws.rest.ext/src/test/resources/groovy2.groovy
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/resources/groovy2.groovy (rev 0)
+++ ws/trunk/exo.ws.rest.ext/src/test/resources/groovy2.groovy 2010-06-17 08:39:29 UTC (rev 2647)
@@ -0,0 +1,24 @@
+import org.exoplatform.services.rest.ext.groovy.GroovyExoComponentTest.Component1;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("a")
+class CroovyResource2
+{
+ private Component1 component
+
+ CroovyResource2(Component1 component)
+ {
+ this.component = component
+ }
+
+ @GET
+ @Path("b")
+ def m0()
+ {
+ return component.getName()
+ }
+
+
+}
\ No newline at end of file
Modified: ws/trunk/pom.xml
===================================================================
--- ws/trunk/pom.xml 2010-06-17 08:34:18 UTC (rev 2646)
+++ ws/trunk/pom.xml 2010-06-17 08:39:29 UTC (rev 2647)
@@ -1,179 +1,177 @@
-<!--
- Copyright (C) 2009 eXo Platform SAS.
+ <!--
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
+ Copyright (C) 2009 eXo Platform SAS. This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at
+ your option) any later version. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details. You should have received a copy of the GNU Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ site: http://www.fsf.org.
+ -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.exoplatform</groupId>
- <artifactId>foundation-parent</artifactId>
- <version>7</version>
- </parent>
+ <parent>
+ <groupId>org.exoplatform</groupId>
+ <artifactId>foundation-parent</artifactId>
+ <version>7</version>
+ </parent>
- <groupId>org.exoplatform.ws</groupId>
- <artifactId>ws-parent</artifactId>
- <version>2.2.0-Beta01-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>eXo WS</name>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>ws-parent</artifactId>
+ <version>2.2.0-Beta01-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>eXo WS</name>
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/exo-jcr/ws/trunk</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/exo-jcr/ws/trunk</developerConnection>
- <url>http://fisheye.jboss.org/browse/exo-jcr/ws/trunk</url>
- </scm>
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/exo-jcr/ws/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/exo-jcr/ws/trunk</developerConnection>
+ <url>http://fisheye.jboss.org/browse/exo-jcr/ws/trunk</url>
+ </scm>
- <properties>
- <exo.product.name>exo-ws</exo.product.name>
- <exo.product.specification>2.1</exo.product.specification>
-
- <org.exoplatform.kernel.version>2.3.0-Beta01-SNAPSHOT</org.exoplatform.kernel.version>
- <org.exoplatform.core.version>2.4.0-Beta01-SNAPSHOT</org.exoplatform.core.version>
- </properties>
+ <properties>
+ <exo.product.name>exo-ws</exo.product.name>
+ <exo.product.specification>2.1</exo.product.specification>
- <modules>
- <module>exo.ws.commons</module>
- <module>exo.ws.frameworks.json</module>
- <module>exo.ws.frameworks.servlet</module>
- <module>exo.ws.testframework</module>
- <module>exo.ws.rest.core</module>
- <module>exo.ws.rest.ext</module>
- <module>packaging/module</module>
- </modules>
+ <org.exoplatform.kernel.version>2.3.0-Beta01-SNAPSHOT</org.exoplatform.kernel.version>
+ <org.exoplatform.core.version>2.4.0-Beta01-SNAPSHOT</org.exoplatform.core.version>
+ </properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.commons</artifactId>
- <version>${org.exoplatform.kernel.version}</version>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.container</artifactId>
- <version>${org.exoplatform.kernel.version}</version>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.component.common</artifactId>
- <version>${org.exoplatform.kernel.version}</version>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.core</groupId>
- <artifactId>exo.core.component.xml-processing</artifactId>
- <version>${org.exoplatform.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.ws</groupId>
- <artifactId>exo.ws.frameworks.json</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.ws</groupId>
- <artifactId>exo.ws.testframework</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.ws</groupId>
- <artifactId>exo.ws.commons</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.ws</groupId>
- <artifactId>exo.ws.rest.core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.xml.stream</groupId>
- <artifactId>stax-api</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- </dependency>
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>2.1</version>
- </dependency>
- <dependency>
- <groupId>picocontainer</groupId>
- <artifactId>picocontainer</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>jtidy</groupId>
- <artifactId>jtidy</artifactId>
- <version>4aug2000r7-dev</version>
- </dependency>
- <dependency>
- <groupId>org.jvnet.jaxb2.maven2</groupId>
- <artifactId>maven-jaxb2-plugin</artifactId>
- <version>0.4</version>
- </dependency>
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <!-- <version>1.2.1</version>-->
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>javax.annotation</groupId>
- <artifactId>jsr250-api</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>xpp3</groupId>
- <artifactId>xpp3</artifactId>
- <version>1.1.3.4.O</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.5.8</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <modules>
+ <module>exo.ws.commons</module>
+ <module>exo.ws.frameworks.json</module>
+ <module>exo.ws.frameworks.servlet</module>
+ <module>exo.ws.testframework</module>
+ <module>exo.ws.rest.core</module>
+ <module>exo.ws.rest.ext</module>
+ <module>packaging/module</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.commons</artifactId>
+ <version>${org.exoplatform.kernel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ <version>${org.exoplatform.kernel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.component.common</artifactId>
+ <version>${org.exoplatform.kernel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.xml-processing</artifactId>
+ <version>${org.exoplatform.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.script.groovy</artifactId>
+ <version>${org.exoplatform.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.frameworks.json</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.testframework</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.commons</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.rest.core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>picocontainer</groupId>
+ <artifactId>picocontainer</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>jtidy</groupId>
+ <artifactId>jtidy</artifactId>
+ <version>4aug2000r7-dev</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ <version>0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <!-- <version>1.2.1</version>-->
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3</artifactId>
+ <version>1.1.3.4.O</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.8</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
13 years, 11 months