diff options
| author | slewis | 2004-12-23 07:00:44 +0000 |
|---|---|---|
| committer | slewis | 2004-12-23 07:00:44 +0000 |
| commit | 7f4e552382196909221a386a682e67a570b941ca (patch) | |
| tree | 7ffeb8fa9ff9c1539780afb2ce03c9bdf7c08695 | |
| parent | 2a6059ec67e295577c82230a9da0e8bc2fe1af06 (diff) | |
| download | org.eclipse.ecf-7f4e552382196909221a386a682e67a570b941ca.tar.gz org.eclipse.ecf-7f4e552382196909221a386a682e67a570b941ca.tar.xz org.eclipse.ecf-7f4e552382196909221a386a682e67a570b941ca.zip | |
Renamed AsynchConnectionDescription to ConnectionDescription and AsynchConnectionFactory to ConnectionFactory
| -rw-r--r-- | framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/AsynchConnectionFactory.java | 140 | ||||
| -rw-r--r-- | framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/ConnectionDescription.java (renamed from framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/AsynchConnectionDescription.java) | 10 | ||||
| -rw-r--r-- | framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/ConnectionFactory.java | 114 | ||||
| -rw-r--r-- | framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/IAsynchConnectionInstantiator.java | 3 |
4 files changed, 120 insertions, 147 deletions
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/AsynchConnectionFactory.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/AsynchConnectionFactory.java deleted file mode 100644 index cb7d52b3d..000000000 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/AsynchConnectionFactory.java +++ /dev/null @@ -1,140 +0,0 @@ -package org.eclipse.ecf.internal.comm; - -import java.util.Hashtable; - -import org.eclipse.ecf.core.util.AbstractFactory; - -public class AsynchConnectionFactory { - - private static Hashtable connectiontypes = new Hashtable(); - - static { - /* - AsynchConnectionDescription cdtcp = - new AsynchConnectionDescription( - TCPReliableConnection.class.getName(), - "1.0.0", - TCPReliableConnection.Creator.class.getName()); - addDescription(cdtcp); - - AsynchConnectionDescription cdjms = - new AsynchConnectionDescription( - JMSClientReliableConnection.class.getName(), - "1.0.0", - JMSClientReliableConnection.Creator.class.getName()); - addDescription(cdjms); - - - AsynchConnectionDescription cdxmpp = - new AsynchConnectionDescription( - SmackConnection.class.getName(), - "1.0.0", - SmackConnection.Creator.class.getName()); - addDescription(cdxmpp); - */ - } - - public final static AsynchConnectionDescription getDescription(AsynchConnectionDescription scd) { - return getDescription0(scd); - } - protected static AsynchConnectionDescription getDescription0(AsynchConnectionDescription scd) { - if (scd == null) - return null; - return (AsynchConnectionDescription) connectiontypes.get(scd.getName()); - } - protected static AsynchConnectionDescription getDescription0(String name) { - if (name == null) - return null; - return (AsynchConnectionDescription) connectiontypes.get(name); - } - public final static AsynchConnectionDescription getDescriptionByName(String name) { - return getDescription0(name); - } - public final static AsynchConnectionDescription removeDescription(AsynchConnectionDescription scd) { - return removeDescription0(scd); - } - - protected static AsynchConnectionDescription removeDescription0(AsynchConnectionDescription n) { - if (n == null) - return null; - return (AsynchConnectionDescription) connectiontypes.remove(n.getName()); - } - public final static AsynchConnectionDescription addDescription(AsynchConnectionDescription scd) { - return addDescription0(scd); - } - - protected static AsynchConnectionDescription addDescription0(AsynchConnectionDescription n) { - if (n == null) - return null; - return (AsynchConnectionDescription) connectiontypes.put(n.getName(), n); - } - public final static boolean containsDescription(AsynchConnectionDescription scd) { - return containsDescription0(scd); - } - protected static boolean containsDescription0(AsynchConnectionDescription scd) { - if (scd == null) - return false; - return connectiontypes.containsKey(scd.getName()); - } - - public static IAsynchConnection makeAsynchConnection(AsynchConnectionDescription desc, - String[] argTypes, - Object[] args) - throws ConnectionInstantiationException { - - if (desc == null) - throw new ConnectionInstantiationException("AsynchConnectionDescription cannot be null"); - AsynchConnectionDescription cd = getDescription0(desc); - if (cd == null) - throw new ConnectionInstantiationException( - "AsynchConnectionDescription " + desc.getName() + " not found"); - IAsynchConnectionInstantiator instantiator = null; - Class clazzes[] = null; - try { - instantiator = (IAsynchConnectionInstantiator) cd.getInstantiator(); - clazzes = AbstractFactory.getClassesForTypes(argTypes, args, cd.getClassLoader()); - if (instantiator == null) - throw new InstantiationException( - "Instantiator for AsynchConnectionDescription " - + cd.getName() - + " is null"); - } catch (Exception e) { - throw new ConnectionInstantiationException("Exception getting instantiator for '"+desc.getName()+"'",e); - } - // Ask instantiator to actually create instance - return instantiator.makeInstance(clazzes, args); - } - public static IAsynchConnection makeAsynchConnection( - AsynchConnectionDescription desc, - Object[] args) - throws ConnectionInstantiationException { - return makeAsynchConnection(desc, null, args); - } - public static IAsynchConnection makeAsynchConnection( - String descriptionName, - Object[] args) - throws ConnectionInstantiationException { - return makeAsynchConnection( - getDescriptionByName(descriptionName), - args); - } - public static IAsynchConnection makeAsynchConnection( - String descriptionName, - String[] argTypes, - Object[] args) - throws ConnectionInstantiationException { - return makeAsynchConnection( - getDescriptionByName(descriptionName), - argTypes, - args); - } - public static IAsynchConnection makeAsynchConnection( - String descriptionName) - throws ConnectionInstantiationException { - return makeAsynchConnection( - getDescriptionByName(descriptionName), - null, - null); - } - -} diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/AsynchConnectionDescription.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/ConnectionDescription.java index e4f64edc9..f24d9690d 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/AsynchConnectionDescription.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/ConnectionDescription.java @@ -1,6 +1,6 @@ package org.eclipse.ecf.internal.comm; -public class AsynchConnectionDescription { +public class ConnectionDescription { protected String name; protected String instantiatorClass; @@ -9,7 +9,7 @@ public class AsynchConnectionDescription { protected int hashCode = 0; protected ClassLoader classLoader = null; - public AsynchConnectionDescription(ClassLoader loader, + public ConnectionDescription(ClassLoader loader, String name, String instantiatorClass) { if (name == null) @@ -20,7 +20,7 @@ public class AsynchConnectionDescription { this.instantiatorClass = instantiatorClass; this.hashCode = name.hashCode(); } - public AsynchConnectionDescription(String name, + public ConnectionDescription(String name, IAsynchConnectionInstantiator inst) { this.instantiator = inst; this.classLoader = this.instantiator.getClass().getClassLoader(); @@ -34,9 +34,9 @@ public class AsynchConnectionDescription { return classLoader; } public boolean equals(Object other) { - if (!(other instanceof AsynchConnectionDescription)) + if (!(other instanceof ConnectionDescription)) return false; - AsynchConnectionDescription scd = (AsynchConnectionDescription) other; + ConnectionDescription scd = (ConnectionDescription) other; return scd.name.equals(name); } diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/ConnectionFactory.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/ConnectionFactory.java new file mode 100644 index 000000000..92903d97f --- /dev/null +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/ConnectionFactory.java @@ -0,0 +1,114 @@ +package org.eclipse.ecf.internal.comm; + +import java.util.Hashtable; + +import org.eclipse.ecf.core.util.AbstractFactory; + +public class ConnectionFactory { + + private static Hashtable connectiontypes = new Hashtable(); + + public final static ConnectionDescription getDescription(ConnectionDescription scd) { + return getDescription0(scd); + } + protected static ConnectionDescription getDescription0(ConnectionDescription scd) { + if (scd == null) + return null; + return (ConnectionDescription) connectiontypes.get(scd.getName()); + } + protected static ConnectionDescription getDescription0(String name) { + if (name == null) + return null; + return (ConnectionDescription) connectiontypes.get(name); + } + public final static ConnectionDescription getDescriptionByName(String name) { + return getDescription0(name); + } + public final static ConnectionDescription removeDescription(ConnectionDescription scd) { + return removeDescription0(scd); + } + + protected static ConnectionDescription removeDescription0(ConnectionDescription n) { + if (n == null) + return null; + return (ConnectionDescription) connectiontypes.remove(n.getName()); + } + public final static ConnectionDescription addDescription(ConnectionDescription scd) { + return addDescription0(scd); + } + + protected static ConnectionDescription addDescription0(ConnectionDescription n) { + if (n == null) + return null; + return (ConnectionDescription) connectiontypes.put(n.getName(), n); + } + public final static boolean containsDescription(ConnectionDescription scd) { + return containsDescription0(scd); + } + protected static boolean containsDescription0(ConnectionDescription scd) { + if (scd == null) + return false; + return connectiontypes.containsKey(scd.getName()); + } + + public static ISynchAsynchConnection makeSynchAsynchConnection(ConnectionDescription desc, + String[] argTypes, + Object[] args) + throws ConnectionInstantiationException { + + if (desc == null) + throw new ConnectionInstantiationException("AsynchConnectionDescription cannot be null"); + ConnectionDescription cd = getDescription0(desc); + if (cd == null) + throw new ConnectionInstantiationException( + "AsynchConnectionDescription " + desc.getName() + " not found"); + IAsynchConnectionInstantiator instantiator = null; + Class clazzes[] = null; + try { + instantiator = (IAsynchConnectionInstantiator) cd.getInstantiator(); + clazzes = AbstractFactory.getClassesForTypes(argTypes, args, cd.getClassLoader()); + if (instantiator == null) + throw new InstantiationException( + "Instantiator for AsynchConnectionDescription " + + cd.getName() + + " is null"); + } catch (Exception e) { + throw new ConnectionInstantiationException("Exception getting instantiator for '"+desc.getName()+"'",e); + } + // Ask instantiator to actually create instance + return instantiator.makeInstance(clazzes, args); + } + public static ISynchAsynchConnection makeSynchAsynchConnection( + ConnectionDescription desc, + Object[] args) + throws ConnectionInstantiationException { + return makeSynchAsynchConnection(desc, null, args); + } + public static ISynchAsynchConnection makeSynchAsynchConnection( + String descriptionName, + Object[] args) + throws ConnectionInstantiationException { + return makeSynchAsynchConnection( + getDescriptionByName(descriptionName), + args); + } + public static ISynchAsynchConnection makeAsynchConnection( + String descriptionName, + String[] argTypes, + Object[] args) + throws ConnectionInstantiationException { + return makeSynchAsynchConnection( + getDescriptionByName(descriptionName), + argTypes, + args); + } + public static ISynchAsynchConnection makeAsynchConnection( + String descriptionName) + throws ConnectionInstantiationException { + return makeSynchAsynchConnection( + getDescriptionByName(descriptionName), + null, + null); + } + +} diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/IAsynchConnectionInstantiator.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/IAsynchConnectionInstantiator.java index 4a5424e9c..d05444b83 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/IAsynchConnectionInstantiator.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/comm/IAsynchConnectionInstantiator.java @@ -1,8 +1,7 @@ package org.eclipse.ecf.internal.comm; import org.eclipse.ecf.internal.comm.ConnectionInstantiationException; -import org.eclipse.ecf.internal.comm.IAsynchConnection; public interface IAsynchConnectionInstantiator { - public IAsynchConnection makeInstance(Class [] clazzes, Object [] args) throws ConnectionInstantiationException; + public ISynchAsynchConnection makeInstance(Class [] clazzes, Object [] args) throws ConnectionInstantiationException; } |
