Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2005-05-23 03:40:07 +0000
committerslewis2005-05-23 03:40:07 +0000
commit65c33767e735cf405e18b8a0fb3d46d29717f2bc (patch)
tree08501bbe95e854bc5f98ffdf2ab431c57c1b0113
parent9b5b9b9c1291f42f4e1a6e88023d2e2e53b2d472 (diff)
downloadorg.eclipse.ecf-65c33767e735cf405e18b8a0fb3d46d29717f2bc.tar.gz
org.eclipse.ecf-65c33767e735cf405e18b8a0fb3d46d29717f2bc.tar.xz
org.eclipse.ecf-65c33767e735cf405e18b8a0fb3d46d29717f2bc.zip
Added setJoinPolicy to ISharedObjectContainerGroupManager interface and generic provider implementation. Added setAddSharedObject to ISharedObjectManager interface and generic provider and test provider implementations. Also corrected trivial bug in clean up code for org.eclipse.ecf.sdo project.
-rw-r--r--examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharing.java13
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerApplication.java42
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java29
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOManager.java5
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ServerSOContainer.java18
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectContainerGroupManager.java10
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectManager.java9
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/IJoinPolicy.java3
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/ISharedObjectPolicy.java29
9 files changed, 124 insertions, 34 deletions
diff --git a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharing.java b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharing.java
index d679269ba..ca68a1a28 100644
--- a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharing.java
+++ b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharing.java
@@ -12,6 +12,7 @@ package org.eclipse.ecf.internal.sdo;
import org.eclipse.ecf.core.ISharedObject;
import org.eclipse.ecf.core.ISharedObjectConfig;
+import org.eclipse.ecf.core.ISharedObjectContext;
import org.eclipse.ecf.core.ISharedObjectManager;
import org.eclipse.ecf.core.SharedObjectInitException;
import org.eclipse.ecf.core.identity.ID;
@@ -133,10 +134,14 @@ public class DataGraphSharing implements
* @see org.eclipse.ecf.core.ISharedObject#dispose(org.eclipse.ecf.core.identity.ID)
*/
public synchronized void dispose(ID containerID) {
- if (config != null
- && config.getContext().getLocalContainerID()
- .equals(containerID))
- config = null;
+ if (config != null) {
+ ISharedObjectContext context = config.getContext();
+ if (context != null) {
+ if (context.getLocalContainerID().equals(containerID)) {
+ config = null;
+ }
+ }
+ }
}
/* (non-Javadoc)
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerApplication.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerApplication.java
index 6681a2780..26a89bb9b 100644
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerApplication.java
+++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerApplication.java
@@ -1,13 +1,19 @@
package org.eclipse.ecf.provider.app;
import java.io.FileInputStream;
+import java.security.PermissionCollection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.ecf.core.ISharedObjectContainerGroupManager;
+import org.eclipse.ecf.core.ISharedObjectManager;
+import org.eclipse.ecf.core.SharedObjectDescription;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.IDInstantiationException;
+import org.eclipse.ecf.core.security.IJoinPolicy;
+import org.eclipse.ecf.core.security.ISharedObjectPolicy;
import org.eclipse.ecf.provider.generic.SOContainerConfig;
import org.eclipse.ecf.provider.generic.TCPServerSOContainer;
import org.eclipse.ecf.provider.generic.TCPServerSOContainerGroup;
@@ -30,6 +36,30 @@ public class ServerApplication {
static TCPServerSOContainerGroup serverGroups[] = null;
static List servers = new ArrayList();
+ static class JoinListener implements IJoinPolicy {
+ public PermissionCollection checkJoin(ID fromID, ID targetID, String targetGroup, Object joinData) throws SecurityException {
+ System.out.println("JOIN From="+fromID+";Group="+targetGroup+";Data="+joinData);
+ return null;
+ }
+
+ public void refresh() {
+ System.out.println("joinpolicy.refresh()");
+ }
+
+ }
+ static class SharedObjectAddListener implements ISharedObjectPolicy {
+
+ public PermissionCollection checkAddSharedObject(ID fromID, ID toID, ID localID, SharedObjectDescription newObject) throws SecurityException {
+ System.out.println("ADDSHAREDOBJECT From="+fromID+";To="+toID+";SharedObject="+newObject);
+ return null;
+ }
+
+ public void refresh() {
+ System.out.println("joinpolicy.refresh()");
+ }
+
+ }
+
public static void main(String args[]) throws Exception {
// Get server identity
String serverName = null;
@@ -83,22 +113,28 @@ public class ServerApplication {
System.out.print("Creating ECF server container...");
TCPServerSOContainer server = new TCPServerSOContainer(config, serverGroups[0], name,
TCPServerSOContainer.DEFAULT_KEEPALIVE);
+ // Setup join policy
+ ((ISharedObjectContainerGroupManager)server).setJoinPolicy(new JoinListener());
+ // Setup add shared object policy
+ ISharedObjectManager manager = server.getSharedObjectManager();
+ manager.setRemoteAddPolicy(new SharedObjectAddListener());
+
serverGroups[0].putOnTheAir();
servers.add(server);
System.out.println("success!");
System.out
- .println("Waiting for client connections at '" + id.getName() + "'...");
+ .println("Waiting for JOIN requests at '" + id.getName() + "'...");
System.out.println("<ctrl>-c to stop server");
}
}
protected static TCPServerSOContainerGroup makeServerGroup(String name, int port) {
- System.out.println("Creating server named "+name+" to listen on port "+port);
+ System.out.println("Creating server group named "+name+" to listen on port "+port);
TCPServerSOContainerGroup group = new TCPServerSOContainerGroup(name,port);
return group;
}
protected static TCPServerSOContainer makeServerContainer(String id, TCPServerSOContainerGroup group, String path, int keepAlive) throws IDInstantiationException {
- System.out.println(" Creating container with identity "+id+", path "+path+" keepAlive="+keepAlive);
+ System.out.println(" Creating container with id="+id+", group="+path+" keepAlive="+keepAlive);
ID newServerID = IDFactory.makeStringID(id);
SOContainerConfig config = new SOContainerConfig(newServerID);
return new TCPServerSOContainer(config,group,path,keepAlive);
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java
index 3f20ec2f2..33522e5cb 100644
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java
+++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java
@@ -45,6 +45,7 @@ import org.eclipse.ecf.core.events.SharedObjectContainerDepartedEvent;
import org.eclipse.ecf.core.events.SharedObjectContainerDisposeEvent;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.security.IJoinContext;
+import org.eclipse.ecf.core.security.ISharedObjectPolicy;
import org.eclipse.ecf.core.util.Event;
import org.eclipse.ecf.core.util.IClassLoaderMapper;
import org.eclipse.ecf.core.util.IQueueEnqueue;
@@ -225,32 +226,22 @@ public abstract class SOContainer implements ISharedObjectContainer {
return processSynch(event);
}
}
-
static Trace debug = Trace.create("container");
-
public static final String DEFAULT_OBJECT_ARG_KEY = SOContainer.class
.getName()
+ ".sharedobjectargs";
-
public static final String DEFAULT_OBJECT_ARGTYPES_KEY = SOContainer.class
.getName()
+ ".sharedobjectargs";
-
protected ISharedObjectContainerConfig config = null;
-
protected SOContainerGMM groupManager = null;
-
protected boolean isClosing = false;
-
private Vector listeners = null;
-
protected ThreadGroup loadingThreadGroup = null;
-
protected MessageReceiver receiver;
-
private long sequenceNumber = 0L;
-
protected SOManager sharedObjectManager = null;
+ protected ISharedObjectPolicy policy = null;
protected ThreadGroup sharedObjectThreadGroup = null;
@@ -279,6 +270,11 @@ public abstract class SOContainer implements ISharedObjectContainer {
}
}
+ protected void setRemoteAddPolicy(ISharedObjectPolicy policy) {
+ synchronized (getGroupMembershipLock()) {
+ this.policy = policy;
+ }
+ }
protected boolean addNewRemoteMember(ID memberID, Object data) {
debug("addNewRemoteMember:" + memberID);
return groupManager.addMember(new Member(memberID, data));
@@ -353,10 +349,11 @@ public abstract class SOContainer implements ISharedObjectContainer {
* sendCreateResponse) to the sender that the creation has
* failed
*/
- protected Object checkRemoteCreate(ID fromID, ID toID, long seq,
- SharedObjectDescription desc) throws Exception {
- debug("checkRemoteCreate(" + fromID + "," + toID + "," + seq + ","
- + desc + ")");
+ protected Object checkRemoteCreate(ID fromID, ID toID, SharedObjectDescription desc) throws Exception {
+ debug("checkRemoteCreate(" + fromID + "," + toID + "," + desc + ")");
+ if (policy != null) {
+ policy.checkAddSharedObject(fromID,toID,getID(),desc);
+ }
return desc;
}
@@ -648,7 +645,7 @@ public abstract class SOContainer implements ISharedObjectContainer {
// method
// returns a non-null object, the creation is allowed to proceed
try {
- checkCreateResult = checkRemoteCreate(fromID, toID, seq, desc);
+ checkCreateResult = checkRemoteCreate(fromID, toID, desc);
} catch (Exception e) {
SharedObjectAddException addException = new SharedObjectAddException(
"shared object " + sharedObjectID
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOManager.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOManager.java
index 239cc321c..c5a8334b7 100644
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOManager.java
+++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOManager.java
@@ -39,6 +39,7 @@ import org.eclipse.ecf.core.events.SharedObjectManagerCreateEvent;
import org.eclipse.ecf.core.events.SharedObjectManagerDisconnectEvent;
import org.eclipse.ecf.core.events.SharedObjectManagerRemoveEvent;
import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.security.ISharedObjectPolicy;
import org.eclipse.ecf.core.util.AbstractFactory;
import org.eclipse.ecf.core.util.IQueueEnqueue;
import org.eclipse.ecf.provider.Trace;
@@ -352,4 +353,8 @@ public class SOManager implements ISharedObjectManager {
}
return clazzes;
}
+
+ public void setRemoteAddPolicy(ISharedObjectPolicy policy) {
+ container.setRemoteAddPolicy(policy);
+ }
} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ServerSOContainer.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ServerSOContainer.java
index bd061e33b..2ab0d031e 100644
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ServerSOContainer.java
+++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ServerSOContainer.java
@@ -27,9 +27,13 @@ import org.eclipse.ecf.core.events.SharedObjectContainerEjectedEvent;
import org.eclipse.ecf.core.events.SharedObjectContainerJoinedEvent;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.security.IJoinContext;
+import org.eclipse.ecf.core.security.IJoinPolicy;
import org.eclipse.ecf.provider.generic.gmm.Member;
public class ServerSOContainer extends SOContainer implements ISharedObjectContainerGroupManager {
+
+ protected IJoinPolicy policy;
+
public ServerSOContainer(ISharedObjectContainerConfig config) {
super(config);
}
@@ -127,6 +131,9 @@ public class ServerSOContainer extends SOContainer implements ISharedObjectConta
"container is closing");
throw e;
}
+ // Now check to see if this request is going to be allowed
+ checkJoin(remoteID,target,jgm.getData());
+
if (addNewRemoteMember(remoteID, conn)) {
// Notify existing remotes about new member
try {
@@ -158,8 +165,11 @@ public class ServerSOContainer extends SOContainer implements ISharedObjectConta
return null;
}
}
- protected Object checkJoin(String hostname, ID id, Serializable data)
+ protected Object checkJoin(ID fromID, String target, Serializable data)
throws Exception {
+ if (this.policy != null) {
+ return this.policy.checkJoin(fromID,getID(),target,data);
+ }
return null;
}
protected void handleLeaveGroupMessage(ContainerMessage mess) {
@@ -258,4 +268,10 @@ public class ServerSOContainer extends SOContainer implements ISharedObjectConta
"ServerApplication cannot join group " + groupID.getName());
throw e;
}
+
+ public void setJoinPolicy(IJoinPolicy policy) {
+ synchronized (getGroupMembershipLock()) {
+ this.policy = policy;
+ }
+ }
} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectContainerGroupManager.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectContainerGroupManager.java
index ea5c91ea1..6cbbf0d93 100644
--- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectContainerGroupManager.java
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectContainerGroupManager.java
@@ -10,12 +10,22 @@ package org.eclipse.ecf.core;
import java.io.Serializable;
import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.security.IJoinPolicy;
/**
* @author slewis
*
*/
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 setJoinPolicy(IJoinPolicy policy);
/**
* Eject the given groupMemberID from the current group of containers, for the given reason.
*
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectManager.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectManager.java
index 8e7f7f27a..7e83e0453 100644
--- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectManager.java
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ISharedObjectManager.java
@@ -13,6 +13,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.security.ISharedObjectPolicy;
/**
* Manager for creating, disposing, and accessing ISharedObjects from an ISharedObjectContainer.
@@ -117,4 +118,12 @@ public interface ISharedObjectManager {
* @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/src/org/eclipse/ecf/core/security/IJoinPolicy.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/IJoinPolicy.java
index 9a2669099..fcbc8abda 100644
--- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/IJoinPolicy.java
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/IJoinPolicy.java
@@ -9,7 +9,6 @@
package org.eclipse.ecf.core.security;
-import java.io.Serializable;
import java.security.PermissionCollection;
import org.eclipse.ecf.core.identity.ID;
@@ -32,5 +31,5 @@ public interface IJoinPolicy extends IContainerPolicy {
* if join is to be refused
*/
public PermissionCollection checkJoin(ID fromID, ID targetID,
- String targetGroup, Serializable joinData) throws SecurityException;
+ String targetGroup, Object joinData) throws SecurityException;
}
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/ISharedObjectPolicy.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/ISharedObjectPolicy.java
index 33b45e96d..8eec475f5 100644
--- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/ISharedObjectPolicy.java
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/ISharedObjectPolicy.java
@@ -16,14 +16,27 @@ import org.eclipse.ecf.core.identity.ID;
public interface ISharedObjectPolicy extends IContainerPolicy {
/**
- * Check the request to add a shared object from external source (i.e. remote container).
+ * 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
- * @param newObject the shared object description 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
+ * @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 newObject
+ * the shared object description 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, SharedObjectDescription newObject) throws SecurityException;
+ public PermissionCollection checkAddSharedObject(ID fromID, ID toID,
+ ID localID, SharedObjectDescription newObject)
+ throws SecurityException;
}

Back to the top