Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'framework/bundles')
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/.classpath7
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/.options15
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/.project28
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/META-INF/MANIFEST.MF14
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/build.properties5
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/plugin.xml5
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/schema/sharedObjectFactory.exsd144
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/AbstractSharedObject.java390
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/AbstractSharedObjectContainerAdapterFactory.java98
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/IReplicaSharedObjectDescriptionFactory.java24
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObject.java52
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectConfig.java58
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectConnector.java34
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainer.java24
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerConfig.java37
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerFactory.java77
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerGroupManager.java49
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerTransaction.java38
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContext.java202
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectFactory.java158
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectManager.java126
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectTransactionConfig.java34
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectTransactionParticipantsFilter.java29
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/OptimisticSharedObject.java67
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ReplicaSharedObjectDescription.java88
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectAddAbortException.java60
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectAddException.java31
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectConnectException.java31
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectContainerFactory.java116
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectContainerInitException.java31
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectCreateException.java31
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectDescription.java65
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectDisconnectException.java31
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectFactory.java211
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectInitException.java31
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsg.java322
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsgEvent.java44
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsgEventProcessor.java37
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectNotFoundException.java31
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectTypeDescription.java66
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/TransactionSharedObject.java57
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/TransactionSharedObjectConfiguration.java42
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/TwoPhaseCommitEventProcessor.java363
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectActivatedEvent.java16
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectCallEvent.java15
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectCommitEvent.java12
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectCreateResponseEvent.java16
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectDeactivatedEvent.java16
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectEvent.java18
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectManagerEvent.java14
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectMessageEvent.java17
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectMessageListener.java27
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectCreateResponseEvent.java51
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectEvent.java57
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectActivatedEvent.java38
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCallEvent.java57
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCommitEvent.java43
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectDeactivatedEvent.java39
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerAddEvent.java63
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerConnectEvent.java57
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerCreateEvent.java49
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerDisconnectEvent.java49
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerRemoveEvent.java47
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/provider/ISharedObjectInstantiator.java40
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/security/ISharedObjectPolicy.java41
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/Activator.java295
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/SharedObjectDebugOptions.java25
67 files changed, 4505 insertions, 0 deletions
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/.classpath b/framework/bundles/org.eclipse.ecf.sharedobject/.classpath
new file mode 100644
index 000000000..751c8f2e5
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/.options b/framework/bundles/org.eclipse.ecf.sharedobject/.options
new file mode 100644
index 000000000..234b9f84a
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/.options
@@ -0,0 +1,15 @@
+# Debugging options for the org.eclipse.ecf.sharedobject plug-in
+
+# Turn on general debugging for the org.eclipse.ecf.identity plug-in
+org.eclipse.ecf.sharedobject/debug=true
+
+# Trace when exceptions are caught
+org.eclipse.ecf.sharedobject/debug/exceptions/catching=false
+# Trace when exceptions are thrown
+org.eclipse.ecf.sharedobject/debug/exceptions/throwing=false
+
+# Trace when methods are entered
+org.eclipse.ecf.sharedobject/debug/methods/entering=false
+# Trace when methods are exited
+org.eclipse.ecf.sharedobject/debug/methods/exiting=false
+
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/.project b/framework/bundles/org.eclipse.ecf.sharedobject/.project
new file mode 100644
index 000000000..91f9f75cc
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ecf.core.sharedobject</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.sharedobject/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..c191acce2
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ECF Sharedobject API
+Bundle-SymbolicName: org.eclipse.ecf.sharedobject;singleton:=true
+Bundle-Version: 0.9.3
+Bundle-Activator: org.eclipse.ecf.internal.core.sharedobject.Activator
+Bundle-Vendor: Eclipse.org
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.ecf
+Eclipse-LazyStart: true
+Export-Package: org.eclipse.ecf.core.sharedobject,
+ org.eclipse.ecf.core.sharedobject.events,
+ org.eclipse.ecf.core.sharedobject.provider,
+ org.eclipse.ecf.core.sharedobject.security
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/build.properties b/framework/bundles/org.eclipse.ecf.sharedobject/build.properties
new file mode 100644
index 000000000..e9863e281
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/plugin.xml b/framework/bundles/org.eclipse.ecf.sharedobject/plugin.xml
new file mode 100644
index 000000000..07643a1c2
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/plugin.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="sharedObjectFactory" name="Shared Object Factory Extension Point" schema="schema/sharedObjectFactory.exsd"/>
+</plugin>
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/schema/sharedObjectFactory.exsd b/framework/bundles/org.eclipse.ecf.sharedobject/schema/sharedObjectFactory.exsd
new file mode 100644
index 000000000..5311f7383
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/schema/sharedObjectFactory.exsd
@@ -0,0 +1,144 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ecf">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.ecf" id="sharedObjectFactory" name="ECF Container Factory"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="sharedObjectFactory" 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>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="sharedObjectFactory">
+ <complexType>
+ <sequence>
+ <element ref="property" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The class implementing the sharedObjectFactory extension point. The given class must implement the &lt;b&gt;org.eclipse.ecf.core.provider.ISharedObjectInstantiator&lt;/b&gt; interface
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ An optional name for the extension. If no name is explicitly provided by the extension, the sharedObjectFactory class name is used as the name. Note that this name must &lt;b&gt;not&lt;/b&gt; conflict with any other name in the ECF SharedObjectFactory in order to be successfully registered. Care should therefore be taken in selection of a name such that it does not conflict with other pre-existing names for this factory implementations
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="description" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="property">
+ <annotation>
+ <documentation>
+ Property (name,value) associated with SharedObjectTypeDescription
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ The name of the property
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="value" type="string" use="required">
+ <annotation>
+ <documentation>
+ The value of the property
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 0.6.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The API for this extension point is provided by the &lt;b&gt;org.eclipse.ecf.core.SharedObjectFactory&lt;/b&gt; static methods. Specifically, the &apos;createSharedObject&apos; methods are to be used by clients. The functionality provided by the extension point mechanism can be used at runtime via the &lt;b&gt;SharedObjectFactory.addDescription(SharedObjectTypeDescription)&lt;/b&gt; method.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/AbstractSharedObject.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/AbstractSharedObject.java
new file mode 100644
index 000000000..7c9fb61b2
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/AbstractSharedObject.java
@@ -0,0 +1,390 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, 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:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.eclipse.ecf.core.IIdentifiable;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.sharedobject.events.ISharedObjectCreateResponseEvent;
+import org.eclipse.ecf.core.sharedobject.events.ISharedObjectMessageEvent;
+import org.eclipse.ecf.core.sharedobject.events.RemoteSharedObjectEvent;
+import org.eclipse.ecf.core.util.Event;
+import org.eclipse.ecf.core.util.IEventProcessor;
+import org.eclipse.ecf.core.util.IQueueEnqueue;
+import org.eclipse.ecf.core.util.QueueException;
+import org.eclipse.ecf.core.util.Trace;
+import org.eclipse.ecf.internal.core.sharedobject.Activator;
+import org.eclipse.ecf.internal.core.sharedobject.SharedObjectDebugOptions;
+
+/**
+ * Base class for shared object classes.
+ *
+ */
+public class AbstractSharedObject implements ISharedObject,
+ IIdentifiable {
+
+ private ISharedObjectConfig config = null;
+ private List eventProcessors = new Vector();
+
+ public AbstractSharedObject() {
+ super();
+ }
+ public final void init(ISharedObjectConfig initData)
+ throws SharedObjectInitException {
+ this.config = initData;
+ trace("init("+initData+")");
+ addEventProcessor(new SharedObjectMsgEventProcessor(this));
+ initialize();
+ }
+ /**
+ * Initialize this shared object. Subclasses may override as appropriate
+ * to define custom initialization behavior. If initialization should
+ * fail, then a SharedObjectInitException should be thrown by implementing code.
+ * Also, subclasses overriding this method should call super.initialize() before
+ * running their own code.
+ *
+ * @throws SharedObjectInitException if initialization should throw
+ */
+ protected void initialize() throws SharedObjectInitException {}
+ /**
+ * Called by replication strategy code (e.g. two phase commit) when creation is completed (i.e. when transactional
+ * replication completed successfully). Subclasses that need to be notified when creation is completed should
+ * override this method.
+ *
+ */
+ protected void creationCompleted() {
+ trace("creationCompleted()");
+ }
+ public void dispose(ID containerID) {
+ trace("dispose("+containerID+")");
+ eventProcessors.clear();
+ config = null;
+ }
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+ public void handleEvent(Event event) {
+ trace("handleEvent("+event+")");
+ synchronized (eventProcessors) {
+ fireEventProcessors(event);
+ }
+ }
+ protected boolean addEventProcessor(IEventProcessor proc) {
+ return eventProcessors.add(proc);
+ }
+ protected boolean removeEventProcessor(IEventProcessor proc) {
+ return eventProcessors.remove(proc);
+ }
+ protected void clearEventProcessors() {
+ eventProcessors.clear();
+ }
+ protected void handleUnhandledEvent(Event event) {
+ trace("handleUnhandledEvent("+event+")");
+ }
+ protected void fireEventProcessors(Event event) {
+ if (event == null) return;
+ Event evt = event;
+ if (eventProcessors.size()==0) {
+ handleUnhandledEvent(event);
+ return;
+ }
+ for(Iterator i=eventProcessors.iterator(); i.hasNext(); ) {
+ IEventProcessor ep = (IEventProcessor) i.next();
+ trace("calling eventProcessor="+ep+" for event="+evt);
+ if (ep.processEvent(evt)) break;
+ }
+ }
+ public void handleEvents(Event[] events) {
+ trace("handleEvents("+Arrays.asList(events)+")");
+ if (events == null) return;
+ for(int i=0; i < events.length; i++) {
+ handleEvent(events[i]);
+ }
+ }
+ public ID getID() {
+ return getConfig().getSharedObjectID();
+ }
+ protected ISharedObjectConfig getConfig() {
+ return config;
+ }
+ protected ISharedObjectContext getContext() {
+ return getConfig().getContext();
+ }
+ protected ID getHomeContainerID() {
+ return getConfig().getHomeContainerID();
+ }
+ protected ID getLocalContainerID() {
+ return getContext().getLocalContainerID();
+ }
+ protected ID getGroupID() {
+ return getContext().getConnectedID();
+ }
+ protected boolean isConnected() {
+ return (getContext().getConnectedID() != null);
+ }
+ protected boolean isPrimary() {
+ ID local = getLocalContainerID();
+ ID home = getHomeContainerID();
+ if (local == null || home == null) {
+ return false;
+ } else return (local.equals(home));
+ }
+ protected Map getProperties() {
+ return getConfig().getProperties();
+ }
+ protected void destroySelf() {
+ trace("destroySelf()");
+ if (isPrimary()) {
+ try {
+ // Send destroy message to all known remotes
+ destroyRemote(null);
+ } catch (IOException e) {
+ traceStack("Exception sending destroy message to remotes", e);
+ }
+ }
+ destroySelfLocal();
+ }
+ protected void destroySelfLocal() {
+ trace("destroySelfLocal()");
+ try {
+ ISharedObjectManager manager = getContext().getSharedObjectManager();
+ if (manager != null) {
+ manager.removeSharedObject(getID());
+ }
+ } catch (Exception e) {
+ traceStack("Exception in destroySelfLocal()",e);
+ }
+ }
+ protected void destroyRemote(ID remoteID) throws IOException {
+ trace("destroyRemote("+remoteID+")");
+ getContext().sendDispose(remoteID);
+ }
+ private void trace(String msg) {
+ Trace.trace(Activator.getDefault(),getID()+":"+msg);
+ }
+ private void traceStack(String msg, Throwable t) {
+ Trace.catching(Activator.getDefault(), SharedObjectDebugOptions.EXCEPTIONS_CATCHING, AbstractSharedObject.class, "traceStack", t);
+ }
+ /**
+ * Send SharedObjectMessage to container with given ID. The toID
+ * parameter may be null, and if null the message will be delivered to
+ * <b>all</b> containers in group. The second parameter may not be null.
+ *
+ * @param toID the target container ID for the SharedObjectMsg. If null, the
+ * given message is sent to all other containers currently in group
+ * @param msg the message instance to send
+ * @throws IOException thrown if the local container is not connected or unable
+ * to send for other reason
+ */
+ protected void sendSharedObjectMsgTo(ID toID, SharedObjectMsg msg)
+ throws IOException {
+ if (msg == null) throw new NullPointerException("msg cannot be null");
+ getContext().sendMessage(toID,
+ new SharedObjectMsgEvent(getID(), toID, msg));
+ }
+ /**
+ * Send SharedObjectMsg to this shared object's primary instance.
+ * @param msg the message instance to send
+ * @throws IOException throws if the local container is not connect or unable
+ * to send for other reason
+ */
+ protected void sendSharedObjectMsgToPrimary(SharedObjectMsg msg) throws IOException {
+ sendSharedObjectMsgTo(getHomeContainerID(), msg);
+ }
+ /**
+ * Send SharedObjectMsg to local shared object. This places the given message at
+ * the end of this shared object's message queue for processing.
+ * @param msg the message instance to send.
+ */
+ protected void sendSharedObjectMsgToSelf(SharedObjectMsg msg) {
+ if (msg == null) throw new NullPointerException("msg cannot be null");
+ ISharedObjectContext context = getContext();
+ if (context == null)
+ return;
+ IQueueEnqueue queue = context.getQueue();
+ try {
+ queue.enqueue(new SharedObjectMsgEvent(getID(), getContext()
+ .getLocalContainerID(), msg));
+ } catch (QueueException e) {
+ traceStack("QueueException enqueing message to self", e);
+ return;
+ }
+ }
+ /**
+ * Get SharedObjectMsg from ISharedObjectMessageEvent. ISharedObjectMessageEvents
+ * can come from both local and remote sources. In the remote case, the SharedObjectMsg
+ * has to be retrieved from the RemoteSharedObjectEvent rather than the
+ * ISharedObjectMessageEvent.getData() directly. This method will provide a non-null
+ * SharedObjectMsg if it's provided either via remotely or locally. Returns null
+ * if the given event does not provide a valid SharedObjectMsg.
+ * @param event
+ * @return SharedObjectMsg the SharedObjectMsg delivered by the given event
+ */
+ protected SharedObjectMsg getSharedObjectMsgFromEvent(
+ ISharedObjectMessageEvent event) {
+ Object eventData = event.getData();
+ Object msgData = null;
+ // If eventData is not null and instanceof RemoteSharedObjectEvent
+ // then its a remote event and we extract the SharedObjectMsgEvent it
+ // contains and get it's data
+ if (eventData != null && eventData instanceof RemoteSharedObjectEvent) {
+ // It's a remote event
+ Object rsoeData = ((RemoteSharedObjectEvent) event).getData();
+ if (rsoeData != null && rsoeData instanceof SharedObjectMsgEvent)
+ msgData = ((SharedObjectMsgEvent) rsoeData).getData();
+ } else
+ msgData = eventData;
+ if (msgData != null && msgData instanceof SharedObjectMsg)
+ return (SharedObjectMsg) msgData;
+ return null;
+ }
+ /**
+ * Handle a ISharedObjectMessageEvent. This method will be automatically called by
+ * the SharedObjectMsgEventProcessor when a ISharedObjectMessageEvent is received.
+ * The SharedObjectMsgEventProcessor is associated with this object via the initialize()
+ * method
+ * @param event the event to handle
+ * @return true if the provided event should receive no further processing. If false the provided Event should be
+ * passed to subsequent event processors.
+ */
+ protected boolean handleSharedObjectMsgEvent(ISharedObjectMessageEvent event) {
+ trace("handleSharedObjectMsgEvent("+event+")");
+ if (event instanceof ISharedObjectCreateResponseEvent) return handleSharedObjectCreateResponseEvent((ISharedObjectCreateResponseEvent)event);
+ else {
+ SharedObjectMsg msg = getSharedObjectMsgFromEvent(event);
+ if (msg != null) return handleSharedObjectMsg(msg);
+ else return false;
+ }
+ }
+ /**
+ * Handle a ISharedObjectCreateResponseEvent. This handler is called by handleSharedObjectMsgEvent
+ * when the ISharedObjectMessageEvent is of type ISharedObjectCreateResponseEvent. This default
+ * implementation simply returns false. Subclasses may override
+ * as appropriate. Note that if return value is true, it will prevent subsequent event processors from
+ * having a chance to process event
+ * @param createResponseEvent the ISharedObjectCreateResponseEvent received
+ * @return true if the provided event should receive no further processing. If false the provided Event should be
+ * passed to subsequent event processors.
+ */
+ protected boolean handleSharedObjectCreateResponseEvent(ISharedObjectCreateResponseEvent createResponseEvent) {
+ trace("handleSharedObjectCreateResponseEvent("+createResponseEvent+")");
+ return false;
+ }
+ /**
+ * SharedObjectMsg handler method. This method will be called by {@link #handleSharedObjectMsgEvent(ISharedObjectMessageEvent)} when
+ * a SharedObjectMsg is received either from a local source or a remote source. This default implementation
+ * simply returns false so that other processing of of the given msg can occur. Subclasses should override this
+ * behavior to define custom logic for handling SharedObjectMsgs.
+ * @param msg the SharedObjectMsg received
+ * @return true if the msg has been completely handled and subsequent processing should stop. False if processing
+ * should continue
+ */
+ protected boolean handleSharedObjectMsg(SharedObjectMsg msg) {
+ trace("handleSharedObjectMsg("+msg+")");
+ return false;
+ }
+ /**
+ * Get a ReplicaSharedObjectDescription for a replica to be created on a given receiver.
+ *
+ * @param receiver the receiver the ReplicaSharedObjectDescription is for
+ * @return ReplicaSharedObjectDescription to be associated with given receiver. A non-null
+ * ReplicaSharedObjectDescription <b>must</b> be returned.
+ */
+ protected ReplicaSharedObjectDescription getReplicaDescription(ID receiver) {
+ return new ReplicaSharedObjectDescription(getClass(),getID(),getConfig().getHomeContainerID(),
+ getConfig().getProperties());
+ }
+ /**
+ * This method is called by replicateToRemoteContainers to
+ * determine the ReplicaSharedObjectDescriptions associated with the given receivers. Receivers
+ * may be null (meaning that all in group are to be receivers), and if so then this method
+ * should return a ReplicaSharedObjectDescription [] of length 1 with a single ReplicaSharedObjectDescription
+ * that will be used for all receivers. If receivers is non-null, then the ReplicaSharedObjectDescription []
+ * result must be of <b>same length</b> as the receivers array. This method calls the
+ * getReplicaDescription method to create a replica description for each receiver. If this method returns
+ * null, <b>null replication is done</b>.
+ *
+ * @param receivers an ID[] of the intended receivers for the resulting ReplicaSharedObjectDescriptions. If null,
+ * then the <b>entire current group</b> is assumed to be the target, and this method should return a
+ * ReplicaSharedObjectDescriptions array of length 1, with a single ReplicaSharedObjectDescriptions for all target receivers.
+ *
+ * @return ReplicaSharedObjectDescription[] to determine replica descriptions for each receiver. A null return
+ * value indicates that no replicas are to be created. If the returned array is not null, then it <b>must</b>
+ * be of same length as the receivers parameter.
+ *
+ */
+ protected ReplicaSharedObjectDescription[] getReplicaDescriptions(ID[] receivers) {
+ ReplicaSharedObjectDescription[] descriptions = null;
+ if (receivers == null || receivers.length == 1) {
+ descriptions = new ReplicaSharedObjectDescription[1];
+ descriptions[0] = getReplicaDescription((receivers==null)?null:receivers[0]);
+ } else {
+ descriptions = new ReplicaSharedObjectDescription[receivers.length];
+ for(int i=0; i < receivers.length; i++) {
+ descriptions[i] = getReplicaDescription(receivers[i]);
+ }
+ }
+ return descriptions;
+ }
+ /**
+ * Replicate this shared object to a given set of remote containers. This
+ * method will invoke the method getReplicaDescriptions in order to
+ * determine the set of ReplicaSharedObjectDescriptions to send to remote
+ * containers.
+ *
+ * @param remoteContainers
+ * the set of remote containers to replicate to. If null, <b>all</b>
+ * containers in the current group are sent a message to create a
+ * replica of this shared object.
+ */
+ protected void replicateToRemoteContainers(ID[] remoteContainers) {
+ if (remoteContainers == null)
+ trace("replicateTo(null)");
+ else
+ trace("replicateTo(" + Arrays.asList(remoteContainers) + ")");
+ try {
+ // Get current group membership
+ ISharedObjectContext context = getContext();
+ if (context == null)
+ return;
+ ID[] group = context.getGroupMemberIDs();
+ if (group == null || group.length < 1) {
+ // we're done
+ return;
+ }
+ ReplicaSharedObjectDescription[] createInfos = getReplicaDescriptions(remoteContainers);
+ if (createInfos != null) {
+ if (createInfos.length == 1) {
+ context.sendCreate((remoteContainers == null) ? null
+ : remoteContainers[0], createInfos[0]);
+ } else {
+ for (int i = 0; i < remoteContainers.length; i++) {
+ context.sendCreate(remoteContainers[i], createInfos[i]);
+ }
+ }
+ }
+ } catch (IOException e) {
+ if (remoteContainers == null)
+ traceStack("Exception in replicateTo(null)", e);
+ else
+ traceStack("Exception in replicateTo("
+ + Arrays.asList(remoteContainers) + ")", e);
+ return;
+ }
+ }
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/AbstractSharedObjectContainerAdapterFactory.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/AbstractSharedObjectContainerAdapterFactory.java
new file mode 100644
index 000000000..0f9d66773
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/AbstractSharedObjectContainerAdapterFactory.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.core.identity.IDCreateException;
+import org.eclipse.ecf.internal.core.sharedobject.Activator;
+
+public abstract class AbstractSharedObjectContainerAdapterFactory implements
+ IAdapterFactory {
+
+ protected static final int ADD_ADAPTER_ERROR_CODE = 300001;
+
+ protected static final String ADD_ADAPTER_ERROR_MESSAGE = "Exception adding shared object adapter";
+
+ private static final int CREATE_ADAPTER_ID_ERROR_CODE = 300002;
+
+ private static final String CREATE_ADAPTER_ID_ERROR_MESSAGE = null;
+
+ protected ID sharedObjectID = null;
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (ISharedObjectContainer.class.isInstance(adaptableObject))
+ return getSharedObjectAdapter(
+ (ISharedObjectContainer) adaptableObject, adapterType);
+ else
+ return null;
+ }
+
+ protected synchronized ISharedObject getSharedObjectAdapter(
+ ISharedObjectContainer container, Class adapterType) {
+ ISharedObjectManager manager = container.getSharedObjectManager();
+ // Check to see if the container already has the given shared object
+ // If so then return it
+ if (sharedObjectID != null) {
+ ISharedObject so = manager.getSharedObject(sharedObjectID);
+ if (so != null) return so;
+ }
+ ISharedObject adapter = createAdapter(container, adapterType);
+ if (adapter == null)
+ return null;
+ sharedObjectID = createAdapterID(adapter,
+ adapterType);
+ if (sharedObjectID == null)
+ return null;
+ Map sharedObjectProperties = createAdapterProperties(
+ adapter, adapterType);
+ try {
+ manager.addSharedObject(sharedObjectID, adapter,
+ sharedObjectProperties);
+ } catch (SharedObjectAddException e) {
+ Activator.getDefault().getLog().log(
+ new Status(IStatus.ERROR, Activator.getDefault()
+ .getBundle().getSymbolicName(),
+ ADD_ADAPTER_ERROR_CODE, ADD_ADAPTER_ERROR_MESSAGE,
+ e));
+ return null;
+ }
+ return adapter;
+ }
+
+ protected Map createAdapterProperties(
+ ISharedObject sharedObjectAdapter, Class adapterType) {
+ return null;
+ }
+
+ protected ID createAdapterID(ISharedObject adapter,
+ Class adapterType) {
+ String singletonName = adapter.getClass().getName();
+ try {
+ return IDFactory.getDefault().createStringID(singletonName);
+ } catch (IDCreateException e) {
+ Activator.getDefault().getLog().log(
+ new Status(IStatus.ERROR, Activator.getDefault()
+ .getBundle().getSymbolicName(),
+ CREATE_ADAPTER_ID_ERROR_CODE, CREATE_ADAPTER_ID_ERROR_MESSAGE,
+ e));
+ return null;
+ }
+ }
+
+ protected abstract ISharedObject createAdapter(ISharedObjectContainer container, Class adapterType);
+
+ public abstract Class[] getAdapterList();
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/IReplicaSharedObjectDescriptionFactory.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/IReplicaSharedObjectDescriptionFactory.java
new file mode 100644
index 000000000..5b97c60e6
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/IReplicaSharedObjectDescriptionFactory.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.identity.ID;
+
+public interface IReplicaSharedObjectDescriptionFactory {
+ /**
+ * Create new ReplicaSharedObjectDescription instance for delivery to remote
+ * container identified by containerID parameter. The containerID parameter ID
+ * provided must not be null
+ *
+ * @param containerID
+ * @return ReplicaSharedObjectDescription. Must not return null, but rather a valid
+ * ReplicaSharedObjectDescription instance
+ */
+ public ReplicaSharedObjectDescription createDescriptionForContainer(ID containerID, ISharedObjectConfig config);
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObject.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObject.java
new file mode 100644
index 000000000..693d2f985
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObject.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.util.IEventHandler;
+
+/**
+ * Core interface for implementing components that exist within
+ * {@link ISharedObjectContainer}
+ *
+ */
+public interface ISharedObject extends IAdaptable, IEventHandler {
+ /**
+ * Initialize this ISharedObject. The ISharedObjectContainer for this
+ * ISharedObject must call this method with a non-null instance of
+ * ISharedObjectConfig. ISharedObject implementations can use this
+ * initialization to perform any initialization necessary prior to receiving
+ * any events (via handleEvent/s). Note that the ISharedObjectContext
+ * provided via the ISharedObjectConfig.getSharedObjectContext() method is
+ * not guaranteed to allow any method calls until after this init() method
+ * call has completed.
+ *
+ * @param initData
+ * the initialization data passed by the ISharedObjectContainer
+ * upon initialization
+ * @exception SharedObjectInitException
+ * thrown by ISharedObject to halt initialization.
+ * ISharedObjectContainers must respond to such an exception
+ * by halting the addition of the ISharedObject instance and
+ * treating it as <b>not </b> in the container.
+ */
+ public void init(ISharedObjectConfig initData)
+ throws SharedObjectInitException;
+
+ /**
+ * Method called by the ISharedObjectContainer upon ISharedObject
+ * destruction. Once this method is called, no more Events will be passed to
+ * a ISharedObject until the init method is called again.
+ *
+ * @param containerID
+ * the ID of the container that is disposing this ISharedObject
+ */
+ public void dispose(ID containerID);
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectConfig.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectConfig.java
new file mode 100644
index 000000000..f45fe1457
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectConfig.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.util.Map;
+import org.eclipse.ecf.core.identity.ID;
+
+/**
+ * Configuration information provided to ISharedObject via its enclosing
+ * ISharedObjectContainer
+ *
+ * @see ISharedObject#init(ISharedObjectConfig)
+ */
+public interface ISharedObjectConfig {
+ /**
+ * Get the ID associated with this ISharedObject by its container.
+ * Containers must provide an implementation of this configuration that
+ * provides a non-null ID instance in response to this method call.
+ *
+ * @return ID that ISharedObject can use for imlementing its own
+ * ISharedObject.getID(). Will not be null.
+ */
+ public ID getSharedObjectID();
+
+ /**
+ * Get the ID of the container that is the home of the primary copy of the
+ * ISharedObject instance.
+ *
+ * @return the ID of the container that is the home of the primary copy of
+ * the ISharedObject instance. Will not be null.
+ */
+ public ID getHomeContainerID();
+
+ /**
+ * Get the ISharedObjectContext instance for this ISharedObject. The
+ * ISharedObjectContext provides access to container-provided services,
+ * including messaging to remote containers and to remote replicas of the
+ * ISharedObject, as well as access to OSGI-platform services.
+ *
+ * @return ISharedObjectContext for the ISharedObject to use to access
+ * container and associated services. <b>Will</b> return null
+ * if context is no longer valid.
+ */
+ public ISharedObjectContext getContext();
+
+ /**
+ * Get properties associated with with this ISharedObject
+ *
+ * @return Map with properties associated with this ISharedObject instance. Will not be null.
+ */
+ public Map getProperties();
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectConnector.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectConnector.java
new file mode 100644
index 000000000..c465016d7
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectConnector.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.sharedobject.events.ISharedObjectEvent;
+import org.eclipse.ecf.core.util.AsynchResult;
+import org.eclipse.ecf.core.util.QueueException;
+
+/**
+ * Implementers which represent the one-way associations between SharedObject
+ * instances within the scope of a given ISharedObjectContainer
+ *
+ * @see ISharedObjectManager#connectSharedObjects(ID, ID[])
+ */
+public interface ISharedObjectConnector {
+ public ID getSender();
+
+ public ID[] getReceivers();
+
+ public void enqueue(ISharedObjectEvent event) throws QueueException;
+
+ public void enqueue(ISharedObjectEvent[] events) throws QueueException;
+
+ public AsynchResult[] callAsynch(ISharedObjectEvent arg) throws Exception;
+
+ public void dispose();
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainer.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainer.java
new file mode 100644
index 000000000..33771f15b
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainer.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.IReliableContainer;
+
+/**
+ * Core interface that must be implemented by all ECF container instances.
+ * Instances are typically created via {@link SharedObjectContainerFactory}
+ */
+public interface ISharedObjectContainer extends IReliableContainer {
+ /**
+ * Get SharedObjectManager for this container
+ *
+ * @return ISharedObjectManager for this container instance
+ */
+ public ISharedObjectManager getSharedObjectManager();
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerConfig.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerConfig.java
new file mode 100644
index 000000000..3a0292de1
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerConfig.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.util.Map;
+
+import org.eclipse.ecf.core.IIdentifiable;
+
+/**
+ * Configuration information associated with ISharedObjectContainer.
+ *
+ */
+public interface ISharedObjectContainerConfig extends IIdentifiable {
+ /**
+ * The properties associated with the owner ISharedObjectContainer
+ *
+ * @return Map the properties associated with owner ISharedObjectContainer
+ */
+ public Map getProperties();
+
+ /**
+ * Returns an object which is an instance of the given class associated with
+ * this object.
+ *
+ * @param clazz
+ * the adapter class to lookup
+ * @return Object a object castable to the given class, or null if this
+ * object does not have an adapter for the given class
+ */
+ public Object getAdapter(Class clazz);
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerFactory.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerFactory.java
new file mode 100644
index 000000000..031c14cbf
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerFactory.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.ContainerTypeDescription;
+
+/**
+ * Factory contract for {@link SharedObjectContainerFactory}
+ */
+public interface ISharedObjectContainerFactory {
+ /**
+ * Make ISharedObjectContainer instance.
+ *
+ * @param desc
+ * the ContainerTypeDescription to use to create the instance
+ * @param argTypes
+ * a String [] defining the types of the args parameter
+ * @param args
+ * an Object [] of arguments passed to the createInstance method of
+ * the IContainerInstantiator
+ * @return a valid instance of ISharedObjectContainer
+ * @throws ContainerCreateException
+ */
+ public ISharedObjectContainer createSharedObjectContainer(
+ ContainerTypeDescription desc, String[] argTypes, Object[] args)
+ throws ContainerCreateException;
+
+ /**
+ * Make ISharedObjectContainer instance.
+ *
+ * @param descriptionName
+ * the ContainerTypeDescription name to lookup
+ * @return a valid instance of ISharedObjectContainer
+ * @throws ContainerCreateException
+ */
+ public ISharedObjectContainer createSharedObjectContainer(
+ String descriptionName) throws ContainerCreateException;
+
+ /**
+ * Make ISharedObjectContainer instance.
+ *
+ * @param descriptionName
+ * the ContainerTypeDescription name to lookup
+ * @param args
+ * the Object [] of arguments passed to the
+ * IContainerInstantiator.createInstance method
+ * @return a valid instance of ISharedObjectContainer
+ * @throws ContainerCreateException
+ */
+ public ISharedObjectContainer createSharedObjectContainer(
+ String descriptionName, Object[] args)
+ throws ContainerCreateException;
+
+ /**
+ * Make ISharedObjectContainer instance.
+ *
+ * @param descriptionName
+ * the ContainerTypeDescription name to lookup
+ * @param argsTypes
+ * the String [] of argument types of the following args
+ * @param args
+ * the Object [] of arguments passed to the
+ * IContainerInstantiator.createInstance method
+ * @return a valid instance of ISharedObjectContainer
+ * @throws ContainerCreateException
+ */
+ public ISharedObjectContainer createSharedObjectContainer(
+ String descriptionName, String[] argsTypes, Object[] args)
+ throws ContainerCreateException;
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerGroupManager.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerGroupManager.java
new file mode 100644
index 000000000..372d5dc47
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerGroupManager.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.io.Serializable;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.security.IConnectPolicy;
+
+/**
+ * Contract for shared object container group manager (e.g. servers)
+ */
+public interface ISharedObjectContainerGroupManager {
+ /**
+ * Set the join policy for this group manager. If the policy is set to null,
+ * the implementing container is not obligated to consult the policy. If
+ * non-null, the given policy's checkJoin method is called before the
+ * manager agrees to the join of a given group participant.
+ *
+ * @param policy
+ */
+ public void setConnectPolicy(IConnectPolicy policy);
+
+ /**
+ * Eject the given groupMemberID from the current group of containers, for
+ * the given reason.
+ *
+ * @param groupMemberID
+ * the ID of the group member to eject. If null, or if group
+ * member is not in group managed by this object, the method has
+ * no effect
+ * @param reason
+ * a reason for the ejection
+ */
+ public void ejectGroupMember(ID groupMemberID, Serializable reason);
+
+ /**
+ * Eject all, for the given reason.
+ *
+ * @param reason
+ * a reason for the ejection
+ */
+ public void ejectAllGroupMembers(Serializable reason);
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerTransaction.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerTransaction.java
new file mode 100644
index 000000000..0d81fd642
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContainerTransaction.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+/**
+ * Implementers represent a transaction associated with the creation of a
+ * SharedObject within the scope of a given SharedObjectContainer
+ *
+ */
+public interface ISharedObjectContainerTransaction {
+ public static final byte ACTIVE = 0;
+ public static final byte VOTING = 1;
+ public static final byte PREPARED = 2;
+ public static final byte COMMITTED = 3;
+ public static final byte ABORTED = 4;
+
+ /**
+ * Method called to wait for a transaction to complete.
+ *
+ * @throws SharedObjectAddAbortException
+ */
+ public void waitToCommit() throws SharedObjectAddAbortException;
+
+ /**
+ * Get state of transaction. Returns one of 'ACTIVE', 'VOTING', 'PREPARED',
+ * 'COMMITTED', or 'ABORTED'.
+ *
+ * @return byte code. Returns one of 'ACTIVE', 'VOTING', 'PREPARED',
+ * 'COMMITTED', or 'ABORTED'.
+ */
+ public byte getTransactionState();
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContext.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContext.java
new file mode 100644
index 000000000..9e8d6ae09
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectContext.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.io.IOException;
+import java.util.Map;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ecf.core.ContainerConnectException;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.IOSGIService;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.core.util.IQueueEnqueue;
+
+/**
+ * Context reference provided to all ISharedObjects upon initialization.
+ * Implementers of this interface provide a runtime context for ISharedObject
+ * instances. Upon initialization within a container (see
+ * {@link ISharedObject#init(ISharedObjectConfig)}, ISharedObject instances can
+ * access an instance of this context by calling
+ * {@link ISharedObjectConfig#getContext()}. They then can have access to the
+ * functions provided by this context object for use in implementing their
+ * behavior.
+ *
+ * @see ISharedObject#init
+ * @see ISharedObjectConfig#getContext()
+ */
+public interface ISharedObjectContext extends IAdaptable {
+ public boolean isActive();
+
+ /**
+ * Get the local container instance's ID
+ *
+ * @return the ID of the enclosing container
+ */
+ public ID getLocalContainerID();
+
+ /**
+ * Get the ISharedObjectManager for this context
+ *
+ * @return ISharedObjectManager the shared object manager instance for this
+ * container. Null if none available.
+ */
+ public ISharedObjectManager getSharedObjectManager();
+
+ /**
+ * Get the IQueueEnqueue instance associated with this ISharedObject. If the
+ * given container provides a queue for this ISharedObject, this method will
+ * return a IQueueEnqueue reference to the appropriate queue.
+ *
+ * @return IQueueEnqueue instance if an active queue is associated with this
+ * ISharedObject. If no active queue is associated with the
+ * ISharedObject, returns null.
+ */
+ public IQueueEnqueue getQueue();
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.IContainer#connect(ID,IConnectContext)
+ */
+ public void connect(ID groupID, IConnectContext connectContext)
+ throws ContainerConnectException;
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.IContainer#disconnect()
+ */
+ public void disconnect();
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.IContainer#getConnectedID()
+ */
+ public ID getConnectedID();
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.sharedobject.ISharedObjectContainer#isGroupManager()
+ */
+ public boolean isGroupManager();
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.sharedobject.ISharedObjectContainer#getGroupMemberIDs()
+ */
+ public ID[] getGroupMemberIDs();
+
+ /**
+ * Send message to create a remote instance of an ISharedObject with the
+ * same ID as this instance. This method allows ISharedObject instances
+ * (with a reference to a valid ISharedObjectContext) to send messages to
+ * remote containers asking them to create an instance of a new
+ * ISharedObject. The given ReplicaSharedObjectDescription provides the
+ * specification of the new object.
+ *
+ * @param toContainerID
+ * the ID of the remote ISharedObjectContainer that is the target
+ * of the create request. If this parameter is null, the request
+ * is assumed to be made of <b>all </b> remote containers
+ * currently in the given group (excepting the local container).
+ * @param sd
+ * the ReplicaSharedObjectDescription describing the class, constructor
+ * and other properties to be associated with the new instance
+ * @throws IOException
+ * thrown if message cannot be sent by container
+ */
+ public void sendCreate(ID toContainerID, ReplicaSharedObjectDescription sd)
+ throws IOException;
+
+ /**
+ * Send create response back to an ISharedObject with the same ID as this
+ * instance. This method allows ISharedObject instances (with a reference to
+ * a valid ISharedObjectContext) to send messages to remote containers
+ * asking them to deliver the create response status back to the
+ * ISharedObject.
+ *
+ * @param toContainerID
+ * the ID of the container that is to receive this response
+ * @param throwable
+ * a throwable associated with the creation. Null means that no
+ * exception occured
+ * @param identifier
+ * the identifier used in the original create message (in the
+ * shared object description)
+ * @exception IOException
+ * thrown if the create response cannot be sent
+ */
+ public void sendCreateResponse(ID toContainerID, Throwable throwable,
+ long identifier) throws IOException;
+
+ /**
+ * Send message to dispose of a remote instance of the ISharedObject with
+ * same ID as this instance. This method allows ISharedObject instances to
+ * control the destruction of remote replicas.
+ *
+ * @param toContainerID
+ * the ID of the remote ISharedObjectContainer that is the target
+ * of the dispose request. If this parameter is null, the request
+ * is assumed to be made of <b>all </b> remote containers
+ * currently in the given group (excepting the local container).
+ * @throws IOException
+ * thrown if message cannot be sent by container
+ */
+ public void sendDispose(ID toContainerID) throws IOException;
+
+ /**
+ * Send arbitrary message to remote instance of the ISharedObject with same
+ * ID as this instance. This method allows ISharedObject instances to send
+ * arbitrary data to one or more remote replicas of this ISharedObject.
+ *
+ * @param toContainerID
+ * the ID of the remote ISharedObjectContainer that is the target
+ * container for the message request. If this parameter is null,
+ * the request is assumed to be made of <b>all </b> remote
+ * containers currently in the given group (excepting the local
+ * container).
+ * @param data
+ * arbitrary message object. The allowable types of this
+ * parameter are dependent upon the type of the underlying
+ * implementing container
+ * @throws IOException
+ * thrown if message cannot be sent by container, or if data
+ * cannot be serialized
+ */
+ public void sendMessage(ID toContainerID, Object data) throws IOException;
+
+ /**
+ * Get a reference to a proxy instance that allows the registration and
+ * access to local OSGI-platform-provided services. If this method returns
+ * null, then such services are not available.
+ *
+ * @return null if OSGI platform services cannot be accessed, a valid
+ * instance of the given interface if the context allows access to
+ * such services
+ */
+ public IOSGIService getServiceAccess();
+ /**
+ * Get the Namespace instance that defines the ID type expected by the remote target container
+ * @return Namespace the namespace by the target for a call to connect(). Null if container
+ * namespace no longer available
+ */
+ public Namespace getConnectNamespace();
+
+ /**
+ * Get local container properties that it wishes to expose to shared object access
+ *
+ * @return Map of properties available to calling shared object. Map returned must not be null.
+ */
+ public Map getLocalContainerProperties();
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectFactory.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectFactory.java
new file mode 100644
index 000000000..6695f4a9d
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectFactory.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.util.List;
+
+/**
+ * Container factory contract {@link SharedObjectFactory} for default implementation.
+ */
+public interface ISharedObjectFactory {
+ /*
+ * Add a SharedObjectTypeDescription to the set of known SharedObjectTypeDescriptions.
+ *
+ * @param scd the SharedObjectTypeDescription to add to this factory @return
+ * SharedObjectTypeDescription the old description of the same name, null if none
+ * found
+ */
+ public SharedObjectTypeDescription addDescription(SharedObjectTypeDescription description);
+
+ /**
+ * Get a collection of the SharedObjectTypeDescriptions currently known to this
+ * factory. This allows clients to query the factory to determine what if
+ * any other SharedObjectTypeDescriptions are currently registered with the
+ * factory, and if so, what they are.
+ *
+ * @return List of SharedObjectTypeDescription instances
+ */
+ public List getDescriptions();
+
+ /**
+ * Check to see if a given named description is already contained by this
+ * factory
+ *
+ * @param description
+ * the SharedObjectTypeDescription to look for
+ * @return true if description is already known to factory, false otherwise
+ */
+ public boolean containsDescription(SharedObjectTypeDescription description);
+
+ /**
+ * Get the known SharedObjectTypeDescription given it's name.
+ *
+ * @param name
+ * @return SharedObjectTypeDescription found
+ * @throws SharedObjectCreateException
+ */
+ public SharedObjectTypeDescription getDescriptionByName(String name)
+ throws SharedObjectCreateException;
+
+ /**
+ * Create ISharedObject instance. Given a SharedObjectTypeDescription object, a String []
+ * of argument types, and an Object [] of parameters, this method will
+ * <p>
+ * <ul>
+ * <li>lookup the known SharedObjectTypeDescriptions to find one of matching name</li>
+ * <li>if found, will retrieve or create an ISharedObjectInstantiator for that
+ * description</li>
+ * <li>Call the ISharedObjectInstantiator.createInstance method to return an
+ * instance of ISharedObject</li>
+ * </ul>
+ *
+ * @param typeDescription
+ * the SharedObjectTypeDescription to use to create the instance
+ * @param argTypes
+ * a String [] defining the types of the args parameter
+ * @param args
+ * an Object [] of arguments passed to the createInstance method of
+ * the ISharedObjectInstantiator
+ * @return a valid instance of ISharedObject
+ * @throws SharedObjectCreateException
+ */
+ public ISharedObject createSharedObject(SharedObjectTypeDescription typeDescription,
+ String[] argTypes, Object[] args)
+ throws SharedObjectCreateException;
+
+ /**
+ * Create ISharedObject instance. Given a SharedObjectTypeDescription name, this method
+ * will
+ * <p>
+ * <ul>
+ * <li>lookup the known SharedObjectTypeDescriptions to find one of matching name</li>
+ * <li>if found, will retrieve or create an ISharedObjectInstantiator for that
+ * description</li>
+ * <li>Call the ISharedObjectInstantiator.createInstance method to return an
+ * instance of ISharedObject</li>
+ * </ul>
+ *
+ * @param descriptionName
+ * the SharedObjectTypeDescription name to lookup
+ * @return a valid instance of ISharedObject
+ * @throws SharedObjectCreateException
+ */
+ public ISharedObject createSharedObject(String descriptionName)
+ throws SharedObjectCreateException;
+
+ /**
+ * Create ISharedObject instance. Given a SharedObjectTypeDescription name, this method
+ * will
+ * <p>
+ * <ul>
+ * <li>lookup the known SharedObjectTypeDescriptions to find one of matching name</li>
+ * <li>if found, will retrieve or create an ISharedObjectInstantiator for that
+ * description</li>
+ * <li>Call the ISharedObjectInstantiator.createInstance method to return an
+ * instance of ISharedObject</li>
+ * </ul>
+ *
+ * @param descriptionName
+ * the SharedObjectTypeDescription name to lookup
+ * @param args
+ * the Object [] of arguments passed to the
+ * ISharedObjectInstantiator.createInstance method
+ * @return a valid instance of IContainer
+ * @throws SharedObjectCreateException
+ */
+ public ISharedObject createSharedObject(String descriptionName, Object[] args)
+ throws SharedObjectCreateException;
+
+ /**
+ * Create ISharedObject instance. Given a SharedObjectTypeDescription name, this method
+ * will
+ * <p>
+ * <ul>
+ * <li>lookup the known SharedObjectTypeDescriptions to find one of matching name</li>
+ * <li>if found, will retrieve or create an ISharedObjectInstantiator for that
+ * description</li>
+ * <li>Call the ISharedObjectInstantiator.createInstance method to return an
+ * instance of ISharedObject</li>
+ * </ul>
+ *
+ * @param descriptionName
+ * the SharedObjectTypeDescription name to lookup
+ * @param argsTypes
+ * the String [] of argument types of the following args
+ * @param args
+ * the Object [] of arguments passed to the
+ * ISharedObjectInstantiator.createInstance method
+ * @return a valid instance of ISharedObject
+ * @throws SharedObjectCreateException
+ */
+ public ISharedObject createSharedObject(String descriptionName, String[] argsTypes,
+ Object[] args) throws SharedObjectCreateException;
+
+ /**
+ * Remove given description from set known to this factory.
+ *
+ * @param scd
+ * the SharedObjectTypeDescription to remove
+ * @return the removed SharedObjectTypeDescription, null if nothing removed
+ */
+ public SharedObjectTypeDescription removeDescription(SharedObjectTypeDescription scd);
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectManager.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectManager.java
new file mode 100644
index 000000000..d1fc32d70
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectManager.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.util.List;
+import java.util.Map;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.sharedobject.security.ISharedObjectPolicy;
+
+/**
+ * Manager for creating, disposing, and accessing ISharedObjects from an
+ * ISharedObjectContainer.
+ *
+ * @see ISharedObjectContainer#getSharedObjectManager()
+ */
+public interface ISharedObjectManager {
+ /**
+ * Add an ISharedObject to this container.
+ *
+ * @param sharedObjectID
+ * the ID of new SharedObject
+ * @param sharedObject
+ * the ISharedObject instance to add
+ * @param properties
+ * the Map associated with the added ISharedObject
+ * @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) throws SharedObjectAddException;
+
+ /**
+ * Create an ISharedObjectConnector instance for sending messages from a
+ * single ISharedObject to one or more receiver ISharedObjects. All
+ * specified ISharedObject instances must be contained by this
+ * ISharedObjectContainer.
+ *
+ * @param sharedObjectFrom
+ * the ID of the sender ISharedObject
+ * @param sharedObjectsTo
+ * the ID[] of the receiver ISharedObjects
+ * @return a valid instance of ISharedObjectConnector. Null if no connector
+ * can be made
+ * @throws SharedObjectConnectException
+ * thrown if specified sender or receivers do not exist within
+ * the context of this container
+ */
+ public ISharedObjectConnector connectSharedObjects(ID sharedObjectFrom,
+ ID[] sharedObjectsTo) throws SharedObjectConnectException;
+
+ /**
+ * Create a new ISharedObject within this container from the given
+ * SharedObjectDescription.
+ *
+ * @param sd
+ * the SharedObjectDescription that describes the SharedObject to
+ * be created
+ * @return ID the sharedObjectID of the added ISharedObject
+ * @throws SharedObjectCreateException
+ * if the SharedObject cannot be created
+ */
+ public ID createSharedObject(SharedObjectDescription sd)
+ throws SharedObjectCreateException;
+
+ /**
+ * Destroy an ISharedObjectConnector instance.
+ *
+ * @param connector
+ * the connector previously created via connectSharedObjects
+ * @throws SharedObjectConnectException
+ * thrown if specified connector does not exist in the context
+ * of this container
+ */
+ public void disconnectSharedObjects(ISharedObjectConnector connector)
+ throws SharedObjectDisconnectException;
+
+ /**
+ * Get the ISharedObject instance corresponding to the given sharedObjectID.
+ *
+ * @param sharedObjectID
+ * of the desired ISharedObject
+ * @return ISharedObject found. Return null if ISharedObject not found.
+ */
+ public ISharedObject getSharedObject(ID sharedObjectID);
+
+ /**
+ * Get the sharedObjectConnectors associated with the given sharedObjectID
+ *
+ * @return List of ISharedObjectConnector instances
+ */
+ public List getSharedObjectConnectors(ID sharedObjectFrom);
+
+ /**
+ * Get the array of SharedObject instances currently contained by this
+ * ISharedObjectContainer
+ *
+ * @return ID[] the IDs of currently contained ISharedObject instances
+ */
+ public ID[] getSharedObjectIDs();
+
+ /**
+ * Remove the given sharedObjectID from this ISharedObjectContainer.
+ *
+ * @param sharedObjectID
+ * the ID of the ISharedObject to remove
+ * @return ISharedObject removed. Returns null if ISharedObject not found
+ */
+ public ISharedObject removeSharedObject(ID sharedObjectID);
+
+ /**
+ * Set this shared object manager's policy for adding remote shared objects.
+ *
+ * @param policy
+ * the ISharedObjectPolicy instance to use to check the validity
+ * of remote requests to add/replicate a shared object into this
+ * container
+ */
+ public void setRemoteAddPolicy(ISharedObjectPolicy policy);
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectTransactionConfig.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectTransactionConfig.java
new file mode 100644
index 000000000..85b27df03
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectTransactionConfig.java
@@ -0,0 +1,34 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, 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:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+
+/**
+ * Transaction configuration information
+ *
+ */
+public interface ISharedObjectTransactionConfig {
+ public static final int DEFAULT_TIMEOUT = 30000;
+ /**
+ * Called by transaction implementation to specify transaction timeout
+ */
+ int getTimeout();
+ /**
+ * Called by transaction implementation to specify filter for determining
+ * transaction participants
+ *
+ * @return {@link ISharedObjectTransactionParticipantsFilter}. If this method returns a
+ * non-null instance, that instance's
+ * {@link ISharedObjectTransactionParticipantsFilter#filterParticipants(org.eclipse.ecf.core.identity.ID[]) }
+ * method will be called
+ */
+ ISharedObjectTransactionParticipantsFilter getParticipantsFilter();
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectTransactionParticipantsFilter.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectTransactionParticipantsFilter.java
new file mode 100644
index 000000000..e11f9ac52
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ISharedObjectTransactionParticipantsFilter.java
@@ -0,0 +1,29 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, 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:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.identity.ID;
+
+/**
+ * Filter for determining transaction participants
+ *
+ */
+public interface ISharedObjectTransactionParticipantsFilter {
+ /**
+ * Return ID[] of participants to participate in transacton.
+ *
+ * @param currentGroup
+ * the current set of container group members
+ * @return intended participants in transaction. If null is returned, all
+ * group members will be included in transaction.
+ */
+ ID[] filterParticipants(ID[] currentGroup);
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/OptimisticSharedObject.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/OptimisticSharedObject.java
new file mode 100644
index 000000000..779c0ca06
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/OptimisticSharedObject.java
@@ -0,0 +1,67 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, 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:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.events.IContainerConnectedEvent;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent;
+import org.eclipse.ecf.core.util.Event;
+import org.eclipse.ecf.core.util.IEventProcessor;
+import org.eclipse.ecf.core.util.Trace;
+import org.eclipse.ecf.internal.core.sharedobject.Activator;
+import org.eclipse.ecf.internal.core.sharedobject.SharedObjectDebugOptions;
+
+/**
+ * Superclass for shared object classes that replicate themselves
+ * optimistically.
+ *
+ */
+public class OptimisticSharedObject extends AbstractSharedObject {
+
+ public OptimisticSharedObject() {
+ super();
+ }
+ protected void trace(String msg) {
+ Trace.trace(Activator.getDefault(),getID() + ":"
+ + (isPrimary() ? "primary:" : "replica:")
+ + msg);
+ }
+ protected void traceStack(String msg, Throwable t) {
+ Trace.catching(Activator.getDefault(), SharedObjectDebugOptions.EXCEPTIONS_CATCHING, OptimisticSharedObject.class, getID() + ":"
+ + (isPrimary() ? "primary" : "replica")
+ + msg, t);
+ }
+
+ protected void initialize() throws SharedObjectInitException {
+ super.initialize();
+ trace("initialize()");
+ addEventProcessor(new IEventProcessor() {
+ public boolean processEvent(Event event) {
+ if (event instanceof ISharedObjectActivatedEvent) {
+ if (isPrimary() && isConnected()) {
+ trace("replicating to all");
+ OptimisticSharedObject.this
+ .replicateToRemoteContainers(null);
+ }
+ } else if (event instanceof IContainerConnectedEvent) {
+ if (isPrimary()) {
+ ID targetID = ((IContainerConnectedEvent) event)
+ .getTargetID();
+ trace("replicating to target="+targetID);
+ OptimisticSharedObject.this
+ .replicateToRemoteContainers(new ID[] { targetID });
+ }
+ }
+ return false;
+ }
+ });
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ReplicaSharedObjectDescription.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ReplicaSharedObjectDescription.java
new file mode 100644
index 000000000..7972e0286
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ReplicaSharedObjectDescription.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.io.Serializable;
+import java.util.Map;
+import org.eclipse.ecf.core.identity.ID;
+
+/**
+ * Description of a remote ISharedObject instance.
+ *
+ */
+public class ReplicaSharedObjectDescription extends SharedObjectDescription
+ implements Serializable {
+ private static final long serialVersionUID = 2764430278848370713L;
+
+ protected static long staticID = 0;
+ public static long getNextUniqueIdentifier() {
+ return staticID++;
+ }
+
+ protected ID homeID;
+ protected long identifier;
+
+ public ReplicaSharedObjectDescription(SharedObjectTypeDescription type, ID objectID, ID homeID, Map props, long ident) {
+ super(type,objectID,props);
+ this.homeID = homeID;
+ this.identifier = ident;
+ }
+ public ReplicaSharedObjectDescription(String typeName, ID objectID, ID homeID, Map props, long ident) {
+ super(new SharedObjectTypeDescription(typeName, null, null, null), objectID, props);
+ this.homeID = homeID;
+ this.identifier = ident;
+ }
+ public ReplicaSharedObjectDescription(String typeName, ID objectID, ID homeID, Map props) {
+ this(typeName,objectID,homeID,props,getNextUniqueIdentifier());
+ }
+ public ReplicaSharedObjectDescription(String typeName, ID objectID, ID homeID) {
+ this(typeName,objectID,homeID,null);
+ }
+ public ReplicaSharedObjectDescription(Class clazz, ID objectID, ID homeID, Map props, long ident) {
+ super(new SharedObjectTypeDescription(clazz.getName(),null),objectID,props);
+ this.homeID = homeID;
+ this.identifier = ident;
+ }
+ public ReplicaSharedObjectDescription(Class clazz, ID objectID, ID homeID, Map props) {
+ this(clazz,objectID,homeID,props,getNextUniqueIdentifier());
+ }
+ public ReplicaSharedObjectDescription(Class clazz, ID objectID, ID homeID) {
+ this(clazz,objectID,homeID,null);
+ }
+ public ReplicaSharedObjectDescription(Class clazz, ID objectID) {
+ this(clazz,objectID,null,null);
+ }
+ public ID getHomeID() {
+ return homeID;
+ }
+ public long getIdentifier() {
+ return identifier;
+ }
+ public void setHomeID(ID theID) {
+ this.homeID = theID;
+ }
+ public void setID(ID theID) {
+ this.id = theID;
+ }
+ public void setIdentifier(long identifier) {
+ this.identifier = identifier;
+ }
+ public void setProperties(Map props) {
+ this.properties = props;
+ }
+ public String toString() {
+ StringBuffer sb = new StringBuffer("ReplicaSharedObjectDescription[");
+ sb.append("type=").append(typeDescription).append(";");
+ sb.append("id:").append(id).append(";");
+ sb.append("homeID:").append(homeID).append(";");
+ sb.append("props:").append(properties).append(";");
+ sb.append("ident:").append(identifier).append("]");
+ return sb.toString();
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectAddAbortException.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectAddAbortException.java
new file mode 100644
index 000000000..44eaf6c24
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectAddAbortException.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.util.List;
+import java.util.Map;
+
+public class SharedObjectAddAbortException extends SharedObjectAddException {
+ private static final long serialVersionUID = 4120851079287223088L;
+ protected long timeout = -1L;
+ protected Map causes;
+ protected List participants;
+
+ public SharedObjectAddAbortException() {
+ super();
+ }
+
+ public SharedObjectAddAbortException(String arg0) {
+ super(arg0);
+ }
+
+ public SharedObjectAddAbortException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public SharedObjectAddAbortException(String msg, Throwable cause,
+ int timeout) {
+ super(msg, cause);
+ this.timeout = timeout;
+ }
+
+ public SharedObjectAddAbortException(String msg, Map causes, int timeout) {
+ this(msg, null, causes, timeout);
+ }
+
+ public SharedObjectAddAbortException(String msg, List participants,
+ Map causes, int timeout) {
+ super(msg);
+ this.participants = participants;
+ this.causes = causes;
+ }
+
+ public SharedObjectAddAbortException(Throwable cause) {
+ super(cause);
+ }
+
+ public long getTimeout() {
+ return timeout;
+ }
+
+ public Map getCauses() {
+ return causes;
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectAddException.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectAddException.java
new file mode 100644
index 000000000..ea90f3cd8
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectAddException.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.util.ECFException;
+
+public class SharedObjectAddException extends ECFException {
+ private static final long serialVersionUID = 3257853198755705913L;
+
+ public SharedObjectAddException() {
+ super();
+ }
+
+ public SharedObjectAddException(String arg0) {
+ super(arg0);
+ }
+
+ public SharedObjectAddException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public SharedObjectAddException(Throwable cause) {
+ super(cause);
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectConnectException.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectConnectException.java
new file mode 100644
index 000000000..65e77fb00
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectConnectException.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.util.ECFException;
+
+public class SharedObjectConnectException extends ECFException {
+ private static final long serialVersionUID = 3256440287659570228L;
+
+ public SharedObjectConnectException() {
+ super();
+ }
+
+ public SharedObjectConnectException(String arg0) {
+ super(arg0);
+ }
+
+ public SharedObjectConnectException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public SharedObjectConnectException(Throwable cause) {
+ super(cause);
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectContainerFactory.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectContainerFactory.java
new file mode 100644
index 000000000..e868292e8
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectContainerFactory.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.ContainerFactory;
+import org.eclipse.ecf.core.ContainerTypeDescription;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.util.Trace;
+import org.eclipse.ecf.internal.core.sharedobject.Activator;
+
+/**
+ * Factory for creating {@link ISharedObjectContainer} instances. This class
+ * provides ECF clients an entry point to constructing
+ * {@link ISharedObjectContainer} instances. <br>
+ * <br>
+ * Here is an example use of the SharedObjectContainerFactory to construct an
+ * instance of the 'standalone' container (has no connection to other
+ * containers): <br>
+ * <br>
+ * <code>
+ * ISharedObjectContainer container = <br>
+ * SharedObjectContainerFactory.getDefault().createSharedObjectContainer('standalone');
+ * <br><br>
+ * ...further use of container variable here...
+ * </code>
+ *
+ */
+public class SharedObjectContainerFactory implements
+ ISharedObjectContainerFactory {
+ protected static ISharedObjectContainerFactory instance = null;
+ static {
+ instance = new SharedObjectContainerFactory();
+ }
+
+ protected SharedObjectContainerFactory() {
+ }
+
+ public static ISharedObjectContainerFactory getDefault() {
+ return instance;
+ }
+
+ private static void trace(String msg) {
+ Trace.trace(Activator.getDefault(),msg);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectContainerFactory#createSharedObjectContainer(org.eclipse.ecf.core.SharedObjectContainerDescription,
+ * java.lang.String[], java.lang.Object[])
+ */
+ public ISharedObjectContainer createSharedObjectContainer(
+ ContainerTypeDescription desc, String[] argTypes, Object[] args)
+ throws ContainerCreateException {
+ trace("createSharedObjectContainer(" + desc + ","
+ + Trace.getArgumentsString(argTypes) + ","
+ + Trace.getArgumentsString(args) + ")");
+ if (desc == null)
+ throw new ContainerCreateException(
+ "ContainerTypeDescription cannot be null");
+ IContainer newContainer = ContainerFactory.getDefault().createContainer(
+ desc, argTypes, args);
+ ISharedObjectContainer soContainer = (ISharedObjectContainer) newContainer
+ .getAdapter(ISharedObjectContainer.class);
+ if (soContainer == null) {
+ newContainer.dispose();
+ throw new ContainerCreateException(
+ "new container is not a shared object container");
+ }
+ return soContainer;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectContainerFactory#createSharedObjectContainer(java.lang.String)
+ */
+ public ISharedObjectContainer createSharedObjectContainer(
+ String descriptionName) throws ContainerCreateException {
+ return createSharedObjectContainer(ContainerFactory.getDefault()
+ .getDescriptionByName(descriptionName), null, null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectContainerFactory#createSharedObjectContainer(java.lang.String,
+ * java.lang.Object[])
+ */
+ public ISharedObjectContainer createSharedObjectContainer(
+ String descriptionName, Object[] args)
+ throws ContainerCreateException {
+ return createSharedObjectContainer(ContainerFactory.getDefault()
+ .getDescriptionByName(descriptionName), null, args);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectContainerFactory#createSharedObjectContainer(java.lang.String,
+ * java.lang.String[], java.lang.Object[])
+ */
+ public ISharedObjectContainer createSharedObjectContainer(
+ String descriptionName, String[] argsTypes, Object[] args)
+ throws ContainerCreateException {
+ return createSharedObjectContainer(ContainerFactory.getDefault()
+ .getDescriptionByName(descriptionName), argsTypes, args);
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectContainerInitException.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectContainerInitException.java
new file mode 100644
index 000000000..862fac8a0
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectContainerInitException.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.util.ECFException;
+
+public class SharedObjectContainerInitException extends ECFException {
+ private static final long serialVersionUID = 3690189958417888565L;
+
+ public SharedObjectContainerInitException() {
+ super();
+ }
+
+ public SharedObjectContainerInitException(String message) {
+ super(message);
+ }
+
+ public SharedObjectContainerInitException(Throwable cause) {
+ super(cause);
+ }
+
+ public SharedObjectContainerInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectCreateException.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectCreateException.java
new file mode 100644
index 000000000..765ca3b29
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectCreateException.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.util.ECFException;
+
+public class SharedObjectCreateException extends ECFException {
+ private static final long serialVersionUID = 3546919195137815606L;
+
+ public SharedObjectCreateException() {
+ super();
+ }
+
+ public SharedObjectCreateException(String arg0) {
+ super(arg0);
+ }
+
+ public SharedObjectCreateException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public SharedObjectCreateException(Throwable cause) {
+ super(cause);
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectDescription.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectDescription.java
new file mode 100644
index 000000000..1a54305a0
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectDescription.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.ecf.core.identity.ID;
+
+/**
+ * Description of a local ISharedObject instance.
+ *
+ */
+public class SharedObjectDescription implements Serializable {
+ private static final long serialVersionUID = -999672007680512082L;
+
+ protected SharedObjectTypeDescription typeDescription;
+ protected ID id;
+ protected Map properties;
+
+ protected SharedObjectDescription(SharedObjectTypeDescription typeDescription, ID id,
+ Map properties) {
+ this.typeDescription = typeDescription;
+ this.id = id;
+ this.properties = properties;
+ }
+ protected SharedObjectDescription(SharedObjectTypeDescription typeDescription, ID id) {
+ this(typeDescription, id, null);
+ }
+ public SharedObjectDescription(String typeName, ID id, Map properties) {
+ this.typeDescription = new SharedObjectTypeDescription(typeName,null,null,null);
+ this.id = id;
+ this.properties = properties;
+ }
+ public SharedObjectDescription(Class clazz, ID id, Map properties) {
+ this.typeDescription = new SharedObjectTypeDescription(clazz.getName(),null);
+ this.id = id;
+ this.properties = properties;
+ }
+ public SharedObjectTypeDescription getTypeDescription() {
+ return typeDescription;
+ }
+ public ID getID() {
+ return id;
+ }
+ public Map getProperties() {
+ if (properties != null)
+ return properties;
+ else
+ return new HashMap();
+ }
+ public String toString() {
+ StringBuffer sb = new StringBuffer("SharedObjectDescription[");
+ sb.append("type=").append(typeDescription).append(";");
+ sb.append("id=").append(id).append(";");
+ sb.append("props=").append(properties).append(";");
+ return sb.toString();
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectDisconnectException.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectDisconnectException.java
new file mode 100644
index 000000000..78874287d
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectDisconnectException.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.util.ECFException;
+
+public class SharedObjectDisconnectException extends ECFException {
+ private static final long serialVersionUID = 3258689922876586289L;
+
+ public SharedObjectDisconnectException() {
+ super();
+ }
+
+ public SharedObjectDisconnectException(String arg0) {
+ super(arg0);
+ }
+
+ public SharedObjectDisconnectException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public SharedObjectDisconnectException(Throwable cause) {
+ super(cause);
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectFactory.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectFactory.java
new file mode 100644
index 000000000..071aea703
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectFactory.java
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.eclipse.ecf.core.sharedobject.provider.ISharedObjectInstantiator;
+import org.eclipse.ecf.core.util.AbstractFactory;
+import org.eclipse.ecf.core.util.Trace;
+import org.eclipse.ecf.internal.core.sharedobject.Activator;
+import org.eclipse.ecf.internal.core.sharedobject.SharedObjectDebugOptions;
+
+/**
+ * Factory for creating {@link ISharedObject} instances. This class provides ECF
+ * clients an entry point to constructing {@link ISharedObject} instances. <br>
+ */
+public class SharedObjectFactory implements ISharedObjectFactory {
+
+ private static Hashtable sharedobjectdescriptions = new Hashtable();
+ protected static ISharedObjectFactory instance = null;
+
+ static {
+ instance = new SharedObjectFactory();
+ }
+
+ protected SharedObjectFactory() {
+ }
+
+ public static ISharedObjectFactory getDefault() {
+ return instance;
+ }
+
+ private static void trace(String msg) {
+ Trace.trace(Activator.getDefault(),msg);
+ }
+
+ private static void dumpStack(String msg, Throwable e) {
+ Trace.catching(Activator.getDefault(), SharedObjectDebugOptions.EXCEPTIONS_CATCHING, SharedObjectFactory.class, "dumpStack", e);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectFactory#addDescription(org.eclipse.ecf.core.SharedObjectTypeDescription)
+ */
+ public SharedObjectTypeDescription addDescription(SharedObjectTypeDescription description) {
+ trace("addDescription(" + description + ")");
+ return addDescription0(description);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectFactory#getDescriptions()
+ */
+ public List getDescriptions() {
+ return getDescriptions0();
+ }
+
+ protected List getDescriptions0() {
+ return new ArrayList(sharedobjectdescriptions.values());
+ }
+
+ protected SharedObjectTypeDescription addDescription0(SharedObjectTypeDescription n) {
+ if (n == null)
+ return null;
+ return (SharedObjectTypeDescription) sharedobjectdescriptions.put(n.getName(), n);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectFactory#containsDescription(org.eclipse.ecf.core.SharedObjectTypeDescription)
+ */
+ public boolean containsDescription(SharedObjectTypeDescription scd) {
+ return containsDescription0(scd);
+ }
+
+ protected boolean containsDescription0(SharedObjectTypeDescription scd) {
+ if (scd == null)
+ return false;
+ return sharedobjectdescriptions.containsKey(scd.getName());
+ }
+
+ protected SharedObjectTypeDescription getDescription0(SharedObjectTypeDescription scd) {
+ if (scd == null)
+ return null;
+ return (SharedObjectTypeDescription) sharedobjectdescriptions.get(scd.getName());
+ }
+
+ protected SharedObjectTypeDescription getDescription0(String name) {
+ if (name == null)
+ return null;
+ return (SharedObjectTypeDescription) sharedobjectdescriptions.get(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectContainerFactory#getDescriptionByName(java.lang.String)
+ */
+ public SharedObjectTypeDescription getDescriptionByName(String name)
+ throws SharedObjectCreateException {
+ trace("getDescriptionByName(" + name + ")");
+ SharedObjectTypeDescription res = getDescription0(name);
+ if (res == null) {
+ throw new SharedObjectCreateException(
+ "SharedObjectCreateException named '" + name + "' not found");
+ }
+ return res;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectContainerFactory#createSharedObject(org.eclipse.ecf.core.SharedObjectTypeDescription,
+ * java.lang.String[], java.lang.Object[])
+ */
+ public ISharedObject createSharedObject(SharedObjectTypeDescription desc,
+ String[] argTypes, Object[] args)
+ throws SharedObjectCreateException {
+ trace("createSharedObject(" + desc + ","
+ + Trace.getArgumentsString(argTypes) + ","
+ + Trace.getArgumentsString(args) + ")");
+ if (desc == null)
+ throw new SharedObjectCreateException(
+ "SharedObjectDescription cannot be null");
+ SharedObjectTypeDescription cd = getDescription0(desc);
+ if (cd == null)
+ throw new SharedObjectCreateException(
+ "SharedObjectDescription named '" + desc.getName()
+ + "' not found");
+ Class clazzes[] = null;
+ ISharedObjectInstantiator instantiator = null;
+ try {
+ instantiator = (ISharedObjectInstantiator) cd.getInstantiator();
+ clazzes = AbstractFactory.getClassesForTypes(argTypes, args, cd
+ .getClass().getClassLoader());
+ } catch (Exception e) {
+ SharedObjectCreateException newexcept = new SharedObjectCreateException(
+ "createSharedObject exception with description: " + desc + ": "
+ + e.getClass().getName() + ": " + e.getMessage());
+ newexcept.setStackTrace(e.getStackTrace());
+ dumpStack("Exception in createSharedObject", newexcept);
+ throw newexcept;
+ }
+ if (instantiator == null)
+ throw new SharedObjectCreateException(
+ "Instantiator for SharedObjectDescription " + cd.getName()
+ + " is null");
+ // Ask instantiator to actually create instance
+ return (ISharedObject) instantiator.createInstance(desc, clazzes, args);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectContainerFactory#createSharedObject(java.lang.String)
+ */
+ public ISharedObject createSharedObject(String descriptionName)
+ throws SharedObjectCreateException {
+ return createSharedObject(getDescriptionByName(descriptionName), null, null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectContainerFactory#createSharedObject(java.lang.String,
+ * java.lang.Object[])
+ */
+ public ISharedObject createSharedObject(String descriptionName, Object[] args)
+ throws SharedObjectCreateException {
+ return createSharedObject(getDescriptionByName(descriptionName), null, args);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectContainerFactory#createSharedObject(java.lang.String,
+ * java.lang.String[], java.lang.Object[])
+ */
+ public ISharedObject createSharedObject(String descriptionName, String[] argsTypes,
+ Object[] args) throws SharedObjectCreateException {
+ return createSharedObject(getDescriptionByName(descriptionName), argsTypes,
+ args);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.ISharedObjectContainerFactory#removeDescription(org.eclipse.ecf.core.SharedObjectTypeDescription)
+ */
+ public SharedObjectTypeDescription removeDescription(SharedObjectTypeDescription scd) {
+ trace("removeDescription(" + scd + ")");
+ return removeDescription0(scd);
+ }
+
+ protected SharedObjectTypeDescription removeDescription0(SharedObjectTypeDescription n) {
+ if (n == null)
+ return null;
+ return (SharedObjectTypeDescription) sharedobjectdescriptions.remove(n.getName());
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectInitException.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectInitException.java
new file mode 100644
index 000000000..8d3e01a5c
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectInitException.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.util.ECFException;
+
+public class SharedObjectInitException extends ECFException {
+ private static final long serialVersionUID = 3617579318620862771L;
+
+ public SharedObjectInitException() {
+ super();
+ }
+
+ public SharedObjectInitException(String arg0) {
+ super(arg0);
+ }
+
+ public SharedObjectInitException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public SharedObjectInitException(Throwable cause) {
+ super(cause);
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsg.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsg.java
new file mode 100644
index 000000000..0e6d7c189
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsg.java
@@ -0,0 +1,322 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, 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:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.io.NotSerializableException;
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Shared Object Message. Instances may be used for sending/receiving messages
+ * among shared object replicas.
+ *
+ */
+public class SharedObjectMsg implements Serializable {
+ private static final long serialVersionUID = -8761203700888592267L;
+ public static final Object[] nullArgs = new Object[0];
+ public static final Class[] nullTypes = new Class[0];
+
+ protected SharedObjectMsg() {}
+ // Static factory methods for creating SharedObjectMsg instances
+ public static SharedObjectMsg createMsg(String className, String methodName,
+ Object[] param) {
+ if (methodName == null || param == null) {
+ throw new NullPointerException(
+ "Invalid SharedObjectMsg construction");
+ }
+ return new SharedObjectMsg(className, methodName, param);
+ }
+ public static SharedObjectMsg createMsg(String methodName, Object[] param) {
+ return createMsg((String) null, methodName, param);
+ }
+ public static SharedObjectMsg createMsg(String methodName) {
+ return createMsg((String) null, methodName, nullArgs);
+ }
+ public static SharedObjectMsg createMsg(String className, String methodName) {
+ return createMsg(className, methodName, nullArgs);
+ }
+ public static SharedObjectMsg createMsg(String className, String methodName,
+ Object arg) {
+ Object args[] = { arg };
+ return createMsg(className, methodName, args);
+ }
+ public static SharedObjectMsg createMsg(String methodName, Object arg) {
+ return createMsg((String) null, methodName, arg);
+ }
+ public static SharedObjectMsg createMsg(String className, String methodName,
+ Object arg1, Object arg2) {
+ Object args[] = { arg1, arg2 };
+ return createMsg(className, methodName, args);
+ }
+ public static SharedObjectMsg createMsg(String className, String methodName,
+ Object arg1, Object arg2, Object arg3) {
+ Object args[] = { arg1, arg2, arg3 };
+ return createMsg(className, methodName, args);
+ }
+ public static SharedObjectMsg createMsg(String className, String methodName,
+ Object arg1, Object arg2, Object arg3, Object arg4) {
+ Object args[] = { arg1, arg2, arg3, arg4 };
+ return createMsg(className, methodName, args);
+ }
+ public static SharedObjectMsg createMsg(String className, String methodName,
+ Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
+ Object args[] = { arg1, arg2, arg3, arg4, arg5 };
+ return createMsg(className, methodName, args);
+ }
+ /**
+ * Utility for getting a Class instance from a String class name. Calls
+ * Class.forName().
+ *
+ * @param loader
+ * the ClassLoader to use to load the given class
+ * @param name
+ * of Class to load
+ * @return Class instance found. If not found, a ClassNotFoundException is
+ * thrown
+ * @exception ClassNotFoundException
+ * thrown if specified class is not found
+ */
+ public static Class getClass(ClassLoader loader, String name)
+ throws ClassNotFoundException {
+ if (name == null)
+ return null;
+ return Class.forName(name, true, loader);
+ }
+ /**
+ * Get name for given class.
+ *
+ * @param clazz
+ * the Class to retrieve the name from
+ * @return String name of given class
+ */
+ public static String getNameForClass(Class clazz) {
+ return clazz.getName();
+ }
+ /**
+ * Get array of argument types from array of objects
+ *
+ * @param args the arguments to get types for
+ * @return Class[] of types for objects in given Object array
+ */
+ public static Class[] getTypesForParameters(Object args[]) {
+ Class argTypes[] = null;
+ if (args == null || args.length == 0)
+ argTypes = nullTypes;
+ else {
+ argTypes = new Class[args.length];
+ for (int i = 0; i < args.length; i++) {
+ if (args[i] == null)
+ argTypes[i] = null;
+ else
+ argTypes[i] = args[i].getClass();
+ }
+ }
+ return argTypes;
+ }
+ /**
+ * Find a Method instance on given class. This method searches for a method
+ * on the given class (first parameter), of the given name (second
+ * parameter), with arity defined by the third parameter. Calls
+ * searchForMethod to actually do the searching.
+ *
+ * @param clazz
+ * the Class to look on
+ * @param meth
+ * the method name to look for
+ * @param args
+ * the arguments that will be passed to the method on the invoke
+ * call
+ * @return Method instance found on given class. Null if none found.
+ */
+ public static Method findMethod(final Class clazz, String meth,
+ Class args[]) {
+ Method methods[] = null;
+ try {
+ methods = (Method[]) AccessController
+ .doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws Exception {
+ return clazz.getDeclaredMethods();
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ return null;
+ }
+ return searchForMethod(methods, meth, args);
+ }
+ public static Method searchForMethod(Method meths[], String meth,
+ Class args[]) {
+ // Find it from among the given set of Method objects
+ for (int i = 0; i < meths.length; i++) {
+ Method test = meths[i];
+ if (test.getName().equals(meth)) {
+ if (test.getParameterTypes().length == args.length)
+ return test;
+ }
+ }
+ return null;
+ }
+ /**
+ * Find a Method instance on given class, and recursively search the class'
+ * superclass tree for given method.
+ *
+ * @param clazz
+ * the Class to look upon
+ * @param meth
+ * the String name of the method to look for
+ * @param args
+ * the array of Object arguments that will be passed to the
+ * method for execution
+ * @return Method instance if found, null if not found
+ */
+ public static Method findMethodRecursive(Class clazz, String meth,
+ Class args[]) {
+ Method aMethod = findMethod(clazz, meth, args);
+ if (aMethod == null) {
+ Class superclazz = clazz.getSuperclass();
+ if (superclazz != null)
+ return findMethodRecursive(superclazz, meth, args);
+ else
+ return null;
+ } else {
+ return aMethod;
+ }
+ }
+ /**
+ * Check a given msg to verify that all Objects in args array implement the
+ * Serializable interface.
+ *
+ * @param aMsg
+ * the Message to check
+ * @exception NotSerializableException
+ * thrown if any objects in args array do not implement
+ * java.io.Serializable
+ */
+ public static void checkForSerializable(SharedObjectMsg aMsg)
+ throws NotSerializableException {
+ Object args[] = aMsg.getParameters();
+ for (int i = 0; i < args.length; i++) {
+ if (args[i] != null && !(args[i] instanceof Serializable))
+ throw new NotSerializableException("Parameter " + i
+ + " not Serializable");
+ }
+ }
+ // Instance fields
+ /**
+ * @serial clazz the class name for the message
+ */
+ protected String clazz;
+ /**
+ * @serial method the method name of the message
+ */
+ protected String method;
+ /**
+ * @serial args arguments
+ */
+ protected Object[] parameters;
+ // Constructor
+ protected SharedObjectMsg(String className, String methodName, Object[] parameters) {
+ this.clazz = className;
+ this.method = methodName;
+ this.parameters = parameters;
+ }
+ public final String getMethod() {
+ return method;
+ }
+ public final void setMethod(String name) {
+ checkAlterMsg();
+ if (name == null)
+ throw new NullPointerException("methodname cannot be null");
+ method = name;
+ }
+ /**
+ * Check if it is permitted to alter the state of this message (args, class
+ * name, method name). Default: NOP; subclasses should override as
+ * appropriate. To disallow, throw a java.lang.RuntimeException.
+ */
+ protected void checkAlterMsg() {
+ // NOP; subclasses should override as appropriate
+ }
+ public final String getClassName() {
+ return clazz;
+ }
+ public final void setClassName(String name) {
+ checkAlterMsg();
+ clazz = name;
+ }
+ public Object[] getParameters() {
+ return parameters;
+ }
+ public final void setParameters(Object[] args) {
+ checkAlterMsg();
+ args = (args == null) ? nullArgs : args;
+ }
+ protected Class[] getParameterTypes() {
+ return getTypesForParameters(getParameters());
+ }
+ protected final Method findMethod(Class clazz) {
+ return findMethod(clazz, getMethod(), getParameterTypes());
+ }
+ protected final Method findMethodRecursive(Class clazz) {
+ return findMethodRecursive(clazz, getMethod(), getParameterTypes());
+ }
+ public final Object invoke(Object target) throws Exception {
+ return doInvoke(target);
+ }
+ Object doInvoke(final Object target) // package scope for security
+ throws Exception {
+ if (target == null)
+ throw new NoSuchMethodException("Null target");
+ Method meth = null;
+ if (clazz == null) {
+ // If not specific class is specified by SharedObjectMsg instance,
+ // then use the target's class
+ meth = findMethodRecursive(target.getClass());
+ } else {
+ // If it is specified, then load the specified class, using the
+ // target object's classloader
+ meth = findMethod(getClass(target.getClass().getClassLoader(),
+ clazz));
+ }
+ // If no method was found, then throw
+ if (meth == null)
+ throw new NoSuchMethodException(getMethod());
+ final Method toCall = meth;
+ // Make priveleged call to set the method as accessible
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws Exception {
+ if (!toCall.isAccessible())
+ toCall.setAccessible(true);
+ return null;
+ }
+ });
+ // Actually invoke method
+ return toCall.invoke(target, getParameters());
+ }
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("SharedObjectMsg[").append(clazz).append(":").append(
+ method).append("(");
+ if (parameters == null) {
+ sb.append(parameters);
+ } else {
+ for (int i = 0; i < parameters.length; i++) {
+ if (i > 0)
+ sb.append(",");
+ sb.append(parameters[i]);
+ }
+ }
+ sb.append(")]");
+ return sb.toString();
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsgEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsgEvent.java
new file mode 100644
index 000000000..522b6f913
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsgEvent.java
@@ -0,0 +1,44 @@
+/****************************************************************************
+* Copyright (c) 2004 Composent, 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:
+* Composent, Inc. - initial API and implementation
+*****************************************************************************/
+
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.sharedobject.events.RemoteSharedObjectEvent;
+
+/**
+ * Event type to represent messages sent between shared objects
+ *
+ */
+public class SharedObjectMsgEvent extends RemoteSharedObjectEvent {
+
+ private static final long serialVersionUID = -8674874265514762123L;
+
+ /**
+ * @param senderObj
+ * @param remoteCont
+ * @param msg
+ */
+ public SharedObjectMsgEvent(ID senderObj, ID remoteCont, SharedObjectMsg msg) {
+ super(senderObj, remoteCont, msg);
+ }
+
+ public SharedObjectMsg getSharedObjectMsg() {
+ return (SharedObjectMsg) super.getData();
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer("SharedObjectMsgEvent[");
+ buf.append(getSenderSharedObjectID()).append(";").append(getRemoteContainerID()).append(";").append(getSharedObjectMsg());
+ buf.append("]");
+ return buf.toString();
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsgEventProcessor.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsgEventProcessor.java
new file mode 100644
index 000000000..1eb22f31a
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsgEventProcessor.java
@@ -0,0 +1,37 @@
+/****************************************************************************
+* Copyright (c) 2004 Composent, 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:
+* Composent, Inc. - initial API and implementation
+*****************************************************************************/
+
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.sharedobject.events.ISharedObjectMessageEvent;
+import org.eclipse.ecf.core.util.Event;
+import org.eclipse.ecf.core.util.IEventProcessor;
+
+/**
+ * Event processor to process SharedObjectMsgEvents
+ *
+ */
+public class SharedObjectMsgEventProcessor implements IEventProcessor {
+
+ AbstractSharedObject sharedObject = null;
+
+ public SharedObjectMsgEventProcessor(AbstractSharedObject sharedObject) {
+ super();
+ this.sharedObject = sharedObject;
+ }
+ public boolean processEvent(Event event) {
+ if (!(event instanceof ISharedObjectMessageEvent)) return false;
+ return processSharedObjectMsgEvent((ISharedObjectMessageEvent) event);
+ }
+ protected boolean processSharedObjectMsgEvent(ISharedObjectMessageEvent event) {
+ return sharedObject.handleSharedObjectMsgEvent(event);
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectNotFoundException.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectNotFoundException.java
new file mode 100644
index 000000000..aab9ef3ad
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectNotFoundException.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import org.eclipse.ecf.core.util.ECFException;
+
+public class SharedObjectNotFoundException extends ECFException {
+ private static final long serialVersionUID = 3256725086957285689L;
+
+ public SharedObjectNotFoundException() {
+ super();
+ }
+
+ public SharedObjectNotFoundException(String arg0) {
+ super(arg0);
+ }
+
+ public SharedObjectNotFoundException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public SharedObjectNotFoundException(Throwable cause) {
+ super(cause);
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectTypeDescription.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectTypeDescription.java
new file mode 100644
index 000000000..c414f24ec
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectTypeDescription.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.eclipse.ecf.core.sharedobject.provider.ISharedObjectInstantiator;
+
+/**
+ * Description of shared object type. This class provides the information
+ * necessary to determine the type of a shared object instance. It is used by
+ * the SharedObjectDescription class to specify the <b>local</b> type of a
+ * shared object instance, and by ReplicaSharedObjectDescription to specify the
+ * type of a remote shared object instance
+ */
+public class SharedObjectTypeDescription implements Serializable {
+ private static final long serialVersionUID = -553771188695892646L;
+
+ protected String name;
+ protected ISharedObjectInstantiator instantiator;
+ protected String description;
+ protected Map typeProperties;
+ protected String className;
+
+ public SharedObjectTypeDescription(String name,
+ ISharedObjectInstantiator instantiator, String desc, Map props) {
+ this.name = name;
+ this.instantiator = instantiator;
+ this.description = desc;
+ this.typeProperties = props;
+ }
+ public SharedObjectTypeDescription(String className, Map props) {
+ this.className = className;
+ this.typeProperties = props;
+ }
+ public String getClassName() {
+ return className;
+ }
+ public String getDescription() {
+ return description;
+ }
+ public ISharedObjectInstantiator getInstantiator() {
+ return instantiator;
+ }
+ public String getName() {
+ return name;
+ }
+ public Map getTypeProperties() {
+ return typeProperties;
+ }
+ public String toString() {
+ StringBuffer buf = new StringBuffer("SharedObjectTypeDescription[");
+ buf.append("name=").append(name).append(";");
+ buf.append("instantiator=").append(instantiator).append(";");
+ buf.append("className=").append(className).append(";");
+ buf.append("typeProperties=").append(typeProperties).append("]");
+ return buf.toString();
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/TransactionSharedObject.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/TransactionSharedObject.java
new file mode 100644
index 000000000..20b8fbbcd
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/TransactionSharedObject.java
@@ -0,0 +1,57 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, 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:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+
+/**
+ * Superclass for shared object classes that replicate themselves transactionally.
+ *
+ */
+public class TransactionSharedObject extends AbstractSharedObject {
+
+ protected ISharedObjectContainerTransaction transaction = null;
+ protected ISharedObjectTransactionConfig configuration = null;
+
+ public TransactionSharedObject() {
+ super();
+ configuration = new TransactionSharedObjectConfiguration();
+ }
+ public TransactionSharedObject(int timeout) {
+ super();
+ configuration = new TransactionSharedObjectConfiguration(timeout);
+ }
+ /**
+ * Construct instance. The config parameter, if given, is used to
+ * configure the transactional replication of instances or subclass instances.
+ * If the config parameter is null, no replication messaging will occur and
+ * only host instance of object will be created.
+ *
+ * @param config
+ */
+ public TransactionSharedObject(ISharedObjectTransactionConfig config) {
+ super();
+ configuration = config;
+ }
+ protected void initialize() throws SharedObjectInitException {
+ super.initialize();
+ if (configuration != null) {
+ TwoPhaseCommitEventProcessor trans = new TwoPhaseCommitEventProcessor(this,configuration);
+ addEventProcessor(trans);
+ transaction = trans;
+ }
+ }
+ public Object getAdapter(Class clazz) {
+ if (clazz.equals(ISharedObjectContainerTransaction.class)) {
+ return transaction;
+ }
+ return null;
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/TransactionSharedObjectConfiguration.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/TransactionSharedObjectConfiguration.java
new file mode 100644
index 000000000..cc0025691
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/TransactionSharedObjectConfiguration.java
@@ -0,0 +1,42 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, 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:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+
+/**
+ * Configuration parameters for transaction shared object creation and replication.
+ *
+ */
+public class TransactionSharedObjectConfiguration implements ISharedObjectTransactionConfig {
+
+ protected int timeout = DEFAULT_TIMEOUT;
+ protected ISharedObjectTransactionParticipantsFilter participantsFilter = null;
+
+ public TransactionSharedObjectConfiguration() {
+ super();
+ }
+ public TransactionSharedObjectConfiguration(int timeout) {
+ this(timeout,null);
+ }
+ public TransactionSharedObjectConfiguration(int timeout, ISharedObjectTransactionParticipantsFilter filter) {
+ this.timeout = timeout;
+ this.participantsFilter = filter;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.sharedobject.ITransactionConfiguration#getTimeout()
+ */
+ public int getTimeout() {
+ return timeout;
+ }
+ public ISharedObjectTransactionParticipantsFilter getParticipantsFilter() {
+ return participantsFilter;
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/TwoPhaseCommitEventProcessor.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/TwoPhaseCommitEventProcessor.java
new file mode 100644
index 000000000..b0c7302e3
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/TwoPhaseCommitEventProcessor.java
@@ -0,0 +1,363 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, 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:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.core.sharedobject;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.eclipse.ecf.core.events.IContainerConnectedEvent;
+import org.eclipse.ecf.core.events.IContainerDisconnectedEvent;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent;
+import org.eclipse.ecf.core.sharedobject.events.ISharedObjectCommitEvent;
+import org.eclipse.ecf.core.sharedobject.events.ISharedObjectCreateResponseEvent;
+import org.eclipse.ecf.core.sharedobject.events.ISharedObjectMessageEvent;
+import org.eclipse.ecf.core.sharedobject.events.SharedObjectCommitEvent;
+import org.eclipse.ecf.core.util.Event;
+import org.eclipse.ecf.core.util.IEventProcessor;
+import org.eclipse.ecf.core.util.Trace;
+import org.eclipse.ecf.internal.core.sharedobject.Activator;
+import org.eclipse.ecf.internal.core.sharedobject.SharedObjectDebugOptions;
+
+/**
+ * Implementation of two-phase commit for transactional replication of shared objects.
+ *
+ */
+public class TwoPhaseCommitEventProcessor implements IEventProcessor,
+ ISharedObjectContainerTransaction {
+ AbstractSharedObject sharedObject = null;
+ byte transactionState = ISharedObjectContainerTransaction.ACTIVE;
+ Object lock = new Object();
+ List participants = new Vector();
+ Map failed = new HashMap();
+ int timeout = ISharedObjectTransactionConfig.DEFAULT_TIMEOUT;
+ int minFailedToAbort = 0;
+ long identifier = 0;
+ ISharedObjectTransactionParticipantsFilter participantsFilter = null;
+
+ public TwoPhaseCommitEventProcessor(AbstractSharedObject bse, ISharedObjectTransactionConfig config) {
+ this.sharedObject = bse;
+ if (config == null) {
+ config = new TransactionSharedObjectConfiguration();
+ }
+ this.timeout = config.getTimeout();
+ this.participantsFilter = config.getParticipantsFilter();
+ }
+ protected void trace(String msg) {
+ Trace.trace(Activator.getDefault(),msg);
+ }
+ protected void traceStack(String msg, Throwable t) {
+ Trace.catching(Activator.getDefault(), SharedObjectDebugOptions.EXCEPTIONS_CATCHING, TwoPhaseCommitEventProcessor.class, "traceStack", t);;
+ }
+ protected int getTimeout() {
+ return timeout;
+ }
+ protected int getMinFailedToAbort() {
+ return minFailedToAbort;
+ }
+ protected boolean isPrimary() {
+ return getSharedObject().isPrimary();
+ }
+ protected AbstractSharedObject getSharedObject() {
+ return sharedObject;
+ }
+ protected ID getHomeID() {
+ return getSharedObject().getHomeContainerID();
+ }
+ protected void addParticipants(ID[] ids) {
+ if (ids != null) {
+ for (int i = 0; i < ids.length; i++) {
+ trace("addParticipant(" + ids[i] + ")");
+ if (!getHomeID().equals(ids[i]))
+ participants.add(ids[i]);
+ }
+ }
+ }
+ protected void removeParticipant(ID id) {
+ if (id != null) {
+ trace("removeParticipant(" + id + ")");
+ participants.remove(id);
+ }
+ }
+ protected void addFailed(ID remote, Throwable failure) {
+ if (remote != null && failure != null) {
+ trace("addFailed(" + remote + "," + failure + ")");
+ failed.put(remote, failure);
+ }
+ }
+ protected ISharedObjectContext getContext() {
+ return getSharedObject().getContext();
+ }
+ /*
+ * Implementation of IEventProcessor. These methods are entry point methods
+ * for AbstractSharedObject method dispatch to call
+ */
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.util.IEventProcessor#processEvent(org.eclipse.ecf.core.util.Event)
+ */
+ public boolean processEvent(Event event) {
+ if (event instanceof ISharedObjectActivatedEvent) {
+ handleActivated((ISharedObjectActivatedEvent) event);
+ } else if (event instanceof IContainerConnectedEvent) {
+ handleJoined((IContainerConnectedEvent) event);
+ } else if (event instanceof ISharedObjectCreateResponseEvent) {
+ handleCreateResponse((ISharedObjectCreateResponseEvent) event);
+ } else if (event instanceof IContainerDisconnectedEvent) {
+ handleDeparted((IContainerDisconnectedEvent) event);
+ } else if (event instanceof ISharedObjectMessageEvent) {
+ ISharedObjectMessageEvent some = (ISharedObjectMessageEvent) event;
+ Object data = some.getData();
+ if (data instanceof ISharedObjectCommitEvent) localCommitted();
+ }
+ // Let other event processors have a shot at this event
+ return false;
+ }
+ protected void handleActivated(ISharedObjectActivatedEvent event) {
+ trace("handleActivated(" + event + ")");
+ // No other state changes while this is going on
+ synchronized (lock) {
+ if (isPrimary()) {
+ // Primary
+ handlePrimaryActivated(event);
+ } else {
+ handleReplicaActivated(event);
+ }
+ // Notify any threads waiting on state change
+ lock.notifyAll();
+ }
+ }
+ protected void replicateTo(ID[] remotes) {
+ getSharedObject().replicateToRemoteContainers(remotes);
+ }
+
+ protected void handlePrimaryActivated(ISharedObjectActivatedEvent event) {
+ trace("handlePrimaryActivated("+event+")");
+ // First get current group membership
+ if (getContext().getConnectedID() != null) {
+ ID[] groupMembers = getContext().getGroupMemberIDs();
+ // Now get participants
+ ID[] transactionParticipants = null;
+ // If there is a participants filter specified then use it and ask it to return an ID [] of participants (given
+ // the current group membership
+ if (participantsFilter != null) {
+ transactionParticipants = participantsFilter.filterParticipants(groupMembers);
+ }
+ // replicate
+ if (transactionParticipants == null) {
+ // This means that all current group members should be included as participants
+ replicateTo(null);
+ transactionParticipants = groupMembers;
+ } else {
+ // This means the participants filter provided us with an ID [] and so we replicate only to that ID []
+ replicateTo(transactionParticipants);
+ }
+
+ // Add participants to the collection
+ addParticipants(transactionParticipants);
+ // Now set transaction state to VOTING
+ setTransactionState(ISharedObjectContainerTransaction.VOTING);
+ } else {
+ setTransactionState(ISharedObjectContainerTransaction.COMMITTED);
+ }
+ }
+ private long getNextIdentifier() {
+ return identifier++;
+ }
+ protected void handleReplicaActivated(ISharedObjectActivatedEvent event) {
+ trace("handleReplicaActivated("+event+")");
+ try {
+ // Try to respond with create success message back to host
+ getContext().sendCreateResponse(getHomeID(), null,
+ getNextIdentifier());
+ // If above succeeds, we're now in prepared state
+ setTransactionState(ISharedObjectContainerTransaction.PREPARED);
+ } catch (Exception except) {
+ // If throws exception, we're doomed
+ traceStack("handleReplicaActivated(" + event + ")", except);
+ setTransactionState(ISharedObjectContainerTransaction.ABORTED);
+ }
+ }
+ protected void handleJoined(IContainerConnectedEvent event) {
+ trace("handleJoined(" + event + ")");
+ // If we are primary then this event matters to us
+ if (isPrimary()) {
+ // If transactionstate is VOTING then we replicate ourselves to participants
+ if (getTransactionState() == ISharedObjectContainerTransaction.VOTING) {
+ synchronized (lock) {
+ // First send replicate message *no matter what state we are in*
+ ID [] newMember = new ID[] { event.getTargetID() };
+ replicateTo(newMember);
+ addParticipants(newMember);
+ }
+ }
+ }
+ }
+ protected void handleCreateResponse(ISharedObjectCreateResponseEvent event) {
+ trace("handleCreateResponse(" + event + ")");
+ if (isPrimary()) {
+ synchronized (lock) {
+ Throwable except = event.getException();
+ ID remoteID = event.getRemoteContainerID();
+ long ident = event.getSequence();
+ if (getTransactionState() == ISharedObjectContainerTransaction.VOTING) {
+ if (except == null) {
+ removeParticipant(remoteID);
+ } else {
+ addFailed(remoteID, except);
+ }
+ } else {
+ handleVotingCompletedCreateResponse(remoteID, except, ident);
+ }
+ lock.notifyAll();
+ }
+ } else {
+ // we don't care as we are note transaction monitor
+ }
+ }
+ protected void handleDeparted(IContainerDisconnectedEvent event) {
+ trace("handleDeparted(" + event + ")");
+ if (isPrimary()) {
+ ID remoteID = event.getTargetID();
+ synchronized (lock) {
+ if (getTransactionState() == ISharedObjectContainerTransaction.VOTING) {
+ addFailed(remoteID, new Exception("Container " + remoteID
+ + " left"));
+ }
+ lock.notifyAll();
+ }
+ } else {
+ // we don't care as we are not transaction monitor
+ }
+ }
+ protected void handleVotingCompletedCreateResponse(ID fromID, Throwable e,
+ long identifier) {
+ trace("handleVotingCompletedCreateResponse(" + fromID + ","+e+","+identifier+")");
+ // If remote creation was successful, simply send commit message back.
+ if (e == null) {
+ try {
+ getSharedObject().getContext().sendMessage(fromID,
+ new SharedObjectCommitEvent(getSharedObject().getID()));
+ } catch (Exception e2) {
+ traceStack("Exception in sendCommit to " + fromID, e2);
+ }
+ } else {
+ // Too late to vote no
+ handlePostCommitFailure(fromID, e, identifier);
+ }
+ }
+ protected void handlePostCommitFailure(ID fromID, Throwable e,
+ long identifier) {
+ // Do nothing but report
+ trace("handlePostCommitFailure(" + fromID + "," + e + "," + identifier
+ + ")");
+ }
+ protected void sendCommit() throws SharedObjectAddAbortException {
+ try {
+ getContext().sendMessage(null,
+ new SharedObjectCommitEvent(getSharedObject().getID()));
+ } catch (Exception e2) {
+ doTMAbort(new SharedObjectAddAbortException(
+ "Exception sending commit message", e2, getTimeout()));
+ }
+ }
+ public byte getTransactionState() {
+ synchronized (lock) {
+ return transactionState;
+ }
+ }
+ protected void setTransactionState(byte state) {
+ synchronized (lock) {
+ transactionState = state;
+ }
+ }
+ public void waitToCommit() throws SharedObjectAddAbortException {
+ if (getTransactionState() == ISharedObjectContainerTransaction.COMMITTED)
+ return;
+ synchronized (lock) {
+ long end = System.currentTimeMillis() + getTimeout();
+ try {
+ while (!isVotingCompleted()) {
+ long wait = end - System.currentTimeMillis();
+ trace("waitForFinish waiting " + wait + "ms on "
+ + getSharedObject().getID());
+ if (wait <= 0L)
+ throw new SharedObjectAddAbortException(
+ "Timeout adding " + getSharedObject().getID()
+ + " to " + getHomeID(),
+ (Throwable) null, getTimeout());
+ // Wait right here
+ lock.wait(wait);
+ }
+ } catch (Exception except) {
+ // Aborted for some reason. Clean up and throw
+ doTMAbort(except);
+ }
+ // Success. Send commit to remotes and clean up before returning.
+ doTMCommit();
+ }
+ }
+ protected void doTMAbort(Throwable except)
+ throws SharedObjectAddAbortException {
+ trace("doTMAbort:" + except);
+ // Set our own state variable to ABORTED
+ setTransactionState(ISharedObjectContainerTransaction.ABORTED);
+ // Send destroy message here so all remotes get destroyed, and we remove
+ // ourselves from local space as well.
+ getSharedObject().destroySelf();
+ // throw so caller gets exception and can deal with it
+ if (except instanceof SharedObjectAddAbortException)
+ throw (SharedObjectAddAbortException) except;
+ else
+ throw new SharedObjectAddAbortException("Aborted", except,
+ getTimeout());
+ }
+ protected void doTMCommit() throws SharedObjectAddAbortException {
+ trace("doTMCommit");
+ // Make sure we are connected. If so then send commit message
+ if (getSharedObject().getGroupID() != null) {
+ sendCommit();
+ }
+ // Call local committed message
+ localCommitted();
+ }
+ protected void localCommitted() {
+ trace("localCommitted()");
+ // Set state variable to committed.
+ setTransactionState(ISharedObjectContainerTransaction.COMMITTED);
+ getSharedObject().creationCompleted();
+ }
+ protected boolean isVotingCompleted() throws SharedObjectAddAbortException {
+ // The test here is is we've received any indication of failed
+ // participants in the transaction. If so, we throw.
+ if (getTransactionState() == ISharedObjectContainerTransaction.COMMITTED) return true;
+ if (failed.size() > getMinFailedToAbort()) {
+ // Abort!
+ trace("isVotingCompleted:aborting:failed>"
+ + getMinFailedToAbort() + ":failed=" + failed);
+ throw new SharedObjectAddAbortException("Abort received",
+ participants, failed, getTimeout());
+ // If no problems, and the number of participants to here from is 0,
+ // then we're done
+ } else if (getTransactionState() == ISharedObjectContainerTransaction.VOTING
+ && participants.size() == 0) {
+ // Success!
+ trace("isVotingCompleted() returning true");
+ return true;
+ }
+ // Else continue waiting
+ trace("isVotingCompleted:false");
+ return false;
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectActivatedEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectActivatedEvent.java
new file mode 100644
index 000000000..14c37e9ba
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectActivatedEvent.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.events.IContainerEvent;
+import org.eclipse.ecf.core.identity.ID;
+
+public interface ISharedObjectActivatedEvent extends IContainerEvent {
+ public ID getActivatedID();
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectCallEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectCallEvent.java
new file mode 100644
index 000000000..42bd2c868
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectCallEvent.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.util.AsynchResult;
+
+public interface ISharedObjectCallEvent extends ISharedObjectEvent {
+ AsynchResult getAsynchResult();
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectCommitEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectCommitEvent.java
new file mode 100644
index 000000000..5a96b43c3
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectCommitEvent.java
@@ -0,0 +1,12 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+public interface ISharedObjectCommitEvent extends ISharedObjectEvent {
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectCreateResponseEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectCreateResponseEvent.java
new file mode 100644
index 000000000..f5035bbe3
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectCreateResponseEvent.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+public interface ISharedObjectCreateResponseEvent extends
+ ISharedObjectMessageEvent {
+ public long getSequence();
+
+ public Throwable getException();
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectDeactivatedEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectDeactivatedEvent.java
new file mode 100644
index 000000000..112fcdefc
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectDeactivatedEvent.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.events.IContainerEvent;
+import org.eclipse.ecf.core.identity.ID;
+
+public interface ISharedObjectDeactivatedEvent extends IContainerEvent {
+ public ID getDeactivatedID();
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectEvent.java
new file mode 100644
index 000000000..c1481ffde
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectEvent.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.util.Event;
+
+public interface ISharedObjectEvent extends Event {
+ public ID getSenderSharedObjectID();
+
+ public Event getEvent();
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectManagerEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectManagerEvent.java
new file mode 100644
index 000000000..c6cfb37a1
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectManagerEvent.java
@@ -0,0 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.events.IContainerEvent;
+
+public interface ISharedObjectManagerEvent extends IContainerEvent {
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectMessageEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectMessageEvent.java
new file mode 100644
index 000000000..a66ea811a
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectMessageEvent.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.identity.ID;
+
+public interface ISharedObjectMessageEvent extends ISharedObjectEvent {
+ public ID getRemoteContainerID();
+
+ public Object getData();
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectMessageListener.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectMessageListener.java
new file mode 100644
index 000000000..b9df8b5cf
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/ISharedObjectMessageListener.java
@@ -0,0 +1,27 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, 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:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+
+/**
+ * Listener for receiving shared object messages
+ *
+ */
+public interface ISharedObjectMessageListener {
+ /**
+ * Receive shared object message via shared object message event.
+ *
+ * @param event
+ * the shared object message event holding the shared object
+ * message
+ */
+ public void handleSharedObjectMessage(ISharedObjectMessageEvent event);
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectCreateResponseEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectCreateResponseEvent.java
new file mode 100644
index 000000000..8a1540cf2
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectCreateResponseEvent.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.identity.ID;
+
+public class RemoteSharedObjectCreateResponseEvent extends
+ RemoteSharedObjectEvent implements ISharedObjectCreateResponseEvent {
+ private static final long serialVersionUID = 3618421544527738673L;
+ long sequence = 0;
+
+ public RemoteSharedObjectCreateResponseEvent(ID senderObj, ID remoteCont,
+ long seq, Throwable exception) {
+ super(senderObj, remoteCont, exception);
+ this.sequence = seq;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.events.ISharedObjectCreateResponseEvent#getSequence()
+ */
+ public long getSequence() {
+ return sequence;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.events.ISharedObjectCreateResponseEvent#getException()
+ */
+ public Throwable getException() {
+ return (Throwable) getData();
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer(
+ "RemoteSharedObjectCreateResponseEvent[");
+ sb.append(getSenderSharedObjectID()).append(";");
+ sb.append(getRemoteContainerID()).append(";");
+ sb.append(getSequence()).append(";");
+ sb.append(getException()).append("]");
+ return sb.toString();
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectEvent.java
new file mode 100644
index 000000000..8b724874d
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectEvent.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import java.io.Serializable;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.util.Event;
+
+public class RemoteSharedObjectEvent implements ISharedObjectMessageEvent,
+ Serializable {
+ private static final long serialVersionUID = 3257572797621680182L;
+ private final ID senderSharedObjectID;
+ private final ID remoteContainerID;
+ private final Object data;
+
+ public RemoteSharedObjectEvent(ID senderObj, ID remoteCont, Object data) {
+ super();
+ this.senderSharedObjectID = senderObj;
+ this.remoteContainerID = remoteCont;
+ this.data = data;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.api.events.ISharedObjectEvent#getSenderSharedObject()
+ */
+ public ID getSenderSharedObjectID() {
+ return senderSharedObjectID;
+ }
+
+ public ID getRemoteContainerID() {
+ return remoteContainerID;
+ }
+
+ public Event getEvent() {
+ return this;
+ }
+
+ public Object getData() {
+ return data;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer("RemoteSharedObjectEvent[");
+ sb.append(getSenderSharedObjectID()).append(";");
+ sb.append(getRemoteContainerID()).append(";");
+ sb.append(getData()).append("]");
+ return sb.toString();
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectActivatedEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectActivatedEvent.java
new file mode 100644
index 000000000..9fa91ab03
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectActivatedEvent.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.identity.ID;
+
+public class SharedObjectActivatedEvent implements ISharedObjectActivatedEvent {
+ private static final long serialVersionUID = 6880286157835412766L;
+ private final ID activatedID;
+ private final ID localContainerID;
+
+ public SharedObjectActivatedEvent(ID container, ID act) {
+ super();
+ this.localContainerID = container;
+ this.activatedID = act;
+ }
+
+ public ID getActivatedID() {
+ return activatedID;
+ }
+
+ public ID getLocalContainerID() {
+ return localContainerID;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer("SharedObjectActivatedEvent[");
+ sb.append(getLocalContainerID()).append(";");
+ sb.append(getActivatedID()).append("]");
+ return sb.toString();
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCallEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCallEvent.java
new file mode 100644
index 000000000..8ec7c88c6
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCallEvent.java
@@ -0,0 +1,57 @@
+/****************************************************************************
+* Copyright (c) 2004 Composent, 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:
+* Composent, Inc. - initial API and implementation
+*****************************************************************************/
+
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.util.AsynchResult;
+import org.eclipse.ecf.core.util.Event;
+
+public class SharedObjectCallEvent implements ISharedObjectCallEvent {
+ private static final long serialVersionUID = 3904674977264250933L;
+ ID sender;
+ Event event;
+ AsynchResult result;
+
+ public SharedObjectCallEvent(ID sender, Event evt, AsynchResult res) {
+ super();
+ this.sender = sender;
+ this.event = evt;
+ this.result = res;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.events.ISharedObjectCallEvent#getAsynchResult()
+ */
+ public AsynchResult getAsynchResult() {
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.events.ISharedObjectEvent#getSenderSharedObjectID()
+ */
+ public ID getSenderSharedObjectID() {
+ return sender;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.events.ISharedObjectEvent#getEvent()
+ */
+ public Event getEvent() {
+ return event;
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCommitEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCommitEvent.java
new file mode 100644
index 000000000..df5ca6e1c
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCommitEvent.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.util.Event;
+
+public class SharedObjectCommitEvent implements ISharedObjectCommitEvent {
+ private static final long serialVersionUID = 4615634472917480497L;
+ ID senderSharedObjectID = null;
+ Event event = null;
+
+ public SharedObjectCommitEvent(ID senderSharedObjectID, Event event) {
+ super();
+ this.senderSharedObjectID = senderSharedObjectID;
+ this.event = event;
+ }
+
+ public SharedObjectCommitEvent(ID senderSharedObjectID) {
+ this(senderSharedObjectID, null);
+ }
+
+ public ID getSenderSharedObjectID() {
+ return senderSharedObjectID;
+ }
+
+ public Event getEvent() {
+ return event;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer("SharedObjectCommitEvent[");
+ sb.append(getSenderSharedObjectID()).append(";");
+ sb.append(getEvent()).append("]");
+ return sb.toString();
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectDeactivatedEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectDeactivatedEvent.java
new file mode 100644
index 000000000..9367eadbf
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectDeactivatedEvent.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.identity.ID;
+
+public class SharedObjectDeactivatedEvent implements
+ ISharedObjectDeactivatedEvent {
+ private static final long serialVersionUID = 3257291344119476786L;
+ private final ID deactivatedID;
+ private final ID localContainerID;
+
+ public SharedObjectDeactivatedEvent(ID container, ID deact) {
+ super();
+ this.localContainerID = container;
+ this.deactivatedID = deact;
+ }
+
+ public ID getDeactivatedID() {
+ return deactivatedID;
+ }
+
+ public ID getLocalContainerID() {
+ return localContainerID;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer("SharedObjectDeactivatedEvent[");
+ sb.append(getLocalContainerID()).append(";");
+ sb.append(getDeactivatedID()).append("]");
+ return sb.toString();
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerAddEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerAddEvent.java
new file mode 100644
index 000000000..f4a34a49d
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerAddEvent.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import java.util.Map;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.sharedobject.ISharedObject;
+
+/**
+ * @author slewis
+ *
+ */
+public class SharedObjectManagerAddEvent implements ISharedObjectManagerEvent {
+ private static final long serialVersionUID = 3258413923916330551L;
+ ID localContainerID = null;
+ Map properties = null;
+ ISharedObject sharedObject = null;
+ ID sharedObjectID = null;
+
+ public SharedObjectManagerAddEvent(ID localContainerID, ID sharedObjectID,
+ ISharedObject object, Map properties) {
+ this.localContainerID = localContainerID;
+ this.sharedObjectID = sharedObjectID;
+ this.sharedObject = object;
+ this.properties = properties;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.events.IContainerEvent#getLocalContainerID()
+ */
+ public ID getLocalContainerID() {
+ return localContainerID;
+ }
+
+ public Map getProperties() {
+ return properties;
+ }
+
+ public ISharedObject getSharedObject() {
+ return sharedObject;
+ }
+
+ public ID getSharedObjectID() {
+ return sharedObjectID;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer("SharedObjectManagerAddEvent[");
+ buf.append(getLocalContainerID()).append(";");
+ buf.append(getSharedObjectID()).append(";");
+ buf.append(getSharedObject()).append(";");
+ buf.append(getProperties()).append("]");
+ return buf.toString();
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerConnectEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerConnectEvent.java
new file mode 100644
index 000000000..030c9c7b3
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerConnectEvent.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import java.util.Arrays;
+import org.eclipse.ecf.core.identity.ID;
+
+/**
+ * @author slewis
+ *
+ */
+public class SharedObjectManagerConnectEvent implements
+ ISharedObjectManagerEvent {
+ private static final long serialVersionUID = 3544670676712633650L;
+ ID localContainerID = null;
+ ID[] sharedObjectReceiverIDs = null;
+ ID sharedObjectSenderID = null;
+
+ public SharedObjectManagerConnectEvent(ID localContainerID,
+ ID sharedObjectSenderID, ID[] sharedObjectReceiverIDs) {
+ this.localContainerID = localContainerID;
+ this.sharedObjectSenderID = sharedObjectSenderID;
+ this.sharedObjectReceiverIDs = sharedObjectReceiverIDs;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.events.IContainerEvent#getLocalContainerID()
+ */
+ public ID getLocalContainerID() {
+ return localContainerID;
+ }
+
+ public ID[] getSharedObjectReceiverIDs() {
+ return (sharedObjectReceiverIDs == null) ? new ID[0]
+ : sharedObjectReceiverIDs;
+ }
+
+ public ID getSharedObjectSenderID() {
+ return sharedObjectSenderID;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer("SharedObjectManagerConnectEvent[");
+ buf.append(getLocalContainerID()).append(";");
+ buf.append(getSharedObjectSenderID()).append(";");
+ buf.append(Arrays.asList(getSharedObjectReceiverIDs())).append("]");
+ return buf.toString();
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerCreateEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerCreateEvent.java
new file mode 100644
index 000000000..8229b4b04
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerCreateEvent.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.sharedobject.SharedObjectDescription;
+
+/**
+ * @author slewis
+ *
+ */
+public class SharedObjectManagerCreateEvent implements
+ ISharedObjectManagerEvent {
+ private static final long serialVersionUID = 3905527103070878006L;
+ SharedObjectDescription description = null;
+ ID localContainerID = null;
+
+ public SharedObjectManagerCreateEvent(ID localContainerID,
+ SharedObjectDescription description) {
+ this.localContainerID = localContainerID;
+ this.description = description;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.events.IContainerEvent#getLocalContainerID()
+ */
+ public ID getLocalContainerID() {
+ return localContainerID;
+ }
+
+ public SharedObjectDescription getDescription() {
+ return description;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer("SharedObjectManagerCreateEvent[");
+ buf.append(getLocalContainerID()).append(";");
+ buf.append(getDescription()).append("]");
+ return buf.toString();
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerDisconnectEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerDisconnectEvent.java
new file mode 100644
index 000000000..2dc0c9536
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerDisconnectEvent.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.identity.ID;
+
+/**
+ * @author slewis
+ *
+ */
+public class SharedObjectManagerDisconnectEvent implements
+ ISharedObjectManagerEvent {
+ private static final long serialVersionUID = 3257008743777448761L;
+ ID localContainerID = null;
+ ID sharedObjectSenderID = null;
+
+ public SharedObjectManagerDisconnectEvent(ID localContainerID,
+ ID sharedObjectSenderID) {
+ this.localContainerID = localContainerID;
+ this.sharedObjectSenderID = sharedObjectSenderID;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.events.IContainerEvent#getLocalContainerID()
+ */
+ public ID getLocalContainerID() {
+ return localContainerID;
+ }
+
+ public ID getSharedObjectSenderID() {
+ return sharedObjectSenderID;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer(
+ "SharedObjectManagerDisconnectEvent[");
+ buf.append(getLocalContainerID()).append(";");
+ buf.append(getSharedObjectSenderID()).append(";");
+ return buf.toString();
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerRemoveEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerRemoveEvent.java
new file mode 100644
index 000000000..3e7e94864
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerRemoveEvent.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.events;
+
+import org.eclipse.ecf.core.identity.ID;
+
+/**
+ * @author slewis
+ *
+ */
+public class SharedObjectManagerRemoveEvent implements
+ ISharedObjectManagerEvent {
+ private static final long serialVersionUID = 3256728389754106931L;
+ ID sharedObjectID = null;
+ ID localContainerID = null;
+
+ public SharedObjectManagerRemoveEvent(ID localContainerID, ID sharedObjectID) {
+ this.localContainerID = localContainerID;
+ this.sharedObjectID = sharedObjectID;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.events.IContainerEvent#getLocalContainerID()
+ */
+ public ID getLocalContainerID() {
+ return localContainerID;
+ }
+
+ public ID getSharedObjectID() {
+ return sharedObjectID;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer("SharedObjectManagerRemoveEvent[");
+ buf.append(getLocalContainerID()).append(";");
+ buf.append(getSharedObjectID()).append("]");
+ return buf.toString();
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/provider/ISharedObjectInstantiator.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/provider/ISharedObjectInstantiator.java
new file mode 100644
index 000000000..1bdb4f059
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/provider/ISharedObjectInstantiator.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.provider;
+
+import org.eclipse.ecf.core.sharedobject.ISharedObject;
+import org.eclipse.ecf.core.sharedobject.SharedObjectCreateException;
+import org.eclipse.ecf.core.sharedobject.SharedObjectTypeDescription;
+
+/**
+ * Interface that must be implemented by extensions of the sharedObjectFactory extension point
+ *
+ */
+public interface ISharedObjectInstantiator {
+ /**
+ * Create instance of ISharedObject. This is the interface that plugin implementations
+ * must implement for the sharedObjectFactory extension point. The caller may optionally
+ * specify both argument types and arguments that will be passed into this method (and
+ * therefore to the provider implementation implementing this method). For example:
+ * <p></p><p><b> SharedObjectFactory.getDefault().createSharedObject("foosharedobject",new String [] { java.lang.String }, new Object { "hello" });</b></p><p></p>
+ *
+ * @param typeDescription the SharedObjectTypeDescription associated with the registered shared object provider
+ * implementation plugin
+ * @param argTypes the argument types specified by the caller. May be null if no
+ * arguments are passed in by caller to SharedObjectFactory.getDefault().createSharedObject(...)
+ * @param args arguments specified by the caller. May be null if no
+ * arguments are passed in by caller to SharedObjectFactory.getDefault().createSharedObject(...)
+ * @return ISharedObject instance. The provider implementation must return a valid object
+ * implementing ISharedObject OR throw a SharedObjectCreateException
+ * @throws SharedObjectCreateException TODO
+ */
+ public ISharedObject createInstance(SharedObjectTypeDescription typeDescription,
+ Class[] argTypes, Object[] args)
+ throws SharedObjectCreateException;
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/security/ISharedObjectPolicy.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/security/ISharedObjectPolicy.java
new file mode 100644
index 000000000..8492995bf
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/security/ISharedObjectPolicy.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.sharedobject.security;
+
+import java.security.PermissionCollection;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.security.IContainerPolicy;
+import org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription;
+
+public interface ISharedObjectPolicy extends IContainerPolicy {
+ /**
+ * Check the request to add a shared object from external source (i.e.
+ * remote container).
+ *
+ * @param fromID
+ * the ID of the container making the container add request
+ * @param toID
+ * the ID of the container receiving/handling the add request.
+ * Null if directed to all containers in group.
+ * @param localID
+ * the ID of the local container
+ * @param newObjectDescription
+ * the ReplicaSharedObjectDescription associated with the shared
+ * object being added
+ * @return PermissionCollection the permission collection associated with
+ * successful acceptance of the add request. Null if the add should
+ * be refused, Non-null if add request is accepted.
+ * @throws SecurityException
+ * if request should be refused <b>and</b> associated container
+ * should leave group
+ */
+ public PermissionCollection checkAddSharedObject(ID fromID, ID toID,
+ ID localID, ReplicaSharedObjectDescription newObjectDescription)
+ throws SecurityException;
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/Activator.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/Activator.java
new file mode 100644
index 000000000..d311c90d5
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/Activator.java
@@ -0,0 +1,295 @@
+package org.eclipse.ecf.internal.core.sharedobject;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionDelta;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IRegistryChangeEvent;
+import org.eclipse.core.runtime.IRegistryChangeListener;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ecf.core.sharedobject.ISharedObjectFactory;
+import org.eclipse.ecf.core.sharedobject.SharedObjectFactory;
+import org.eclipse.ecf.core.sharedobject.SharedObjectTypeDescription;
+import org.eclipse.ecf.core.sharedobject.provider.ISharedObjectInstantiator;
+import org.eclipse.ecf.core.util.Trace;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.ecf.sharedobject";
+
+ protected static final String CLASS_ATTRIBUTE = "class";
+
+ protected static final String NAME_ATTRIBUTE = "name";
+
+ protected static final String PROPERTY_ELEMENT_NAME = "property";
+
+ protected static final String VALUE_ATTRIBUTE = "value";
+
+ protected static final String NAMESPACE_NAME = "sharedObjectFactory";
+
+ protected static final String SHAREDOBJECT_FACTORY_EPOINT = PLUGIN_ID + "."
+ + NAMESPACE_NAME;
+
+ protected static final String DESCRIPTION_ATTRIBUTE = "description";
+
+ private static final int REMOVE_SHAREDOBJECT_ERRORCODE = 1001;
+
+ private static final int FACTORY_NAME_COLLISION_ERRORCODE = 2001;
+
+ // The shared instance
+ private static Activator plugin;
+
+ private IRegistryChangeListener registryManager = null;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ setupSharedObjectExtensionPoint(context);
+ this.registryManager = new SharedObjectRegistryManager();
+ Platform.getExtensionRegistry().addRegistryChangeListener(
+ registryManager);
+ Trace.exiting(Activator.getDefault(),
+ SharedObjectDebugOptions.METHODS_ENTERING, Activator.class,
+ "start");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ Trace.entering(Activator.getDefault(),
+ SharedObjectDebugOptions.METHODS_EXITING, Activator.class,
+ "stop");
+ Platform.getExtensionRegistry().removeRegistryChangeListener(
+ registryManager);
+ registryManager = null;
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Remove extensions for shared object extension point
+ *
+ * @param members
+ * the members to remove
+ */
+ protected void removeSharedObjectExtensions(IConfigurationElement[] members) {
+ String bundleName = getDefault().getBundle().getSymbolicName();
+ for (int m = 0; m < members.length; m++) {
+ IConfigurationElement member = members[m];
+ String name = null;
+ IExtension extension = member.getDeclaringExtension();
+ try {
+ name = member.getAttribute(NAME_ATTRIBUTE);
+ if (name == null) {
+ name = member.getAttribute(CLASS_ATTRIBUTE);
+ }
+ if (name == null)
+ continue;
+ ISharedObjectFactory factory = SharedObjectFactory.getDefault();
+ SharedObjectTypeDescription sd = factory
+ .getDescriptionByName(name);
+ if (sd == null || !factory.containsDescription(sd)) {
+ continue;
+ }
+ // remove
+ factory.removeDescription(sd);
+ org.eclipse.ecf.core.util.Trace.trace(Activator.getDefault(),
+ SharedObjectDebugOptions.DEBUG,
+ "removeSharedObjectExtensions.removedDescription(" + sd
+ + ")");
+ } catch (Exception e) {
+ org.eclipse.ecf.core.util.Trace.catching(
+ Activator.getDefault(),
+ SharedObjectDebugOptions.EXCEPTIONS_CATCHING,
+ Activator.class, "removeSharedObjectExtensions", e);
+ getDefault()
+ .getLog()
+ .log(
+ new Status(
+ IStatus.ERROR,
+ Activator.PLUGIN_ID,
+ REMOVE_SHAREDOBJECT_ERRORCODE,
+ "Exception removing sharedobject extension",
+ e));
+ }
+ }
+ }
+
+ /**
+ * Add shared object extension point extensions
+ *
+ * @param members
+ * to add
+ */
+ protected void addSharedObjectExtensions(IConfigurationElement[] members) {
+ String bundleName = getDefault().getBundle().getSymbolicName();
+ // For each configuration element
+ for (int m = 0; m < members.length; m++) {
+ IConfigurationElement member = members[m];
+ // Get the label of the extender plugin and the ID of the extension.
+ IExtension extension = member.getDeclaringExtension();
+ ISharedObjectInstantiator exten = null;
+ String name = null;
+ try {
+ // The only required attribute is "class"
+ exten = (ISharedObjectInstantiator) member
+ .createExecutableExtension(CLASS_ATTRIBUTE);
+ name = member.getAttribute(NAME_ATTRIBUTE);
+ if (name == null) {
+ name = member.getAttribute(CLASS_ATTRIBUTE);
+ }
+ // Get description, if present
+ String description = member.getAttribute(DESCRIPTION_ATTRIBUTE);
+ if (description == null) {
+ description = "";
+ }
+ // Get any property elements
+ Map properties = getProperties(member
+ .getChildren(PROPERTY_ELEMENT_NAME));
+ // Now make description instance
+ SharedObjectTypeDescription scd = new SharedObjectTypeDescription(
+ name, exten, description, properties);
+ org.eclipse.ecf.core.util.Trace.trace(Activator.getDefault(),
+ SharedObjectDebugOptions.DEBUG,
+ "setupSharedObjectExtensionPoint:createdDescription("
+ + scd + ")");
+ ISharedObjectFactory factory = SharedObjectFactory.getDefault();
+ if (factory.containsDescription(scd))
+ throw new CoreException(
+ new Status(
+ Status.ERROR,
+ bundleName,
+ FACTORY_NAME_COLLISION_ERRORCODE,
+ "name="
+ + name
+ + ";extension point id="
+ + extension
+ .getExtensionPointUniqueIdentifier(),
+ null));
+
+ // Now add the description and we're ready to go.
+ factory.addDescription(scd);
+ org.eclipse.ecf.core.util.Trace.trace(Activator.getDefault(),
+ SharedObjectDebugOptions.DEBUG,
+ "setupSharedObjectExtensionPoint.addedDescriptionToFactory("
+ + scd + ")");
+ } catch (CoreException e) {
+ getDefault().getLog().log(e.getStatus());
+ org.eclipse.ecf.core.util.Trace.catching(
+ Activator.getDefault(),
+ SharedObjectDebugOptions.EXCEPTIONS_CATCHING,
+ Activator.class, "addSharedObjectExtensions", e);
+ } catch (Exception e) {
+ getDefault()
+ .getLog()
+ .log(
+ new Status(
+ Status.ERROR,
+ bundleName,
+ FACTORY_NAME_COLLISION_ERRORCODE,
+ "name="
+ + name
+ + ";extension point id="
+ + extension
+ .getExtensionPointUniqueIdentifier(),
+ null));
+ org.eclipse.ecf.core.util.Trace.catching(
+ Activator.getDefault(),
+ SharedObjectDebugOptions.EXCEPTIONS_CATCHING,
+ Activator.class, "addSharedObjectExtensions", e);
+ }
+ }
+ }
+
+ /**
+ * Setup shared object extension point
+ *
+ * @param context
+ * the BundleContext for this bundle
+ */
+ protected void setupSharedObjectExtensionPoint(BundleContext bc) {
+ IExtensionRegistry reg = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = reg
+ .getExtensionPoint(SHAREDOBJECT_FACTORY_EPOINT);
+ if (extensionPoint == null) {
+ return;
+ }
+ addSharedObjectExtensions(extensionPoint.getConfigurationElements());
+ }
+
+ protected Map getProperties(IConfigurationElement[] propertyElements) {
+ Properties props = new Properties();
+ if (propertyElements != null) {
+ if (propertyElements.length > 0) {
+ for (int i = 0; i < propertyElements.length; i++) {
+ String name = propertyElements[i]
+ .getAttribute(NAME_ATTRIBUTE);
+ String value = propertyElements[i]
+ .getAttribute(VALUE_ATTRIBUTE);
+ if (name != null && !name.equals("") && value != null
+ && !value.equals("")) {
+ props.setProperty(name, value);
+ }
+ }
+ }
+ }
+ return props;
+ }
+
+ protected class SharedObjectRegistryManager implements
+ IRegistryChangeListener {
+ public void registryChanged(IRegistryChangeEvent event) {
+ IExtensionDelta delta[] = event.getExtensionDeltas(PLUGIN_ID,
+ NAMESPACE_NAME);
+ for (int i = 0; i < delta.length; i++) {
+ switch (delta[i].getKind()) {
+ case IExtensionDelta.ADDED:
+ addSharedObjectExtensions(delta[i].getExtension()
+ .getConfigurationElements());
+ break;
+ case IExtensionDelta.REMOVED:
+ removeSharedObjectExtensions(delta[i].getExtension()
+ .getConfigurationElements());
+ break;
+ }
+ }
+ }
+ }
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/SharedObjectDebugOptions.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/SharedObjectDebugOptions.java
new file mode 100644
index 000000000..320c9a64c
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/SharedObjectDebugOptions.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.internal.core.sharedobject;
+
+public interface SharedObjectDebugOptions {
+
+ public static final String DEBUG = Activator.PLUGIN_ID + "/debug"; //$NON-NLS-1$
+
+ public static final String EXCEPTIONS_CATCHING = DEBUG
+ + "/exceptions/catching"; //$NON-NLS-1$
+
+ public static final String EXCEPTIONS_THROWING = DEBUG
+ + "/exceptions/throwing"; //$NON-NLS-1$
+
+ public static final String METHODS_ENTERING = DEBUG + "/methods/entering"; //$NON-NLS-1$
+
+ public static final String METHODS_EXITING = DEBUG + "/methods/exiting"; //$NON-NLS-1$
+
+}

Back to the top