diff --git a/rse/plugins/org.eclipse.rse.core/plugin.properties b/rse/plugins/org.eclipse.rse.core/plugin.properties index fee9b2d0838..b4fb0a182d8 100644 --- a/rse/plugins/org.eclipse.rse.core/plugin.properties +++ b/rse/plugins/org.eclipse.rse.core/plugin.properties @@ -14,3 +14,7 @@ pluginName = RSE Core providerName = Eclipse.org + +extPoint.systemTypes=RSE System Types +extPoint.persistenceProviders=RSE Persistence Providers +extPoint.systemTypeProviders=RSE System Type Providers diff --git a/rse/plugins/org.eclipse.rse.core/plugin.xml b/rse/plugins/org.eclipse.rse.core/plugin.xml index 188a193f557..e970efccb08 100644 --- a/rse/plugins/org.eclipse.rse.core/plugin.xml +++ b/rse/plugins/org.eclipse.rse.core/plugin.xml @@ -1,12 +1,15 @@ - + + diff --git a/rse/plugins/org.eclipse.rse.core/schema/systemTypeProviders.exsd b/rse/plugins/org.eclipse.rse.core/schema/systemTypeProviders.exsd new file mode 100644 index 00000000000..02678892659 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.core/schema/systemTypeProviders.exsd @@ -0,0 +1,129 @@ + + + + + + + + + This extension point is used to allow the contribution of dynamically generated RSE system types by vendors where needed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + a unique name that will be used to identify the system type Provider. + + + + + + + a fully qualified name of the Java class that implements the <samp>org.eclipse.rse.core.IRSESystemTypeProvider</samp> interface. + + + + + + + + + + + + + + + RSE 2.0 + + + + + + + + + he following is an example of this extension point's usage: + +<p> +<pre> + <extension point="org.eclipse.rse.core.systemTypeProviders"> + <systemTypeProvider + id="org.eclipse.rse.core.DefaultSystemTypeProvider" + class="org.eclipse.rse.core.DefaultRSESystemTypeProvider"> + </systemTypeProvider> + </extension> +</pre> + + + + + + + + + Plug-ins that want to extend this extension point must implement <samp>org.eclipse.rse.core.IRSESystemTypesProvider</samp> interface. + + + + + + + + + + + + + + + + + + Copyright (c) 2007 Wind River Systems, Inc. and others. +All rights reserved. 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 available at +http://www.eclipse.org/legal/epl-v10.html + +Contributors: +Uwe Stieber (Wind River) - initial API and implementation. + + + + diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSECoreRegistry.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSECoreRegistry.java index b711f05fbc9..7c2ff58b47a 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSECoreRegistry.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSECoreRegistry.java @@ -11,7 +11,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Uwe Stieber (Wind River) - Added system types provider extension. ********************************************************************************/ package org.eclipse.rse.core; @@ -25,6 +25,7 @@ public interface IRSECoreRegistry { public static final String PI_RSE_CORE = "org.eclipse.rse.core"; //$NON-NLS-1$ public static final String PI_SYSTEM_TYPES = "systemTypes"; //$NON-NLS-1$ + public static final String PI_SYSTEM_TYPES_PROVIDER = "systemTypeProviders"; //$NON-NLS-1$ /** * Returns all defined system types. diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSESystemTypeProvider.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSESystemTypeProvider.java new file mode 100644 index 00000000000..d6d4c2a4f08 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSESystemTypeProvider.java @@ -0,0 +1,34 @@ +/******************************************************************************** + * Copyright (c) 2007 Wind River Systems, Inc. and others. + * All rights reserved. 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 available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Uwe Stieber (Wind River) - initial API and implementation. + ********************************************************************************/ +package org.eclipse.rse.core; + +/** + * Dynamic RSE system types provider interface. + * @see Extension point {@link org.eclipse.rse.core.systemTypeProviders} + * + * Clients may implement this interface. + * + * @since RSE 2.0 + */ +public interface IRSESystemTypeProvider { + + /** + * Returns a list of possible RSE system types to register + * at initialization of the RSE core system. The method will + * be called only once for each provider from {@link RSECoreRegistry}. + * The list of the returned RSE system types will be checked + * for duplicates (via the system type id). Duplicates will + * be dropped. + * + * @return The list of RSE system types to register or null. + */ + public IRSESystemType[] getSystemTypesForRegistration(); +} diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/internal/RSECoreRegistry.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/internal/RSECoreRegistry.java index 14e2a9fb0ee..37e0a68892a 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/internal/RSECoreRegistry.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/internal/RSECoreRegistry.java @@ -11,15 +11,23 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Uwe Stieber (Wind River) - Added system types provider extension. ********************************************************************************/ package org.eclipse.rse.core.internal; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; import org.eclipse.rse.core.IRSECoreRegistry; import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.IRSESystemTypeProvider; +import org.eclipse.rse.core.RSECorePlugin; /** * Singleton class representing the RSE core registry. @@ -122,21 +130,67 @@ public class RSECoreRegistry implements IRSECoreRegistry { * @return an array of system types that have been defined */ private IRSESystemType[] readSystemTypes() { + List types = new LinkedList(); + List typeIds = new ArrayList(); IExtensionRegistry registry = getExtensionRegistry(); + + // First we take the direct system type contributions via extension point IConfigurationElement[] elements = registry.getConfigurationElementsFor(PI_RSE_CORE, PI_SYSTEM_TYPES); - IRSESystemType[] types = new IRSESystemType[elements.length]; - for (int i = 0; i < elements.length; i++) { IConfigurationElement element = elements[i]; if (element.getName().equals(ELEMENT_SYTEM_TYPE)) { RSESystemType type = new RSESystemType(element); - types[i] = type; + if (!typeIds.contains(type.getId())) { + types.add(type); + typeIds.add(type.getId()); + + String message = "Successfully registered RSE system type ''{0}'' (id = ''{1}'')."; //$NON-NLS-1$ + message = MessageFormat.format(message, new Object[] { type.getName(), type.getId() }); + RSECorePlugin.getDefault().getLogger().logInfo(message); + } else { + String message = "RSE system type contribution skipped. Non-unique system type id (plugin: {0}, id: {1})."; //$NON-NLS-1$ + message = MessageFormat.format(message, new Object[] { element.getContributor().getName(), type.getId()}); + RSECorePlugin.getDefault().getLogger().logWarning(message); + } } } - return types; + // check on the IRSESystemTypeProviders now + elements = registry.getConfigurationElementsFor(PI_RSE_CORE, PI_SYSTEM_TYPES_PROVIDER); + for (int i = 0; i < elements.length; i++) { + IConfigurationElement element = elements[i]; + try { + Object provider = element.createExecutableExtension("class"); //$NON-NLS-1$ + if (provider instanceof IRSESystemTypeProvider) { + IRSESystemType[] typesForRegistration = ((IRSESystemTypeProvider)provider).getSystemTypesForRegistration(); + if (typesForRegistration == null) continue; + + for (int j = 0; j < typesForRegistration.length; j++) { + IRSESystemType type = typesForRegistration[j]; + if (!typeIds.contains(type.getId())) { + types.add(type); + typeIds.add(type.getId()); + + String message = "Successfully registered RSE system type ''{0}'' (id = ''{1}'')."; //$NON-NLS-1$ + message = MessageFormat.format(message, new Object[] { type.getName(), type.getId() }); + RSECorePlugin.getDefault().getLogger().logInfo(message); + } else { + String message = "RSE system type contribution skipped. Non-unique system type id (plugin: {0}, id: {1})."; //$NON-NLS-1$ + message = MessageFormat.format(message, new Object[] { element.getContributor().getName(), type.getId()}); + RSECorePlugin.getDefault().getLogger().logWarning(message); + } + } + } + } catch (CoreException e) { + String message = "RSE system types provider failed creation (plugin: {0}, id: {1})."; //$NON-NLS-1$ + message = MessageFormat.format(message, new Object[] { element.getContributor().getName(), element.getDeclaringExtension().getSimpleIdentifier()}); + RSECorePlugin.getDefault().getLogger().logError(message, e); + } + } + + return (IRSESystemType[])types.toArray(new IRSESystemType[types.size()]); } /** @@ -146,4 +200,4 @@ public class RSECoreRegistry implements IRSECoreRegistry { private IExtensionRegistry getExtensionRegistry() { return registry; } -} \ No newline at end of file +}