[exo-jcr-commits] exo-jcr SVN: r2615 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Jun 16 03:38:35 EDT 2010
Author: tolusha
Date: 2010-06-16 03:38:34 -0400 (Wed, 16 Jun 2010)
New Revision: 2615
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
Log:
EXOJCR-756: privileged for enlistResource() & delistResource()
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-16 07:20:49 UTC (rev 2614)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-06-16 07:38:34 UTC (rev 2615)
@@ -113,13 +113,49 @@
/**
* {@inheritDoc}
*/
- public void delistResource(ExoResource exores) throws RollbackException, SystemException
+ public void delistResource(final ExoResource exores) throws RollbackException, SystemException
{
TransactionManager tm = getTransactionManager();
- Transaction tx = tm.getTransaction();
+ final Transaction tx = tm.getTransaction();
if (tx != null)
{
- tx.delistResource(exores.getXAResource(), XAResource.TMNOFLAGS);
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ tx.delistResource(exores.getXAResource(), XAResource.TMNOFLAGS);
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+
+ if (cause instanceof RollbackException)
+ {
+ throw (RollbackException)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);
+ }
+ }
}
else
{
@@ -130,13 +166,49 @@
/**
* {@inheritDoc}
*/
- public void enlistResource(ExoResource exores) throws RollbackException, SystemException
+ public void enlistResource(final ExoResource exores) throws RollbackException, SystemException
{
TransactionManager tm = getTransactionManager();
- Transaction tx = tm.getTransaction();
+ final Transaction tx = tm.getTransaction();
if (tx != null)
{
- tx.enlistResource(exores.getXAResource());
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ tx.enlistResource(exores.getXAResource());
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+
+ if (cause instanceof RollbackException)
+ {
+ throw (RollbackException)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);
+ }
+ }
}
else
{
More information about the exo-jcr-commits
mailing list