diff options
| author | slewis | 2005-07-09 22:29:23 +0000 |
|---|---|---|
| committer | slewis | 2005-07-09 22:29:23 +0000 |
| commit | 56c126fd31ff11429cf1db096ae3088d5767973d (patch) | |
| tree | dcc3f3ad69943919ac055ee156ac0c1049f3adee | |
| parent | 3c98e7b038bba2bbe5f8886fc12e340fd32cf655 (diff) | |
| download | org.eclipse.ecf-56c126fd31ff11429cf1db096ae3088d5767973d.tar.gz org.eclipse.ecf-56c126fd31ff11429cf1db096ae3088d5767973d.tar.xz org.eclipse.ecf-56c126fd31ff11429cf1db096ae3088d5767973d.zip | |
Changed IDFactory.makeID() API to be: IDFactory.getDefault().makeID(). Updated all client code. Added IIDFactory interface. Changed IDFactory.getDefault() to return IIDFactory. Changed SharedObjectContainerFactory.getDefault() to return ISharedObjectContainerFactory.
26 files changed, 281 insertions, 180 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java index f6aadd9e9..e66c35b91 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java @@ -176,7 +176,7 @@ public class Client { } } public Client() throws Exception { - defaultGroupID = IDFactory.makeStringID(DEFAULT_SERVER_ID); + defaultGroupID = IDFactory.getDefault().makeStringID(DEFAULT_SERVER_ID); } protected User getUserData(String containerType, ID clientID, String usernick, IResource project) { @@ -239,7 +239,7 @@ public class Client { removeClientEntry(proj,client.getType()); } }); - ID newID = IDFactory.makeStringID(COLLAB_SHARED_OBJECT_ID); + ID newID = IDFactory.getDefault().makeStringID(COLLAB_SHARED_OBJECT_ID); client.getContainer().getSharedObjectManager().addSharedObject(newID, sharedObject, new HashMap()); client.setObject(sharedObject); diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/DiscoveryStartup.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/DiscoveryStartup.java index a6327bc01..8a67f8d01 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/DiscoveryStartup.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/DiscoveryStartup.java @@ -110,7 +110,7 @@ public class DiscoveryStartup { String targetString = null; try { targetString = svcInfo.getServiceURI().toString(); - targetID = IDFactory.makeStringID(targetString); + targetID = IDFactory.getDefault().makeStringID(targetString); } catch (Exception e) { ClientPlugin.log("cannot create target id for "+targetString,e); } diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ServerStartup.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ServerStartup.java index 352f168ac..981e2860a 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ServerStartup.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ServerStartup.java @@ -106,7 +106,7 @@ public class ServerStartup { protected TCPServerSOContainer makeServerContainer(String id, TCPServerSOContainerGroup group, String path, int keepAlive) throws IDInstantiationException { - ID newServerID = IDFactory.makeStringID(id); + ID newServerID = IDFactory.getDefault().makeStringID(id); SOContainerConfig config = new SOContainerConfig(newServerID); return new TCPServerSOContainer(config, group, path, keepAlive); } diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectAction.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectAction.java index e47594393..1eaf4180b 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectAction.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectAction.java @@ -57,7 +57,7 @@ public class ClientConnectAction implements IWorkbenchWindowActionDelegate { public ClientConnectAction() { try { - targetID = IDFactory.makeStringID(DEFAULT_SERVER_ID); + targetID = IDFactory.getDefault().makeStringID(DEFAULT_SERVER_ID); client = new Client(); } catch (Exception e) { throw new RuntimeException("Exception in ClientConnectAction()",e); diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectComposentAction.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectComposentAction.java index 3065557f7..4622c7435 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectComposentAction.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectComposentAction.java @@ -21,7 +21,7 @@ public class ClientConnectComposentAction extends ClientConnectAction { public ClientConnectComposentAction() { super(); try { - targetID = IDFactory.makeStringID(COMPOSENT_TARGET); + targetID = IDFactory.getDefault().makeStringID(COMPOSENT_TARGET); } catch (Exception e) { throw new RuntimeException("Exception in ClientConnectAction()",e); } diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/GenericSharedObject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/GenericSharedObject.java index 72b30001a..6f4aa9d9e 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/GenericSharedObject.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/GenericSharedObject.java @@ -472,7 +472,7 @@ public void handleEvent(Event event) { public ID makeObject(ID target, String className, Map map) throws Exception { ISharedObjectContext crs = getContext(); - ID newID = IDFactory.makeStringID(getNewUniqueIDString()); + ID newID = IDFactory.getDefault().makeStringID(getNewUniqueIDString()); if (crs == null) { throw new InstantiationException( "Cannot make object. Have no local creation capability because context is null"); diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatComposite.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatComposite.java index c644d51f0..6339487a7 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatComposite.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatComposite.java @@ -1093,7 +1093,7 @@ public class ChatComposite extends Composite { String fileName, Date startDate, ID target, final boolean launch) { try { ID eclipseStageID = IDFactory - .makeStringID(org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject.ECLIPSEOBJECTNAME); + .getDefault().makeStringID(org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject.ECLIPSEOBJECTNAME); java.io.BufferedInputStream ins = new java.io.BufferedInputStream( local); java.io.File remoteFile = new File((new File(fileName)).getName()); diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizard.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizard.java index 925458def..6fbd0f75e 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizard.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizard.java @@ -63,8 +63,8 @@ public class JoinGroupWizard extends Wizard { try { ID groupID = null; if (namespace != null) { - groupID = IDFactory.makeID(namespace,new Object[] { groupName }); - } else groupID = IDFactory.makeStringID(groupName); + groupID = IDFactory.getDefault().makeID(namespace,new Object[] { groupName }); + } else groupID = IDFactory.getDefault().makeStringID(groupName); client = new ClientConnectAction(); client.setProject(project); client.setUsername(nickName); diff --git a/examples/bundles/org.eclipse.ecf.example.sdo.editor/src/org/eclipse/ecf/example/sdo/editor/EditorPlugin.java b/examples/bundles/org.eclipse.ecf.example.sdo.editor/src/org/eclipse/ecf/example/sdo/editor/EditorPlugin.java index 6f6601e6b..a7889467a 100644 --- a/examples/bundles/org.eclipse.ecf.example.sdo.editor/src/org/eclipse/ecf/example/sdo/editor/EditorPlugin.java +++ b/examples/bundles/org.eclipse.ecf.example.sdo.editor/src/org/eclipse/ecf/example/sdo/editor/EditorPlugin.java @@ -117,7 +117,7 @@ public class EditorPlugin extends AbstractUIPlugin { .getWorkspace().getRoot().getProject(p.segment(0))); PublishedGraphTracker tracker = getTracker(container); - ID id = IDFactory.makeStringID(path); + ID id = IDFactory.getDefault().makeStringID(path); WaitableSubscriptionCallback mutex = new WaitableSubscriptionCallback(); ISharedDataGraph result = DataGraphSharingFactory.getDataGraphSharing( container, "default").subscribe(id, new EMFUpdateProvider(), @@ -143,7 +143,7 @@ public class EditorPlugin extends AbstractUIPlugin { .getWorkspace().getRoot().getProject(p.segment(0))); PublishedGraphTracker tracker = getTracker(container); - ID id = IDFactory.makeStringID(path); + ID id = IDFactory.getDefault().makeStringID(path); WaitablePublicationCallback mutex = new WaitablePublicationCallback(); ISharedDataGraph result = DataGraphSharingFactory.getDataGraphSharing( container, "default").publish(dataGraph, id, @@ -164,7 +164,7 @@ public class EditorPlugin extends AbstractUIPlugin { ISharedObjectContainer container = getContainer(ResourcesPlugin .getWorkspace().getRoot().getProject(p.segment(0))); PublishedGraphTracker tracker = getTracker(container); - return tracker.isPublished(IDFactory.makeStringID(path)); + return tracker.isPublished(IDFactory.getDefault().makeStringID(path)); } public synchronized void checkConnected(IProject project) @@ -181,7 +181,7 @@ public class EditorPlugin extends AbstractUIPlugin { private PublishedGraphTracker getTracker(ISharedObjectContainer container) throws ECFException { - ID id = IDFactory.makeStringID(PublishedGraphTracker.class.getName()); + ID id = IDFactory.getDefault().makeStringID(PublishedGraphTracker.class.getName()); PublishedGraphTracker tracker = (PublishedGraphTracker) container .getSharedObjectManager().getSharedObject(id); if (tracker == null) { diff --git a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharingManager.java b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharingManager.java index 5a79e9e56..fc2dcca0a 100644 --- a/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharingManager.java +++ b/examples/bundles/org.eclipse.ecf.sdo/src/org/eclipse/ecf/internal/sdo/DataGraphSharingManager.java @@ -31,7 +31,7 @@ public class DataGraphSharingManager implements IDataGraphSharingManager { public synchronized IDataGraphSharing getInstance( ISharedObjectContainer container) throws ECFException { ISharedObjectManager mgr = container.getSharedObjectManager(); - ID id = IDFactory.makeStringID(DataGraphSharing.DATA_GRAPH_SHARING_ID); + ID id = IDFactory.getDefault().makeStringID(DataGraphSharing.DATA_GRAPH_SHARING_ID); DataGraphSharing result = (DataGraphSharing) mgr.getSharedObject(id); if (result == null) { result = new DataGraphSharing(); diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ClientApplication.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ClientApplication.java index 3198fce1f..7d95ef1f3 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ClientApplication.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ClientApplication.java @@ -75,7 +75,7 @@ public class ClientApplication { protected ISharedObjectContainer makeClient() throws Exception { // Make identity instance for the new container - ID newContainerID = IDFactory.makeGUID(); + ID newContainerID = IDFactory.getDefault().makeGUID(); ISharedObjectContainer result = SharedObjectContainerFactory.getDefault().makeSharedObjectContainer(contd,null,new Object[] { newContainerID, new Integer(DEFAULT_TIMEOUT)}); return result; } @@ -102,7 +102,7 @@ public class ClientApplication { ISharedObjectContainer scg = sm[j]; for(int i=0; i < sharedObjectClassNames.length; i++) { System.out.println("Creating sharedObject: "+sharedObjectClassNames[i]+" for client "+scg.getConfig().getID().getName()); - SharedObjectDescription sd = new SharedObjectDescription(IDFactory.makeStringID(String.valueOf(aRan.nextInt())),sharedObjectClassNames[i]); + SharedObjectDescription sd = new SharedObjectDescription(IDFactory.getDefault().makeStringID(String.valueOf(aRan.nextInt())),sharedObjectClassNames[i]); scg.getSharedObjectManager().createSharedObject(sd); System.out.println("Created sharedObject for client "+scg.getConfig().getID().getName()); } @@ -123,7 +123,7 @@ public class ClientApplication { ClientApplication st = new ClientApplication(); st.init(args); // Get server id to join - ID serverID = IDFactory.makeStringID(st.serverName); + ID serverID = IDFactory.getDefault().makeStringID(st.serverName); st.joinGroup(serverID); st.createStages(); System.out.println("Waiting "+DEFAULT_WAITTIME+" ms..."); 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 a9d3cbf02..daf57c864 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 @@ -107,7 +107,7 @@ public class ServerApplication { // Setup server group serverGroups[0] = new TCPServerSOContainerGroup(anURL.getPort()); // Create identity for server - ID id = IDFactory.makeStringID(serverName); + ID id = IDFactory.getDefault().makeStringID(serverName); // Create server config object with identity and default timeout SOContainerConfig config = new SOContainerConfig(id); // Make server instance @@ -136,7 +136,7 @@ public class ServerApplication { } protected static TCPServerSOContainer makeServerContainer(String id, TCPServerSOContainerGroup group, String path, int keepAlive) throws IDInstantiationException { System.out.println(" Creating container with id="+id+", group="+path+" keepAlive="+keepAlive); - ID newServerID = IDFactory.makeStringID(id); + ID newServerID = IDFactory.getDefault().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/comm/tcp/Client.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/comm/tcp/Client.java index 560a66cac..8b98cbdfa 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/comm/tcp/Client.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/comm/tcp/Client.java @@ -184,7 +184,7 @@ public final class Client implements ISynchAsynchConnection { return null; ID retID = null; try { - retID = IDFactory.makeStringID(PROTOCOL + "://" + retID = IDFactory.getDefault().makeStringID(PROTOCOL + "://" + socket.getLocalAddress().getHostName() + ":" + socket.getLocalPort()); } catch (Exception e) { return null; diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ContainerInstantiator.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ContainerInstantiator.java index e08fa6508..49369fefd 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ContainerInstantiator.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/ContainerInstantiator.java @@ -42,12 +42,12 @@ public class ContainerInstantiator implements if (arg instanceof String) { String val = (String) arg; if (val == null || val.equals("")) { - return IDFactory.makeGUID(); - } else return IDFactory.makeStringID((String) arg); + return IDFactory.getDefault().makeGUID(); + } else return IDFactory.getDefault().makeStringID((String) arg); } else if (arg instanceof Integer) { - return IDFactory.makeGUID(((Integer) arg).intValue()); + return IDFactory.getDefault().makeGUID(((Integer) arg).intValue()); } else - return IDFactory.makeGUID(); + return IDFactory.getDefault().makeGUID(); } protected Integer getIntegerFromArg(Class type, Object arg) diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/TCPClientSOContainer.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/TCPClientSOContainer.java index 3e8612ec5..a6123fda1 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/TCPClientSOContainer.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/TCPClientSOContainer.java @@ -44,10 +44,10 @@ public class TCPClientSOContainer extends ClientSOContainer { public static final void main(String[] args) throws Exception { ISharedObjectContainerConfig config = new SOContainerConfig(IDFactory - .makeGUID()); + .getDefault().makeGUID()); TCPClientSOContainer container = new TCPClientSOContainer(config); // now join group - ID serverID = IDFactory.makeStringID(TCPServerSOContainer + ID serverID = IDFactory.getDefault().makeStringID(TCPServerSOContainer .getDefaultServerURL()); container.joinGroup(serverID, null); Thread.sleep(200000); diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java index b838e12db..e04d523c7 100644 --- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java +++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java @@ -765,7 +765,7 @@ public class RosterView extends ViewPart implements IPresenceListener, protected void addPendingEntry(String user, String nickname, String group) { ID newID = null; try { - newID = IDFactory.makeStringID(user); + newID = IDFactory.getDefault().makeStringID(user); } catch (Exception e) { } IRosterEntry newEntry = new RosterEntry(newID, nickname); @@ -807,7 +807,7 @@ public class RosterView extends ViewPart implements IPresenceListener, if (strres != null && !strres.equals("")) { ID target = null; try { - target = IDFactory.makeStringID(strres); + target = IDFactory.getDefault().makeStringID(strres); } catch (Exception e) { MessageDialog.openError(getSite().getShell(), "Error", "Error in IM target"); diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/SharedObjectContainerFactory.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/SharedObjectContainerFactory.java index e96a40ddb..98ebeacfa 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/SharedObjectContainerFactory.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/SharedObjectContainerFactory.java @@ -39,14 +39,14 @@ public class SharedObjectContainerFactory implements ISharedObjectContainerFacto private static Trace debug = Trace.create("containerfactory"); private static Hashtable containerdescriptions = new Hashtable(); - protected static SharedObjectContainerFactory instance = null; + protected static ISharedObjectContainerFactory instance = null; static { instance = new SharedObjectContainerFactory(); } protected SharedObjectContainerFactory() { } - public static SharedObjectContainerFactory getDefault() { + public static ISharedObjectContainerFactory getDefault() { return instance; } private static void trace(String msg) { diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java index 46d067d8d..4b285cae6 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java @@ -24,7 +24,7 @@ import org.eclipse.ecf.internal.core.Trace; * manufacture ID instances. * */ -public class IDFactory { +public class IDFactory implements IIDFactory { private static final Trace debug = Trace.create("idfactory"); @@ -34,7 +34,10 @@ public class IDFactory { private static Hashtable namespaces = new Hashtable(); private static boolean securityEnabled = false; + protected static IIDFactory instance = null; + static { + instance = new IDFactory(); addNamespace0(new Namespace(IDFactory.class.getClassLoader(), StringID.STRINGID_NAME, StringID.STRINGID_INSTANTIATOR_CLASS, null)); @@ -48,19 +51,16 @@ public class IDFactory { e.printStackTrace(); } } - - /** - * Add the given Namespace to our table of available Namespaces - * - * @param n - * the Namespace to add - * @return Namespace the namespace already in table (null if Namespace not - * previously in table) - * @exception SecurityException - * thrown if caller does not have appropriate - * NamespacePermission for given namespace - */ - public final static Namespace addNamespace(Namespace n) + protected IDFactory() { + + } + public static IIDFactory getDefault() { + return instance; + } + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#addNamespace(org.eclipse.ecf.core.identity.Namespace) + */ + public Namespace addNamespace(Namespace n) throws SecurityException { if (n == null) return null; @@ -80,17 +80,10 @@ public class IDFactory { if (securityEnabled) AccessController.checkPermission(p); } - /** - * Check whether table contains given Namespace instance - * - * @param n - * the Namespace to look for - * @return true if table does contain given Namespace, false otherwise - * @exception SecurityException - * thrown if caller does not have appropriate - * NamespacePermission for given namespace - */ - public final static boolean containsNamespace(Namespace n) + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#containsNamespace(org.eclipse.ecf.core.identity.Namespace) + */ + public boolean containsNamespace(Namespace n) throws SecurityException { debug("containsNamespace("+n+")"); if (n == null) @@ -99,7 +92,10 @@ public class IDFactory { NamespacePermission.CONTAINS_NAMESPACE)); return containsNamespace0(n); } - public final static List getNamespaces() { + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#getNamespaces() + */ + public List getNamespaces() { debug("getNamespaces()"); return new ArrayList(namespaces.values()); } @@ -119,17 +115,10 @@ public class IDFactory { return false; return namespaces.containsKey(n.getName()); } - /** - * Get the given Namespace instance from table - * - * @param n - * the Namespace to look for - * @return Namespace - * @exception SecurityException - * thrown if caller does not have appropriate - * NamespacePermission for given namespace - */ - public final static Namespace getNamespace(Namespace n) + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#getNamespace(org.eclipse.ecf.core.identity.Namespace) + */ + public Namespace getNamespace(Namespace n) throws SecurityException { debug("getNamespace("+n+")"); if (n == null) @@ -139,7 +128,10 @@ public class IDFactory { return getNamespace0(n); } - public final static Namespace getNamespaceByName(String name) + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#getNamespaceByName(java.lang.String) + */ + public Namespace getNamespaceByName(String name) throws SecurityException { debug("getNamespaceByName("+name+")"); Namespace ns = new Namespace(null, name, name, null); @@ -152,11 +144,17 @@ public class IDFactory { return (Namespace) namespaces.get(n.getName()); } - public static final ID makeGUID() throws IDInstantiationException { + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#makeGUID() + */ + public ID makeGUID() throws IDInstantiationException { return makeGUID(GUID.DEFAULT_BYTE_LENGTH); } - public static final ID makeGUID(int length) throws IDInstantiationException { + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#makeGUID(int) + */ + public ID makeGUID(int length) throws IDInstantiationException { debug("makeGUID("+length+")"); Namespace n = new Namespace(GUID.class.getClassLoader(), GUID.GUID_NAME, GUID.GUID_INSTANTIATOR_CLASS, null); @@ -190,23 +188,10 @@ public class IDFactory { logException(s, null); throw e; } - /** - * Make a new identity. Given a Namespace instance, constructor argument - * types, and an array of arguments, return a new instance of an ID - * belonging to the given Namespace - * - * @param n - * the Namespace to which the ID belongs - * @param argTypes - * a String [] of the arg types for the ID instance constructor - * @param args - * an Object [] of the args for the ID instance constructor - * @exception IDInstantiationException - * thrown if class for instantiator or instance can't be - * loaded, if something goes wrong during instance - * construction - */ - public static final ID makeID(Namespace n, String[] argTypes, Object[] args) + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#makeID(org.eclipse.ecf.core.identity.Namespace, java.lang.String[], java.lang.Object[]) + */ + public ID makeID(Namespace n, String[] argTypes, Object[] args) throws IDInstantiationException { debug("makeID("+n+","+Trace.convertStringAToString(argTypes)+","+Trace.convertObjectAToString(args)+")"); // Verify namespace is non-null @@ -240,82 +225,35 @@ public class IDFactory { // Ask instantiator to actually create instance return instantiator.makeInstance(ns, clazzes, args); } - /** - * Make a new identity. Given a Namespace name, constructor argument - * types, and an array of arguments, return a new instance of an ID - * belonging to the given Namespace - * - * @param namespacename - * the name of the Namespace to which the ID belongs - * @param argTypes - * a String [] of the arg types for the ID instance constructor - * @param args - * an Object [] of the args for the ID instance constructor - * @exception IDInstantiationException - * thrown if class for instantiator or instance can't be - * loaded, if something goes wrong during instance - * construction - */ - public static final ID makeID(String namespacename, String[] argTypes, + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#makeID(java.lang.String, java.lang.String[], java.lang.Object[]) + */ + public ID makeID(String namespacename, String[] argTypes, Object[] args) throws IDInstantiationException { Namespace n = getNamespaceByName(namespacename); if (n == null) throw new IDInstantiationException("Namespace named "+namespacename+" not found"); return makeID(n, argTypes, args); } - /** - * Make a new identity. Given a Namespace, and an array of instance - * constructor arguments, return a new instance of an ID belonging to the - * given Namespace - * - * @param n - * the Namespace to which the ID will belong - * @param args - * an Object [] of the args for the ID instance constructor - * @exception Exception - * thrown if class for instantiator or instance can't be - * loaded, if something goes wrong during instance - * construction - */ - public static final ID makeID(Namespace n, Object[] args) + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#makeID(org.eclipse.ecf.core.identity.Namespace, java.lang.Object[]) + */ + public ID makeID(Namespace n, Object[] args) throws IDInstantiationException { return makeID(n, null, args); } - /** - * Make a new identity. Given a Namespace name, and an array of instance - * constructor arguments, return a new instance of an ID belonging to the - * given Namespace - * - * @param n - * the name of the Namespace to which the ID will belong - * @param args - * an Object [] of the args for the ID instance constructor - * @exception Exception - * thrown if class for instantiator or instance can't be - * loaded, if something goes wrong during instance - * construction - */ - public static final ID makeID(String namespacename, Object[] args) + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#makeID(java.lang.String, java.lang.Object[]) + */ + public ID makeID(String namespacename, Object[] args) throws IDInstantiationException { Namespace n = getNamespaceByName(namespacename); if (n == null) throw new IDInstantiationException("Namespace "+namespacename+" not found"); return makeID(n, args); } - /** - * Make a new identity instance from a URI. Returns a new instance of an - * ID belonging to the Namespace associated with the URI <b>scheme</b>. The URI scheme (e.g. http) - * is used to lookup the Namespace instance, and the entire URI is then passed to the - * IDInstantiator as a single item Object []. - * - * @param uri - * the URI to use to make ID. - * @param args - * an Object [] of the args for the ID instance constructor - * @exception Exception - * thrown if class for instantiator or iD instance can't be - * loaded, if something goes wrong during instance - * construction - */ - public static final ID makeID(URI uri) throws IDInstantiationException { + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#makeID(java.net.URI) + */ + public ID makeID(URI uri) throws IDInstantiationException { if (uri == null) throw new IDInstantiationException("Null uri not allowed"); String scheme = uri.getScheme(); Namespace n = getNamespaceByName(scheme); @@ -324,7 +262,10 @@ public class IDFactory { } - public static final ID makeStringID(String idstring) + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#makeStringID(java.lang.String) + */ + public ID makeStringID(String idstring) throws IDInstantiationException { if (idstring == null) throw new IDInstantiationException("String cannot be null"); Namespace n = new Namespace(StringID.class.getClassLoader(), @@ -333,31 +274,29 @@ public class IDFactory { return makeID(n, new String[] { String.class.getName() }, new Object[] { idstring }); } - public static final ID makeLongID(Long l) throws IDInstantiationException { + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#makeLongID(java.lang.Long) + */ + public ID makeLongID(Long l) throws IDInstantiationException { if (l == null) throw new IDInstantiationException("Long cannot be null"); Namespace n = new Namespace(LongID.class.getClassLoader(), LongID.LONGID_NAME, LongID.LONGID_INSTANTIATOR_CLASS, null); return makeID(n, new String[] { String.class.getName() }, new Object[] { l }); } - public static final ID makeLongID(long l) throws IDInstantiationException { + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#makeLongID(long) + */ + public ID makeLongID(long l) throws IDInstantiationException { Namespace n = new Namespace(LongID.class.getClassLoader(), LongID.LONGID_NAME, LongID.LONGID_INSTANTIATOR_CLASS, null); return makeID(n, new String[] { String.class.getName() }, new Object[] { new Long(l) }); } - /** - * Remove the given Namespace from our table of available Namespaces - * - * @param n - * the Namespace to remove - * @return Namespace the namespace already in table (null if Namespace not - * previously in table) - * @exception SecurityException - * thrown if caller does not have appropriate - * NamespacePermission for given namespace - */ - public final static Namespace removeNamespace(Namespace n) + /* (non-Javadoc) + * @see org.eclipse.ecf.core.identity.IIDFactory#removeNamespace(org.eclipse.ecf.core.identity.Namespace) + */ + public Namespace removeNamespace(Namespace n) throws SecurityException { debug("removeNamespace("+n+")"); if (n == null) diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IIDFactory.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IIDFactory.java new file mode 100644 index 000000000..6512c1a48 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IIDFactory.java @@ -0,0 +1,161 @@ +package org.eclipse.ecf.core.identity; + +import java.net.URI; +import java.util.List; + +public interface IIDFactory { + + /** + * Add the given Namespace to our table of available Namespaces + * + * @param n + * the Namespace to add + * @return Namespace the namespace already in table (null if Namespace not + * previously in table) + * @exception SecurityException + * thrown if caller does not have appropriate + * NamespacePermission for given namespace + */ + public Namespace addNamespace(Namespace n) throws SecurityException; + + /** + * Check whether table contains given Namespace instance + * + * @param n + * the Namespace to look for + * @return true if table does contain given Namespace, false otherwise + * @exception SecurityException + * thrown if caller does not have appropriate + * NamespacePermission for given namespace + */ + public boolean containsNamespace(Namespace n) throws SecurityException; + + public List getNamespaces(); + + /** + * Get the given Namespace instance from table + * + * @param n + * the Namespace to look for + * @return Namespace + * @exception SecurityException + * thrown if caller does not have appropriate + * NamespacePermission for given namespace + */ + public Namespace getNamespace(Namespace n) throws SecurityException; + + public Namespace getNamespaceByName(String name) throws SecurityException; + + public ID makeGUID() throws IDInstantiationException; + + public ID makeGUID(int length) throws IDInstantiationException; + + /** + * Make a new identity. Given a Namespace instance, constructor argument + * types, and an array of arguments, return a new instance of an ID + * belonging to the given Namespace + * + * @param n + * the Namespace to which the ID belongs + * @param argTypes + * a String [] of the arg types for the ID instance constructor + * @param args + * an Object [] of the args for the ID instance constructor + * @exception IDInstantiationException + * thrown if class for instantiator or instance can't be + * loaded, if something goes wrong during instance + * construction + */ + public ID makeID(Namespace n, String[] argTypes, Object[] args) + throws IDInstantiationException; + + /** + * Make a new identity. Given a Namespace name, constructor argument + * types, and an array of arguments, return a new instance of an ID + * belonging to the given Namespace + * + * @param namespacename + * the name of the Namespace to which the ID belongs + * @param argTypes + * a String [] of the arg types for the ID instance constructor + * @param args + * an Object [] of the args for the ID instance constructor + * @exception IDInstantiationException + * thrown if class for instantiator or instance can't be + * loaded, if something goes wrong during instance + * construction + */ + public ID makeID(String namespacename, String[] argTypes, Object[] args) + throws IDInstantiationException; + + /** + * Make a new identity. Given a Namespace, and an array of instance + * constructor arguments, return a new instance of an ID belonging to the + * given Namespace + * + * @param n + * the Namespace to which the ID will belong + * @param args + * an Object [] of the args for the ID instance constructor + * @exception Exception + * thrown if class for instantiator or instance can't be + * loaded, if something goes wrong during instance + * construction + */ + public ID makeID(Namespace n, Object[] args) + throws IDInstantiationException; + + /** + * Make a new identity. Given a Namespace name, and an array of instance + * constructor arguments, return a new instance of an ID belonging to the + * given Namespace + * + * @param n + * the name of the Namespace to which the ID will belong + * @param args + * an Object [] of the args for the ID instance constructor + * @exception Exception + * thrown if class for instantiator or instance can't be + * loaded, if something goes wrong during instance + * construction + */ + public ID makeID(String namespacename, Object[] args) + throws IDInstantiationException; + + /** + * Make a new identity instance from a URI. Returns a new instance of an + * ID belonging to the Namespace associated with the URI <b>scheme</b>. The URI scheme (e.g. http) + * is used to lookup the Namespace instance, and the entire URI is then passed to the + * IDInstantiator as a single item Object []. + * + * @param uri + * the URI to use to make ID. + * @param args + * an Object [] of the args for the ID instance constructor + * @exception Exception + * thrown if class for instantiator or iD instance can't be + * loaded, if something goes wrong during instance + * construction + */ + public ID makeID(URI uri) throws IDInstantiationException; + + public ID makeStringID(String idstring) throws IDInstantiationException; + + public ID makeLongID(Long l) throws IDInstantiationException; + + public ID makeLongID(long l) throws IDInstantiationException; + + /** + * Remove the given Namespace from our table of available Namespaces + * + * @param n + * the Namespace to remove + * @return Namespace the namespace already in table (null if Namespace not + * previously in table) + * @exception SecurityException + * thrown if caller does not have appropriate + * NamespacePermission for given namespace + */ + public Namespace removeNamespace(Namespace n) throws SecurityException; + +}
\ No newline at end of file diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/StringID.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/StringID.java index f8b6df7f8..cf35ecb2b 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/StringID.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/StringID.java @@ -99,7 +99,7 @@ public class StringID extends BaseID { } protected synchronized void setEmptyNamespace() { if (namespace == null) { - namespace = IDFactory.getNamespaceByName(StringID.class.getName()); + namespace = IDFactory.getDefault().getNamespaceByName(StringID.class.getName()); } } }
\ No newline at end of file diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java index 87a55126e..417e17a66 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java @@ -23,6 +23,7 @@ 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.ISharedObjectContainerFactory; import org.eclipse.ecf.core.SharedObjectContainerDescription; import org.eclipse.ecf.core.SharedObjectContainerFactory; import org.eclipse.ecf.core.comm.ConnectionDescription; @@ -216,7 +217,7 @@ public class ECFPlugin extends Plugin { description, defaults.getTypes(), defaults .getDefaults(), defaults.getNames(), properties); debug("setupContainerExtensionPoint:created description:" + scd); - SharedObjectContainerFactory factory = SharedObjectContainerFactory.getDefault(); + ISharedObjectContainerFactory factory = SharedObjectContainerFactory.getDefault(); if (factory.containsDescription(scd)) { throw new CoreException(getStatusForContException( extension, bundleName, name)); @@ -297,12 +298,12 @@ public class ECFPlugin extends Plugin { throw new CoreException(s); } debug("setupIdentityExtensionPoint:created namespace:" + ns); - if (IDFactory.containsNamespace(ns)) { + if (IDFactory.getDefault().containsNamespace(ns)) { throw new CoreException(getStatusForIDException(extension, bundleName, nsName)); } // Now add to known namespaces - IDFactory.addNamespace(ns); + IDFactory.getDefault().addNamespace(ns); debug("setupIdentityExtensionPoint:added namespace to factory:" + ns); } catch (CoreException e) { diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/ContainerInstantiator.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/ContainerInstantiator.java index 61fdd6aca..30a1d5b53 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/ContainerInstantiator.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/ContainerInstantiator.java @@ -28,13 +28,13 @@ public class ContainerInstantiator implements ISharedObjectContainerInstantiator if (arg instanceof String) { String val = (String) arg; if (val == null || val.equals("")) { - return IDFactory.makeGUID(); + return IDFactory.getDefault().makeGUID(); } else - return IDFactory.makeStringID((String) arg); + return IDFactory.getDefault().makeStringID((String) arg); } else if (arg instanceof Integer) { - return IDFactory.makeGUID(((Integer) arg).intValue()); + return IDFactory.getDefault().makeGUID(((Integer) arg).intValue()); } else - return IDFactory.makeGUID(); + return IDFactory.getDefault().makeGUID(); } protected Integer getIntegerFromArg(Class type, Object arg) diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java index 3e2039f09..ddcd7a10f 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java @@ -71,13 +71,13 @@ public class XMPPClientSOContainer extends ClientSOContainer { } public XMPPClientSOContainer(int ka) throws Exception { - super(new SOContainerConfig(IDFactory.makeGUID())); + super(new SOContainerConfig(IDFactory.getDefault().makeGUID())); keepAlive = ka; initializeSharedObject(); } public XMPPClientSOContainer(String userhost, int ka) throws Exception { - super(new SOContainerConfig(IDFactory.makeStringID(userhost))); + super(new SOContainerConfig(IDFactory.getDefault().makeStringID(userhost))); keepAlive = ka; initializeSharedObject(); } @@ -214,7 +214,7 @@ public class XMPPClientSOContainer extends ClientSOContainer { } protected void initializeSharedObject() throws Exception { - sharedObjectID = IDFactory.makeStringID(XMPP_SHARED_OBJECT_ID); + sharedObjectID = IDFactory.getDefault().makeStringID(XMPP_SHARED_OBJECT_ID); sharedObject = new XMPPPresenceSharedObject(); } diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPGroupChatSOContainer.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPGroupChatSOContainer.java index 0ac0fc4fb..20a6dc96c 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPGroupChatSOContainer.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPGroupChatSOContainer.java @@ -123,7 +123,7 @@ public class XMPPGroupChatSOContainer extends ClientSOContainer { } protected void initializeSharedObject() throws Exception { - sharedObjectID = IDFactory.makeStringID(XMPP_GROUP_CHAT_SHARED_OBJECT_ID); + sharedObjectID = IDFactory.getDefault().makeStringID(XMPP_GROUP_CHAT_SHARED_OBJECT_ID); sharedObject = new XMPPGroupChatSharedObject(); } diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPPresenceSharedObject.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPPresenceSharedObject.java index f91221559..f2b5d0de0 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPPresenceSharedObject.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPPresenceSharedObject.java @@ -331,7 +331,7 @@ public class XMPPPresenceSharedObject implements ISharedObject, IAccountManager protected ID makeIDFromName(String name) { ID result = null; try { - result = IDFactory.makeID(XMPPID.PROTOCOL, new Object[] { name }); + result = IDFactory.getDefault().makeID(XMPPID.PROTOCOL, new Object[] { name }); return result; } catch (Exception e) { dumpStack("Exception in makeIDFromName", e); diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/smack/ChatConnection.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/smack/ChatConnection.java index 629260560..93d731163 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/smack/ChatConnection.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/smack/ChatConnection.java @@ -174,7 +174,7 @@ public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender if (!isConnected()) return null; try { - return IDFactory.makeID(XMPPID.PROTOCOL, new Object[] { connection + return IDFactory.getDefault().makeID(XMPPID.PROTOCOL, new Object[] { connection .getConnectionID() }); } catch (Exception e) { logException("Exception in getLocalID", e); |
