Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpnehrer2005-02-02 15:45:19 -0500
committerpnehrer2005-02-02 15:45:19 -0500
commitd44dd594131c7c864d335be33ec6b2f0436e3bdd (patch)
treecf2dcbc8fa9a44747f79b2958f8869ba137fe079 /examples/bundles/org.eclipse.ecf.sdo
parent1ebdaf7cddc27342e532e6ae0f8d3f404b32ba15 (diff)
downloadorg.eclipse.ecf-d44dd594131c7c864d335be33ec6b2f0436e3bdd.tar.gz
org.eclipse.ecf-d44dd594131c7c864d335be33ec6b2f0436e3bdd.tar.xz
org.eclipse.ecf-d44dd594131c7c864d335be33ec6b2f0436e3bdd.zip
Refactored, fixed bugs, and made SharedSDOEditor work!
Diffstat (limited to 'examples/bundles/org.eclipse.ecf.sdo')
-rw-r--r--examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharing.java16
-rw-r--r--examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/SharedDataGraph.java19
-rw-r--r--examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/IDataGraphSharing.java18
-rw-r--r--examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/IPublicationCallback.java29
-rw-r--r--examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/WaitablePublicationCallback.java48
5 files changed, 110 insertions, 20 deletions
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 fadf0cd58..d1dcf55c5 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
@@ -19,6 +19,7 @@ import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.core.util.Event;
import org.eclipse.ecf.sdo.IDataGraphSharing;
+import org.eclipse.ecf.sdo.IPublicationCallback;
import org.eclipse.ecf.sdo.ISharedDataGraph;
import org.eclipse.ecf.sdo.ISubscriptionCallback;
import org.eclipse.ecf.sdo.IUpdateConsumer;
@@ -45,11 +46,12 @@ public class DataGraphSharing extends PlatformObject implements
* @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.IUpdateConsumer,
+ * org.eclipse.ecf.sdo.IPublicationCallback)
*/
public synchronized ISharedDataGraph publish(DataGraph dataGraph, ID id,
- IUpdateProvider provider, IUpdateConsumer consumer)
- throws ECFException {
+ IUpdateProvider provider, IUpdateConsumer consumer,
+ IPublicationCallback callback) throws ECFException {
if (config == null)
throw new ECFException("Not initialized.");
@@ -57,7 +59,7 @@ public class DataGraphSharing extends PlatformObject implements
// create local object
ISharedObjectManager mgr = config.getContext().getSharedObjectManager();
SharedDataGraph sdg = new SharedDataGraph(dataGraph, provider,
- consumer, null);
+ consumer, callback, null);
sdg.setDebug(debug);
mgr.addSharedObject(id, sdg, null, null);
@@ -73,8 +75,8 @@ public class DataGraphSharing extends PlatformObject implements
* org.eclipse.ecf.sdo.IUpdateConsumer)
*/
public synchronized ISharedDataGraph subscribe(ID id,
- ISubscriptionCallback callback, IUpdateProvider provider,
- IUpdateConsumer consumer) throws ECFException {
+ IUpdateProvider provider, IUpdateConsumer consumer,
+ ISubscriptionCallback callback) throws ECFException {
if (config == null)
throw new ECFException("Not initialized.");
@@ -82,7 +84,7 @@ public class DataGraphSharing extends PlatformObject implements
// create local object
ISharedObjectManager mgr = config.getContext().getSharedObjectManager();
SharedDataGraph sdg = new SharedDataGraph(null, provider, consumer,
- callback);
+ null, callback);
sdg.setDebug(debug);
mgr.addSharedObject(id, sdg, null, null);
diff --git a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/SharedDataGraph.java b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/SharedDataGraph.java
index 6f50b5bd6..870c0ea9b 100644
--- a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/SharedDataGraph.java
+++ b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/SharedDataGraph.java
@@ -22,6 +22,7 @@ import org.eclipse.ecf.core.events.ISharedObjectMessageEvent;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.core.util.Event;
+import org.eclipse.ecf.sdo.IPublicationCallback;
import org.eclipse.ecf.sdo.ISharedDataGraph;
import org.eclipse.ecf.sdo.ISubscriptionCallback;
import org.eclipse.ecf.sdo.IUpdateConsumer;
@@ -40,6 +41,8 @@ public class SharedDataGraph extends PlatformObject implements ISharedObject,
private final ISubscriptionCallback subscriptionCallback;
+ private final IPublicationCallback publicationCallback;
+
private final IUpdateProvider updateProvider;
private ISharedObjectConfig config;
@@ -52,6 +55,7 @@ public class SharedDataGraph extends PlatformObject implements ISharedObject,
SharedDataGraph(DataGraph dataGraph, IUpdateProvider updateProvider,
IUpdateConsumer updateConsumer,
+ IPublicationCallback publicationCallback,
ISubscriptionCallback subscriptionCallback) {
if (updateProvider == null)
throw new IllegalArgumentException("updateProvider");
@@ -62,6 +66,7 @@ public class SharedDataGraph extends PlatformObject implements ISharedObject,
this.dataGraph = dataGraph;
this.updateProvider = updateProvider;
this.updateConsumer = updateConsumer;
+ this.publicationCallback = publicationCallback;
this.subscriptionCallback = subscriptionCallback;
}
@@ -138,6 +143,12 @@ public class SharedDataGraph extends PlatformObject implements ISharedObject,
config = initData;
else
throw new SharedObjectInitException("Already initialized.");
+
+ if (version == null)
+ version = new Version(config.getSharedObjectID());
+
+ if (dataGraph != null)
+ dataGraph.getChangeSummary().beginLogging();
}
/*
@@ -158,12 +169,8 @@ public class SharedDataGraph extends PlatformObject implements ISharedObject,
if (subscriptionCallback != null)
subscriptionCallback.subscriptionFailed(this, e);
}
- } else {
- if (version == null)
- version = new Version(config.getSharedObjectID());
-
- dataGraph.getChangeSummary().beginLogging();
- }
+ } else if (publicationCallback != null)
+ publicationCallback.dataGraphPublished(this);
}
} else if (event instanceof ISharedObjectDeactivatedEvent
&& ((ISharedObjectDeactivatedEvent) event).getDeactivatedID()
diff --git a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/IDataGraphSharing.java b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/IDataGraphSharing.java
index 451fb7a52..8fe8faa69 100644
--- a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/IDataGraphSharing.java
+++ b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/IDataGraphSharing.java
@@ -36,31 +36,35 @@ public interface IDataGraphSharing {
* implementation
* @param consumer
* application-specific update consumer
+ * @param callback
+ * optional callback used to notify the caller about publication
+ * status
* @return shared data graph
* @throws ECFException
*/
ISharedDataGraph publish(DataGraph dataGraph, ID id,
- IUpdateProvider provider, IUpdateConsumer consumer)
- throws ECFException;
+ IUpdateProvider provider, IUpdateConsumer consumer,
+ IPublicationCallback callback) throws ECFException;
/**
* Subscribes to a data graph with the given id.
*
* @param id
* identifier of a previously-published data graph
- * @param callback
- * optional callback used to notify the caller about subscription
- * status
* @param provider
* update provider compatible with the given data graph's
* implementation
* @param consumer
* application-specific update consumer
+ * @param callback
+ * optional callback used to notify the caller about subscription
+ * status
+ *
* @return shared data graph
* @throws ECFException
*/
- ISharedDataGraph subscribe(ID id, ISubscriptionCallback callback,
- IUpdateProvider provider, IUpdateConsumer consumer)
+ ISharedDataGraph subscribe(ID id, IUpdateProvider provider,
+ IUpdateConsumer consumer, ISubscriptionCallback callback)
throws ECFException;
/**
diff --git a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/IPublicationCallback.java b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/IPublicationCallback.java
new file mode 100644
index 000000000..6c3068c56
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/IPublicationCallback.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.sdo;
+
+/**
+ * Interface used by service implementations to notify publishing applications
+ * of the publication status.
+ *
+ * @author pnehrer
+ */
+public interface IPublicationCallback {
+
+ /**
+ * Notifies implementor that the give data graph has been successfully
+ * published.
+ *
+ * @param graph
+ * data graph that has been published
+ */
+ void dataGraphPublished(ISharedDataGraph graph);
+}
diff --git a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/WaitablePublicationCallback.java b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/WaitablePublicationCallback.java
new file mode 100644
index 000000000..5c9d0a7c5
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/sdo/WaitablePublicationCallback.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.sdo;
+
+/**
+ * Convenience callback implementation that can be used to block the calling
+ * thread until the data graph is published.
+ *
+ * @author pnehrer
+ */
+public class WaitablePublicationCallback implements IPublicationCallback {
+
+ private boolean published;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.sdo.IPublicationCallback#dataGraphPublished(org.eclipse.ecf.sdo.ISharedDataGraph)
+ */
+ public synchronized void dataGraphPublished(ISharedDataGraph graph) {
+ published = true;
+ notifyAll();
+ }
+
+ /**
+ * Blocks the calling thread until the data graph is published.
+ *
+ * @param timeout
+ * period, in milliseconds, to wait for publication
+ * @throws InterruptedException
+ * if interrupted while waiting for notification
+ */
+ public synchronized boolean waitForPublication(long timeout)
+ throws InterruptedException {
+ if (!published)
+ wait(timeout);
+
+ return published;
+ }
+}

Back to the top