1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

[172662] [api] Add a dynamic systemTypeProvider extension point

This commit is contained in:
Uwe Stieber 2007-02-05 15:09:52 +00:00
parent 897779cd0b
commit d6df8489b5
6 changed files with 233 additions and 8 deletions

View file

@ -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

View file

@ -1,12 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<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 -->
<!-- ================================================================= -->
<extension-point id="persistenceProviders" name="%extPoint.persistenceProviders" schema="schema/persistenceProviders.exsd"/>
<extension-point id="systemTypeProviders"
name="%extPoint.systemTypeProviders"
schema="schema/systemTypeProviders.exsd"/>

View 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 &lt;samp&gt;org.eclipse.rse.core.IRSESystemTypeProvider&lt;/samp&gt; 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&apos;s usage:
&lt;p&gt;
&lt;pre&gt;
&lt;extension point=&quot;org.eclipse.rse.core.systemTypeProviders&quot;&gt;
&lt;systemTypeProvider
id=&quot;org.eclipse.rse.core.DefaultSystemTypeProvider&quot;
class=&quot;org.eclipse.rse.core.DefaultRSESystemTypeProvider&quot;&gt;
&lt;/systemTypeProvider&gt;
&lt;/extension&gt;
&lt;/pre&gt;
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
Plug-ins that want to extend this extension point must implement &lt;samp&gt;org.eclipse.rse.core.IRSESystemTypesProvider&lt;/samp&gt; 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>

View file

@ -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.

View file

@ -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();
}

View file

@ -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;
}
}
}