Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2005-06-18 21:30:09 +0000
committerslewis2005-06-18 21:30:09 +0000
commit371ac3d2a78a9f2159166cb685f4a3ae57d06c00 (patch)
tree7fc9c0c21d4f912a665b7cb7d612d16a2544d489
parenta6f86f4ab4c67c5acfc8047c52900d96ad566026 (diff)
downloadorg.eclipse.ecf-371ac3d2a78a9f2159166cb685f4a3ae57d06c00.tar.gz
org.eclipse.ecf-371ac3d2a78a9f2159166cb685f4a3ae57d06c00.tar.xz
org.eclipse.ecf-371ac3d2a78a9f2159166cb685f4a3ae57d06c00.zip
Added static factory method to IDFactory: IDFactory.makeID(URI uri). This constructs an ID instance from a URI. The URI *scheme* (e.g. getScheme()) is used to lookup an associated Namespace instance (e.g. http -> http Namespace).
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/BaseID.java4
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java66
2 files changed, 62 insertions, 8 deletions
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/BaseID.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/BaseID.java
index 30eebe1cc..6ad864aa6 100644
--- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/BaseID.java
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/BaseID.java
@@ -17,8 +17,8 @@ public abstract class BaseID implements ID {
Namespace namespace;
protected BaseID() {}
-
- protected BaseID(Namespace namespace) {
+
+ protected BaseID(Namespace namespace) {
if (namespace == null)
throw new RuntimeException(new InstantiationException(
"namespace cannot be null"));
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 9195cbe36..46d067d8d 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
@@ -9,6 +9,7 @@
package org.eclipse.ecf.core.identity;
+import java.net.URI;
import java.security.AccessController;
import java.util.ArrayList;
import java.util.Hashtable;
@@ -190,20 +191,20 @@ public class IDFactory {
throw e;
}
/**
- * Make a new identity. Given a classloader, Namespace, constructor argument
+ * 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 will belong
+ * 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 Exception
+ * @exception IDInstantiationException
* thrown if class for instantiator or instance can't be
* loaded, if something goes wrong during instance
- * construction or if instance cannot be created
+ * construction
*/
public static final ID makeID(Namespace n, String[] argTypes, Object[] args)
throws IDInstantiationException {
@@ -239,6 +240,22 @@ 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,
Object[] args) throws IDInstantiationException {
Namespace n = getNamespaceByName(namespacename);
@@ -257,19 +274,56 @@ public class IDFactory {
* @exception Exception
* thrown if class for instantiator or instance can't be
* loaded, if something goes wrong during instance
- * construction or if instance cannot be created
+ * construction
*/
public static final 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)
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 {
+ if (uri == null) throw new IDInstantiationException("Null uri not allowed");
+ String scheme = uri.getScheme();
+ Namespace n = getNamespaceByName(scheme);
+ if (n == null) throw new IDInstantiationException("Namespace "+scheme+" not found");
+ return makeID(n,new Object[] { uri });
+ }
+
+
public static final ID makeStringID(String idstring)
throws IDInstantiationException {
if (idstring == null) throw new IDInstantiationException("String cannot be null");

Back to the top