summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-12-16 10:45:33 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-12-16 14:21:26 +0100
commite9e61809ea31b30f50d39dda45e54bed6f0e4742 (patch)
tree4da2b3bc056956880e6bea7717b6eea74a0281ab /framework
parentfc44b7104cacc5ec76d2a0b560a9f6bbc5c252b5 (diff)
Simplify TransactionManager
Change-Id: I51d1969f9f88d9e29fc081fd54df365578900126
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/threadhelp/transactionmanager.hxx21
-rw-r--r--framework/source/fwi/threadhelp/transactionmanager.cxx114
2 files changed, 25 insertions, 110 deletions
diff --git a/framework/inc/threadhelp/transactionmanager.hxx b/framework/inc/threadhelp/transactionmanager.hxx
index cc9e0b1ea549..e4beb04741d4 100644
--- a/framework/inc/threadhelp/transactionmanager.hxx
+++ b/framework/inc/threadhelp/transactionmanager.hxx
@@ -52,18 +52,6 @@ enum EWorkingMode
};
/*-************************************************************************************************************
- @descr If a request was refused by a transaction manager (internal state different E_WORK ...)
- user can check the reason by using this enum values.
-*//*-*************************************************************************************************************/
-enum ERejectReason
-{
- E_UNINITIALIZED ,
- E_NOREASON ,
- E_INCLOSE ,
- E_CLOSED
-};
-
-/*-************************************************************************************************************
@descr A transaction object should support throwing exceptions if user used it at wrong working mode.
e.g. We can throw a DisposedException if user try to work and our mode is E_CLOSE!
But sometimes he doesn't need this feature - will handle it by himself.
@@ -120,18 +108,9 @@ class FWI_DLLPUBLIC TransactionManager: private boost::noncopyable
~TransactionManager ( );
void setWorkingMode ( EWorkingMode eMode );
EWorkingMode getWorkingMode ( ) const;
- bool isCallRejected ( ERejectReason& eReason ) const;
void registerTransaction ( EExceptionMode eMode ) throw( css::uno::RuntimeException, css::lang::DisposedException );
void unregisterTransaction ( ) throw( css::uno::RuntimeException, css::lang::DisposedException );
- // private methods
-
- private:
-
- void impl_throwExceptions( EExceptionMode eMode, ERejectReason eReason ) const throw( css::uno::RuntimeException, css::lang::DisposedException );
-
- // private member
-
private:
mutable ::osl::Mutex m_aAccessLock; /// regulate access on internal member of this instance
diff --git a/framework/source/fwi/threadhelp/transactionmanager.cxx b/framework/source/fwi/threadhelp/transactionmanager.cxx
index 6639d78a4695..a6d8efc466a1 100644
--- a/framework/source/fwi/threadhelp/transactionmanager.cxx
+++ b/framework/source/fwi/threadhelp/transactionmanager.cxx
@@ -155,22 +155,34 @@ EWorkingMode TransactionManager::getWorkingMode() const
*//*-*****************************************************************************************************/
void TransactionManager::registerTransaction( EExceptionMode eMode ) throw( css::uno::RuntimeException, css::lang::DisposedException )
{
- // Look for rejected calls first.
- // If call was refused we throw some exceptions or do nothing!
- // It depends from given parameter eMode.
- ERejectReason eReason;
- if( isCallRejected( eReason ) )
+ ::osl::MutexGuard aAccessGuard( m_aAccessLock );
+ switch( m_eWorkingMode )
{
- impl_throwExceptions( eMode, eReason );
+ case E_INIT:
+ if( eMode == E_HARDEXCEPTIONS )
+ {
+ // Help programmer to find out, why this exception is thrown!
+ SAL_WARN( "fwk", "TransactionManager...: Owner instance not correctly initialized yet. Call was rejected! Normally it's an algorithm error ... wrong use of class!" );
+ //ATTENTION: temp. disabled - till all bad code positions are detected and changed! */
+ // throw css::uno::RuntimeException( "TransactionManager...\nOwner instance not right initialized yet. Call was rejected! Normally it's an algorithm error... wrong using of class!\n", css::uno::Reference< css::uno::XInterface >() );
+ }
+ break;
+ case E_WORK:
+ break;
+ case E_BEFORECLOSE:
+ if( eMode == E_HARDEXCEPTIONS )
+ {
+ // Help programmer to find out, why this exception is thrown!
+ SAL_WARN( "fwk", "TransactionManager...: Owner instance stand in close method. Call was rejected!" );
+ throw css::lang::DisposedException( "TransactionManager...\nOwner instance stand in close method. Call was rejected!" );
+ }
+ break;
+ case E_CLOSE:
+ // Help programmer to find out, why this exception is thrown!
+ SAL_WARN( "fwk", "TransactionManager...: Owner instance already closed. Call was rejected!" );
+ throw css::lang::DisposedException( "TransactionManager...\nOwner instance already closed. Call was rejected!" );
}
- // BUT if no exception was thrown ... (may be eMode = E_SOFTEXCEPTIONS!)
- // we must register this transaction too!
- // Don't use "else" or a new scope here!!!
-
- // Safe access to internal member.
- ::osl::MutexGuard aAccessGuard( m_aAccessLock );
-
// Register this new transaction.
// If it is the first one .. close gate to disable changing of working mode.
++m_nTransactionCount;
@@ -203,82 +215,6 @@ void TransactionManager::unregisterTransaction() throw( css::uno::RuntimeExcept
}
}
-/*-****************************************************************************************************
- @short look for rejected calls
- @descr Sometimes user need a possibility to get information about rejected calls
- without starting a transaction!
- @param "eReason" returns reason of a rejected call
- @return true if call was rejected, false otherwise
-
- @onerror We return false.
-*//*-*****************************************************************************************************/
-bool TransactionManager::isCallRejected( ERejectReason& eReason ) const
-{
- // This call must safe access to internal member only.
- // Set "possible reason" for return and check reject-state then!
- // User should look for return value first - reason then ...
- ::osl::MutexGuard aAccessGuard( m_aAccessLock );
- switch( m_eWorkingMode )
- {
- case E_INIT : eReason = E_UNINITIALIZED;
- break;
- case E_WORK : eReason = E_NOREASON;
- break;
- case E_BEFORECLOSE : eReason = E_INCLOSE;
- break;
- case E_CLOSE : eReason = E_CLOSED;
- break;
- }
- return( eReason!=E_NOREASON );
-}
-
-/*-****************************************************************************************************
- @short throw any exceptions for rejected calls
- @descr If a user wishes to use our automatic exception mode we use this impl-method.
- We check all combinations of eReason and eExceptionMode and throw correct exception with some
- descriptions for the recipient.
-
- @seealso method registerTransaction()
- @seealso enum ERejectReason
- @seealso enum EExceptionMode
-
- @param "eReason" , reason for rejected call
- @param "eMode" , exception mode - set by user
-*//*-*****************************************************************************************************/
-void TransactionManager::impl_throwExceptions( EExceptionMode eMode, ERejectReason eReason ) const throw( css::uno::RuntimeException, css::lang::DisposedException )
-{
- switch( eReason )
- {
- case E_UNINITIALIZED : if( eMode == E_HARDEXCEPTIONS )
- {
- // Help programmer to find out, why this exception is thrown!
- SAL_WARN( "fwk", "TransactionManager...: Owner instance not correctly initialized yet. Call was rejected! Normally it's an algorithm error ... wrong use of class!" );
- //ATTENTION: temp. disabled - till all bad code positions are detected and changed! */
- // throw css::uno::RuntimeException( "TransactionManager...\nOwner instance not right initialized yet. Call was rejected! Normally it's an algorithm error... wrong using of class!\n", css::uno::Reference< css::uno::XInterface >() );
- }
- break;
- case E_INCLOSE : if( eMode == E_HARDEXCEPTIONS )
- {
- // Help programmer to find out, why this exception is thrown!
- SAL_WARN( "fwk", "TransactionManager...: Owner instance stand in close method. Call was rejected!" );
- throw css::lang::DisposedException( "TransactionManager...\nOwner instance stand in close method. Call was rejected!" );
- }
- break;
- case E_CLOSED : {
- // Help programmer to find out, why this exception is thrown!
- SAL_WARN( "fwk", "TransactionManager...: Owner instance already closed. Call was rejected!" );
- throw css::lang::DisposedException( "TransactionManager...\nOwner instance already closed. Call was rejected!" );
- }
- case E_NOREASON : {
- // Help programmer to find out
- SAL_WARN( "fwk", "TransactionManager...: Impossible case E_NOREASON!" );
- }
- break;
- default:
- assert(false);
- }
-}
-
} // namespace framework
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */