mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 18:56:02 +02:00
[177332][api][breaking] added autostart attribute to persistence providers & minor changes to IRSEPersistenceManager API
This commit is contained in:
parent
891420a8af
commit
7ef8f1b99f
4 changed files with 64 additions and 22 deletions
|
@ -19,10 +19,12 @@
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.rse.core.persistenceProviders">
|
point="org.eclipse.rse.core.persistenceProviders">
|
||||||
<persistenceProvider
|
<persistenceProvider
|
||||||
|
autostart="false"
|
||||||
class="org.eclipse.rse.internal.persistence.SerializingProvider"
|
class="org.eclipse.rse.internal.persistence.SerializingProvider"
|
||||||
id="org.eclipse.rse.persistence.SerializingProvider"
|
id="org.eclipse.rse.persistence.SerializingProvider"
|
||||||
name="Serializing Persistence Provider"/>
|
name="Serializing Persistence Provider"/>
|
||||||
<persistenceProvider
|
<persistenceProvider
|
||||||
|
autostart="true"
|
||||||
class="org.eclipse.rse.internal.persistence.PropertyFileProvider"
|
class="org.eclipse.rse.internal.persistence.PropertyFileProvider"
|
||||||
id="org.eclipse.rse.persistence.PropertyFileProvider"
|
id="org.eclipse.rse.persistence.PropertyFileProvider"
|
||||||
name="Property File Persistence Provider"/>
|
name="Property File Persistence Provider"/>
|
||||||
|
|
|
@ -65,6 +65,13 @@
|
||||||
</appInfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="autostart" type="boolean" use="default" value="false">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
The autostart attribute determines if the persistence provider will be loaded and asked to restore the profiles known to it at the time RSE starts.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
|
@ -81,7 +88,8 @@
|
||||||
<persistenceProvider
|
<persistenceProvider
|
||||||
id="org.eclipse.rse.persistence.DefaultRSEpersistenceProvider"
|
id="org.eclipse.rse.persistence.DefaultRSEpersistenceProvider"
|
||||||
name="Default persistence Provider"
|
name="Default persistence Provider"
|
||||||
class="org.eclipse.rse.persistence.DefaultRSEpersistenceProvider">
|
class="org.eclipse.rse.persistence.DefaultRSEpersistenceProvider"
|
||||||
|
autostart="true">
|
||||||
</persistenceProvider>
|
</persistenceProvider>
|
||||||
</extension>
|
</extension>
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -112,13 +120,14 @@
|
||||||
<meta.section type="copyright"/>
|
<meta.section type="copyright"/>
|
||||||
</appInfo>
|
</appInfo>
|
||||||
<documentation>
|
<documentation>
|
||||||
Copyright (c) 2006 IBM Corporation. All Rights Reserved.
|
Copyright (c) 2006, 2007 IBM Corporation. All Rights Reserved.
|
||||||
This program and the accompanying materials are made available under the terms
|
This program and the accompanying materials are made available under the terms
|
||||||
of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
available at http://www.eclipse.org/legal/epl-v10.html
|
available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
|
||||||
Contributors:
|
Contributors:
|
||||||
IBM Corporation - initial API and implementation
|
IBM Corporation - initial API and implementation
|
||||||
|
David Dykstal (IBM) - added autostart attribute
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.eclipse.rse.internal.persistence;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -62,12 +63,17 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
|
||||||
private IConfigurationElement configurationElement = null;
|
private IConfigurationElement configurationElement = null;
|
||||||
private IRSEPersistenceProvider provider = null;
|
private IRSEPersistenceProvider provider = null;
|
||||||
private boolean restored = false;
|
private boolean restored = false;
|
||||||
synchronized boolean getRestored() {
|
synchronized boolean isRestored() {
|
||||||
return restored;
|
return restored;
|
||||||
}
|
}
|
||||||
synchronized void setRestored(boolean restored) {
|
synchronized void setRestored(boolean restored) {
|
||||||
this.restored = restored;
|
this.restored = restored;
|
||||||
}
|
}
|
||||||
|
boolean isAutostart() {
|
||||||
|
boolean isAutostart = (configurationElement != null && ("true".equals(configurationElement.getAttribute("autostart")))); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
boolean isDefault = (providerId.equals(getDefaultPersistenceProviderId()));
|
||||||
|
return isAutostart || isDefault;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map knownProviders = new HashMap(10);
|
private Map knownProviders = new HashMap(10);
|
||||||
|
@ -198,16 +204,25 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
|
||||||
* @see org.eclipse.rse.persistence.IRSEPersistenceManager#restoreProfiles()
|
* @see org.eclipse.rse.persistence.IRSEPersistenceManager#restoreProfiles()
|
||||||
*/
|
*/
|
||||||
public ISystemProfile[] restoreProfiles(long timeout) {
|
public ISystemProfile[] restoreProfiles(long timeout) {
|
||||||
List profiles = new ArrayList(10);
|
|
||||||
String[] ids = getPersistenceProviderIds();
|
String[] ids = getPersistenceProviderIds();
|
||||||
|
List selectedRecords = new ArrayList(10);
|
||||||
for (int i = 0; i < ids.length; i++) {
|
for (int i = 0; i < ids.length; i++) {
|
||||||
String id = ids[i];
|
String id = ids[i];
|
||||||
IRSEPersistenceProvider provider = getPersistenceProvider(id);
|
ProviderRecord pr = getProviderRecord(id);
|
||||||
if (provider != null) {
|
if (pr.isAutostart()) {
|
||||||
ISystemProfile[] providerProfiles = restoreProfiles(provider, timeout);
|
IRSEPersistenceProvider provider = getPersistenceProvider(id);
|
||||||
profiles.addAll(Arrays.asList(providerProfiles));
|
if (provider != null) {
|
||||||
|
pr.setRestored(false);
|
||||||
|
selectedRecords.add(pr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List profiles = new ArrayList(10);
|
||||||
|
for (Iterator z = selectedRecords.iterator(); z.hasNext();) {
|
||||||
|
ProviderRecord pr = (ProviderRecord) z.next();
|
||||||
|
ISystemProfile[] providerProfiles = restoreProfiles(pr.provider, timeout);
|
||||||
|
profiles.addAll(Arrays.asList(providerProfiles));
|
||||||
|
}
|
||||||
ISystemProfile[] result = new ISystemProfile[profiles.size()];
|
ISystemProfile[] result = new ISystemProfile[profiles.size()];
|
||||||
profiles.toArray(result);
|
profiles.toArray(result);
|
||||||
return result;
|
return result;
|
||||||
|
@ -218,7 +233,7 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
|
||||||
*/
|
*/
|
||||||
public ISystemProfile[] restoreProfiles(IRSEPersistenceProvider provider, long timeout) {
|
public ISystemProfile[] restoreProfiles(IRSEPersistenceProvider provider, long timeout) {
|
||||||
ProviderRecord pr = getProviderRecord(provider);
|
ProviderRecord pr = getProviderRecord(provider);
|
||||||
pr.setRestored(false);
|
pr.setRestored(false); // may already be false or true
|
||||||
List profiles = loadProfiles(provider, timeout);
|
List profiles = loadProfiles(provider, timeout);
|
||||||
pr.setRestored(true);
|
pr.setRestored(true);
|
||||||
ISystemProfile[] result = new ISystemProfile[profiles.size()];
|
ISystemProfile[] result = new ISystemProfile[profiles.size()];
|
||||||
|
@ -229,10 +244,15 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.rse.persistence.IRSEPersistenceManager#isRestoreComplete(java.lang.String)
|
* @see org.eclipse.rse.persistence.IRSEPersistenceManager#isRestoreComplete(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public boolean isRestoreComplete(String providerId) {
|
public boolean isRestoreComplete() {
|
||||||
ProviderRecord providerRecord = getProviderRecord(providerId);
|
boolean isComplete = true;
|
||||||
boolean result = providerRecord.getRestored();
|
String[] ids = getPersistenceProviderIds();
|
||||||
return result;
|
for (int i = 0; i < ids.length && isComplete; i++) {
|
||||||
|
String id = ids[i];
|
||||||
|
ProviderRecord pr = getProviderRecord(id);
|
||||||
|
isComplete = pr.isAutostart() && pr.isRestored();
|
||||||
|
}
|
||||||
|
return isComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProviderRecord getProviderRecord(String providerId) {
|
private ProviderRecord getProviderRecord(String providerId) {
|
||||||
|
@ -277,6 +297,7 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
|
||||||
if (candidateId != null) {
|
if (candidateId != null) {
|
||||||
ProviderRecord pr = getProviderRecord(candidateId);
|
ProviderRecord pr = getProviderRecord(candidateId);
|
||||||
pr.configurationElement = configurationElement;
|
pr.configurationElement = configurationElement;
|
||||||
|
pr.providerId = candidateId;
|
||||||
} else {
|
} else {
|
||||||
logger.logError("Missing id attribute in persistenceProvider element", null); //$NON-NLS-1$
|
logger.logError("Missing id attribute in persistenceProvider element", null); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -296,11 +317,22 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
|
||||||
* @return the default IRSEPersistenceProvider for this installation.
|
* @return the default IRSEPersistenceProvider for this installation.
|
||||||
*/
|
*/
|
||||||
private IRSEPersistenceProvider getDefaultPersistenceProvider() {
|
private IRSEPersistenceProvider getDefaultPersistenceProvider() {
|
||||||
Preferences preferences = RSECorePlugin.getDefault().getPluginPreferences();
|
String providerId = getDefaultPersistenceProviderId();
|
||||||
String providerId = preferences.getString(IRSEPreferenceNames.DEFAULT_PERSISTENCE_PROVIDER);
|
|
||||||
IRSEPersistenceProvider provider = getPersistenceProvider(providerId);
|
IRSEPersistenceProvider provider = getPersistenceProvider(providerId);
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the default persistence provider id from the preferences.
|
||||||
|
* This persistence provider identifier is specified in the org.eclipse.rse.core/DEFAULT_PERSISTENCE_PROVIDER
|
||||||
|
* preference and can be specified a product's plugin_customization.ini file.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getDefaultPersistenceProviderId() {
|
||||||
|
Preferences preferences = RSECorePlugin.getDefault().getPluginPreferences();
|
||||||
|
String providerId = preferences.getString(IRSEPreferenceNames.DEFAULT_PERSISTENCE_PROVIDER);
|
||||||
|
return providerId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the profiles for a given persistence provider.
|
* Loads the profiles for a given persistence provider.
|
||||||
|
|
|
@ -43,7 +43,7 @@ public interface IRSEPersistenceManager {
|
||||||
public ISystemProfile[] commitProfiles(long timeout);
|
public ISystemProfile[] commitProfiles(long timeout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore all profiles.
|
* Restore all profiles known to autostart persistence providers.
|
||||||
* @param timeout the maximum number of milliseconds to wait for the manager to become idle for each profile.
|
* @param timeout the maximum number of milliseconds to wait for the manager to become idle for each profile.
|
||||||
* @return an array of restored profiles.
|
* @return an array of restored profiles.
|
||||||
*/
|
*/
|
||||||
|
@ -106,14 +106,13 @@ public interface IRSEPersistenceManager {
|
||||||
public boolean isBusy();
|
public boolean isBusy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicate if all profiles for a particular persistence provider have been restored.
|
* Indicate if all profiles for all autostart persistence provider have been restored.
|
||||||
* Profiles are typically restored when RSE is activated and when profiles
|
* These profiles are restored when RSE is activated and when profiles
|
||||||
* are reloaded by the user. This will not load the persistence provider. If the persistence
|
* are reloaded by the user.
|
||||||
* provider has not yet been loaded it will return false. This can be used from a different thread
|
* This can be used from a different thread
|
||||||
* than the one that requested the restore.
|
* than the one that requested the restore.
|
||||||
* @param providerId the persistence providerId
|
|
||||||
* @return true if the profiles have been fully restored
|
* @return true if the profiles have been fully restored
|
||||||
*/
|
*/
|
||||||
public boolean isRestoreComplete(String providerId);
|
public boolean isRestoreComplete();
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue