[jboss-cvs] JBossCache/src/org/jboss/cache/pojo/interceptors ...
Manik Surtani
manik at jboss.org
Wed May 23 06:28:56 EDT 2007
User: msurtani
Date: 07/05/23 06:28:56
Modified: src/org/jboss/cache/pojo/interceptors
CheckIdInterceptor.java
PojoTxUndoSynchronizationInterceptor.java
StaticFieldInterceptor.java
MethodReentrancyStopperInterceptor.java
PojoTxLockInterceptor.java
CheckNonSerializableInterceptor.java
PojoEventInterceptor.java AbstractInterceptor.java
PojoTxInterceptor.java PojoTxUndoInterceptor.java
PojoBeginInterceptor.java
Log:
Initiated a bunch of performance fixes, including replacing CopyOnWriteArraySets with org.jboss.cache.util.concurrent.ConcurrentHashSet.
Also ran an imports optimiser on the code base - there were a lot of unused imports floating about.
Revision Changes Path
1.2 +12 -9 JBossCache/src/org/jboss/cache/pojo/interceptors/CheckIdInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CheckIdInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/interceptors/CheckIdInterceptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- CheckIdInterceptor.java 13 Jan 2007 15:55:06 -0000 1.1
+++ CheckIdInterceptor.java 23 May 2007 10:28:56 -0000 1.2
@@ -10,27 +10,30 @@
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.cache.Fqn;
-import org.jboss.cache.pojo.InternalConstant;
-import org.jboss.cache.pojo.util.AopUtil;
-/** Interceptor (done via aop advice) to check the validity of the id specified by the user.
- * @version $Id: CheckIdInterceptor.java,v 1.1 2007/01/13 15:55:06 bwang Exp $
+/**
+ * Interceptor (done via aop advice) to check the validity of the id specified by the user.
+ *
+ * @version $Id: CheckIdInterceptor.java,v 1.2 2007/05/23 10:28:56 msurtani Exp $
*/
public class CheckIdInterceptor extends AbstractInterceptor
{
public Object invoke(Invocation in) throws Throwable
{
- if(!(in instanceof MethodInvocation))
+ if (!(in instanceof MethodInvocation))
{
throw new IllegalArgumentException("CheckIdInterceptor.invoke(): invocation not MethodInvocation");
}
- MethodInvocation invocation = (MethodInvocation)in;
+ MethodInvocation invocation = (MethodInvocation) in;
invocation.getAdvisor();
- try {
- checkFqnValidity((Fqn)invocation.getArguments()[0]);
+ try
+ {
+ checkFqnValidity((Fqn) invocation.getArguments()[0]);
return invocation.invokeNext(); // proceed to next advice or actual call
- } finally {
+ }
+ finally
+ {
}
}
1.2 +19 -13 JBossCache/src/org/jboss/cache/pojo/interceptors/PojoTxUndoSynchronizationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoTxUndoSynchronizationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/interceptors/PojoTxUndoSynchronizationInterceptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- PojoTxUndoSynchronizationInterceptor.java 13 Jan 2007 15:55:06 -0000 1.1
+++ PojoTxUndoSynchronizationInterceptor.java 23 May 2007 10:28:56 -0000 1.2
@@ -9,18 +9,19 @@
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.cache.pojo.PojoTxSynchronizationHandler;
import org.jboss.cache.pojo.PojoCacheException;
+import org.jboss.cache.pojo.PojoTxSynchronizationHandler;
-import javax.transaction.Transaction;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
+import javax.transaction.Transaction;
-/** Interceptor that handles registration of tx synchronization for rollback
+/**
+ * Interceptor that handles registration of tx synchronization for rollback
* operations.
*
* @author Ben Wang
- * @version $Id: PojoTxUndoSynchronizationInterceptor.java,v 1.1 2007/01/13 15:55:06 bwang Exp $
+ * @version $Id: PojoTxUndoSynchronizationInterceptor.java,v 1.2 2007/05/23 10:28:56 msurtani Exp $
*/
public class PojoTxUndoSynchronizationInterceptor extends AbstractInterceptor
{
@@ -31,15 +32,18 @@
public Object invoke(Invocation in) throws Throwable
{
- if(!(in instanceof MethodInvocation))
+ if (!(in instanceof MethodInvocation))
{
throw new IllegalArgumentException("TxSyncrhonizationInterceptor.invoke(): invocation not MethodInvocation");
}
- MethodInvocation invocation = (MethodInvocation)in;
- try {
+ MethodInvocation invocation = (MethodInvocation) in;
+ try
+ {
registerTxHandler(invocation);
return invocation.invokeNext(); // proceed to next advice or actual call
- } finally {
+ }
+ finally
+ {
}
}
@@ -52,7 +56,7 @@
if (handler == null)
{
// First entry point for this transaction scope.
- Transaction tx = (Transaction)invocation.getMetaData(PojoTxInterceptor.TAG, PojoTxInterceptor.TX);
+ Transaction tx = (Transaction) invocation.getMetaData(PojoTxInterceptor.TAG, PojoTxInterceptor.TX);
if (tx == null)
{
throw new IllegalStateException("PojoCache.registerTxHanlder(). Can't have null tx handle.");
@@ -60,16 +64,18 @@
handler = new PojoTxSynchronizationHandler();
- log.debug("Registering PojoTxSynchronizationHandler for rollback if ncessary " +handler);
+ log.debug("Registering PojoTxSynchronizationHandler for rollback if ncessary " + handler);
// Register so we can rollback if necessary
tx.registerSynchronization(handler);
synchronizationHandler_.set(handler);
}
- } catch (RollbackException e)
+ }
+ catch (RollbackException e)
{
throw new PojoCacheException("PojoTxUndoSynchronizationInterceptor.registerTxHandler(): Exception: " + e);
- } catch (SystemException e)
+ }
+ catch (SystemException e)
{
throw new PojoCacheException("PojoTxUndoSynchronizationInterceptor.registerTxHandler(): Exception: " + e);
}
@@ -77,7 +83,7 @@
public static PojoTxSynchronizationHandler getSynchronizationHandler()
{
- return (PojoTxSynchronizationHandler)synchronizationHandler_.get();
+ return (PojoTxSynchronizationHandler) synchronizationHandler_.get();
}
public static void reset()
1.2 +2 -10 JBossCache/src/org/jboss/cache/pojo/interceptors/StaticFieldInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StaticFieldInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/interceptors/StaticFieldInterceptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- StaticFieldInterceptor.java 13 Jan 2007 15:55:06 -0000 1.1
+++ StaticFieldInterceptor.java 23 May 2007 10:28:56 -0000 1.2
@@ -8,19 +8,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.aop.Advisor;
import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.FieldInvocation;
-import org.jboss.aop.joinpoint.FieldReadInvocation;
-import org.jboss.aop.joinpoint.FieldWriteInvocation;
import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.cache.Fqn;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.pojo.CachedType;
-import org.jboss.cache.pojo.PojoCacheFactory;
+import org.jboss.cache.Fqn;
import org.jboss.cache.pojo.InternalConstant;
-import org.jboss.cache.pojo.PojoCacheException;
import org.jboss.cache.pojo.impl.PojoCacheImpl;
import java.lang.reflect.Field;
@@ -93,7 +85,7 @@
private void needInit(Field field)
{
- if(pCache_ == null)
+ if (pCache_ == null)
{
String cn = field.getDeclaringClass().getName();
fqn_ = Fqn.fromString(InternalConstant.JBOSS_INTERNAL_STATIC + "/" + cn);
1.2 +14 -13 JBossCache/src/org/jboss/cache/pojo/interceptors/MethodReentrancyStopperInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MethodReentrancyStopperInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/interceptors/MethodReentrancyStopperInterceptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- MethodReentrancyStopperInterceptor.java 13 Jan 2007 15:55:06 -0000 1.1
+++ MethodReentrancyStopperInterceptor.java 23 May 2007 10:28:56 -0000 1.2
@@ -7,17 +7,16 @@
package org.jboss.cache.pojo.interceptors;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.cache.pojo.PojoCacheException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import java.lang.reflect.Method;
/**
- *
* @author Ben Wang
*/
@@ -40,7 +39,7 @@
public String getName()
{
- return MethodReentrancyStopperInterceptor.class.getName() + "-" +methodName;
+ return MethodReentrancyStopperInterceptor.class.getName() + "-" + methodName;
}
public Object invoke(Invocation invocation) throws Throwable
@@ -53,26 +52,28 @@
{
done.set(true);
return invocation.invokeNext();
- } else
+ }
+ else
{
//Needs adding, and will invoke target joinpoint skipping the rest of the chain
- if(log_.isDebugEnabled())
+ if (log_.isDebugEnabled())
{
- Method method = ((MethodInvocation)invocation).getMethod();
- log_.debug("Detect recursive interception. Will call the target directly: " +method.getName());
+ Method method = ((MethodInvocation) invocation).getMethod();
+ log_.debug("Detect recursive interception. Will call the target directly: " + method.getName());
}
- if(methodName.equals("toString"))
+ if (methodName.equals("toString"))
{
return invocation.getTargetObject().getClass().getName();
- } else
- if(methodName.equals("hashCode"))
+ }
+ else if (methodName.equals("hashCode"))
{
return 0;
- } else
+ }
+ else
{
throw new PojoCacheException("MethodReentrancyStopperInterceptor.invoke(): unknown method name"
- +methodName);
+ + methodName);
}
}
}
1.2 +20 -15 JBossCache/src/org/jboss/cache/pojo/interceptors/PojoTxLockInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoTxLockInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/interceptors/PojoTxLockInterceptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- PojoTxLockInterceptor.java 13 Jan 2007 15:55:06 -0000 1.1
+++ PojoTxLockInterceptor.java 23 May 2007 10:28:56 -0000 1.2
@@ -9,18 +9,18 @@
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.cache.pojo.PojoCacheException;
-import org.jboss.cache.pojo.PojoTreeCache;
-import org.jboss.cache.pojo.InternalConstant;
-import org.jboss.cache.lock.UpgradeException;
import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.lock.UpgradeException;
+import org.jboss.cache.pojo.InternalConstant;
+import org.jboss.cache.pojo.PojoCacheException;
-/** Interceptor that handles the parent node lock associated with transaction.
+/**
+ * Interceptor that handles the parent node lock associated with transaction.
*
* @author Ben Wang
- * @version $Id: PojoTxLockInterceptor.java,v 1.1 2007/01/13 15:55:06 bwang Exp $
+ * @version $Id: PojoTxLockInterceptor.java,v 1.2 2007/05/23 10:28:56 msurtani Exp $
*/
public class PojoTxLockInterceptor extends AbstractInterceptor
{
@@ -30,18 +30,21 @@
public Object invoke(Invocation in) throws Throwable
{
- MethodInvocation invocation = (MethodInvocation)in;
- try {
+ MethodInvocation invocation = (MethodInvocation) in;
+ try
+ {
handleLock(invocation);
return invocation.invokeNext(); // proceed to next advice or actual call
- } finally {
+ }
+ finally
+ {
// handleUnLock(invocation);
}
}
private void handleLock(MethodInvocation invocation) throws Throwable
{
- Fqn id = (Fqn)invocation.getArguments()[0];
+ Fqn id = (Fqn) invocation.getArguments()[0];
CacheSPI cache = getCache(invocation);
// Object owner = cache.getLockOwner();
Object owner = null;
@@ -64,7 +67,7 @@
// Collection, and we need to lock the parent as well.
// TODO Still a bit ad hoc.
Fqn realId = id;
- if(id.isChildOrEquals(InternalConstant.JBOSS_INTERNAL) && id.size() > 2)
+ if (id.isChildOrEquals(InternalConstant.JBOSS_INTERNAL) && id.size() > 2)
{
realId = id.getParent();
if (log.isDebugEnabled())
@@ -79,7 +82,8 @@
{
cache.put(realId, LOCK, "LOCK");
isNeeded = false;
- } catch (UpgradeException upe)
+ }
+ catch (UpgradeException upe)
{
log.warn("lockPojo(): can't upgrade the lock during lockPojo. Will re-try. id: " + realId
+ " retry times: " + retry);
@@ -93,7 +97,8 @@
try
{
Thread.sleep(10);
- } catch (InterruptedException e)
+ }
+ catch (InterruptedException e)
{
;
}
1.2 +15 -9 JBossCache/src/org/jboss/cache/pojo/interceptors/CheckNonSerializableInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CheckNonSerializableInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/interceptors/CheckNonSerializableInterceptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- CheckNonSerializableInterceptor.java 13 Jan 2007 15:55:06 -0000 1.1
+++ CheckNonSerializableInterceptor.java 23 May 2007 10:28:56 -0000 1.2
@@ -9,11 +9,13 @@
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.cache.pojo.util.AopUtil;
import org.jboss.cache.Fqn;
+import org.jboss.cache.pojo.util.AopUtil;
-/** Interceptor (done via aop advice) to check the validity of the id specified by the user.
- * @version $Id: CheckNonSerializableInterceptor.java,v 1.1 2007/01/13 15:55:06 bwang Exp $
+/**
+ * Interceptor (done via aop advice) to check the validity of the id specified by the user.
+ *
+ * @version $Id: CheckNonSerializableInterceptor.java,v 1.2 2007/05/23 10:28:56 msurtani Exp $
*/
public class CheckNonSerializableInterceptor extends AbstractInterceptor
{
@@ -21,26 +23,30 @@
public Object invoke(Invocation in) throws Throwable
{
- if(!(in instanceof MethodInvocation))
+ if (!(in instanceof MethodInvocation))
{
throw new IllegalArgumentException("CheckIdInterceptor.invoke(): invocation not MethodInvocation");
}
- MethodInvocation invocation = (MethodInvocation)in;
+ MethodInvocation invocation = (MethodInvocation) in;
Fqn id = (Fqn) invocation.getArguments()[0];
Object obj = invocation.getArguments()[1];
if (!marshallNonSerializable_)
{
AopUtil.checkObjectType(obj);
- } else
+ }
+ else
{
log.debug("invoke(): marshallNonSerializable is set to true. We will skip object type checking for id:"
+ id.toString());
}
- try {
+ try
+ {
return invocation.invokeNext(); // proceed to next advice or actual call
- } finally {
+ }
+ finally
+ {
}
}
1.2 +10 -7 JBossCache/src/org/jboss/cache/pojo/interceptors/PojoEventInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoEventInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/interceptors/PojoEventInterceptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- PojoEventInterceptor.java 13 Jan 2007 15:55:06 -0000 1.1
+++ PojoEventInterceptor.java 23 May 2007 10:28:56 -0000 1.2
@@ -7,28 +7,31 @@
package org.jboss.cache.pojo.interceptors;
-import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
-/** Handles the POJO event notification.
+/**
+ * Handles the POJO event notification.
*
* @author Ben Wang
- * @version $Id: PojoEventInterceptor.java,v 1.1 2007/01/13 15:55:06 bwang Exp $
+ * @version $Id: PojoEventInterceptor.java,v 1.2 2007/05/23 10:28:56 msurtani Exp $
*/
public class PojoEventInterceptor extends AbstractInterceptor
{
public Object invoke(Invocation in) throws Throwable
{
- if(!(in instanceof MethodInvocation))
+ if (!(in instanceof MethodInvocation))
{
throw new IllegalArgumentException("PojoEventInterceptor.invoke(): invocation not MethodInvocation");
}
- MethodInvocation invocation = (MethodInvocation)in;
- try {
+ MethodInvocation invocation = (MethodInvocation) in;
+ try
+ {
System.out.println("**** Entering method: **** " + invocation.getMethod());
return invocation.invokeNext(); // proceed to next advice or actual call
- } finally {
+ }
+ finally
+ {
System.out.println("Leaving method: " + invocation.getMethod());
}
}
1.2 +8 -9 JBossCache/src/org/jboss/cache/pojo/interceptors/AbstractInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/interceptors/AbstractInterceptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- AbstractInterceptor.java 13 Jan 2007 15:55:06 -0000 1.1
+++ AbstractInterceptor.java 23 May 2007 10:28:56 -0000 1.2
@@ -7,20 +7,19 @@
package org.jboss.cache.pojo.interceptors;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.cache.pojo.PojoTreeCache;
-import org.jboss.cache.pojo.impl.PojoCacheImpl;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.InvocationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.pojo.impl.PojoCacheImpl;
-/** Base interceptor class for PojoCache interceptor stack.
+/**
+ * Base interceptor class for PojoCache interceptor stack.
*
* @author Ben Wang
- * @version $Id: AbstractInterceptor.java,v 1.1 2007/01/13 15:55:06 bwang Exp $
+ * @version $Id: AbstractInterceptor.java,v 1.2 2007/05/23 10:28:56 msurtani Exp $
*/
public abstract class AbstractInterceptor implements Interceptor
{
@@ -28,12 +27,12 @@
protected InvocationContext getInvocationContext(MethodInvocation in)
{
- return ((PojoCacheImpl)in.getTargetObject()).getUnderlyingCache().getInvocationContext();
+ return ((PojoCacheImpl) in.getTargetObject()).getUnderlyingCache().getInvocationContext();
}
protected CacheSPI getCache(MethodInvocation in)
{
- return ((PojoCacheImpl)in.getTargetObject()).getUnderlyingCache();
+ return ((PojoCacheImpl) in.getTargetObject()).getUnderlyingCache();
}
public String getName()
1.3 +16 -11 JBossCache/src/org/jboss/cache/pojo/interceptors/PojoTxInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoTxInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/interceptors/PojoTxInterceptor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- PojoTxInterceptor.java 25 Jan 2007 21:54:06 -0000 1.2
+++ PojoTxInterceptor.java 23 May 2007 10:28:56 -0000 1.3
@@ -9,8 +9,8 @@
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.cache.pojo.PojoCacheException;
import org.jboss.cache.Fqn;
+import org.jboss.cache.pojo.PojoCacheException;
import org.jboss.cache.transaction.BatchModeTransactionManager;
import javax.transaction.RollbackException;
@@ -22,7 +22,7 @@
* Interceptor (done via aop advice) for transaction
*
* @author Ben Wang
- * @version $Id: PojoTxInterceptor.java,v 1.2 2007/01/25 21:54:06 genman Exp $
+ * @version $Id: PojoTxInterceptor.java,v 1.3 2007/05/23 10:28:56 msurtani Exp $
*/
public class PojoTxInterceptor extends AbstractInterceptor
{
@@ -40,17 +40,18 @@
}
MethodInvocation invocation = (MethodInvocation) in;
- if(txManager_ == null)
+ if (txManager_ == null)
{
txManager_ = getCache(invocation).getTransactionManager();
}
Transaction tx = null;
- if(txManager_ != null)
+ if (txManager_ != null)
{
// Use the configured one if so setup.
localTm_ = txManager_;
- } else
+ }
+ else
{
localTm_ = BatchModeTransactionManager.getInstance();
}
@@ -65,7 +66,7 @@
if (needTx)
{
id = (Fqn) invocation.getArguments()[0];
- log.debug("Initiating a local transaction for batch processing with id: " +id.toString());
+ log.debug("Initiating a local transaction for batch processing with id: " + id.toString());
// Start one of our own as batch processing.
try
{
@@ -88,14 +89,16 @@
}
throw new PojoCacheException("PojoCache operation will be rollback. id: " + id
- + ". Operation: " +invocation.getMethod().getName(), e);
+ + ". Operation: " + invocation.getMethod().getName(), e);
+ }
}
- } else
+ else
{
invocation.getMetaData().addMetaData(TAG, TX, tx);
return invocation.invokeNext(); // proceed to next advice or actual call
}
- } finally
+ }
+ finally
{
if (needTx)
{
@@ -118,10 +121,12 @@
if (localTm_.getTransaction().getStatus() != Status.STATUS_MARKED_ROLLBACK)
{
localTm_.commit();
- } else if (localTm_.getTransaction().getStatus() == Status.STATUS_ROLLEDBACK)
+ }
+ else if (localTm_.getTransaction().getStatus() == Status.STATUS_ROLLEDBACK)
{
log.info("endTransaction(): has been rolled back for id: " + id);
- } else
+ }
+ else
{
log.info("endTransaction(): rolling back tx for id: " + id);
localTm_.rollback();
1.2 +31 -25 JBossCache/src/org/jboss/cache/pojo/interceptors/PojoTxUndoInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoTxUndoInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/interceptors/PojoTxUndoInterceptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- PojoTxUndoInterceptor.java 13 Jan 2007 15:55:06 -0000 1.1
+++ PojoTxUndoInterceptor.java 23 May 2007 10:28:56 -0000 1.2
@@ -7,15 +7,16 @@
package org.jboss.cache.pojo.interceptors;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.cache.Fqn;
import org.jboss.cache.pojo.MethodDeclarations;
-import org.jboss.cache.pojo.PojoTxSynchronizationHandler;
import org.jboss.cache.pojo.PojoCacheException;
+import org.jboss.cache.pojo.PojoTxSynchronizationHandler;
import org.jboss.cache.pojo.util.MethodCall;
-import org.jboss.cache.Fqn;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import java.lang.reflect.Method;
+
import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.util.List;
/**
@@ -23,7 +24,7 @@
* operation that needs a corresponding rollback, e.g., attachInterceptor.
*
* @author Ben Wang
- * @version $Id: PojoTxUndoInterceptor.java,v 1.1 2007/01/13 15:55:06 bwang Exp $
+ * @version $Id: PojoTxUndoInterceptor.java,v 1.2 2007/05/23 10:28:56 msurtani Exp $
*/
public class PojoTxUndoInterceptor extends AbstractInterceptor
{
@@ -41,7 +42,7 @@
PojoTxSynchronizationHandler handler =
PojoTxUndoSynchronizationInterceptor.getSynchronizationHandler();
- if(handler == null)
+ if (handler == null)
{
return invocation.invokeNext();
// TODO handler is null can mean we are not calling the right interceptor stack. Need to revisit.
@@ -52,46 +53,51 @@
// Add to the rollback list
String methodName = invocation.getMethod().getName();
// TODO Needs to handle Collection interceptor as well.
- if( methodName.equals(MethodDeclarations.attachInterceptor.getName()))
+ if (methodName.equals(MethodDeclarations.attachInterceptor.getName()))
{
Method method = MethodDeclarations.undoAttachInterceptor;
MethodCall mc = new MethodCall(method, invocation.getArguments(), invocation.getTargetObject());
handler.addToList(mc);
- } else if ( methodName.equals(MethodDeclarations.detachInterceptor.getName()))
+ }
+ else if (methodName.equals(MethodDeclarations.detachInterceptor.getName()))
{
Method method = MethodDeclarations.undoDetachInterceptor;
MethodCall mc = new MethodCall(method, invocation.getArguments(), invocation.getTargetObject());
handler.addToList(mc);
- } else if ( methodName.equals(MethodDeclarations.inMemorySubstitution.getName()))
+ }
+ else if (methodName.equals(MethodDeclarations.inMemorySubstitution.getName()))
{
Method method = MethodDeclarations.undoInMemorySubstitution;
Object obj = invocation.getArguments()[0];
- Field field = (Field)invocation.getArguments()[1];
+ Field field = (Field) invocation.getArguments()[1];
Object oldValue = field.get(obj);
- Object[] args = new Object[] { obj, field, oldValue };
+ Object[] args = new Object[]{obj, field, oldValue};
MethodCall mc = new MethodCall(method, args, invocation.getTargetObject());
handler.addToList(mc);
- } else if ( methodName.equals(MethodDeclarations.incrementReferenceCount.getName()))
+ }
+ else if (methodName.equals(MethodDeclarations.incrementReferenceCount.getName()))
{
Method method = MethodDeclarations.undoIncrementReferenceCount;
- Fqn fqn = (Fqn)invocation.getArguments()[0];
- int count = (Integer)invocation.getArguments()[1];
- List referenceList = (List)invocation.getArguments()[2];
- Object[] args = new Object[] { fqn, count, referenceList };
+ Fqn fqn = (Fqn) invocation.getArguments()[0];
+ int count = (Integer) invocation.getArguments()[1];
+ List referenceList = (List) invocation.getArguments()[2];
+ Object[] args = new Object[]{fqn, count, referenceList};
MethodCall mc = new MethodCall(method, args, invocation.getTargetObject());
handler.addToList(mc);
- } else if ( methodName.equals(MethodDeclarations.decrementReferenceCount.getName()))
+ }
+ else if (methodName.equals(MethodDeclarations.decrementReferenceCount.getName()))
{
Method method = MethodDeclarations.undoDecrementReferenceCount;
- Fqn fqn = (Fqn)invocation.getArguments()[0];
- int count = (Integer)invocation.getArguments()[1];
- List referenceList = (List)invocation.getArguments()[2];
- Object[] args = new Object[] { fqn, count, referenceList };
+ Fqn fqn = (Fqn) invocation.getArguments()[0];
+ int count = (Integer) invocation.getArguments()[1];
+ List referenceList = (List) invocation.getArguments()[2];
+ Object[] args = new Object[]{fqn, count, referenceList};
MethodCall mc = new MethodCall(method, args, invocation.getTargetObject());
handler.addToList(mc);
- } else
+ }
+ else
{
- throw new PojoCacheException("PojoTxUndoInterceptor: invalid invocation name: " +methodName);
+ throw new PojoCacheException("PojoTxUndoInterceptor: invalid invocation name: " + methodName);
}
return invocation.invokeNext();
1.2 +14 -11 JBossCache/src/org/jboss/cache/pojo/interceptors/PojoBeginInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoBeginInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/interceptors/PojoBeginInterceptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- PojoBeginInterceptor.java 13 Jan 2007 15:55:06 -0000 1.1
+++ PojoBeginInterceptor.java 23 May 2007 10:28:56 -0000 1.2
@@ -7,19 +7,19 @@
package org.jboss.cache.pojo.interceptors;
-import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.aop.metadata.SimpleMetaData;
-/** The first interceptor that deals initialization.
+/**
+ * The first interceptor that deals initialization.
*
* @author Ben Wang
- * @version $Id: PojoBeginInterceptor.java,v 1.1 2007/01/13 15:55:06 bwang Exp $
+ * @version $Id: PojoBeginInterceptor.java,v 1.2 2007/05/23 10:28:56 msurtani Exp $
*/
public class PojoBeginInterceptor extends AbstractInterceptor
{
- private static ThreadLocal REPLICATE_FINAL = new ThreadLocal() ;
+ private static ThreadLocal REPLICATE_FINAL = new ThreadLocal();
public void setReplicateFinalField(String isTrue)
{
@@ -33,26 +33,29 @@
public static boolean getReplicateFinalField()
{
- if(REPLICATE_FINAL.get() == null) return false;
+ if (REPLICATE_FINAL.get() == null) return false;
- return (Boolean)REPLICATE_FINAL.get();
+ return (Boolean) REPLICATE_FINAL.get();
}
public Object invoke(Invocation in) throws Throwable
{
- if(!(in instanceof MethodInvocation))
+ if (!(in instanceof MethodInvocation))
{
throw new IllegalArgumentException("BeginInterceptor.invoke(): invocation not MethodInvocation");
}
- MethodInvocation invocation = (MethodInvocation)in;
+ MethodInvocation invocation = (MethodInvocation) in;
// Let's initialize the metadata
SimpleMetaData simple = new SimpleMetaData();
invocation.setMetaData(simple);
- try {
+ try
+ {
log.debug("**** Entering method: **** " + invocation.getMethod());
return invocation.invokeNext(); // proceed to next advice or actual call
- } finally {
+ }
+ finally
+ {
// reset(); // reset
log.debug("Leaving method: " + invocation.getMethod());
}
More information about the jboss-cvs-commits
mailing list