[prev in list] [next in list] [prev in thread] [next in thread]
List: slide-dev
Subject: cvs commit: jakarta-slide/src/share/org/apache/slide/transaction SlideTransactionManager.java
From: juergen () apache ! org
Date: 2003-04-24 16:22:12
[Download RAW message or body]
juergen 2003/04/24 09:22:10
Modified: src/share/org/apache/slide/macro ConflictException.java
src/share/org/apache/slide/security SecurityException.java
src/share/org/apache/slide/common
ServiceAccessException.java
src/share/org/apache/slide/transaction
SlideTransactionManager.java
Log:
minimise the noise of tracing in case of a standard environment. Only logging is \
now printed.
Revision Changes Path
1.5 +29 -29 \
jakarta-slide/src/share/org/apache/slide/macro/ConflictException.java
Index: ConflictException.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/ConflictException.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ConflictException.java 25 Apr 2002 21:12:32 -0000 1.4
+++ ConflictException.java 24 Apr 2003 16:22:08 -0000 1.5
@@ -77,11 +77,11 @@
* @version $Revision$
*/
public class ConflictException extends SlideException {
-
-
+
+
// ----------------------------------------------------------- Constructors
-
-
+
+
/**
* Constructor.
*
@@ -90,8 +90,8 @@
public ConflictException(String objectUri) {
this(objectUri, new SlideException("no cause given", false));
}
-
-
+
+
/**
* Constructor.
*
@@ -99,32 +99,32 @@
* @param t Throwable containing the reason
*/
public ConflictException(String objectUri, Throwable t) {
- super(Messages.format(ConflictException.class.getName(), objectUri, \
computeCause(t)), t!=null); + \
super(Messages.format(ConflictException.class.getName(), objectUri, computeCause(t)), \
false); this.objectUri = objectUri;
this.nestedException = t;
}
-
-
-
-
+
+
+
+
// ----------------------------------------------------- Instance Variables
-
-
+
+
/**
* Object uri.
*/
private String objectUri;
-
+
/* hold the cause exception, if supplied */
private Throwable nestedException = null;
-
-
-
+
+
+
// ------------------------------------------------------------- Properties
-
-
+
+
/**
* Object Uri accessor.
*
@@ -133,9 +133,9 @@
public String getObjectUri() {
return objectUri;
}
-
-
-
+
+
+
/**
* computeCause.
*
@@ -144,7 +144,7 @@
private static String computeCause(Throwable e) {
return computeCause(e==null?"":e.getMessage(), e);
}
-
+
/**
* computeCause.
*
@@ -160,6 +160,6 @@
}
return result;
}
-
-
+
+
}
1.5 +17 -17 \
jakarta-slide/src/share/org/apache/slide/security/SecurityException.java
Index: SecurityException.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/security/SecurityException.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SecurityException.java 25 Apr 2002 21:30:16 -0000 1.4
+++ SecurityException.java 24 Apr 2003 16:22:09 -0000 1.5
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -23,15 +23,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Slide", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
@@ -59,7 +59,7 @@
*
* [Additional notices, if required by prior licensing conditions]
*
- */
+ */
package org.apache.slide.security;
@@ -67,23 +67,23 @@
/**
* Generic security exception.
- *
+ *
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
* @version $Revision$
*/
public class SecurityException extends SlideException {
-
-
+
+
// ----------------------------------------------------------- Constructors
-
-
+
+
/**
* Constructor.
- *
+ *
* @param message Exception message
*/
public SecurityException(String message) {
- super(message);
+ super(message, false);
}
}
1.8 +16 -16 \
jakarta-slide/src/share/org/apache/slide/common/ServiceAccessException.java
Index: ServiceAccessException.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/ServiceAccessException.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ServiceAccessException.java 25 Apr 2002 21:30:12 -0000 1.7
+++ ServiceAccessException.java 24 Apr 2003 16:22:09 -0000 1.8
@@ -74,15 +74,15 @@
* @version $Revision$
*/
public class ServiceAccessException extends SlideException {
-
+
/* hold the cause exception, if supplied */
private Throwable nestedException = null;
-
+
// ----------------------------------------------------------- Constructors
-
-
+
+
/**
* Constructor.
*
@@ -91,10 +91,10 @@
*/
public ServiceAccessException(Service service, String cause) {
super(Messages.format
- (ServiceAccessException.class.getName(), service, \
computeCause(cause))); + (ServiceAccessException.class.getName(), \
service, computeCause(cause)), false); }
-
-
+
+
/**
* Constructor.
*
@@ -105,7 +105,7 @@
this(service, computeCause(e));
nestedException = e;
}
-
+
/**
* computeCause.
*
@@ -121,7 +121,7 @@
}
return result;
}
-
+
/**
* computeCause.
*
@@ -130,7 +130,7 @@
private static String computeCause(String delieveredCause) {
return computeCause(delieveredCause, new SlideException("cause is empty", \
false)); }
-
+
/**
* computeCause.
*
@@ -149,6 +149,6 @@
public Throwable getCauseException() {
return nestedException;
}
-
-
+
+
}
1.11 +82 -82 \
jakarta-slide/src/share/org/apache/slide/transaction/SlideTransactionManager.java
Index: SlideTransactionManager.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/transaction/SlideTransactionManager.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SlideTransactionManager.java 25 Apr 2002 21:15:11 -0000 1.10
+++ SlideTransactionManager.java 24 Apr 2003 16:22:09 -0000 1.11
@@ -95,67 +95,67 @@
* @version $Revision$
*/
public final class SlideTransactionManager implements TransactionManager {
-
-
+
+
// -------------------------------------------------------------- Constants
-
-
+
+
protected static final String LOG_CHANNEL =
SlideTransactionManager.class.getName();
-
-
+
+
public static final int DEFAULT_TRANSACTION_TIMEOUT = 30;
-
-
+
+
// ------------------------------------------------------------ Constructor
-
-
+
+
// ----------------------------------------------------- Instance Variables
-
-
+
+
/**
* Transaction bindings thread id <-> transaction object.
*/
private Hashtable bindings = new Hashtable();
-
-
+
+
/**
* Transaction bindings thread id <-> transaction timeout.
*/
private Hashtable timeouts = new Hashtable();
-
-
+
+
/**
* Associated logger.
*/
private Logger logger = new SimpleLogger();
-
-
+
+
// ------------------------------------------------------------- Properties
-
-
+
+
// --------------------------------------------------------- Public Methods
-
-
+
+
/**
* Get the logger associated with the transaction manager.
*/
public Logger getLogger() {
return logger;
}
-
-
+
+
/**
* Set the logger of the transaction manager.
*/
public void setLogger(Logger logger) {
this.logger = logger;
}
-
-
+
+
// --------------------------------------------- TransactionManager Methods
-
-
+
+
/**
* Create a new transaction and associate it with the current thread.
*
@@ -167,24 +167,24 @@
*/
public void begin()
throws NotSupportedException, SystemException {
-
+
Transaction currentTransaction = getTransaction();
if (currentTransaction != null)
throw new NotSupportedException();
-
+
currentTransaction = new SlideTransaction(this);
bindings.put(Thread.currentThread(), currentTransaction);
-
+
if (logger.isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
String logMessage = Messages.format
(SlideTransactionManager.class.getName() + ".begin",
currentTransaction.toString());
logger.log(logMessage, LOG_CHANNEL, Logger.DEBUG);
}
-
+
}
-
-
+
+
/**
* Complete the transaction associated with the current thread. When this
* method completes, the thread becomes associated with no transaction.
@@ -210,31 +210,31 @@
throws RollbackException, HeuristicMixedException,
HeuristicRollbackException, SecurityException, IllegalStateException,
SystemException {
-
+
Thread currentThread = Thread.currentThread();
Transaction currentTransaction =
(Transaction) bindings.get(currentThread);
if (currentTransaction == null)
throw new IllegalStateException();
-
+
timeouts.remove(currentThread);
-
+
if (logger.isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
String logMessage = Messages.format
(SlideTransactionManager.class.getName() + ".commit",
currentTransaction.toString());
logger.log(logMessage, LOG_CHANNEL, Logger.DEBUG);
}
-
+
try {
currentTransaction.commit();
} finally {
bindings.remove(currentThread);
}
-
+
}
-
-
+
+
/**
* Roll back the transaction associated with the current thread. When
* this method completes, the thread becomes associated with no
@@ -249,25 +249,25 @@
*/
public void rollback()
throws SecurityException, IllegalStateException, SystemException {
-
+
Thread currentThread = Thread.currentThread();
Transaction currentTransaction =
(Transaction) bindings.remove(currentThread);
if (currentTransaction == null)
throw new IllegalStateException();
-
+
timeouts.remove(currentThread);
-
+
String logMessage = Messages.format
(SlideTransactionManager.class.getName() + ".rollback",
currentTransaction.toString());
- logger.log(logMessage, LOG_CHANNEL, Logger.WARNING);
-
+ logger.log(logMessage, LOG_CHANNEL, Logger.DEBUG);
+
currentTransaction.rollback();
-
+
}
-
-
+
+
/**
* Modify the transaction associated with the current thread such that
* the only possible outcome of the transaction is to roll back the
@@ -280,21 +280,21 @@
*/
public void setRollbackOnly()
throws IllegalStateException, SystemException {
-
+
Transaction currentTransaction = getTransaction();
if (currentTransaction == null)
throw new IllegalStateException();
-
+
String logMessage = Messages.format
(SlideTransactionManager.class.getName() + ".rollbackOnly",
currentTransaction.toString());
logger.log(logMessage, LOG_CHANNEL, Logger.INFO);
-
+
currentTransaction.setRollbackOnly();
-
+
}
-
-
+
+
/**
* Obtain the status of the transaction associated with the current thread.
*
@@ -305,16 +305,16 @@
*/
public int getStatus()
throws SystemException {
-
+
Transaction currentTransaction = getTransaction();
if (currentTransaction == null)
return Status.STATUS_NO_TRANSACTION;
-
+
return currentTransaction.getStatus();
-
+
}
-
-
+
+
/**
* Get the transaction object that represents the transaction context of
* the calling thread.
@@ -328,8 +328,8 @@
throws SystemException {
return (Transaction) bindings.get(Thread.currentThread());
}
-
-
+
+
/**
* Resume the transaction context association of the calling thread with
* the transaction represented by the supplied Transaction object. When
@@ -348,18 +348,18 @@
public void resume(Transaction tobj)
throws InvalidTransactionException, IllegalStateException,
SystemException {
-
+
if (getTransaction() != null)
throw new IllegalStateException();
-
+
if (tobj == null)
throw new InvalidTransactionException();
-
+
bindings.put(Thread.currentThread(), tobj);
-
+
}
-
-
+
+
/**
* Suspend the transaction currently associated with the calling thread
* and return a Transaction object that represents the transaction
@@ -373,20 +373,20 @@
*/
public Transaction suspend()
throws SystemException {
-
+
Transaction currentTransaction = getTransaction();
-
+
if (currentTransaction != null) {
Thread currentThread = Thread.currentThread();
bindings.remove(currentThread);
timeouts.remove(currentThread);
}
-
+
return currentTransaction;
-
+
}
-
-
+
+
/**
* Modify the value of the timeout value that is associated with the
* transactions started by the current thread with the begin method.
@@ -401,10 +401,10 @@
*/
public void setTransactionTimeout(int seconds)
throws SystemException {
-
+
timeouts.put(Thread.currentThread(), new Integer(seconds));
-
+
}
-
-
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic