+ public ObjectName beginConfig(boolean blankTransaction) {
+ // If we're closed or in the process of closing then all modules are destroyed or being destroyed
+ // so there's no point in trying to acquire the lock and beginning an actual transaction. Also we want
+ // to avoid trying to lock as it may block the shutdown process if there is an outstanding transaction
+ // attempting to be committed.
+ //
+ // We could throw an exception here to indicate this but that's not part of the original API contract
+ // and callers may not be expecting an unchecked exception. Therefore we return a special transaction
+ // handle that signifies a "no-op".
+ if(closed.get()) {
+ return NOOP_TX_NAME;
+ }
+
+ if(blankTransaction) {
+ try {
+ // For a "blank" transaction, we'll try to obtain the config lock but "blank" transactions
+ // are initiated via OSGi events so we don't want to block indefinitely or for a long period
+ // of time.
+ if(!configTransactionLock.tryLock(5, TimeUnit.SECONDS)) {
+ LOG.debug("Timed out trying to obtain configTransactionLock");
+ return NOOP_TX_NAME;
+ }
+ } catch(InterruptedException e) {
+ LOG.debug("Interrupted trying to obtain configTransactionLock", e);
+ Thread.currentThread().interrupt();
+ return NOOP_TX_NAME;
+ }
+ } else {
+ configTransactionLock.lock();
+ }
+
+ try {
+ return beginConfigSafe(blankTransaction).getControllerObjectName();
+ } finally {
+ configTransactionLock.unlock();
+ }