diff options
| author | pnehrer | 2005-02-17 03:24:31 +0000 |
|---|---|---|
| committer | pnehrer | 2005-02-17 03:24:31 +0000 |
| commit | 415ea0dc8b0962e4ada8d8d47fc29e016338bc11 (patch) | |
| tree | 1782e3579405a76cd3fb8cdbc9bf2cbae244cdc6 | |
| parent | df012168333eaa3f6a3c5c99daeb449124cc17dd (diff) | |
| download | org.eclipse.ecf-415ea0dc8b0962e4ada8d8d47fc29e016338bc11.tar.gz org.eclipse.ecf-415ea0dc8b0962e4ada8d8d47fc29e016338bc11.tar.xz org.eclipse.ecf-415ea0dc8b0962e4ada8d8d47fc29e016338bc11.zip | |
Added the manager extension point.
6 files changed, 422 insertions, 271 deletions
diff --git a/examples/bundles/org.eclipse.ecf.sdo/build.properties b/examples/bundles/org.eclipse.ecf.sdo/build.properties index 9bf14fcd7..193cfb156 100644 --- a/examples/bundles/org.eclipse.ecf.sdo/build.properties +++ b/examples/bundles/org.eclipse.ecf.sdo/build.properties @@ -2,4 +2,5 @@ source.ecf.sdo.jar = src/ output.ecf.sdo.jar = bin/ bin.includes = plugin.xml,\ META-INF/,\ - ecf.sdo.jar + ecf.sdo.jar,\ + schema/ diff --git a/examples/bundles/org.eclipse.ecf.sdo/plugin.xml b/examples/bundles/org.eclipse.ecf.sdo/plugin.xml index 9f1961178..e87b752c5 100644 --- a/examples/bundles/org.eclipse.ecf.sdo/plugin.xml +++ b/examples/bundles/org.eclipse.ecf.sdo/plugin.xml @@ -1,5 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.0"?> <plugin> + <extension-point id="manager" name="Data Graph Sharing Manager" schema="schema/manager.exsd"/> + <extension + point="org.eclipse.ecf.sdo.manager"> + <manager + class="org.eclipse.ecf.internal.sdo.DataGraphSharingManager" + name="default"> + </manager> + </extension> </plugin>
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.sdo/schema/manager.exsd b/examples/bundles/org.eclipse.ecf.sdo/schema/manager.exsd new file mode 100644 index 000000000..54ce9bda0 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.sdo/schema/manager.exsd @@ -0,0 +1,117 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.ecf.sdo"> +<annotation> + <appInfo> + <meta.schema plugin="org.eclipse.ecf.sdo" id="manager" name="Data Graph Sharing Manager"/> + </appInfo> + <documentation> + Allows plugins to provide custom implementations of the Data Graph Sharing facility by registering uniquely named Data Graph Sharing Managers (classes that implement org.eclipse.ecf.sdo.IDataGraphSharingManager), which are responsible for producing per-container instances of Data Graph Sharing (org.eclipse.ecf.sdo.IDataGraphSharing). + </documentation> + </annotation> + + <element name="extension"> + <complexType> + <sequence> + <element ref="manager" 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="manager"> + <annotation> + <appInfo> + <meta.element labelAttribute="name"/> + </appInfo> + </annotation> + <complexType> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn="org.eclipse.ecf.sdo.IDataGraphSharingManager"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiInfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="copyright"/> + </appInfo> + <documentation> + + </documentation> + </annotation> + +</schema> diff --git a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharing.java b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharing.java index d1dcf55c5..266b75650 100644 --- a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharing.java +++ b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharing.java @@ -31,128 +31,128 @@ import commonj.sdo.DataGraph; * @author pnehrer */ public class DataGraphSharing extends PlatformObject implements - IDataGraphSharing, ISharedObject { - - public static final String DATA_GRAPH_SHARING_ID = DataGraphSharing.class - .getName(); - - private ISharedObjectConfig config; - - private boolean debug; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ecf.sdo.IDataGraphSharing#publish(commonj.sdo.DataGraph, - * org.eclipse.ecf.core.identity.ID, - * org.eclipse.ecf.sdo.IUpdateProvider, - * org.eclipse.ecf.sdo.IUpdateConsumer, - * org.eclipse.ecf.sdo.IPublicationCallback) - */ - public synchronized ISharedDataGraph publish(DataGraph dataGraph, ID id, - IUpdateProvider provider, IUpdateConsumer consumer, - IPublicationCallback callback) throws ECFException { - - if (config == null) - throw new ECFException("Not initialized."); - - // create local object - ISharedObjectManager mgr = config.getContext().getSharedObjectManager(); - SharedDataGraph sdg = new SharedDataGraph(dataGraph, provider, - consumer, callback, null); - sdg.setDebug(debug); - - mgr.addSharedObject(id, sdg, null, null); - return sdg; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ecf.sdo.IDataGraphSharing#subscribe(org.eclipse.ecf.core.identity.ID, - * org.eclipse.ecf.sdo.ISubscriptionCallback, - * org.eclipse.ecf.sdo.IUpdateProvider, - * org.eclipse.ecf.sdo.IUpdateConsumer) - */ - public synchronized ISharedDataGraph subscribe(ID id, - IUpdateProvider provider, IUpdateConsumer consumer, - ISubscriptionCallback callback) throws ECFException { - - if (config == null) - throw new ECFException("Not initialized."); - - // create local object - ISharedObjectManager mgr = config.getContext().getSharedObjectManager(); - SharedDataGraph sdg = new SharedDataGraph(null, provider, consumer, - null, callback); - sdg.setDebug(debug); - - mgr.addSharedObject(id, sdg, null, null); - return sdg; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ecf.sdo.IDataGraphSharing#dispose() - */ - public synchronized void dispose() { - if (config != null) - config.getContext().getSharedObjectManager().removeSharedObject( - config.getSharedObjectID()); - } - - /** - * Sets the debug flag. - * - * @param debug - * @deprecated Use Eclipse's plugin tracing support instead. - */ - public void setDebug(boolean debug) { - this.debug = debug; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ecf.core.ISharedObject#init(org.eclipse.ecf.core.ISharedObjectConfig) - */ - public synchronized void init(ISharedObjectConfig initData) - throws SharedObjectInitException { - - if (config == null) - config = initData; - else - throw new SharedObjectInitException("Already initialized."); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ecf.core.ISharedObject#handleEvent(org.eclipse.ecf.core.util.Event) - */ - public void handleEvent(Event event) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ecf.core.ISharedObject#handleEvents(org.eclipse.ecf.core.util.Event[]) - */ - public void handleEvents(Event[] events) { - for (int i = 0; i < events.length; ++i) - handleEvent(events[i]); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ecf.core.ISharedObject#dispose(org.eclipse.ecf.core.identity.ID) - */ - public synchronized void dispose(ID containerID) { - if (config != null - && config.getContext().getLocalContainerID() - .equals(containerID)) - config = null; - } + IDataGraphSharing, ISharedObject { + + static final String DATA_GRAPH_SHARING_ID = DataGraphSharing.class + .getName(); + + private ISharedObjectConfig config; + + private boolean debug; + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.sdo.IDataGraphSharing#publish(commonj.sdo.DataGraph, + * org.eclipse.ecf.core.identity.ID, + * org.eclipse.ecf.sdo.IUpdateProvider, + * org.eclipse.ecf.sdo.IUpdateConsumer, + * org.eclipse.ecf.sdo.IPublicationCallback) + */ + public synchronized ISharedDataGraph publish(DataGraph dataGraph, ID id, + IUpdateProvider provider, IUpdateConsumer consumer, + IPublicationCallback callback) throws ECFException { + + if (config == null) + throw new ECFException("Not initialized."); + + // create local object + ISharedObjectManager mgr = config.getContext().getSharedObjectManager(); + SharedDataGraph sdg = new SharedDataGraph(dataGraph, provider, + consumer, callback, null); + sdg.setDebug(debug); + + mgr.addSharedObject(id, sdg, null, null); + return sdg; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.sdo.IDataGraphSharing#subscribe(org.eclipse.ecf.core.identity.ID, + * org.eclipse.ecf.sdo.ISubscriptionCallback, + * org.eclipse.ecf.sdo.IUpdateProvider, + * org.eclipse.ecf.sdo.IUpdateConsumer) + */ + public synchronized ISharedDataGraph subscribe(ID id, + IUpdateProvider provider, IUpdateConsumer consumer, + ISubscriptionCallback callback) throws ECFException { + + if (config == null) + throw new ECFException("Not initialized."); + + // create local object + ISharedObjectManager mgr = config.getContext().getSharedObjectManager(); + SharedDataGraph sdg = new SharedDataGraph(null, provider, consumer, + null, callback); + sdg.setDebug(debug); + + mgr.addSharedObject(id, sdg, null, null); + return sdg; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.sdo.IDataGraphSharing#dispose() + */ + public synchronized void dispose() { + if (config != null) + config.getContext().getSharedObjectManager().removeSharedObject( + config.getSharedObjectID()); + } + + /** + * Sets the debug flag. + * + * @param debug + * @deprecated Use Eclipse's plugin tracing support instead. + */ + public void setDebug(boolean debug) { + this.debug = debug; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.core.ISharedObject#init(org.eclipse.ecf.core.ISharedObjectConfig) + */ + public synchronized void init(ISharedObjectConfig initData) + throws SharedObjectInitException { + + if (config == null) + config = initData; + else + throw new SharedObjectInitException("Already initialized."); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.core.ISharedObject#handleEvent(org.eclipse.ecf.core.util.Event) + */ + public void handleEvent(Event event) { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.core.ISharedObject#handleEvents(org.eclipse.ecf.core.util.Event[]) + */ + public void handleEvents(Event[] events) { + for (int i = 0; i < events.length; ++i) + handleEvent(events[i]); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.core.ISharedObject#dispose(org.eclipse.ecf.core.identity.ID) + */ + public synchronized void dispose(ID containerID) { + if (config != null + && config.getContext().getLocalContainerID() + .equals(containerID)) + config = null; + } }
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharingManager.java b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharingManager.java new file mode 100644 index 000000000..b126aea28 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharingManager.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 Peter Nehrer and Composent, Inc. + * 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: + * Peter Nehrer - initial API and implementation + *******************************************************************************/ +package org.eclipse.ecf.internal.sdo; + +import org.eclipse.ecf.core.ISharedObjectContainer; +import org.eclipse.ecf.core.ISharedObjectManager; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.core.identity.IDFactory; +import org.eclipse.ecf.core.util.ECFException; +import org.eclipse.ecf.sdo.IDataGraphSharing; +import org.eclipse.ecf.sdo.IDataGraphSharingManager; + +/** + * @author pnehrer + */ +public class DataGraphSharingManager implements IDataGraphSharingManager { + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.sdo.IDataGraphSharingManager#getInstance(org.eclipse.ecf.core.ISharedObjectContainer) + */ + public synchronized IDataGraphSharing getInstance( + ISharedObjectContainer container) throws ECFException { + ISharedObjectManager mgr = container.getSharedObjectManager(); + ID id = IDFactory.makeStringID(DataGraphSharing.DATA_GRAPH_SHARING_ID); + DataGraphSharing result = (DataGraphSharing) mgr.getSharedObject(id); + if (result == null) { + result = new DataGraphSharing(); + // result.setDebug(debug); + mgr.addSharedObject(id, result, null, null); + } + + return result; + } +} diff --git a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/SDOPlugin.java b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/SDOPlugin.java index 4a3b91127..a1c497a33 100644 --- a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/SDOPlugin.java +++ b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/SDOPlugin.java @@ -18,11 +18,7 @@ import org.eclipse.core.runtime.IRegistryChangeListener; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Plugin; import org.eclipse.ecf.core.ISharedObjectContainer; -import org.eclipse.ecf.core.ISharedObjectManager; -import org.eclipse.ecf.core.identity.ID; -import org.eclipse.ecf.core.identity.IDFactory; import org.eclipse.ecf.core.util.ECFException; -import org.eclipse.ecf.internal.sdo.DataGraphSharing; import org.osgi.framework.BundleContext; /** @@ -36,147 +32,132 @@ import org.osgi.framework.BundleContext; */ public class SDOPlugin extends Plugin { - private static final String MANAGER_EXTENSION_POINT = "manager"; - - private static final String MANAGER_EXTENSION = "manager"; - - private static final String ATTR_NAME = "name"; - - private static final String ATTR_CLASS = "class"; - - // The shared instance. - private static SDOPlugin plugin; - - private IRegistryChangeListener registryChangeListener; - - private boolean debug; - - /** - * The constructor. - */ - public SDOPlugin() { - super(); - plugin = this; - } - - /** - * This method is called upon plug-in activation - */ - public void start(BundleContext context) throws Exception { - super.start(context); - registryChangeListener = new IRegistryChangeListener() { - public void registryChanged(IRegistryChangeEvent event) { - IExtensionDelta[] deltas = event.getExtensionDeltas(getBundle() - .getSymbolicName(), MANAGER_EXTENSION_POINT); - for (int i = 0; i < deltas.length; ++i) { - switch (deltas[i].getKind()) { - case IExtensionDelta.ADDED: - registerManagers(deltas[i].getExtension() - .getConfigurationElements()); - break; - - case IExtensionDelta.REMOVED: - IConfigurationElement[] elems = deltas[i] - .getExtension().getConfigurationElements(); - for (int j = 0; j < elems.length; ++j) { - IConfigurationElement[] children = elems[j] - .getChildren(MANAGER_EXTENSION); - for (int k = 0; k < children.length; ++k) { - String name = children[k] - .getAttribute(ATTR_NAME); - if (name != null && name.length() > 0) - DataGraphSharingFactory - .unregisterManager(name); - } - } - - break; - } - } - } - }; - - IExtensionRegistry reg = Platform.getExtensionRegistry(); - IConfigurationElement[] elems = reg.getConfigurationElementsFor( - getBundle().getSymbolicName(), MANAGER_EXTENSION_POINT); - registerManagers(elems); - } - - private void registerManagers(IConfigurationElement[] elems) { - for (int i = 0; i < elems.length; ++i) { - IConfigurationElement[] children = elems[i] - .getChildren(MANAGER_EXTENSION); - for (int j = 0; j < children.length; ++j) { - String name = children[j].getAttribute(ATTR_NAME); - if (name == null || name.length() == 0) - continue; - - IDataGraphSharingManager mgr; - try { - mgr = (IDataGraphSharingManager) children[j] - .createExecutableExtension(ATTR_CLASS); - } catch (Exception ex) { - continue; - } - - DataGraphSharingFactory.registerManager(name, mgr); - } - } - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception { - if (registryChangeListener != null) - Platform.getExtensionRegistry().removeRegistryChangeListener( - registryChangeListener); - - DataGraphSharingFactory.unregisterAllManagers(); - super.stop(context); - } - - /** - * Returns the shared instance. - */ - public static SDOPlugin getDefault() { - return plugin; - } - - /** - * @param container - * @return - * @throws ECFException - * @deprecated Use - * {@link DataGraphSharingFactory#getDataGraphSharing(ISharedObjectContainer, String) DataGraphSharingFactory.getDataGraphSharing(ISharedObjectContainer, String)} - * instead. - */ - public IDataGraphSharing getDataGraphSharing( - ISharedObjectContainer container) throws ECFException { - - ISharedObjectManager mgr = container.getSharedObjectManager(); - ID id = IDFactory.makeStringID(DataGraphSharing.DATA_GRAPH_SHARING_ID); - synchronized (container) { - DataGraphSharing result = (DataGraphSharing) mgr - .getSharedObject(id); - if (result == null) { - result = new DataGraphSharing(); - result.setDebug(debug); - mgr.addSharedObject(id, result, null, null); - } - - return result; - } - } - - /** - * Sets the debug flag. - * - * @param debug - * @deprecated Use Eclipse plug-in tracing support instead. - */ - public void setDebug(boolean debug) { - this.debug = debug; - } + private static final String MANAGER_EXTENSION_POINT = "manager"; + + private static final String MANAGER_EXTENSION = "manager"; + + private static final String ATTR_NAME = "name"; + + private static final String ATTR_CLASS = "class"; + + // The shared instance. + private static SDOPlugin plugin; + + private IRegistryChangeListener registryChangeListener; + + private boolean debug; + + /** + * The constructor. + */ + public SDOPlugin() { + super(); + plugin = this; + } + + /** + * This method is called upon plug-in activation + */ + public void start(BundleContext context) throws Exception { + super.start(context); + registryChangeListener = new IRegistryChangeListener() { + public void registryChanged(IRegistryChangeEvent event) { + IExtensionDelta[] deltas = event.getExtensionDeltas(getBundle() + .getSymbolicName(), MANAGER_EXTENSION_POINT); + for (int i = 0; i < deltas.length; ++i) { + switch (deltas[i].getKind()) { + case IExtensionDelta.ADDED: + registerManagers(deltas[i].getExtension() + .getConfigurationElements()); + break; + + case IExtensionDelta.REMOVED: + IConfigurationElement[] elems = deltas[i] + .getExtension().getConfigurationElements(); + for (int j = 0; j < elems.length; ++j) { + if (!MANAGER_EXTENSION.equals(elems[j].getName())) + continue; + + String name = elems[j].getAttribute(ATTR_NAME); + if (name != null && name.length() > 0) + DataGraphSharingFactory.unregisterManager(name); + } + + break; + } + } + } + }; + + IExtensionRegistry reg = Platform.getExtensionRegistry(); + IConfigurationElement[] elems = reg.getConfigurationElementsFor( + getBundle().getSymbolicName(), MANAGER_EXTENSION_POINT); + registerManagers(elems); + } + + private void registerManagers(IConfigurationElement[] elems) { + for (int i = 0; i < elems.length; ++i) { + if (!MANAGER_EXTENSION.equals(elems[i].getName())) + continue; + + String name = elems[i].getAttribute(ATTR_NAME); + if (name == null || name.length() == 0) + continue; + + IDataGraphSharingManager mgr; + try { + mgr = (IDataGraphSharingManager) elems[i] + .createExecutableExtension(ATTR_CLASS); + } catch (Exception ex) { + continue; + } + + DataGraphSharingFactory.registerManager(name, mgr); + } + } + + /** + * This method is called when the plug-in is stopped + */ + public void stop(BundleContext context) throws Exception { + if (registryChangeListener != null) + Platform.getExtensionRegistry().removeRegistryChangeListener( + registryChangeListener); + + DataGraphSharingFactory.unregisterAllManagers(); + super.stop(context); + } + + /** + * Returns the shared instance. + */ + public static SDOPlugin getDefault() { + return plugin; + } + + /** + * @param container + * @return + * @throws ECFException + * @deprecated Use + * {@link DataGraphSharingFactory#getDataGraphSharing(ISharedObjectContainer, String) DataGraphSharingFactory.getDataGraphSharing(ISharedObjectContainer, String)} + * instead. + */ + public IDataGraphSharing getDataGraphSharing( + ISharedObjectContainer container) throws ECFException { + + return DataGraphSharingFactory + .getDataGraphSharing(container, "default"); + } + + /** + * Sets the debug flag. + * + * @param debug + * @deprecated Use Eclipse plug-in tracing support instead. + */ + public void setDebug(boolean debug) { + this.debug = debug; + } }
\ No newline at end of file |
