diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-05-02 03:27:07 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-05-02 03:27:07 +0000 |
commit | 5f342d668a30647b7d7182b4b296e65f7cfc2b07 (patch) | |
tree | 53f13aa7e79a77da4ca6133cf170812d3995d8b2 /java/src/IceInternal/EndpointFactoryManager.java | |
parent | adding assertions (diff) | |
download | ice-5f342d668a30647b7d7182b4b296e65f7cfc2b07.tar.bz2 ice-5f342d668a30647b7d7182b4b296e65f7cfc2b07.tar.xz ice-5f342d668a30647b7d7182b4b296e65f7cfc2b07.zip |
align with C++ changes for thread pool, properties, plug-ins
Diffstat (limited to 'java/src/IceInternal/EndpointFactoryManager.java')
-rw-r--r-- | java/src/IceInternal/EndpointFactoryManager.java | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/java/src/IceInternal/EndpointFactoryManager.java b/java/src/IceInternal/EndpointFactoryManager.java new file mode 100644 index 00000000000..a56a600d6de --- /dev/null +++ b/java/src/IceInternal/EndpointFactoryManager.java @@ -0,0 +1,112 @@ +// ********************************************************************** +// +// Copyright (c) 2002 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +package IceInternal; + +public final class EndpointFactoryManager +{ + EndpointFactoryManager(Instance instance) + { + _instance = instance; + } + + public synchronized void + add(EndpointFactory factory) + { + for (int i = 0; i < _factories.size(); i++) + { + EndpointFactory f = (EndpointFactory)_factories.get(i); + if (f.type() == factory.type()) + { + assert(false); + } + } + _factories.add(factory); + } + + public synchronized EndpointFactory + get(short type) + { + for (int i = 0; i < _factories.size(); i++) + { + EndpointFactory f = (EndpointFactory)_factories.get(i); + if (f.type() == type) + { + return f; + } + } + return null; + } + + public synchronized Endpoint + create(String str) + { + String s = str.trim(); + if (s.length() == 0) + { + throw new Ice.EndpointParseException(); + } + + java.util.regex.Pattern p = java.util.regex.Pattern.compile("([ \t\n\r]+)|$"); + java.util.regex.Matcher m = p.matcher(s); + boolean b = m.find(); + assert(b); + + String protocol = s.substring(0, m.start()); + + if (protocol.equals("default")) + { + protocol = _instance.defaultProtocol(); + } + + for (int i = 0; i < _factories.size(); i++) + { + EndpointFactory f = (EndpointFactory)_factories.get(i); + if (f.protocol().equals(protocol)) + { + return f.create(s.substring(m.end())); + } + } + + throw new Ice.EndpointParseException(); + } + + public synchronized Endpoint + read(BasicStream s) + { + Endpoint v; + short type = s.readShort(); + + for (int i = 0; i < _factories.size(); i++) + { + EndpointFactory f = (EndpointFactory)_factories.get(i); + if (f.type() == type) + { + return f.read(s); + } + } + + return new UnknownEndpoint(type, s); + } + + void + destroy() + { + for (int i = 0; i < _factories.size(); i++) + { + EndpointFactory f = (EndpointFactory)_factories.get(i); + f.destroy(); + } + _factories.clear(); + } + + private Instance _instance; + private java.util.ArrayList _factories = new java.util.ArrayList(); +} |