Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2006-10-24 01:12:17 -0400
committerslewis2006-10-24 01:12:17 -0400
commitff38c999fa391a988ca2979fe54c0664a5a628be (patch)
tree411929bd91046e215136c1a248f4c3129ca5b92e
parent6dc7fa606bfc3ca479e865c535671371373dce13 (diff)
downloadorg.eclipse.ecf-ff38c999fa391a988ca2979fe54c0664a5a628be.tar.gz
org.eclipse.ecf-ff38c999fa391a988ca2979fe54c0664a5a628be.tar.xz
org.eclipse.ecf-ff38c999fa391a988ca2979fe54c0664a5a628be.zip
Initial checkin of new org.eclipse.ecf.core.identity plugin
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/.classpath7
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/.options15
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/.project28
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/META-INF/MANIFEST.MF12
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/build.properties8
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/plugin.xml5
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/schema/namespace.exsd187
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java81
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java135
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/ID.java69
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDCreateException.java31
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDFactory.java387
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IIDFactory.java293
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/LongID.java78
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java172
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/NamespacePermission.java53
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java125
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AbstractFactory.java33
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/Base64.java150
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/ECFException.java39
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/Trace.java509
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java240
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/IdentityDebugOptions.java25
23 files changed, 2682 insertions, 0 deletions
diff --git a/framework/bundles/org.eclipse.ecf.identity/.classpath b/framework/bundles/org.eclipse.ecf.identity/.classpath
new file mode 100644
index 000000000..751c8f2e5
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/.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.identity/.options b/framework/bundles/org.eclipse.ecf.identity/.options
new file mode 100644
index 000000000..a82aa7cb4
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/.options
@@ -0,0 +1,15 @@
+# Debugging options for the org.eclipse.ecf.identity plug-in
+
+# Turn on general debugging for the org.eclipse.ecf.identity plug-in
+org.eclipse.ecf.identity/debug=true
+
+# Trace when exceptions are caught
+org.eclipse.ecf.identity/debug/exceptions/catching=false
+# Trace when exceptions are thrown
+org.eclipse.ecf.identity/debug/exceptions/throwing=false
+
+# Trace when methods are entered
+org.eclipse.ecf.identity/debug/methods/entering=false
+# Trace when methods are exited
+org.eclipse.ecf.identity/debug/methods/exiting=false
+
diff --git a/framework/bundles/org.eclipse.ecf.identity/.project b/framework/bundles/org.eclipse.ecf.identity/.project
new file mode 100644
index 000000000..879d30b5d
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ecf.core.identity</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.identity/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.identity/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..f75101af3
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ECF Identity API
+Bundle-SymbolicName: org.eclipse.ecf.identity;singleton:=true
+Bundle-Version: 0.9.3
+Bundle-Activator: org.eclipse.ecf.internal.core.identity.Activator
+Bundle-Vendor: Eclipse.org
+Require-Bundle: org.eclipse.core.runtime
+Eclipse-LazyStart: true
+Export-Package: org.eclipse.ecf.core.identity,
+ org.eclipse.ecf.core.util
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/framework/bundles/org.eclipse.ecf.identity/build.properties b/framework/bundles/org.eclipse.ecf.identity/build.properties
new file mode 100644
index 000000000..825927a7f
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
+src.includes = plugin.xml,\
+ META-INF/,\
+ src/
diff --git a/framework/bundles/org.eclipse.ecf.identity/plugin.xml b/framework/bundles/org.eclipse.ecf.identity/plugin.xml
new file mode 100644
index 000000000..49a52ac4d
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/plugin.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="namespace" name="namespace" schema="schema/namespace.exsd"/>
+</plugin>
diff --git a/framework/bundles/org.eclipse.ecf.identity/schema/namespace.exsd b/framework/bundles/org.eclipse.ecf.identity/schema/namespace.exsd
new file mode 100644
index 000000000..2923072ee
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/schema/namespace.exsd
@@ -0,0 +1,187 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ecf.identity">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.ecf.identity" id="namespace" name="ECF Namespace"/>
+ </appInfo>
+ <documentation>
+ Extension point that allows other plugins to define new Namespaces. Namespaces are used by the IDFactory for creating new ID instances. Plugins may define extension Namespace implementation, which will then be used to construct ID instances within than Namespace when clients use the default ECF identity factory (accessed via org.eclipse.ecf.core.identity.IDFactory.getDefault()).
+&lt;p&gt;
+Plugins implementing this extension point must define a Namespace class that extends &lt;b&gt;org.eclipse.ecf.core.identity.Namespace&lt;/b&gt;. The class attribute of the namespace extension must provide a valid Namespace subclass. The name attribute defines the namespace name. If the name attribute is not present, then the Namespace class will be used as the Namespace name. The optional description attribute is an optional arbitrary description for the Namespace.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="namespace" 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="namespace">
+ <annotation>
+ <documentation>
+ Element allowing plugins to define new ECF Namespaces. Plugins wishing to define new Namespaces must provide an extension of this extension point.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ Optional name for new Namespace. If not provided, the name will be assumed to be the value provided by the &apos;class&apos; attribute for this extension point. Note that this name must &lt;b&gt;not&lt;/b&gt; conflict with any other Namespace name in the ECF IDFactory in order to be successfully registered. Care should therefore be taken in selection of a namespace name such that it does not conflict with other implementations.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ Required class for namespace. Note that the given class &lt;b&gt;must&lt;/b&gt; extend &lt;b&gt;org.eclipse.ecf.core.identity.Namespace&lt;/b&gt;.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="description" type="string">
+ <annotation>
+ <documentation>
+ An optional description for the Namespace extension
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 0.4.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ Here&apos;s an extension definition that associates an namespace class with namespace &apos;testid&apos;:
+
+&lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.ecf.identity.namespace&quot;&gt;
+ &lt;namespace name=&quot;testnamespace&quot; class=&quot;org.eclipse.ecf.test.FooNamespace&quot; description=&quot;my namespace implementation&quot;/&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+
+Here is some example code to implement this FooNamespace class:
+
+&lt;pre&gt;
+package org.eclipse.ecf.test;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDCreateException;
+import org.eclipse.ecf.core.identity.Namespace;
+
+public class FooNamespace extends
+ org.eclipse.ecf.core.identity.Namespace {
+
+ public ID createInstance(Class[] argTypes, Object[] args)
+ throws IDCreateException {
+ return new FooID((String) args[0]);
+ }
+}
+&lt;/pre&gt;
+
+In this example, the FooNamespace class implements the abstract &lt;b&gt;Namesapce&lt;/b&gt;.createInstance method by creating and returning a new instance of FooID, a class also defined by the extension plugin. This class must implement &lt;b&gt;ID&lt;/b&gt;, so that it can successfully be returned from the Namespace.createInstance call.
+
+&lt;h3&gt;Example Usage of IDFactory by Clients&lt;/h3&gt;
+
+Clients that wish to use the &apos;testnamespace&apos; Namespace implementation can do so simply by making the following call to create an &lt;b&gt;IDFactory&lt;/b&gt;:
+
+&lt;pre&gt;
+ID newID = IDFactory.getDefault().createID(&quot;testnamespace&quot;,&quot;email@emailserver.com&quot;);
+&lt;/pre&gt;
+Another example would be:
+&lt;pre&gt;
+ID newID = IDFactory.getDefault().createID(new URI(&quot;testnamespace:email@emailserver.com&quot;));
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The client API for this extension point is provided by the &lt;b&gt;org.eclipse.ecf.core.IIDFactory.createID&lt;/b&gt; methods. A valid IIDFactory is provided by the by the static &lt;b&gt;org.eclipse.ecf.core.identityIDFactory.getDefault()&lt;/b&gt; method.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ The following implementations of this extension point are provided by ECF itself:
+&lt;p&gt;
+StringID -- A namespace of ID instances that are implemented by &lt;b&gt;org.eclipse.ecf.core.identity.StringID&lt;/b&gt;
+&lt;p&gt;Clients may use this namespace with calls to:
+&lt;pre&gt;
+ID newID = org.eclipse.ecf.core.identity.IDFactory.createStringID(&apos;idstringvalue&apos;);
+&lt;/pre&gt;
+&lt;/p&gt;
+&lt;/p&gt;
+&lt;p&gt;
+LongID -- A namespace of ID instances that are implemented by &lt;b&gt;org.eclipse.ecf.core.identity.LongID&lt;/b&gt;
+&lt;p&gt;Clients may use this namespace with calls to:
+&lt;pre&gt;
+ID newID = org.eclipse.ecf.core.identity.IDFactory.createLongID(2004L);
+&lt;/pre&gt;
+&lt;/p&gt;
+&lt;/p&gt;
+&lt;p&gt;
+GUID -- A namespace of ID instances that are implemented by &lt;b&gt;org.eclipse.ecf.core.identity.GUID&lt;/b&gt;
+&lt;p&gt;Clients may use this namespace with calls to:
+&lt;pre&gt;
+ID newID = org.eclipse.ecf.core.identity.IDFactory.createGUID(16);
+&lt;/pre&gt;
+&lt;/p&gt;
+&lt;/p&gt;
+ </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.identity/src/org/eclipse/ecf/core/identity/BaseID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java
new file mode 100644
index 000000000..ee7c37c7b
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * 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.identity;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * Base class for ID implementation classes
+ *
+ * Plugin providers wishing to provide new Namespaces and ID implementations are
+ * recommended (but not required) to use this class as a super class for their
+ * ID implementation class
+ *
+ */
+public abstract class BaseID implements ID {
+ private static final long serialVersionUID = -6242599410460002514L;
+
+ Namespace namespace;
+
+ protected BaseID() {
+ }
+
+ protected BaseID(Namespace namespace) {
+ if (namespace == null)
+ throw new RuntimeException(new InstantiationException(
+ "namespace cannot be null"));
+ this.namespace = namespace;
+ }
+
+ public int compareTo(Object o) {
+ if (o == null || !(o instanceof BaseID))
+ throw new ClassCastException("incompatible types for compare");
+ return namespace.getCompareToForObject(this, (BaseID) o);
+ }
+
+ public boolean equals(Object o) {
+ if (o == null)
+ return false;
+ if (!(o instanceof BaseID)) {
+ return false;
+ }
+ return namespace.testIDEquals(this, (BaseID) o);
+ }
+
+ public String getName() {
+ return namespace.getNameForID(this);
+ }
+
+ public Namespace getNamespace() {
+ return namespace;
+ }
+
+ public int hashCode() {
+ return namespace.getHashCodeForID(this);
+ }
+
+ protected abstract int namespaceCompareTo(BaseID o);
+
+ protected abstract boolean namespaceEquals(BaseID o);
+
+ protected abstract String namespaceGetName();
+
+ protected abstract int namespaceHashCode();
+
+ protected abstract URI namespaceToURI() throws URISyntaxException;
+
+ public URI toURI() throws URISyntaxException {
+ return namespace.getURIForID(this);
+ }
+
+ public Object getAdapter(Class clazz) {
+ return null;
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java
new file mode 100644
index 000000000..a77ff0320
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * 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.identity;
+
+import java.security.SecureRandom;
+import java.security.Security;
+import java.util.Set;
+import org.eclipse.ecf.core.util.Base64;
+
+/**
+ * Globally unique ID implementation class. Uses
+ * {@link java.security.SecureRandom}to create a unique number of given byte
+ * length. Default byte length for secure number is 20 bytes. Default algorithm
+ * used for creating a SecureRandom instance is SHA1PRNG.
+ */
+public class GUID extends StringID {
+ private static final long serialVersionUID = 3545794369039972407L;
+
+ public static class GUIDNamespace extends Namespace {
+ private static final long serialVersionUID = -8546568877571886386L;
+
+ public GUIDNamespace() {
+ super(GUID.class.getName(), "GUID Namespace");
+ }
+
+ public ID createInstance(Class[] argTypes, Object[] args)
+ throws IDCreateException {
+ if (args.length == 1)
+ return new GUID(this, ((Integer) args[0]).intValue());
+ else
+ return new GUID(this);
+ }
+
+ public String getScheme() {
+ return GUID.class.getName();
+ }
+ }
+
+ public static final String SR_DEFAULT_ALGO = null;
+
+ public static final String SR_DEFAULT_PROVIDER = null;
+
+ public static final int DEFAULT_BYTE_LENGTH = 20;
+
+ // Class specific SecureRandom instance
+ protected static transient SecureRandom random;
+
+ /**
+ * Protected constructor for factory-based construction
+ *
+ * @param n
+ * the Namespace this identity will belong to
+ * @param provider
+ * the name of the algorithm to use. See {@link SecureRandom}
+ * @param byteLength
+ * the length of the target number (in bytes)
+ */
+ protected GUID(Namespace n, String algo, String provider, int byteLength)
+ throws IDCreateException {
+ super(n, "");
+ // Get SecureRandom instance for class
+ try {
+ getRandom(algo, provider);
+ } catch (Exception e) {
+ throw new IDCreateException("GUID creation failure: "
+ + e.getMessage());
+ }
+ // make sure we have reasonable byteLength
+ if (byteLength <= 0)
+ byteLength = 1;
+ byte[] newBytes = new byte[byteLength];
+ // Fill up random bytes
+ random.nextBytes(newBytes);
+ // Set value
+ value = Base64.encode(newBytes);
+ }
+
+ protected GUID(Namespace n, int byteLength) throws IDCreateException {
+ this(n, SR_DEFAULT_ALGO, SR_DEFAULT_PROVIDER, byteLength);
+ }
+
+ protected GUID(Namespace n) throws IDCreateException {
+ this(n, DEFAULT_BYTE_LENGTH);
+ }
+
+ /**
+ * Get SecureRandom instance for creation of random number.
+ *
+ * @param algo
+ * the String algorithm specification (e.g. "SHA1PRNG") for
+ * creation of the SecureRandom instance
+ * @param provider
+ * the provider of the implementation of the given algorighm
+ * (e.g. "SUN")
+ * @return SecureRandom
+ * @exception Exception
+ * thrown if SecureRandom instance cannot be created/accessed
+ */
+ protected static synchronized SecureRandom getRandom(String algo,
+ String provider) throws Exception {
+ // Given algo and provider, get SecureRandom instance
+ if (random == null) {
+ initializeRandom(algo, provider);
+ }
+ return random;
+ }
+
+ protected static synchronized void initializeRandom(String algo,
+ String provider) throws Exception {
+ if (provider == null) {
+ if (algo == null) {
+ Set algos = Security.getAlgorithms("SecureRandom");
+ if (algos.contains("IBMSECURERANDOM"))
+ algo = "IBMSECURERANDOM";
+ else
+ algo = "SHA1PRNG";
+ }
+ random = SecureRandom.getInstance(algo);
+ } else {
+ random = SecureRandom.getInstance(algo, provider);
+ }
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer("GUID[");
+ sb.append(value).append("]");
+ return sb.toString();
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/ID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/ID.java
new file mode 100644
index 000000000..9495f46e8
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/ID.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.identity;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * Contract for ECF identity
+ * <p>
+ * ECF IDs are immutable once constructed, and unique within the containing
+ * {@link Namespace}.
+ * <p>
+ * ID instances are created via the Namespace.createInstance(...) method. This
+ * method is called by the IDFactory.createID(...) methods for the given
+ * Namespace. So, for example, to create an ID instance with the name "slewis":
+ *
+ * <pre>
+ * ID id = IDFactory.getDefault().createID(namespace, &quot;slewis&quot;);
+ * </pre>
+ *
+ * <p>
+ *
+ * @see Namespace
+ *
+ */
+public interface ID extends java.io.Serializable, java.lang.Comparable,
+ java.security.Principal, IAdaptable {
+
+ public boolean equals(Object obj);
+
+ public int hashCode();
+
+ /**
+ * Get the unique name of this identity.
+ *
+ * @return String unique name for this identity. Must not be null, and must
+ * be a unique String within the Namespace returned by
+ * getNamespace()
+ */
+ public String getName();
+
+ /**
+ * Get the Namespace instance associated with this identity
+ *
+ * @return Namespace the Namespace corresponding to this identity. Must not
+ * return null.
+ */
+ public Namespace getNamespace();
+
+ /**
+ * If available, return this identity in URI form. If not available as URI,
+ * throw URISyntaxException
+ *
+ * @return URI the URI representation of this identity. Will not return
+ * null.
+ * @throws URISyntaxException
+ * if this ID cannot be converted to URI form
+ */
+ public URI toURI() throws URISyntaxException;
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDCreateException.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDCreateException.java
new file mode 100644
index 000000000..be68fa0e9
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDCreateException.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.identity;
+
+import org.eclipse.ecf.core.util.ECFException;
+
+public class IDCreateException extends ECFException {
+ private static final long serialVersionUID = 3258416140119323960L;
+
+ public IDCreateException() {
+ super();
+ }
+
+ public IDCreateException(String message) {
+ super(message);
+ }
+
+ public IDCreateException(Throwable cause) {
+ super(cause);
+ }
+
+ public IDCreateException(String message, Throwable cause) {
+ super(message, cause);
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDFactory.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDFactory.java
new file mode 100644
index 000000000..c1cd30969
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDFactory.java
@@ -0,0 +1,387 @@
+/*******************************************************************************
+ * 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.identity;
+
+import java.net.URI;
+import java.security.AccessController;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ecf.core.util.AbstractFactory;
+import org.eclipse.ecf.core.util.Trace;
+import org.eclipse.ecf.internal.core.identity.Activator;
+import org.eclipse.ecf.internal.core.identity.IdentityDebugOptions;
+
+/**
+ * A factory class for creating ID instances. This is the factory for plugins to
+ * manufacture ID instances.
+ *
+ */
+public class IDFactory implements IIDFactory {
+ public static final String SECURITY_PROPERTY = IDFactory.class.getName()
+ + ".security";
+
+ private static Hashtable namespaces = new Hashtable();
+
+ private static boolean securityEnabled = false;
+
+ protected static IIDFactory instance = null;
+
+ static {
+ instance = new IDFactory();
+ addNamespace0(new StringID.StringIDNamespace());
+ addNamespace0(new GUID.GUIDNamespace());
+ addNamespace0(new LongID.LongNamespace());
+ try {
+ securityEnabled = Boolean.valueOf(
+ System.getProperty(SECURITY_PROPERTY, "false"))
+ .booleanValue();
+ } catch (Exception e) {
+ Trace.catching(Activator.getDefault(),
+ IdentityDebugOptions.EXCEPTIONS_CATCHING, IDFactory.class,
+ "staticinitializer", e);
+ Activator.getDefault().getLog().log(
+ new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ "Exception reading SECURITY_PROPERTY", e));
+ }
+ }
+
+ protected IDFactory() {
+ }
+
+ public static IIDFactory getDefault() {
+ return instance;
+ }
+
+ protected boolean isInitialized = false;
+
+ protected synchronized void initialize() {
+ if (!isInitialized) {
+ Activator.getDefault().setupNamespaceExtensionPoint();
+ isInitialized = true;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#addNamespace(org.eclipse.ecf.core.identity.Namespace)
+ */
+ public Namespace addNamespace(Namespace namespace) throws SecurityException {
+ if (namespace == null)
+ return null;
+ Trace.entering(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_ENTERING, IDFactory.class,
+ "addNamespace", namespace);
+ checkPermission(new NamespacePermission(namespace.toString(),
+ NamespacePermission.ADD_NAMESPACE));
+ return addNamespace0(namespace);
+ }
+
+ protected final static Namespace addNamespace0(Namespace namespace) {
+ if (namespace == null)
+ return null;
+ return (Namespace) namespaces.put(namespace.getName(), namespace);
+ }
+
+ protected final static void checkPermission(
+ NamespacePermission namespacepermission) throws SecurityException {
+ if (securityEnabled)
+ AccessController.checkPermission(namespacepermission);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#containsNamespace(org.eclipse.ecf.core.identity.Namespace)
+ */
+ public boolean containsNamespace(Namespace namespace)
+ throws SecurityException {
+ Trace.entering(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_ENTERING, IDFactory.class,
+ "containsNamespace", namespace);
+ if (namespace == null)
+ return false;
+ checkPermission(new NamespacePermission(namespace.toString(),
+ NamespacePermission.CONTAINS_NAMESPACE));
+ return containsNamespace0(namespace);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#getNamespaces()
+ */
+ public List getNamespaces() {
+ initialize();
+ Trace.entering(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_ENTERING, IDFactory.class,
+ "getNamespaces");
+ return new ArrayList(namespaces.values());
+ }
+
+ protected final static boolean containsNamespace0(Namespace n) {
+ if (n == null)
+ return false;
+ return namespaces.containsKey(n.getName());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#getNamespace(org.eclipse.ecf.core.identity.Namespace)
+ */
+ public Namespace getNamespace(Namespace namespace) throws SecurityException {
+ initialize();
+ Trace.entering(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_ENTERING, IDFactory.class,
+ "getNamespace", namespace);
+ if (namespace == null)
+ return null;
+ checkPermission(new NamespacePermission(namespace.toString(),
+ NamespacePermission.GET_NAMESPACE));
+ return getNamespace0(namespace);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#getNamespaceByName(java.lang.String)
+ */
+ public Namespace getNamespaceByName(String name) throws SecurityException {
+ initialize();
+ Trace.entering(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_ENTERING, IDFactory.class,
+ "getNamespaceByName", name);
+ return getNamespace0(name);
+ }
+
+ protected final static Namespace getNamespace0(Namespace n) {
+ if (n == null)
+ return null;
+ return (Namespace) namespaces.get(n.getName());
+ }
+
+ protected final static Namespace getNamespace0(String name) {
+ if (name == null)
+ return null;
+ else
+ return (Namespace) namespaces.get(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#createGUID()
+ */
+ public ID createGUID() throws IDCreateException {
+ return createGUID(GUID.DEFAULT_BYTE_LENGTH);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#createGUID(int)
+ */
+ public ID createGUID(int length) throws IDCreateException {
+ Trace.entering(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_ENTERING, IDFactory.class,
+ "createGUID", new Integer(length));
+ Namespace namespace = new GUID.GUIDNamespace();
+ return createID(namespace, new String[] { Namespace.class.getName(),
+ Integer.class.getName() }, new Object[] { namespace,
+ new Integer(length) });
+ }
+
+ protected static void logAndThrow(String s, Throwable t)
+ throws IDCreateException {
+ IDCreateException e = null;
+ if (t != null) {
+ e = new IDCreateException(s + ": " + t.getClass().getName() + ": "
+ + t.getMessage());
+ e.setStackTrace(t.getStackTrace());
+ } else {
+ e = new IDCreateException(s);
+ }
+ Trace.catching(Activator.getDefault(),
+ IdentityDebugOptions.EXCEPTIONS_CATCHING, IDFactory.class,
+ "logAndThrow", e);
+ Activator.getDefault().getLog().log(
+ new Status(IStatus.ERROR, Activator.PLUGIN_ID, s, e));
+ throw e;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#createID(org.eclipse.ecf.core.identity.Namespace,
+ * java.lang.String[], java.lang.Object[])
+ */
+ public ID createID(Namespace n, String[] argTypes, Object[] args)
+ throws IDCreateException {
+ initialize();
+ Trace.entering(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_ENTERING, IDFactory.class,
+ "createID", new Object[] { n,
+ Trace.getArgumentsString(argTypes),
+ Trace.getArgumentsString(args) });
+ // Verify namespace is non-null
+ if (n == null)
+ logAndThrow("Namespace cannot be null", null);
+ // Make sure that namespace is in table of known namespace. If not,
+ // throw...we don't create any instances that we don't know about!
+ Namespace ns = getNamespace0(n);
+ if (ns == null)
+ logAndThrow("Namespace '" + n.getName() + "' not found", null);
+ // We're OK, go ahead and setup array of classes for call to
+ // instantiator
+ Class clazzes[] = null;
+ ClassLoader cl = ns.getClass().getClassLoader();
+ try {
+ clazzes = AbstractFactory.getClassesForTypes(argTypes, args, cl);
+ } catch (ClassNotFoundException e) {
+ logAndThrow("Exception in getClassesForTypes", e);
+ }
+ // Ask instantiator to actually create instance
+ ID result = ns.createInstance(clazzes, args);
+
+ Trace.exiting(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_ENTERING, IDFactory.class,
+ "createID", result);
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#createID(java.lang.String,
+ * java.lang.String[], java.lang.Object[])
+ */
+ public ID createID(String namespacename, String[] argTypes, Object[] args)
+ throws IDCreateException {
+ Namespace n = getNamespaceByName(namespacename);
+ if (n == null)
+ throw new IDCreateException("Namespace named " + namespacename
+ + " not found");
+ return createID(n, argTypes, args);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#createID(org.eclipse.ecf.core.identity.Namespace,
+ * java.lang.Object[])
+ */
+ public ID createID(Namespace n, Object[] args) throws IDCreateException {
+ return createID(n, null, args);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#createID(java.lang.String,
+ * java.lang.Object[])
+ */
+ public ID createID(String namespacename, Object[] args)
+ throws IDCreateException {
+ Namespace n = getNamespaceByName(namespacename);
+ if (n == null)
+ throw new IDCreateException("Namespace " + namespacename
+ + " not found");
+ return createID(n, args);
+ }
+
+ public ID createID(Namespace namespace, URI uri) throws IDCreateException {
+ return createID(namespace, new Object[] { uri });
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#createID(java.lang.String,
+ * java.net.URI)
+ */
+ public ID createID(String namespacename, URI uri) throws IDCreateException {
+ if (uri == null)
+ throw new IDCreateException("Null uri not allowed");
+ Namespace n = getNamespaceByName(namespacename);
+ if (n == null)
+ throw new IDCreateException("Namespace " + n + " not found");
+ return createID(n, new Object[] { uri });
+ }
+
+ public ID createID(Namespace namespace, String uri)
+ throws IDCreateException {
+ return createID(namespace, new Object[] { uri });
+ }
+
+ public ID createID(String namespace, String uri) throws IDCreateException {
+ return createID(namespace, new Object[] { uri });
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#createStringID(java.lang.String)
+ */
+ public ID createStringID(String idstring) throws IDCreateException {
+ if (idstring == null)
+ throw new IDCreateException("String cannot be null");
+ Namespace n = new StringID.StringIDNamespace();
+ return createID(n, new String[] { String.class.getName() },
+ new Object[] { idstring });
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#createLongID(java.lang.Long)
+ */
+ public ID createLongID(Long l) throws IDCreateException {
+ if (l == null)
+ throw new IDCreateException("Long cannot be null");
+ Namespace n = new LongID.LongNamespace();
+ return createID(n, new String[] { String.class.getName() },
+ new Object[] { l });
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#createLongID(long)
+ */
+ public ID createLongID(long l) throws IDCreateException {
+ Namespace n = new LongID.LongNamespace();
+ return createID(n, new String[] { String.class.getName() },
+ new Object[] { new Long(l) });
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.core.identity.IIDFactory#removeNamespace(org.eclipse.ecf.core.identity.Namespace)
+ */
+ public Namespace removeNamespace(Namespace n) throws SecurityException {
+ Trace.trace(Activator.getDefault(), "removeNamespace(" + n + ")");
+ if (n == null)
+ return null;
+ checkPermission(new NamespacePermission(n.toString(),
+ NamespacePermission.REMOVE_NAMESPACE));
+ return removeNamespace0(n);
+ }
+
+ protected final static Namespace removeNamespace0(Namespace n) {
+ if (n == null)
+ return null;
+ return (Namespace) namespaces.remove(n);
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IIDFactory.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IIDFactory.java
new file mode 100644
index 000000000..e7027d6e7
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IIDFactory.java
@@ -0,0 +1,293 @@
+/*******************************************************************************
+ * 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.identity;
+
+import java.net.URI;
+import java.util.List;
+
+/**
+ * Contract for {@link IDFactory}
+ *
+ */
+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;
+
+ /**
+ * Get a list of the current Namespace instances exposed by this factory.
+ *
+ * @return List<Namespace> of Namespace instances
+ * @exception SecurityException
+ * thrown if caller does not have appropriate
+ * NamespacePermission for given namespace
+ */
+ public List getNamespaces() throws SecurityException;
+
+ /**
+ * 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;
+
+ /**
+ * Get a Namespace instance by its string name.
+ *
+ * @param name
+ * the name to use for lookup
+ * @return Namespace instance. Null if not found.
+ * @exception SecurityException
+ * thrown if caller does not have appropriate
+ * NamespacePermission for given namespace
+ */
+ public Namespace getNamespaceByName(String name) throws SecurityException;
+
+ /**
+ * Make a GUID using SHA-1 hash algorithm and a default of 16bits of data
+ * length. The value is Base64 encoded to allow for easy display.
+ *
+ * @return new ID instance
+ * @throws IDCreateException
+ * if ID cannot be constructed
+ */
+ public ID createGUID() throws IDCreateException;
+
+ /**
+ * Make a GUID using SHA-1 hash algorithm and a default of 16bits of data
+ * length. The value is Base64 encoded to allow for easy display.
+ *
+ * @param length
+ * the byte-length of data used to create a GUID
+ * @return new ID instance
+ * @throws IDCreateException
+ * if ID cannot be constructed
+ */
+ public ID createGUID(int length) throws IDCreateException;
+
+ /**
+ * 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 IDCreateException
+ * thrown if class for instantiator or instance can't be
+ * loaded, if something goes wrong during instance
+ * construction
+ */
+ public ID createID(Namespace n, String[] argTypes, Object[] args)
+ throws IDCreateException;
+
+ /**
+ * 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 IDCreateException
+ * thrown if class for instantiator or instance can't be
+ * loaded, if something goes wrong during instance
+ * construction
+ */
+ public ID createID(String namespacename, String[] argTypes, Object[] args)
+ throws IDCreateException;
+
+ /**
+ * 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 IDCreateException
+ * thrown if class for instantiator or instance can't be
+ * loaded, if something goes wrong during instance
+ * construction
+ */
+ public ID createID(Namespace n, Object[] args) throws IDCreateException;
+
+ /**
+ * 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 namespacename
+ * the name of the Namespace to which the ID will belong
+ * @param args
+ * an Object [] of the args for the ID instance constructor
+ * @exception IDCreateException
+ * thrown if class for instantiator or ID instance can't be
+ * loaded, if something goes wrong during instance
+ * construction
+ */
+ public ID createID(String namespacename, Object[] args)
+ throws IDCreateException;
+
+ /**
+ * Make a new identity instance from a namespace and String.
+ *
+ * @param namespace
+ * the namespace to use to create the ID
+ * @param uri
+ * the String uri to use to create the ID
+ * @exception IDCreateException
+ * thrown if class for instantiator or ID instance can't be
+ * loaded, if something goes wrong during instance
+ * construction
+ */
+ public ID createID(Namespace namespace, String uri)
+ throws IDCreateException;
+
+ /**
+ * Make a new identity instance from a namespacename and URI. The
+ * namespacename is first used to lookup the namespace with
+ * getNamespaceByName(), and then the result is passed into
+ * createID(Namespace,String).
+ *
+ * @param namespacename
+ * the namespacename to use to create the ID
+ * @param uri
+ * the String uri to use to create the ID
+ * @exception IDCreateException
+ * thrown if class for instantiator or ID instance can't be
+ * loaded, if something goes wrong during instance
+ * construction
+ */
+ public ID createID(String namespacename, String uri)
+ throws IDCreateException;
+
+ /**
+ * Make a new identity instance from a namespace and URI.
+ *
+ * @param namespace
+ * the namespace to use to create the ID
+ * @param uri
+ * the URI to use to create ID.
+ * @exception IDCreateException
+ * thrown if class for instantiator or ID instance can't be
+ * loaded, if something goes wrong during instance
+ * construction
+ */
+ public ID createID(Namespace namespace, URI uri) throws IDCreateException;
+
+ /**
+ * Make a new identity instance from a namespace name and URI.
+ *
+ * @param namespacename
+ * the name of the namespace to use to create the ID
+ * @param uri
+ * the URI to use to create ID.
+ * @exception IDCreateException
+ * thrown if class for instantiator or ID instance can't be
+ * loaded, if something goes wrong during instance
+ * construction
+ */
+ public ID createID(String namespacename, URI uri) throws IDCreateException;
+
+ /**
+ * Make a an ID from a String
+ *
+ * @param idstring
+ * the String to use as this ID's unique value. Note: It is
+ * incumbent upon the caller of this method to be sure that the
+ * given string allows the resulting ID to satisfy the ID
+ * contract for global uniqueness within the associated
+ * Namespace.
+ *
+ * @return valid ID instance
+ * @throws IDCreateException
+ * thrown if class for instantiator or ID instance can't be
+ * loaded, if something goes wrong during instance construction
+ */
+ public ID createStringID(String idstring) throws IDCreateException;
+
+ /**
+ * Make a an ID from a Long
+ *
+ * @param l
+ * the Long to use as this ID's unique value. Note: It is
+ * incumbent upon the caller of this method to be sure that the
+ * given Long allows the resulting ID to satisfy the ID contract
+ * for global uniqueness within the associated Namespace.
+ *
+ * @return valid ID instance
+ * @throws IDCreateException
+ * thrown if class for instantiator or ID instance can't be
+ * loaded, if something goes wrong during instance construction
+ */
+ public ID createLongID(Long l) throws IDCreateException;
+
+ /**
+ * Make a an ID from a long
+ *
+ * @param l
+ * the long to use as this ID's unique value. Note: It is
+ * incumbent upon the caller of this method to be sure that the
+ * given long allows the resulting ID to satisfy the ID contract
+ * for global uniqueness within the associated Namespace.
+ *
+ * @return valid ID instance
+ * @throws IDCreateException
+ * thrown if class for instantiator or ID instance can't be
+ * loaded, if something goes wrong during instance construction
+ */
+ public ID createLongID(long l) throws IDCreateException;
+
+ /**
+ * 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.identity/src/org/eclipse/ecf/core/identity/LongID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/LongID.java
new file mode 100644
index 000000000..bdde2eb2a
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/LongID.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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.identity;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * A unique ID class based upon Long/long
+ *
+ */
+public class LongID extends BaseID {
+ private static final long serialVersionUID = 4049072748317914423L;
+
+ Long value = null;
+
+ public static class LongNamespace extends Namespace {
+ private static final long serialVersionUID = -1580533392719331665L;
+
+ public LongNamespace() {
+ super(LongID.class.getName(), "Long Namespace");
+ }
+
+ public ID createInstance(Class[] argTypes, Object[] args)
+ throws IDCreateException {
+ return new LongID(this, (Long) args[0]);
+ }
+
+ public String getScheme() {
+ return LongID.class.toString();
+ }
+ }
+
+ protected LongID(Namespace n, Long v) {
+ super(n);
+ value = v;
+ }
+
+ protected LongID(Namespace n, long v) {
+ super(n);
+ value = new Long(v);
+ }
+
+ protected int namespaceCompareTo(BaseID o) {
+ Long ovalue = ((LongID) o).value;
+ return value.compareTo(ovalue);
+ }
+
+ protected boolean namespaceEquals(BaseID o) {
+ if (!(o instanceof LongID))
+ return false;
+ LongID obj = (LongID) o;
+ return value.equals(obj.value);
+ }
+
+ protected String namespaceGetName() {
+ return value.toString();
+ }
+
+ protected int namespaceHashCode() {
+ return value.hashCode();
+ }
+
+ protected URI namespaceToURI() throws URISyntaxException {
+ throw new URISyntaxException(value.toString(),
+ "LongID instances cannot create URL values");
+ }
+
+ public long longValue() {
+ return value.longValue();
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java
new file mode 100644
index 000000000..f432e8ac2
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * 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.identity;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * Namespace base class
+ * <p>
+ * This class and subclasses define a namespace for the creation and management
+ * of ID instances. Creation of ID instances is accomplished via the
+ * {@link #createInstance(Class[], Object[])} method, implemented by subclasses
+ * of this Namespace superclass.
+ * <p>
+ * All Namespace instances must have a unique name passed to the Namespace upon
+ * construction.
+ * <p>
+ * Typically Namespace instances are created via plugins that define extensions
+ * of the org.eclipse.ecf.namespace extension point. For example, to define a
+ * new Namespace subclass XMPPNamespace with name "ecf.xmpp" and add it to the
+ * ECF extension registry:
+ *
+ * <pre>
+ * &lt;extension
+ * point=&quot;org.eclipse.ecf.namespace&quot;&gt;
+ * &lt;namespace
+ * class=&quot;XMPPNamespace&quot;
+ * name=&quot;ecf.xmpp&quot;/&gt;
+ * &lt;/extension&gt;
+ * </pre>
+ *
+ * @see ID
+ */
+public abstract class Namespace implements Serializable {
+ private static final long serialVersionUID = 3976740272094720312L;
+
+ private String name;
+
+ private String description;
+
+ private int hashCode;
+
+ private boolean isInitialized = false;
+
+ public Namespace() {
+ }
+
+ public final boolean initialize(String name, String desc) {
+ if (name == null)
+ throw new RuntimeException(new InstantiationException(
+ "Namespace<init> name cannot be null"));
+ if (!isInitialized) {
+ this.name = name;
+ this.description = desc;
+ this.hashCode = name.hashCode();
+ return true;
+ } else
+ return false;
+ }
+
+ public Namespace(String name, String desc) {
+ initialize(name, desc);
+ }
+
+ /**
+ * Override of Object.equals. This equals method returns true if the
+ * provided Object is also a Namespace instance, and the names of the two
+ * instances match.
+ *
+ * @param other
+ * the Object to test for equality
+ */
+ public boolean equals(Object other) {
+ if (!(other instanceof Namespace))
+ return false;
+ return ((Namespace) other).name.equals(name);
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+
+ protected boolean testIDEquals(BaseID first, BaseID second) {
+ // First check that namespaces are the same and non-null
+ Namespace sn = second.getNamespace();
+ if (sn == null || !this.equals(sn))
+ return false;
+ return first.namespaceEquals(second);
+ }
+
+ protected String getNameForID(BaseID id) {
+ return id.namespaceGetName();
+ }
+
+ protected URI getURIForID(BaseID id) throws URISyntaxException {
+ return id.namespaceToURI();
+ }
+
+ protected int getCompareToForObject(BaseID first, BaseID second) {
+ return first.namespaceCompareTo(second);
+ }
+
+ protected int getHashCodeForID(BaseID id) {
+ return id.namespaceHashCode();
+ }
+
+ /**
+ * Get the name of this namespace. May not return null.
+ *
+ * @return String name of Namespace instance
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get the description, associated with this Namespace. The returned value
+ * may be null.
+ *
+ * @return the description associated with this Namespace
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Make an instance of this namespace. Namespace subclasses, provided by
+ * plugins must implement this method to construct ID instances for the
+ * given namespace.
+ *
+ * @param argTypes
+ * a Class[] of classes defining the types of the args. May be
+ * null if no arguments given. The arity and classes provided
+ * must correspond to the types of the associated arguments
+ * @param args
+ * an Object[] of arguments for creating ID instances. May be
+ * null if no arguments provided
+ * @return a non-null ID instance. The class used may extend BaseID or may
+ * implement the ID interface directly
+ * @throws IDCreateException
+ * if construction fails
+ */
+ public abstract ID createInstance(Class[] argTypes, Object[] args)
+ throws IDCreateException;
+
+ /**
+ * Get the URI scheme associated with this namespace instance. For example,
+ * a namespace with name "ecf.http" would have an associated scheme
+ * identifier of "http". Subclasses must provide an implementation that
+ * returns a valid non-null scheme identifier.
+ *
+ * @return a String scheme identifier
+ */
+ public abstract String getScheme();
+
+ public String toString() {
+ StringBuffer b = new StringBuffer("Namespace[");
+ b.append("name=").append(name).append(";");
+ b.append("scheme=").append(getScheme()).append(";");
+ b.append("description=").append("]");
+ return b.toString();
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/NamespacePermission.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/NamespacePermission.java
new file mode 100644
index 000000000..35f4a34c6
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/NamespacePermission.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.identity;
+
+import java.security.BasicPermission;
+import java.security.Permission;
+
+public class NamespacePermission extends BasicPermission {
+ private static final long serialVersionUID = 3257004371500806969L;
+
+ public static final String ADD_NAMESPACE = "add";
+
+ public static final String ALL_NAMESPACE = "all";
+
+ public static final String CONTAINS_NAMESPACE = "contains";
+
+ public static final String GET_NAMESPACE = "get";
+
+ public static final String REMOVE_NAMESPACE = "remove";
+
+ protected String actions;
+
+ public NamespacePermission(String s) {
+ super(s);
+ }
+
+ public NamespacePermission(String s, String s1) {
+ super(s, s1);
+ actions = s1;
+ }
+
+ public String getActions() {
+ return actions;
+ }
+
+ public boolean implies(Permission p) {
+ if ((p == null) || (p.getClass() != getClass()))
+ return false;
+ NamespacePermission np = (NamespacePermission) p;
+ String act = getActions();
+ if (act == null)
+ return false;
+ if (act.equals(ALL_NAMESPACE) || act.equals(np.getActions()))
+ return true;
+ return false;
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java
new file mode 100644
index 000000000..b547c3e75
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * 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.identity;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * A string-based identity
+ *
+ */
+public class StringID extends BaseID {
+ private static final long serialVersionUID = 3256437019155446068L;
+
+ public static class StringIDNamespace extends Namespace {
+ private static final long serialVersionUID = 7924280015192029963L;
+
+ public StringIDNamespace(String name, String desc) {
+ super(name, desc);
+ }
+
+ public StringIDNamespace() {
+ super(StringID.class.getName(), "String Namespace");
+ }
+
+ public ID createInstance(Class[] argTypes, Object[] args)
+ throws IDCreateException {
+ return new StringID(this, (String) args[0]);
+ }
+
+ public String getScheme() {
+ return StringID.class.getName();
+ }
+ }
+
+ protected String value;
+
+ /**
+ * Protected constructor for factory-based construction
+ *
+ * @param n
+ * the Namespace this identity will belong to
+ * @param s
+ * the String defining this StringID
+ */
+ protected StringID(Namespace n, String s) {
+ super(n);
+ value = s;
+ setEmptyNamespace();
+ }
+
+ public int compareTo(Object o) {
+ setEmptyNamespace();
+ return super.compareTo(o);
+ }
+
+ public boolean equals(Object o) {
+ setEmptyNamespace();
+ return super.equals(o);
+ }
+
+ public String getName() {
+ setEmptyNamespace();
+ return super.getName();
+ }
+
+ public int hashCode() {
+ setEmptyNamespace();
+ return super.hashCode();
+ }
+
+ public Namespace getNamespace() {
+ setEmptyNamespace();
+ return namespace;
+ }
+
+ public String toString() {
+ setEmptyNamespace();
+ int strlen = value.length();
+ StringBuffer sb = new StringBuffer(strlen + 10);
+ sb.insert(0, "StringID[").insert(9, value).insert(strlen + 9, ']');
+ return sb.toString();
+ }
+
+ public URI toURI() throws URISyntaxException {
+ setEmptyNamespace();
+ return super.toURI();
+ }
+
+ protected int namespaceCompareTo(BaseID obj) {
+ return getName().compareTo(obj.getName());
+ }
+
+ protected boolean namespaceEquals(BaseID obj) {
+ if (!(obj instanceof StringID))
+ return false;
+ StringID o = (StringID) obj;
+ return value.equals(o.getName());
+ }
+
+ protected String namespaceGetName() {
+ return value;
+ }
+
+ protected int namespaceHashCode() {
+ return value.hashCode() ^ getClass().hashCode();
+ }
+
+ protected URI namespaceToURI() throws URISyntaxException {
+ return new URI(getName());
+ }
+
+ protected synchronized void setEmptyNamespace() {
+ if (namespace == null) {
+ namespace = IDFactory.getDefault().getNamespaceByName(
+ StringID.class.getName());
+ }
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AbstractFactory.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AbstractFactory.java
new file mode 100644
index 000000000..3d6de9753
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AbstractFactory.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.util;
+
+public class AbstractFactory {
+ public static Class[] getClassesForTypes(String[] argTypes, Object[] args,
+ ClassLoader cl) throws ClassNotFoundException {
+ Class clazzes[] = null;
+ if (args == null || args.length == 0)
+ clazzes = new Class[0];
+ else if (argTypes != null) {
+ clazzes = new Class[argTypes.length];
+ for (int i = 0; i < argTypes.length; i++) {
+ clazzes[i] = Class.forName(argTypes[i], true, cl);
+ }
+ } else {
+ clazzes = new Class[args.length];
+ for (int i = 0; i < args.length; i++) {
+ if (args[i] == null)
+ clazzes[i] = null;
+ else
+ clazzes[i] = args[i].getClass();
+ }
+ }
+ return clazzes;
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/Base64.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/Base64.java
new file mode 100644
index 000000000..338501bbb
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/Base64.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * 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.util;
+
+/**
+ *
+ * Encode/decode byte arrays into base64 strings. Code originally acquired from
+ * ftp://ftp.ora.com/pub/examples/java/crypto/files/oreilly/jonathan/util/
+ *
+ * Several small modifications were made: the '_' character was substituted for
+ * the '/' character, the '-' char substituted for the '=' char, and the '.'
+ * substituted for the '+' char so that the resulting string does not use any of
+ * the reserved characters in the URI reserved character set as described in
+ * RFC2396. See ftp://ftp.isi.edu/in-notes/rfc2396.txt for details.
+ *
+ */
+public final class Base64 {
+ /**
+ * Encode a byte array into a String
+ *
+ * @param raw
+ * the raw data to encode
+ * @return String that is base64 encoded
+ */
+ public static String encode(byte[] raw) {
+ if (raw == null)
+ throw new NumberFormatException("Input data cannot be null");
+ StringBuffer encoded = new StringBuffer();
+ for (int i = 0; i < raw.length; i += 3) {
+ encoded.append(encodeBlock(raw, i));
+ }
+ return encoded.toString();
+ }
+
+ protected static char[] encodeBlock(byte[] raw, int offset) {
+ int block = 0;
+ int slack = raw.length - offset - 1;
+ int end = (slack >= 2) ? 2 : slack;
+ for (int i = 0; i <= end; i++) {
+ byte b = raw[offset + i];
+ int neuter = (b < 0) ? b + 256 : b;
+ block += neuter << (8 * (2 - i));
+ }
+ char[] base64 = new char[4];
+ for (int i = 0; i < 4; i++) {
+ int sixbit = (block >>> (6 * (3 - i))) & 0x3f;
+ base64[i] = getChar(sixbit);
+ }
+ // modify to use '-' instead of '='
+ if (slack < 1)
+ base64[2] = '-';
+ if (slack < 2)
+ base64[3] = '-';
+ return base64;
+ }
+
+ protected static char getChar(int sixBit) {
+ if (sixBit >= 0 && sixBit <= 25)
+ return (char) ('A' + sixBit);
+ if (sixBit >= 26 && sixBit <= 51)
+ return (char) ('a' + (sixBit - 26));
+ if (sixBit >= 52 && sixBit <= 61)
+ return (char) ('0' + (sixBit - 52));
+ if (sixBit == 62)
+ return '.';
+ // modify to use '_' instead of '/'
+ if (sixBit == 63)
+ return '_';
+ return '?';
+ }
+
+ /**
+ * Decode base64 string into a byte array.
+ *
+ * @param base64
+ * the base64 encoded string
+ * @return byte[] the resulting decoded data array
+ * @exception NumberFormatException
+ * thrown if String not in base64 format.
+ */
+ public static byte[] decode(String base64) throws NumberFormatException {
+ int pad = 0;
+ for (int i = base64.length() - 1; base64.charAt(i) == '-'; i--)
+ pad++;
+ int length = base64.length() * 6 / 8 - pad;
+ byte[] raw = new byte[length];
+ int rawIndex = 0;
+ for (int i = 0; i < base64.length(); i += 4) {
+ int block = (getValue(base64.charAt(i)) << 18)
+ + (getValue(base64.charAt(i + 1)) << 12)
+ + (getValue(base64.charAt(i + 2)) << 6)
+ + (getValue(base64.charAt(i + 3)));
+ for (int j = 0; j < 3 && rawIndex + j < raw.length; j++)
+ raw[rawIndex + j] = (byte) ((block >> (8 * (2 - j))) & 0xff);
+ rawIndex += 3;
+ }
+ return raw;
+ }
+
+ protected static int getValue(char c) throws NumberFormatException {
+ if (c >= 'A' && c <= 'Z')
+ return c - 'A';
+ if (c >= 'a' && c <= 'z')
+ return c - 'a' + 26;
+ if (c >= '0' && c <= '9')
+ return c - '0' + 52;
+ if (c == '.')
+ return 62;
+ // modify to use '_' instead of '/'
+ if (c == '_')
+ return 63;
+ // modify to use '-' instead of '='
+ if (c == '-')
+ return 0;
+ throw new NumberFormatException("Invalid value '" + c
+ + "' in base64 string");
+ }
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting Base64 test program.");
+ int byteLength = 16;
+ java.security.SecureRandom ar = new java.security.SecureRandom();
+ byte[] buf = new byte[byteLength];
+ ar.nextBytes(buf);
+ System.out.println("Secure random bytes are:");
+ for (int i = 0; i < buf.length; i++)
+ System.out.print(buf[i] + " ");
+ System.out.println();
+ System.out.println("Converting secure random number to Base64...");
+ String res = Base64.encode(buf);
+ System.out.println("Converted string is: ");
+ System.out.println(res);
+ byte[] buf2 = new byte[byteLength];
+ System.out.println("Converting string back to byte array...");
+ buf2 = Base64.decode(res);
+ System.out.println("Converted byte array as: ");
+ for (int i = 0; i < buf2.length; i++)
+ System.out.print(buf2[i] + " ");
+ System.out.println();
+ System.out.println("Trying to decode a bogus string...");
+ buf2 = Base64.decode("ADDFDSFasdfasdf%$###");
+ System.out.println("Done.");
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/ECFException.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/ECFException.java
new file mode 100644
index 000000000..32a7256fd
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/ECFException.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.util;
+
+public class ECFException extends Exception {
+ private static final long serialVersionUID = 3256440309134406707L;
+
+ public ECFException() {
+ super();
+ }
+
+ /**
+ * @param message
+ */
+ public ECFException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public ECFException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public ECFException(String message, Throwable cause) {
+ super(message, cause);
+ }
+} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/Trace.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/Trace.java
new file mode 100644
index 000000000..723dd284f
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/Trace.java
@@ -0,0 +1,509 @@
+package org.eclipse.ecf.core.util;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+
+/**
+ * A utility for tracing debug information. Provides a simple interface for
+ * filtering and generating trace output.
+ *
+ */
+public class Trace {
+
+ /**
+ * private constructor for the static class.
+ */
+ private Trace() {
+ super();
+ }
+
+ /**
+ * String containing an open parenthesis.
+ *
+ */
+ protected static final String PARENTHESIS_OPEN = "("; //$NON-NLS-1$
+
+ /**
+ * String containing a close parenthesis.
+ *
+ */
+ protected static final String PARENTHESIS_CLOSE = ")"; //$NON-NLS-1$
+
+ /**
+ * String containing TRACE
+ *
+ */
+ protected static final String TRACE_STR = "TRACE"; //$NON-NLS-1$
+
+ /**
+ * Prefix for tracing the changing of values.
+ *
+ */
+ protected static final String PREFIX_CHANGING = "CHANGING "; //$NON-NLS-1$
+
+ /**
+ * Prefix for tracing the catching of throwables.
+ *
+ */
+ protected static final String PREFIX_CATCHING = "CAUGHT "; //$NON-NLS-1$
+
+ /**
+ * Prefix for tracing the throwing of throwables.
+ *
+ */
+ protected static final String PREFIX_THROWING = "THROWN "; //$NON-NLS-1$
+
+ /**
+ * Prefix for tracing the entering of methods.
+ *
+ */
+ protected static final String PREFIX_ENTERING = "ENTERING "; //$NON-NLS-1$
+
+ /**
+ * Prefix for tracing the exiting of methods.
+ *
+ */
+ protected static final String PREFIX_EXITING = "EXITING "; //$NON-NLS-1$
+
+ /**
+ * Separator for methods.
+ *
+ */
+ protected static final String SEPARATOR_METHOD = "#"; //$NON-NLS-1$
+
+ /**
+ * Separator for parameters.
+ *
+ */
+ protected static final String SEPARATOR_PARAMETER = ", "; //$NON-NLS-1$
+
+ /**
+ * Separator for return values.
+ *
+ */
+ protected static final String SEPARATOR_RETURN = ":"; //$NON-NLS-1$
+
+ /**
+ * Separator containing a space.
+ *
+ */
+ protected static final String SEPARATOR_SPACE = " "; //$NON-NLS-1$
+
+ /**
+ * Label indicating old value.
+ *
+ */
+ protected static final String LABEL_OLD_VALUE = "old="; //$NON-NLS-1$
+
+ /**
+ * Label indicating new value.
+ *
+ */
+ protected static final String LABEL_NEW_VALUE = "new="; //$NON-NLS-1$
+
+ /**
+ * The cached debug options (for optimization).
+ */
+ private static final Map cachedOptions = new HashMap();
+
+ /**
+ * Retrieves a Boolean value indicating whether tracing is enabled for the
+ * specified plug-in.
+ *
+ * @return Whether tracing is enabled for the plug-in.
+ * @param plugin
+ * The plug-in for which to determine trace enablement.
+ *
+ */
+ protected static boolean shouldTrace(Plugin plugin) {
+ return plugin.isDebugging();
+ }
+
+ /**
+ * Retrieves a Boolean value indicating whether tracing is enabled for the
+ * specified debug option of the specified plug-in.
+ *
+ * @return Whether tracing is enabled for the debug option of the plug-in.
+ * @param plugin
+ * The plug-in for which to determine trace enablement.
+ * @param option
+ * The debug option for which to determine trace enablement.
+ *
+ */
+ public static boolean shouldTrace(Plugin plugin, String option) {
+ if (shouldTrace(plugin)) {
+ Boolean value = null;
+
+ synchronized (cachedOptions) {
+ value = (Boolean) cachedOptions.get(option);
+
+ if (null == value) {
+ value = Boolean.valueOf(Platform.getDebugOption(option));
+
+ cachedOptions.put(option, value);
+ }
+ }
+
+ return value.booleanValue();
+ }
+
+ return false;
+ }
+
+ /**
+ * Retrieves a textual representation of the specified argument.
+ *
+ * @return A textual representation of the specified argument.
+ * @param argument
+ * The argument for which to retrieve a textual representation.
+ *
+ */
+ public static String getArgumentString(Object argument) {
+ if (argument.getClass().isArray()) return getArgumentsString((Object []) argument);
+ else return String.valueOf(argument);
+ }
+
+ /**
+ * Retrieves a textual representation of the specified arguments.
+ *
+ * @return A textual representation of the specified arguments.
+ * @param arguments
+ * The arguments for which to retrieve a textual representation.
+ *
+ */
+ public static String getArgumentsString(Object[] arguments) {
+ if (arguments == null) return "";
+ StringBuffer buffer = new StringBuffer("[");
+
+ for (int i = 0; i < arguments.length; i++) {
+ buffer.append(getArgumentString(arguments[i]));
+
+ if (i < arguments.length - 1) {
+ buffer.append(SEPARATOR_PARAMETER);
+ }
+ }
+ buffer.append("]");
+ return buffer.toString();
+ }
+
+ /**
+ * Traces the specified message.
+ *
+ * @param message
+ * The message to be traced.
+ *
+ */
+ protected static void trace(String message) {
+ StringBuffer buf = new StringBuffer(PARENTHESIS_OPEN);
+ buf.append(TRACE_STR).append(PARENTHESIS_CLOSE).append(getTimeString())
+ .append(message).append(SEPARATOR_SPACE);
+ System.out.println(buf.toString());
+ }
+
+ /**
+ * Get date and time string
+ *
+ * @return String with current date and time
+ */
+ protected static String getTimeString() {
+ Date d = new Date();
+ SimpleDateFormat df = new SimpleDateFormat("[MM/dd/yy;HH:mm:ss:SSS]");
+ return df.format(d);
+ }
+
+ /**
+ * Traces the specified message from the specified plug-in.
+ *
+ * @param plugin
+ * The plug-in from which to trace.
+ * @param message
+ * The message to be traced.
+ *
+ */
+ public static void trace(Plugin plugin, String message) {
+ if (shouldTrace(plugin))
+ trace(message);
+ }
+
+ /**
+ * Traces the specified message from the specified plug-in for the specified
+ * debug option.
+ *
+ * @param plugin
+ * The plug-in from which to trace.
+ * @param option
+ * The debug option for which to trace.
+ * @param message
+ * The message to be traced.
+ *
+ */
+ public static void trace(Plugin plugin, String option, String message) {
+ if (shouldTrace(plugin, option))
+ trace(message);
+ }
+
+ /**
+ * Traces the changing of a value.
+ *
+ * @param plugin
+ * The plug-in from which to trace.
+ * @param option
+ * The debug option for which to trace.
+ * @param valueDescription
+ * The description of the value which is changing.
+ * @param oldValue
+ * The old value.
+ * @param newValue
+ * The new value.
+ */
+ public static void changing(Plugin plugin, String option,
+ String valueDescription, Object oldValue, Object newValue) {
+
+ if (shouldTrace(plugin, option)) {
+ StringBuffer buf = new StringBuffer(PREFIX_CHANGING);
+ buf.append(valueDescription).append(SEPARATOR_SPACE).append(
+ LABEL_OLD_VALUE).append(getArgumentString(oldValue));
+ buf.append(SEPARATOR_PARAMETER).append(LABEL_NEW_VALUE).append(
+ getArgumentString(newValue));
+ trace(buf.toString());
+ }
+ }
+
+ /**
+ *
+ * @param plugin
+ * The plug-in from which to trace.
+ * @param option
+ * The debug option for which to trace.
+ * @param clazz
+ * The class in which the value is changing.
+ * @param methodName
+ * The name of the method in which the value is changing.
+ * @param valueDescription
+ * The description of the value which is changing.
+ * @param oldValue
+ * The old value.
+ * @param newValue
+ * The new value.
+ */
+ public static void changing(Plugin plugin, String option, Class clazz,
+ String methodName, String valueDescription, Object oldValue,
+ Object newValue) {
+ if (shouldTrace(plugin, option)) {
+ StringBuffer buf = new StringBuffer(PREFIX_CHANGING);
+ buf.append(valueDescription).append(SEPARATOR_SPACE).append(
+ LABEL_OLD_VALUE).append(getArgumentString(oldValue));
+ buf.append(SEPARATOR_PARAMETER).append(LABEL_NEW_VALUE).append(
+ getArgumentString(newValue));
+ buf.append(SEPARATOR_SPACE).append(PARENTHESIS_OPEN).append(
+ clazz.getName()).append(SEPARATOR_METHOD);
+ buf.append(methodName).append(PARENTHESIS_CLOSE);
+ trace(buf.toString());
+ }
+ }
+
+ /**
+ * Traces the catching of the specified throwable in the specified method of
+ * the specified class.
+ *
+ * @param plugin
+ * The plug-in from which to trace.
+ * @param option
+ * The debug option for which to trace.
+ * @param clazz
+ * The class in which the throwable is being caught.
+ * @param methodName
+ * The name of the method in which the throwable is being caught.
+ * @param throwable
+ * The throwable that is being caught.
+ *
+ */
+ public static void catching(Plugin plugin, String option, Class clazz,
+ String methodName, Throwable throwable) {
+
+ if (shouldTrace(plugin, option)) {
+ StringBuffer buf = new StringBuffer(PREFIX_CATCHING);
+ buf.append(throwable.getMessage()).append(SEPARATOR_SPACE);
+ buf.append(PARENTHESIS_OPEN).append(clazz.getName()).append(
+ SEPARATOR_METHOD);
+ buf.append(methodName).append(PARENTHESIS_CLOSE);
+ trace(buf.toString());
+ throwable.printStackTrace(System.err);
+ }
+ }
+
+ /**
+ * Traces the throwing of the specified throwable from the specified method
+ * of the specified class.
+ *
+ * @param plugin
+ * The plug-in from which to trace.
+ * @param option
+ * The debug option for which to trace.
+ * @param clazz
+ * The class from which the throwable is being thrown.
+ * @param methodName
+ * The name of the method from which the throwable is being
+ * thrown.
+ * @param throwable
+ * The throwable that is being thrown.
+ *
+ */
+ public static void throwing(Plugin plugin, String option, Class clazz,
+ String methodName, Throwable throwable) {
+
+ if (shouldTrace(plugin, option)) {
+ StringBuffer buf = new StringBuffer(PREFIX_THROWING);
+ buf.append(throwable.getMessage()).append(SEPARATOR_SPACE);
+ buf.append(PARENTHESIS_OPEN).append(clazz.getName()).append(
+ SEPARATOR_METHOD);
+ buf.append(methodName).append(PARENTHESIS_CLOSE);
+ trace(buf.toString());
+ throwable.printStackTrace(System.err);
+ }
+ }
+
+ /**
+ * Traces the entering into the specified method of the specified class.
+ *
+ * @param plugin
+ * The plug-in from which to trace.
+ * @param option
+ * The debug option for which to trace.
+ * @param clazz
+ * The class whose method is being entered.
+ * @param methodName
+ * The name of method that is being entered.
+ *
+ */
+ public static void entering(Plugin plugin, String option, Class clazz,
+ String methodName) {
+
+ if (shouldTrace(plugin, option)) {
+ StringBuffer buf = new StringBuffer(PREFIX_ENTERING).append(clazz
+ .getName());
+ buf.append(SEPARATOR_METHOD).append(methodName);
+ trace(buf.toString());
+ }
+ }
+
+ /**
+ * Traces the entering into the specified method of the specified class,
+ * with the specified parameter.
+ *
+ * @param plugin
+ * The plug-in from which to trace.
+ * @param option
+ * The debug option for which to trace.
+ * @param clazz
+ * The class whose method is being entered.
+ * @param methodName
+ * The name of method that is being entered.
+ * @param parameter
+ * The parameter to the method being entered.
+ *
+ */
+ public static void entering(Plugin plugin, String option, Class clazz,
+ String methodName, Object parameter) {
+
+ if (shouldTrace(plugin, option)) {
+ StringBuffer buf = new StringBuffer(PREFIX_ENTERING).append(clazz
+ .getName());
+ buf.append(SEPARATOR_METHOD).append(methodName);
+ buf.append(PARENTHESIS_OPEN).append(getArgumentString(parameter))
+ .append(PARENTHESIS_CLOSE);
+ trace(buf.toString());
+ }
+
+ }
+
+ /**
+ * Traces the entering into the specified method of the specified class,
+ * with the specified parameters.
+ *
+ * @param plugin
+ * The plug-in from which to trace.
+ * @param option
+ * The debug option for which to trace.
+ * @param clazz
+ * The class whose method is being entered.
+ * @param methodName
+ * The name of method that is being entered.
+ * @param parameters
+ * The parameters to the method being entered.
+ *
+ */
+ public static void entering(Plugin plugin, String option, Class clazz,
+ String methodName, Object[] parameters) {
+
+ if (shouldTrace(plugin, option)) {
+ StringBuffer buf = new StringBuffer(PREFIX_ENTERING).append(clazz
+ .getName());
+ buf.append(SEPARATOR_METHOD).append(methodName);
+ buf.append(PARENTHESIS_OPEN).append(getArgumentString(parameters))
+ .append(PARENTHESIS_CLOSE);
+ trace(buf.toString());
+ }
+
+ }
+
+ /**
+ * Traces the exiting from the specified method of the specified class.
+ *
+ * @param plugin
+ * The plug-in from which to trace.
+ * @param option
+ * The debug option for which to trace.
+ * @param clazz
+ * The class whose method is being exited.
+ * @param methodName
+ * The name of method that is being exited.
+ *
+ */
+ public static void exiting(Plugin plugin, String option, Class clazz,
+ String methodName) {
+
+ if (shouldTrace(plugin, option)) {
+ StringBuffer buf = new StringBuffer(PREFIX_EXITING).append(clazz
+ .getName());
+ buf.append(SEPARATOR_METHOD).append(methodName);
+ trace(buf.toString());
+ }
+ }
+
+ /**
+ * Traces the exiting from the specified method of the specified class, with
+ * the specified return value.
+ *
+ * @param plugin
+ * The plug-in from which to trace.
+ * @param option
+ * The debug option for which to trace.
+ * @param clazz
+ * The class whose method is being exited.
+ * @param methodName
+ * The name of method that is being exited.
+ * @param returnValue
+ * The return value of the method being exited.
+ *
+ */
+ public static void exiting(Plugin plugin, String option, Class clazz,
+ String methodName, Object returnValue) {
+
+ if (shouldTrace(plugin, option)) {
+ StringBuffer buf = new StringBuffer(PREFIX_EXITING).append(clazz
+ .getName());
+ buf.append(SEPARATOR_METHOD).append(methodName);
+ buf.append(PARENTHESIS_OPEN).append(getArgumentString(returnValue))
+ .append(PARENTHESIS_CLOSE);
+ trace(buf.toString());
+ }
+
+ }
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java
new file mode 100644
index 000000000..0e66c9f64
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java
@@ -0,0 +1,240 @@
+/*******************************************************************************
+ * 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.identity;
+
+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.identity.IDFactory;
+import org.eclipse.ecf.core.identity.IIDFactory;
+import org.eclipse.ecf.core.identity.Namespace;
+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.identity";
+
+ protected static final String NAMESPACE_NAME = "namespace";
+
+ protected static final String NAMESPACE_EPOINT = PLUGIN_ID + "." + NAMESPACE_NAME;
+
+ protected static final String NAME_ATTRIBUTE = "name";
+
+ protected static final String CLASS_ATTRIBUTE = "class";
+
+ protected static final int REMOVE_NAMESPACE_ERRORCODE = 100;
+
+ protected static final int FACTORY_NAME_COLLISION_ERRORCODE = 200;
+
+ protected static final String DESCRIPTION_ATTRIBUTE = "description";
+
+ // 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;
+ this.registryManager = new IdentityRegistryManager();
+ Platform.getExtensionRegistry().addRegistryChangeListener(
+ registryManager);
+ Trace.exiting(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_ENTERING, Activator.class,
+ "start");
+ }
+
+ protected class IdentityRegistryManager 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:
+ addNamespaceExtensions(delta[i].getExtension()
+ .getConfigurationElements());
+ break;
+ case IExtensionDelta.REMOVED:
+ removeNamespaceExtensions(delta[i].getExtension()
+ .getConfigurationElements());
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Remove extensions for identity namespace extension point
+ *
+ * @param members
+ * the members to remove
+ */
+ protected void removeNamespaceExtensions(IConfigurationElement[] members) {
+ org.eclipse.ecf.core.util.Trace.entering(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_ENTERING, Activator.class,
+ "removeNamespaceExtensions", members);
+ for (int m = 0; m < members.length; m++) {
+ IConfigurationElement member = members[m];
+ String name = null;
+ try {
+ name = member.getAttribute(NAME_ATTRIBUTE);
+ if (name == null) {
+ name = member.getAttribute(CLASS_ATTRIBUTE);
+ }
+ if (name == null)
+ continue;
+ IIDFactory factory = IDFactory.getDefault();
+ Namespace n = factory.getNamespaceByName(name);
+ if (n == null || !factory.containsNamespace(n)) {
+ continue;
+ }
+ // remove
+ factory.removeNamespace(n);
+ org.eclipse.ecf.core.util.Trace
+ .trace(Activator.getDefault(),
+ IdentityDebugOptions.DEBUG,
+ "removeNamespaceExtensions.removedNamespace("
+ + n + ")");
+ } catch (Exception e) {
+ org.eclipse.ecf.core.util.Trace.catching(Activator.getDefault(),
+ IdentityDebugOptions.EXCEPTIONS_CATCHING,
+ Activator.class, "removeNamespaceExtensions", e);
+ getDefault().getLog().log(
+ new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REMOVE_NAMESPACE_ERRORCODE,
+ "Exception removing namespace", e));
+ }
+ }
+ org.eclipse.ecf.core.util.Trace.exiting(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_EXITING, Activator.class,
+ "removeNamespaceExtensions", members);
+ }
+
+ /**
+ * Add identity namespace extension point extensions
+ *
+ * @param members
+ * the members to add
+ */
+ protected void addNamespaceExtensions(IConfigurationElement[] members) {
+ org.eclipse.ecf.core.util.Trace.entering(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_ENTERING, Activator.class,
+ "addNamespaceExtensions", members);
+ String bundleName = getDefault().getBundle().getSymbolicName();
+ 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();
+ String nsName = null;
+ try {
+ Namespace ns = (Namespace) member
+ .createExecutableExtension(CLASS_ATTRIBUTE);
+ String clazz = ns.getClass().getName();
+ nsName = member.getAttribute(NAME_ATTRIBUTE);
+ if (nsName == null) {
+ nsName = clazz;
+ }
+ String nsDescription = member
+ .getAttribute(DESCRIPTION_ATTRIBUTE);
+ ns.initialize(nsName, nsDescription);
+ org.eclipse.ecf.core.util.Trace.trace(Activator.getDefault(), IdentityDebugOptions.DEBUG,
+ "addNamespaceExtensions.createdNamespace(" + ns + ")");
+ // Check to see if we have a namespace name collision
+ if (IDFactory.getDefault().containsNamespace(ns))
+ throw new CoreException(new Status(Status.ERROR, bundleName,
+ FACTORY_NAME_COLLISION_ERRORCODE, "name=" + nsName
+ + ";extension point id="
+ + extension.getExtensionPointUniqueIdentifier(), null));
+ // Now add to known namespaces
+ IDFactory.getDefault().addNamespace(ns);
+ org.eclipse.ecf.core.util.Trace.trace(Activator.getDefault(), IdentityDebugOptions.DEBUG,
+ "addNamespaceExtensions.addedNamespaceToFactory("+ns+")");
+ } catch (CoreException e) {
+ getDefault().getLog().log(e.getStatus());
+ org.eclipse.ecf.core.util.Trace.catching(Activator.getDefault(),
+ IdentityDebugOptions.EXCEPTIONS_CATCHING,
+ Activator.class, "addNamespaceExtensions", e);
+ } catch (Exception e) {
+ getDefault().getLog().log(
+ new Status(Status.ERROR, bundleName,
+ FACTORY_NAME_COLLISION_ERRORCODE, "name=" + nsName
+ + ";extension point id="
+ + extension.getExtensionPointUniqueIdentifier(), null));
+ org.eclipse.ecf.core.util.Trace.catching(Activator.getDefault(),
+ IdentityDebugOptions.EXCEPTIONS_CATCHING,
+ Activator.class, "addNamespaceExtensions", e);
+ }
+ }
+ org.eclipse.ecf.core.util.Trace.exiting(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_EXITING, Activator.class,
+ "addNamespaceExtensions");
+ }
+
+ /**
+ * Setup identity namespace extension point
+ *
+ */
+ public void setupNamespaceExtensionPoint() {
+ // Process extension points
+ IExtensionRegistry reg = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = reg
+ .getExtensionPoint(NAMESPACE_EPOINT);
+ if (extensionPoint == null) {
+ return;
+ }
+ addNamespaceExtensions(extensionPoint.getConfigurationElements());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ Trace.entering(Activator.getDefault(),
+ IdentityDebugOptions.METHODS_EXITING, Activator.class, "stop");
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/IdentityDebugOptions.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/IdentityDebugOptions.java
new file mode 100644
index 000000000..197c985b6
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/IdentityDebugOptions.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.identity;
+
+public interface IdentityDebugOptions {
+
+ 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