diff options
| author | slewis | 2005-07-05 16:20:54 +0000 |
|---|---|---|
| committer | slewis | 2005-07-05 16:20:54 +0000 |
| commit | 0119e38b11983be5bcf422ebcb865eaf089807b9 (patch) | |
| tree | db08c77edd64f132e5c073bc75848c487cec584d | |
| parent | 9f167ce0172a8f9914d1d65b68f7150268bd12ab (diff) | |
| download | org.eclipse.ecf-0119e38b11983be5bcf422ebcb865eaf089807b9.tar.gz org.eclipse.ecf-0119e38b11983be5bcf422ebcb865eaf089807b9.tar.xz org.eclipse.ecf-0119e38b11983be5bcf422ebcb865eaf089807b9.zip | |
API Change. Modified ISharedObjectManager.addSharedObject and ISharedObjectManager.createSharedObject so that they no longer have the ISharedObjectContainerTransaction parameter at the end. Now, instead of having the caller pass this instance in, the shared object implementer is expected to return a non-null instance when getAdapter(ISharedObjectContainerTransaction.class) is called. This getAdapter call is made on the target instance *before* it is added to the container. If a non-null value is returned, it's waitToCommit() method is called during shared object create and add.
12 files changed, 31 insertions, 34 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java index 1eb2ab446..f6aadd9e9 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java @@ -241,7 +241,7 @@ public class Client { }); ID newID = IDFactory.makeStringID(COLLAB_SHARED_OBJECT_ID); client.getContainer().getSharedObjectManager().addSharedObject(newID, sharedObject, - new HashMap(), null); + new HashMap()); client.setObject(sharedObject); } diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/GenericSharedObject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/GenericSharedObject.java index 9ddbb5af6..e2fab9e81 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/GenericSharedObject.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/GenericSharedObject.java @@ -191,6 +191,9 @@ public class GenericSharedObject implements ISharedObject { * @see org.eclipse.ecf.core.ISharedObject#getAdapter(java.lang.Class) */ public Object getAdapter(Class clazz) { + if (clazz.equals(ISharedObjectContainerTransaction.class) && (this instanceof ISharedObjectContainerTransaction)) { + return this; + } return null; } @@ -484,13 +487,13 @@ public void handleEvent(Event event) { throw new InstantiationException("Exception creating instance of class: "+className+". Does not implement ISharedObject"); } if (inst instanceof ISharedObjectContainerTransaction) { - crs.getSharedObjectManager().addSharedObject(newID,(ISharedObject) inst,map,(ISharedObjectContainerTransaction)inst); + crs.getSharedObjectManager().addSharedObject(newID,(ISharedObject) inst,map); } else { SharedObjectDescription sd = new SharedObjectDescription(newID , className, map); crs.getSharedObjectManager() - .createSharedObject(sd, null); + .createSharedObject(sd); } } catch (Exception e) { traceDump("Exception creating replicated object.", e); diff --git a/examples/bundles/org.eclipse.ecf.example.sdo.editor/src/org/eclipse/ecf/example/sdo/editor/EditorPlugin.java b/examples/bundles/org.eclipse.ecf.example.sdo.editor/src/org/eclipse/ecf/example/sdo/editor/EditorPlugin.java index 5d07c7060..6f6601e6b 100644 --- a/examples/bundles/org.eclipse.ecf.example.sdo.editor/src/org/eclipse/ecf/example/sdo/editor/EditorPlugin.java +++ b/examples/bundles/org.eclipse.ecf.example.sdo.editor/src/org/eclipse/ecf/example/sdo/editor/EditorPlugin.java @@ -187,7 +187,7 @@ public class EditorPlugin extends AbstractUIPlugin { if (tracker == null) { tracker = new PublishedGraphTracker(); container.getSharedObjectManager().addSharedObject(id, tracker, - null, null); + null); } return tracker; 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 ca68a1a28..f16097d87 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 @@ -58,7 +58,7 @@ public class DataGraphSharing implements ISharedObjectManager mgr = config.getContext().getSharedObjectManager(); SharedDataGraph sdg = new SharedDataGraph(dataGraph, provider, consumer, callback, null); - mgr.addSharedObject(id, sdg, null, null); + mgr.addSharedObject(id, sdg, null); return sdg; } @@ -81,7 +81,7 @@ public class DataGraphSharing implements ISharedObjectManager mgr = config.getContext().getSharedObjectManager(); SharedDataGraph sdg = new SharedDataGraph(null, provider, consumer, null, callback); - mgr.addSharedObject(id, sdg, null, null); + mgr.addSharedObject(id, sdg, null); return sdg; } 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 index 0169ed609..5a79e9e56 100644 --- 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 @@ -35,7 +35,7 @@ public class DataGraphSharingManager implements IDataGraphSharingManager { DataGraphSharing result = (DataGraphSharing) mgr.getSharedObject(id); if (result == null) { result = new DataGraphSharing(); - mgr.addSharedObject(id, result, null, null); + mgr.addSharedObject(id, result, null); } return result; diff --git a/framework/bundles/org.eclipse.ecf.datashare/src/org/eclipse/ecf/internal/datashare/DataShareService.java b/framework/bundles/org.eclipse.ecf.datashare/src/org/eclipse/ecf/internal/datashare/DataShareService.java index d43f4259c..a4f49bf1c 100644 --- a/framework/bundles/org.eclipse.ecf.datashare/src/org/eclipse/ecf/internal/datashare/DataShareService.java +++ b/framework/bundles/org.eclipse.ecf.datashare/src/org/eclipse/ecf/internal/datashare/DataShareService.java @@ -54,8 +54,7 @@ public class DataShareService implements IDataShareService { IBootstrap bootstrap = getBootstrap(); AbstractMulticaster sender = getSender(); agent = new Agent(dataGraph, bootstrap, sender, provider, callback); - container.getSharedObjectManager().addSharedObject(id, agent, null, - null); + container.getSharedObjectManager().addSharedObject(id, agent, null); } /* diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ClientApplication.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ClientApplication.java index e5264c8c2..3198fce1f 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ClientApplication.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ClientApplication.java @@ -103,7 +103,7 @@ public class ClientApplication { for(int i=0; i < sharedObjectClassNames.length; i++) { System.out.println("Creating sharedObject: "+sharedObjectClassNames[i]+" for client "+scg.getConfig().getID().getName()); SharedObjectDescription sd = new SharedObjectDescription(IDFactory.makeStringID(String.valueOf(aRan.nextInt())),sharedObjectClassNames[i]); - scg.getSharedObjectManager().createSharedObject(sd,null); + scg.getSharedObjectManager().createSharedObject(sd); System.out.println("Created sharedObject for client "+scg.getConfig().getID().getName()); } } diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOManager.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOManager.java index a56d4dc4f..4ca5280e3 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOManager.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOManager.java @@ -45,13 +45,12 @@ import org.eclipse.ecf.core.util.IQueueEnqueue; import org.eclipse.ecf.provider.Trace; /** - * + * */ public class SOManager implements ISharedObjectManager { static Trace debug = Trace.create("sharedobjectmanager"); SOContainer container = null; - Vector connectors = null; public SOManager(SOContainer cont) { @@ -112,9 +111,8 @@ public class SOManager implements ISharedObjectManager { if (newSharedObject instanceof ISharedObject) return (ISharedObject) newSharedObject; else - throw new ClassCastException("shared object " - + newSharedObject.toString() + " does not implement " - + ISharedObject.class.getName()); + throw new ClassCastException("Object " + newSharedObject.toString() + + " does not implement " + ISharedObject.class.getName()); } protected ISharedObject loadSharedObject(SharedObjectDescription sd) @@ -146,10 +144,9 @@ public class SOManager implements ISharedObjectManager { * @see org.eclipse.ecf.core.ISharedObjectManager#createSharedObject(org.eclipse.ecf.core.SharedObjectDescription, * org.eclipse.ecf.core.ISharedObjectContainerTransaction) */ - public ID createSharedObject(SharedObjectDescription sd, - ISharedObjectContainerTransaction trans) + public ID createSharedObject(SharedObjectDescription sd) throws SharedObjectCreateException { - debug("createSharedObject(" + sd + "," + trans + ")"); + debug("createSharedObject(" + sd + ")"); // notify listeners if (sd == null) throw new SharedObjectCreateException( @@ -165,7 +162,7 @@ public class SOManager implements ISharedObjectManager { try { newObject = loadSharedObject(sd); result = addSharedObject(sharedObjectID, newObject, sd - .getProperties(), trans); + .getProperties()); } catch (Exception e) { dumpStack("Exception in createSharedObject", e); SharedObjectCreateException newExcept = new SharedObjectCreateException( @@ -187,10 +184,9 @@ public class SOManager implements ISharedObjectManager { * org.eclipse.ecf.core.ISharedObjectContainerTransaction) */ public ID addSharedObject(ID sharedObjectID, ISharedObject sharedObject, - Map properties, ISharedObjectContainerTransaction trans) - throws SharedObjectAddException { + Map properties) throws SharedObjectAddException { debug("addSharedObject(" + sharedObjectID + "," + sharedObject + "," - + properties + "," + trans + ")"); + + properties + ")"); // notify listeners container.fireContainerEvent(new SharedObjectManagerAddEvent(container .getID(), sharedObjectID, sharedObject, properties)); @@ -201,7 +197,9 @@ public class SOManager implements ISharedObjectManager { sharedObject.getClass().getClassLoader(), sharedObjectID, container.getID(), sharedObject.getClass().getName(), properties, 0); - container.addSharedObjectAndWait(sd, so, trans); + ISharedObjectContainerTransaction transaction = (ISharedObjectContainerTransaction) so + .getAdapter(ISharedObjectContainerTransaction.class); + container.addSharedObjectAndWait(sd, so, transaction); } catch (Exception e) { dumpStack("Exception in addSharedObject", e); SharedObjectAddException newExcept = new SharedObjectAddException( diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/sobject/BaseSharedObject.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/sobject/BaseSharedObject.java index 5c3c679aa..8a2d9ac67 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/sobject/BaseSharedObject.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/sobject/BaseSharedObject.java @@ -20,6 +20,7 @@ import java.util.Vector; import org.eclipse.ecf.core.IIdentifiable; import org.eclipse.ecf.core.ISharedObject; import org.eclipse.ecf.core.ISharedObjectConfig; +import org.eclipse.ecf.core.ISharedObjectContainerTransaction; import org.eclipse.ecf.core.ISharedObjectContext; import org.eclipse.ecf.core.ISharedObjectManager; import org.eclipse.ecf.core.SharedObjectDescription; @@ -139,6 +140,9 @@ public class BaseSharedObject implements ISharedObject, IIdentifiable { * @see org.eclipse.ecf.core.ISharedObject#getAdapter(java.lang.Class) */ public Object getAdapter(Class clazz) { + if (clazz.equals(ISharedObjectContainerTransaction.class)) { + return new TwoPhaseCommit(this); + } return null; } diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectManager.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectManager.java index 9a83c9526..c2a3efaf6 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectManager.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectManager.java @@ -30,15 +30,12 @@ public interface ISharedObjectManager { * the ISharedObject instance to add * @param properties * the Map associated with the added ISharedObject - * @param trans - * the transaction governing the creation of the shared object. - * If null, creation will not be transactional * @return ID the sharedObjectID of the added ISharedObject * @throws SharedObjectAddException * if the add cannot be accomplished for any reason */ public ID addSharedObject(ID sharedObjectID, ISharedObject sharedObject, - Map properties, ISharedObjectContainerTransaction trans) + Map properties) throws SharedObjectAddException; /** * Create an ISharedObjectConnector instance for sending messages from a @@ -65,16 +62,12 @@ public interface ISharedObjectManager { * @param sd * the SharedObjectDescription that describes the SharedObject to * be created - * @param trans - * the transaction governing the creation of the shared object. - * If null, creation will not be transactional * @return ID the sharedObjectID of the added ISharedObject * @throws SharedObjectCreateException * if the SharedObject cannot be created */ - public ID createSharedObject(SharedObjectDescription sd, - ISharedObjectContainerTransaction trans) + public ID createSharedObject(SharedObjectDescription sd) throws SharedObjectCreateException; /** diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java index 4fcb034e5..3e2039f09 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java @@ -101,7 +101,7 @@ public class XMPPClientSOContainer extends ClientSOContainer { protected void addSharedObjectToContainer(ID remote) throws SharedObjectAddException { getSharedObjectManager().addSharedObject(sharedObjectID, sharedObject, - new HashMap(), null); + new HashMap()); } protected void cleanUpConnectFail() { diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPGroupChatSOContainer.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPGroupChatSOContainer.java index e07484766..0ac0fc4fb 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPGroupChatSOContainer.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPGroupChatSOContainer.java @@ -130,7 +130,7 @@ public class XMPPGroupChatSOContainer extends ClientSOContainer { protected void addSharedObjectToContainer(ID remote) throws SharedObjectAddException { getSharedObjectManager().addSharedObject(sharedObjectID, sharedObject, - new HashMap(), null); + new HashMap()); } protected void cleanUpConnectFail() { |
