Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'providers')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc/plugin.xml2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Activator.java2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java3
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCNamespace.java57
4 files changed, 38 insertions, 26 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/plugin.xml b/providers/bundles/org.eclipse.ecf.provider.irc/plugin.xml
index c777b2b66..6ddde06ba 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc/plugin.xml
+++ b/providers/bundles/org.eclipse.ecf.provider.irc/plugin.xml
@@ -14,7 +14,7 @@
point="org.eclipse.ecf.identity.namespace">
<namespace
class="org.eclipse.ecf.internal.provider.irc.identity.IRCNamespace"
- name="ecfircid"/>
+ name="ecf.irc.irclib"/>
</extension>
</plugin>
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Activator.java b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Activator.java
index 44a89650d..8a1cf91cb 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Activator.java
+++ b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Activator.java
@@ -23,8 +23,6 @@ import org.osgi.util.tracker.ServiceTracker;
*/
public class Activator implements BundleActivator {
- public static final String NAMESPACE_IDENTIFIER = "ecfircid"; //$NON-NLS-1$
-
public static final String PLUGIN_ID = "org.eclipse.ecf.provider.irc"; //$NON-NLS-1$
//The shared instance.
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java
index 7e056fe75..d5cac0ec4 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java
@@ -21,6 +21,7 @@ import org.eclipse.ecf.core.util.TimeoutException;
import org.eclipse.ecf.internal.provider.irc.Activator;
import org.eclipse.ecf.internal.provider.irc.Messages;
import org.eclipse.ecf.internal.provider.irc.identity.IRCID;
+import org.eclipse.ecf.internal.provider.irc.identity.IRCNamespace;
import org.eclipse.ecf.presence.chatroom.*;
import org.eclipse.ecf.presence.history.IHistory;
import org.eclipse.ecf.presence.history.IHistoryManager;
@@ -322,7 +323,7 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
* @see org.eclipse.ecf.core.IContainer#getConnectNamespace()
*/
public Namespace getConnectNamespace() {
- return IDFactory.getDefault().getNamespaceByName(Activator.NAMESPACE_IDENTIFIER);
+ return IDFactory.getDefault().getNamespaceByName(IRCNamespace.IRC_SCHEME);
}
public IChatRoomInfo getChatRoomInfo(final String roomName) {
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCNamespace.java b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCNamespace.java
index 222a84f9a..24f2fd667 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCNamespace.java
+++ b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCNamespace.java
@@ -12,8 +12,7 @@ package org.eclipse.ecf.internal.provider.irc.identity;
import java.net.URI;
import java.net.URISyntaxException;
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.identity.IDCreateException;
+import org.eclipse.ecf.core.identity.*;
import org.eclipse.ecf.internal.provider.irc.Messages;
import org.eclipse.osgi.util.NLS;
@@ -23,30 +22,44 @@ public class IRCNamespace extends org.eclipse.ecf.core.identity.Namespace {
public static final String IRC_PROTOCOL = "irc"; //$NON-NLS-1$
+ public static final String IRC_SCHEME = "ecf.irc.irclib"; //$NON-NLS-1$
+
+ public static final String IRCNAMESPACE_NAME = IRC_SCHEME;
+
private String getProtocolPrefix() {
- return getScheme() + "://"; //$NON-NLS-1$
+ return IRC_PROTOCOL + "://"; //$NON-NLS-1$
}
- public ID createInstance(Object[] args) throws IDCreateException {
- URI newURI = null;
- String s = null;
- try {
- s = (String) args[0];
- } catch (ClassCastException e) {
- throw new IDCreateException(NLS.bind(Messages.IRCNamespace_EXCEPTION_CREATE_CANNOT_CAST_TO_STRING, args[0]));
+ private String getInitFromExternalForm(Object[] args) {
+ if (args == null || args.length < 1 || args[0] == null)
+ return null;
+ if (args[0] instanceof String) {
+ String arg = (String) args[0];
+ if (arg.startsWith(getScheme() + Namespace.SCHEME_SEPARATOR)) {
+ int index = arg.indexOf(Namespace.SCHEME_SEPARATOR);
+ if (index >= arg.length())
+ return null;
+ return arg.substring(index + 1);
+ }
}
- if (!s.startsWith(getProtocolPrefix()))
- s = getProtocolPrefix() + s;
+ return null;
+ }
+
+ public ID createInstance(Object[] args) throws IDCreateException {
try {
- newURI = createURI(s);
- } catch (URISyntaxException e) {
- throw new IDCreateException(NLS.bind(Messages.IRCNamespace_EXCEPTION_CREATING_URI, s));
- }
- String uriScheme = newURI.getScheme();
- if (uriScheme == null || !uriScheme.equalsIgnoreCase(getScheme())) {
- throw new IDCreateException(NLS.bind(Messages.IRCNamespace_EXCEPTION_INVALID_PROTOCOL, newURI, IRC_PROTOCOL));
+ String init = getInitFromExternalForm(args);
+ String s = (init == null) ? (String) args[0] : init;
+ if (!s.startsWith(getProtocolPrefix()))
+ s = getProtocolPrefix() + s;
+ URI newURI = createURI(s);
+ String uriScheme = newURI.getScheme();
+ if (uriScheme == null || !uriScheme.equalsIgnoreCase(IRC_PROTOCOL)) {
+ throw new IDCreateException(NLS.bind(Messages.IRCNamespace_EXCEPTION_INVALID_PROTOCOL, newURI, IRC_PROTOCOL));
+ }
+ return new IRCID(this, newURI);
+ } catch (Exception e) {
+ throw new IDCreateException(NLS.bind("{0} createInstance()", getName()), e); //$NON-NLS-1$
}
- return new IRCID(this, newURI);
}
private URI createURI(String s) throws IDCreateException, URISyntaxException {
@@ -66,13 +79,13 @@ public class IRCNamespace extends org.eclipse.ecf.core.identity.Namespace {
}
String path = s.substring(hostend, s.length());
- ret = new URI(getScheme(), uname, host, port, path, null, null);
+ ret = new URI(IRC_PROTOCOL, uname, host, port, path, null, null);
return ret;
}
public String getScheme() {
- return IRC_PROTOCOL;
+ return IRC_SCHEME;
}
/*

Back to the top