diff --git a/rse/plugins/org.eclipse.rse.core/plugin.xml b/rse/plugins/org.eclipse.rse.core/plugin.xml index 68791d3d4de..3d050216522 100644 --- a/rse/plugins/org.eclipse.rse.core/plugin.xml +++ b/rse/plugins/org.eclipse.rse.core/plugin.xml @@ -22,7 +22,24 @@ autostart="true" class="org.eclipse.rse.internal.persistence.PropertyFileProvider" id="org.eclipse.rse.persistence.PropertyFileProvider" - name="Property File Persistence Provider"/> + name="Property File Persistence Provider (workspace)"> + + + + diff --git a/rse/plugins/org.eclipse.rse.core/schema/persistenceProviders.exsd b/rse/plugins/org.eclipse.rse.core/schema/persistenceProviders.exsd index cfcad857f75..4337d822b6c 100644 --- a/rse/plugins/org.eclipse.rse.core/schema/persistenceProviders.exsd +++ b/rse/plugins/org.eclipse.rse.core/schema/persistenceProviders.exsd @@ -40,7 +40,15 @@ + + + The persistenceProvider element defines a class that implements the IRSEPersistenceProvider interface. It is used to persist the RSE object model to a form of external storage. + + + + + @@ -75,6 +83,30 @@ + + + + The property element is contained within the persistenceProvider element. Use these to provide properties that can tailor the behavior of a persistence provider. Each provider must document the properties that it expects. + + + + + + + The name attribute provides the name for this property. + + + + + + + The value attribute provides the string value for this property. + + + + + + diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/PropertyFileProvider.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/PropertyFileProvider.java index 2a66253ca40..8aa9bf149c8 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/PropertyFileProvider.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/PropertyFileProvider.java @@ -98,6 +98,14 @@ public class PropertyFileProvider implements IRSEPersistenceProvider { private static final String VALID = "abcdefghijklmnopqrstuvwxyz0123456789-._"; //$NON-NLS-1$ private static final String UPPER = "ABCDEFGHIJKLMNOPQRTSUVWXYZ"; //$NON-NLS-1$ + /* properties */ + private static final String P_LOCATION = "location"; //$NON-NLS-1$ + + /* property values */ + private static final String PV_LOCATION_WORKSPACE = "workspace"; //$NON-NLS-1$ + private static final String PV_LOCATION_METADATA = "metadata"; //$NON-NLS-1$ + + interface PersistenceAnchor { String[] getProfileLocationNames(); IStatus deleteProfileLocation(String profileName, IProgressMonitor monitor); @@ -337,6 +345,7 @@ public class PropertyFileProvider implements IRSEPersistenceProvider { private Map typeQualifiers = getTypeQualifiers(); private Map saveJobs = new HashMap(); private PersistenceAnchor anchor = new WorkspaceAnchor(); + private Properties properties = null; /* (non-Javadoc) * @see org.eclipse.rse.persistence.IRSEPersistenceProvider#getSavedProfileNames() @@ -413,6 +422,23 @@ public class PropertyFileProvider implements IRSEPersistenceProvider { } return saveJob; } + + /* (non-Javadoc) + * @see org.eclipse.rse.persistence.IRSEPersistenceProvider#setProperties(java.util.Properties) + */ + public void setProperties(Properties properties) { + Properties defaults = new Properties(); + defaults.setProperty(P_LOCATION, PV_LOCATION_WORKSPACE); + this.properties = new Properties(defaults); + Set keys = properties.keySet(); + for (Iterator z = keys.iterator(); z.hasNext();) { + String key = (String) z.next(); + String value = properties.getProperty(key); + if (value != null) { + this.properties.put(key, value); + } + } + } /** * Saves a node from the DOM to the file system. diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java index 8e79679d5dc..c2ef46fa7dd 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; import org.eclipse.core.runtime.CoreException; @@ -113,15 +114,7 @@ public class RSEPersistenceManager implements IRSEPersistenceManager { */ public IRSEPersistenceProvider getPersistenceProvider(String id) { ProviderRecord pr = getProviderRecord(id); - if (pr.provider == null && pr.configurationElement != null) { - try { - pr.provider = (IRSEPersistenceProvider) pr.configurationElement.createExecutableExtension("class"); //$NON-NLS-1$ - loadedProviders.put(pr.provider, pr.providerId); - } catch (CoreException e) { - Logger logger = RSECorePlugin.getDefault().getLogger(); - logger.logError("Exception loading persistence provider", e); //$NON-NLS-1$ - } - } + loadProvider(pr); return pr.provider; } @@ -279,7 +272,7 @@ public class RSEPersistenceManager implements IRSEPersistenceManager { } return pr; } - + /** * Loads the map of known providers from the extensions made by all the plugins. * This is done once at initialization of the manager. As these ids are resolved to @@ -307,6 +300,35 @@ public class RSEPersistenceManager implements IRSEPersistenceManager { } } + /** + * Loads a provider given a provider record. If the provider has already been loaded + * it will not load it again. After loading, the provider will be initialized with any + * properties found in the extension. + * @param pr the provider record containing the configuration element describing the provider + * @return the provider + */ + private IRSEPersistenceProvider loadProvider(ProviderRecord pr) { + if (pr.provider == null) { + try { + pr.provider = (IRSEPersistenceProvider) pr.configurationElement.createExecutableExtension("class"); //$NON-NLS-1$ + loadedProviders.put(pr.provider, pr.providerId); + Properties properties = new Properties(); + IConfigurationElement[] children = pr.configurationElement.getChildren("property"); //$NON-NLS-1$ + for (int i = 0; i < children.length; i++) { + IConfigurationElement child = children[i]; + String name = child.getAttribute("name"); //$NON-NLS-1$ + String value = child.getAttribute("value"); //$NON-NLS-1$ + properties.put(name, value); + } + pr.provider.setProperties(properties); + } catch (CoreException e) { + Logger logger = RSECorePlugin.getDefault().getLogger(); + logger.logError("Exception loading persistence provider", e); //$NON-NLS-1$ + } + } + return pr.provider; + } + /** * Retrieves the default persistence provider for this workbench configuration. * Several persistence providers may be registered, but the default one is used for all diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/SerializingProvider.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/SerializingProvider.java index d7df076bf86..14f3f49cbe7 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/SerializingProvider.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/SerializingProvider.java @@ -23,6 +23,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.util.List; +import java.util.Properties; import java.util.Vector; import org.eclipse.core.resources.IFile; @@ -173,4 +174,11 @@ public class SerializingProvider implements IRSEPersistenceProvider { } return result; } + + /* (non-Javadoc) + * @see org.eclipse.rse.persistence.IRSEPersistenceProvider#setProperties(java.util.Properties) + */ + public void setProperties(Properties properties) { + // Do nothing. The serializing provider does not make use of properties + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/persistence/IRSEPersistenceProvider.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/persistence/IRSEPersistenceProvider.java index 942bd71e851..6cf319a472b 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/persistence/IRSEPersistenceProvider.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/persistence/IRSEPersistenceProvider.java @@ -17,6 +17,8 @@ package org.eclipse.rse.persistence; +import java.util.Properties; + import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.jobs.Job; @@ -34,6 +36,15 @@ import org.eclipse.rse.persistence.dom.RSEDOM; */ public interface IRSEPersistenceProvider { + /** + * Sets the properties for this provider. This must be done immediately + * after the provider is instantiated. The persistence manager will + * provide these properties for providers defined as extensions. + * @param properties the properties object containing the properties + * supplied in the extension. + */ + public void setProperties(Properties properties); + /** * Restores an RSE DOM given a profileName. * @@ -53,7 +64,7 @@ public interface IRSEPersistenceProvider { * @return true if succcessful */ public boolean saveRSEDOM(RSEDOM dom, IProgressMonitor monitor); - + /** * Returns a job suitable for saving a DOM. * The result can be null if the persistence provider determines that