pull out doSave() method from ComponentManagerImpl

This commit is contained in:
Dmitry Jemerov
2011-08-18 18:32:21 +02:00
parent 3c8544c74e
commit 11faa80daa
4 changed files with 43 additions and 16 deletions
@@ -1214,7 +1214,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
public void _saveSettings() { // public for testing purposes
if (mySaveSettingsIsInProgress.compareAndSet(false, true)) {
try {
doSave();
StoreUtil.doSave(getStateStore());
}
catch (final Throwable ex) {
if (isUnitTestMode()) {
@@ -708,20 +708,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
}
}
protected void doSave() throws IOException {
IComponentStore.SaveSession session = null;
try {
session = getStateStore().startSave();
session.save();
}
finally {
if (session != null) {
session.finishSave();
}
}
}
public final int hashCode() {
public final int hashCode() {
return super.hashCode();
}
@@ -0,0 +1,39 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.components.impl.stores;
import java.io.IOException;
/**
* @author yole
*/
public class StoreUtil {
private StoreUtil() {
}
public static void doSave(IComponentStore stateStore) throws IOException {
IComponentStore.SaveSession session = null;
try {
session = stateStore.startSave();
session.save();
}
finally {
if (session != null) {
session.finishSave();
}
}
}
}
@@ -34,6 +34,7 @@ import com.intellij.openapi.components.impl.ComponentManagerImpl;
import com.intellij.openapi.components.impl.ProjectPathMacroManager;
import com.intellij.openapi.components.impl.stores.IComponentStore;
import com.intellij.openapi.components.impl.stores.IProjectStore;
import com.intellij.openapi.components.impl.stores.StoreUtil;
import com.intellij.openapi.components.impl.stores.UnknownMacroNotification;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.ExtensionPointName;
@@ -304,7 +305,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
}
}
doSave();
StoreUtil.doSave(getStateStore());
}
catch (IComponentStore.SaveCancelledException e) {
LOG.info(e);