mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-26 02:15:31 +02:00
[172662] [api] Add a dynamic systemTypeProvider extension point
This commit is contained in:
parent
897779cd0b
commit
d6df8489b5
6 changed files with 233 additions and 8 deletions
|
@ -14,3 +14,7 @@
|
||||||
|
|
||||||
pluginName = RSE Core
|
pluginName = RSE Core
|
||||||
providerName = Eclipse.org
|
providerName = Eclipse.org
|
||||||
|
|
||||||
|
extPoint.systemTypes=RSE System Types
|
||||||
|
extPoint.persistenceProviders=RSE Persistence Providers
|
||||||
|
extPoint.systemTypeProviders=RSE System Type Providers
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<?eclipse version="3.0"?>
|
<?eclipse version="3.0"?>
|
||||||
<plugin>
|
<plugin>
|
||||||
<extension-point id="systemTypes" name="RSE System Types" schema="schema/systemTypes.exsd"/>
|
<extension-point id="systemTypes" name="%extPoint.systemTypes" schema="schema/systemTypes.exsd"/>
|
||||||
|
|
||||||
<!-- ================================================================= -->
|
<!-- ================================================================= -->
|
||||||
<!-- Define Persistence Provider extension point -->
|
<!-- Define Persistence Provider extension point -->
|
||||||
<!-- ================================================================= -->
|
<!-- ================================================================= -->
|
||||||
<extension-point id="persistenceProviders" name="%extPoint.persistenceProviders" schema="schema/persistenceProviders.exsd"/>
|
<extension-point id="persistenceProviders" name="%extPoint.persistenceProviders" schema="schema/persistenceProviders.exsd"/>
|
||||||
|
<extension-point id="systemTypeProviders"
|
||||||
|
name="%extPoint.systemTypeProviders"
|
||||||
|
schema="schema/systemTypeProviders.exsd"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
129
rse/plugins/org.eclipse.rse.core/schema/systemTypeProviders.exsd
Normal file
129
rse/plugins/org.eclipse.rse.core/schema/systemTypeProviders.exsd
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!-- Schema file written by PDE -->
|
||||||
|
<schema targetNamespace="org.eclipse.rse.core">
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.schema plugin="org.eclipse.rse.core" id="systemTypesProvider" name="RSE System Types Provider"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
This extension point is used to allow the contribution of dynamically generated RSE system types by vendors where needed.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<element name="extension">
|
||||||
|
<complexType>
|
||||||
|
<sequence>
|
||||||
|
<element ref="systemTypeProvider" minOccurs="1" maxOccurs="unbounded"/>
|
||||||
|
</sequence>
|
||||||
|
<attribute name="point" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="id" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="name" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute translatable="true"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<element name="systemTypeProvider">
|
||||||
|
<complexType>
|
||||||
|
<attribute name="id" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
a unique name that will be used to identify the system type Provider.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="class" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
a fully qualified name of the Java class that implements the <samp>org.eclipse.rse.core.IRSESystemTypeProvider</samp> interface.
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute kind="java" basedOn="org.eclipse.rse.core.IRSESystemTypeProvider"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="since"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
RSE 2.0
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="examples"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
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>
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="apiInfo"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
Plug-ins that want to extend this extension point must implement <samp>org.eclipse.rse.core.IRSESystemTypesProvider</samp> interface.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="implementation"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="copyright"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
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.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
</schema>
|
|
@ -11,7 +11,7 @@
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* {Name} (company) - description of contribution.
|
* Uwe Stieber (Wind River) - Added system types provider extension.
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
package org.eclipse.rse.core;
|
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_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 = "systemTypes"; //$NON-NLS-1$
|
||||||
|
public static final String PI_SYSTEM_TYPES_PROVIDER = "systemTypeProviders"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all defined system types.
|
* Returns all defined system types.
|
||||||
|
|
|
@ -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 <code>null</code>.
|
||||||
|
*/
|
||||||
|
public IRSESystemType[] getSystemTypesForRegistration();
|
||||||
|
}
|
|
@ -11,15 +11,23 @@
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* {Name} (company) - description of contribution.
|
* Uwe Stieber (Wind River) - Added system types provider extension.
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
package org.eclipse.rse.core.internal;
|
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.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.rse.core.IRSECoreRegistry;
|
import org.eclipse.rse.core.IRSECoreRegistry;
|
||||||
import org.eclipse.rse.core.IRSESystemType;
|
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.
|
* 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
|
* @return an array of system types that have been defined
|
||||||
*/
|
*/
|
||||||
private IRSESystemType[] readSystemTypes() {
|
private IRSESystemType[] readSystemTypes() {
|
||||||
|
List types = new LinkedList();
|
||||||
|
List typeIds = new ArrayList();
|
||||||
|
|
||||||
IExtensionRegistry registry = getExtensionRegistry();
|
IExtensionRegistry registry = getExtensionRegistry();
|
||||||
|
|
||||||
|
// First we take the direct system type contributions via extension point
|
||||||
IConfigurationElement[] elements = registry.getConfigurationElementsFor(PI_RSE_CORE, PI_SYSTEM_TYPES);
|
IConfigurationElement[] elements = registry.getConfigurationElementsFor(PI_RSE_CORE, PI_SYSTEM_TYPES);
|
||||||
IRSESystemType[] types = new IRSESystemType[elements.length];
|
|
||||||
|
|
||||||
for (int i = 0; i < elements.length; i++) {
|
for (int i = 0; i < elements.length; i++) {
|
||||||
IConfigurationElement element = elements[i];
|
IConfigurationElement element = elements[i];
|
||||||
|
|
||||||
if (element.getName().equals(ELEMENT_SYTEM_TYPE)) {
|
if (element.getName().equals(ELEMENT_SYTEM_TYPE)) {
|
||||||
RSESystemType type = new RSESystemType(element);
|
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() {
|
private IExtensionRegistry getExtensionRegistry() {
|
||||||
return registry;
|
return registry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue