diff options
author | Michi Henning <michi@zeroc.com> | 2007-05-10 05:09:05 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2007-05-10 05:09:05 +0000 |
commit | 9cb97bc06da9fdf7e63d167ea5855ad5d5fbfe9c (patch) | |
tree | 7b1fecab8ebe32a9e2e8c3c32a90e9643a4bebf7 /java/src/IceInternal | |
parent | Fixed misplaced assignment to _rawBytes. (diff) | |
download | ice-9cb97bc06da9fdf7e63d167ea5855ad5d5fbfe9c.tar.bz2 ice-9cb97bc06da9fdf7e63d167ea5855ad5d5fbfe9c.tar.xz ice-9cb97bc06da9fdf7e63d167ea5855ad5d5fbfe9c.zip |
Bug 1022.
Diffstat (limited to 'java/src/IceInternal')
-rw-r--r-- | java/src/IceInternal/EndpointFactoryManager.java | 43 | ||||
-rw-r--r-- | java/src/IceInternal/UnknownEndpointI.java | 100 |
2 files changed, 138 insertions, 5 deletions
diff --git a/java/src/IceInternal/EndpointFactoryManager.java b/java/src/IceInternal/EndpointFactoryManager.java index b2d341b04ba..3ddbbe42b60 100644 --- a/java/src/IceInternal/EndpointFactoryManager.java +++ b/java/src/IceInternal/EndpointFactoryManager.java @@ -73,7 +73,50 @@ public final class EndpointFactoryManager if(f.protocol().equals(protocol)) { return f.create(s.substring(m.end())); + + // Code below left in place for debugging. + + /* + EndpointI e = f.create(s.substring(m.end())); + BasicStream bs = new BasicStream(_instance, true); + e.streamWrite(bs); + java.nio.ByteBuffer buf = bs.prepareRead(); + buf.position(0); + short type = bs.readShort(); + EndpointI ue = new IceInternal.UnknownEndpointI(type, bs); + System.err.println("Normal: " + e); + System.err.println("Opaque: " + ue); + return e; + */ + } + } + + // + // If the stringified endpoint is opaque, create an unknown endpoint, + // then see whether the type matches one of the known endpoints. + // + if(protocol.equals("opaque")) + { + EndpointI ue = new UnknownEndpointI(s.substring(m.end())); + for(int i = 0; i < _factories.size(); i++) + { + EndpointFactory f = (EndpointFactory)_factories.get(i); + if(f.type() == ue.type()) + { + // + // Make a temporary stream, write the opaque endpoint data into the stream, + // and ask the factory to read the endpoint data from that stream to create + // the actual endpoint. + // + BasicStream bs = new BasicStream(_instance, true); + ue.streamWrite(bs); + java.nio.ByteBuffer buf = bs.prepareRead(); + buf.position(0); + short type = bs.readShort(); + return f.read(bs); + } } + return ue; // Endpoint is opaque, but we don't have a factory for its type. } return null; diff --git a/java/src/IceInternal/UnknownEndpointI.java b/java/src/IceInternal/UnknownEndpointI.java index 0b9b4271715..c8621132123 100644 --- a/java/src/IceInternal/UnknownEndpointI.java +++ b/java/src/IceInternal/UnknownEndpointI.java @@ -12,9 +12,96 @@ package IceInternal; final class UnknownEndpointI extends EndpointI { public + UnknownEndpointI(String str) + { + int topt = 0; + int vopt = 0; + + String[] arr = str.split("[ \t\n\r]+"); + int i = 0; + while(i < arr.length) + { + if(arr[i].length() == 0) + { + i++; + continue; + } + + String option = arr[i++]; + if(option.length() != 2 || option.charAt(0) != '-') + { + throw new Ice.EndpointParseException("opaque " + str); + } + + String argument = null; + if(i < arr.length && arr[i].charAt(0) != '-') + { + argument = arr[i++]; + } + + switch(option.charAt(1)) + { + case 't': + { + if(argument == null) + { + throw new Ice.EndpointParseException("opaque " + str); + } + + int t; + try + { + t = Integer.parseInt(argument); + } + catch(NumberFormatException ex) + { + throw new Ice.EndpointParseException("opaque " + str); + } + + if(t < 0 || t > 65535) + { + throw new Ice.EndpointParseException("opaque " + str); + } + + _type = (short)t; + ++topt; + break; + } + + case 'v': + { + if(argument == null) + { + throw new Ice.EndpointParseException("opaque " + str); + } + for(int j = 0; j < argument.length(); ++j) + { + if(!IceUtil.Base64.isBase64(argument.charAt(j))) + { + throw new Ice.EndpointParseException("opaque " + str); + } + } + _rawBytes = IceUtil.Base64.decode(argument); + ++vopt; + break; + } + + default: + { + throw new Ice.EndpointParseException("opaque " + str); + } + } + } + + if(topt != 1 || vopt != 1) + { + throw new Ice.EndpointParseException("opaque " + str); + } + } + + public UnknownEndpointI(short type, BasicStream s) { - _instance = s.instance(); _type = type; s.startReadEncaps(); int sz = s.getReadEncapsSize(); @@ -41,7 +128,8 @@ final class UnknownEndpointI extends EndpointI public String _toString() { - return ""; + String val = IceUtil.Base64.encode(_rawBytes); + return "opaque -t " + _type + " -v " + val; } // @@ -187,8 +275,11 @@ final class UnknownEndpointI extends EndpointI public java.util.ArrayList expand(boolean server) { - assert(false); - return null; + + java.util.ArrayList endps = new java.util.ArrayList(); + calcHashValue(); + endps.add(this); + return endps; } // @@ -299,7 +390,6 @@ final class UnknownEndpointI extends EndpointI } } - private Instance _instance; private short _type; private byte[] _rawBytes; private int _hashCode; |