You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ad...@apache.org on 2005/12/02 08:59:10 UTC
svn commit: r351623 [3/4] - in /geronimo/trunk/sandbox/freeorb/geronimo-orb:
./ src/main/java/org/apache/geronimo/corba/
src/main/java/org/apache/geronimo/corba/channel/
src/main/java/org/apache/geronimo/corba/channel/nio/
src/main/java/org/apache/gero...
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/IIOPInvocationProfile.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/IIOPInvocationProfile.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/IIOPInvocationProfile.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/IIOPInvocationProfile.java Thu Dec 1 23:58:55 2005
@@ -16,21 +16,90 @@
*/
package org.apache.geronimo.corba.io;
+import java.io.IOException;
+
+import org.apache.geronimo.corba.ClientDelegate;
+import org.apache.geronimo.corba.ClientInvocation;
import org.apache.geronimo.corba.InvocationProfile;
+import org.apache.geronimo.corba.giop.GIOPInputStream;
+import org.apache.geronimo.corba.giop.GIOPMessageTransport;
import org.apache.geronimo.corba.giop.GIOPOutputStream;
+import org.apache.geronimo.corba.giop.RequestID;
import org.apache.geronimo.corba.ior.IIOPProfile;
-
+import org.apache.geronimo.corba.ior.InternalServiceContextList;
+import org.apache.geronimo.corba.ior.InternalTargetAddress;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.TRANSIENT;
+import org.omg.CORBA.portable.InputStream;
public class IIOPInvocationProfile implements InvocationProfile {
- public IIOPInvocationProfile(IIOPProfile profile, ClientConnectionFactory endpoint) {
- // TODO Auto-generated constructor stub
- }
-
- public GIOPOutputStream startRequest() {
-
- // TODO Auto-generated method stub
- return null;
- }
+ private IIOPProfile profile;
+
+ private ClientConnectionFactory endpoint;
+
+ private GIOPMessageTransport mt;
+
+ public IIOPInvocationProfile(IIOPProfile profile,
+ ClientConnectionFactory endpoint) {
+ this.profile = profile;
+ this.endpoint = endpoint;
+
+ ClientConnection conn = endpoint.getConnection();
+
+ try {
+ mt = conn.getGIOPMessageTransport();
+ } catch (IOException e) {
+ e.printStackTrace();
+ TRANSIENT tt = new TRANSIENT();
+ tt.initCause(e);
+ throw tt;
+ }
+ }
+
+ public GIOPOutputStream startRequest(ClientInvocation inv) {
+
+ byte[] principal = new byte[0]; // TODO: old-style principal handling
+ InternalTargetAddress targetAddress = profile.getTargetAddress();
+ GIOPVersion version = profile.getGIOPVersion();
+
+ try {
+ return mt.startRequest(version, targetAddress, inv, principal);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ MARSHAL ex = new MARSHAL("failed to start request", MinorCodes.REQUEST_START_FAILED,
+ CompletionStatus.COMPLETED_NO);
+ ex.initCause(e);
+ throw ex;
+ }
+ }
+
+ public InputStreamBase invoke(ClientInvocation invocation,
+ ClientDelegate delegate, OutputStreamBase out) {
+
+ GIOPOutputStream gout = (GIOPOutputStream) out;
+
+ if (invocation.isResponseExpected()) {
+ mt.registerResponse(invocation.getRequestID());
+ }
+
+ // push message
+ gout.finishGIOPMessage();
+
+ if (!invocation.isResponseExpected()) {
+ return null;
+ }
+
+ GIOPInputStream in = mt.waitForResponse(invocation);
+
+ return in;
+ }
+
+ public void releaseReply(InputStreamBase in) {
+ GIOPInputStream gin = (GIOPInputStream) in;
+ gin.finishGIOPMessage();
+ }
}
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/InputStreamBase.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/InputStreamBase.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/InputStreamBase.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/InputStreamBase.java Thu Dec 1 23:58:55 2005
@@ -28,8 +28,10 @@
import org.apache.geronimo.corba.AbstractORB;
import org.apache.geronimo.corba.AnyImpl;
import org.apache.geronimo.corba.ClientDelegate;
+import org.apache.geronimo.corba.ClientInvocation;
import org.apache.geronimo.corba.PlainObject;
import org.apache.geronimo.corba.TypeCodeUtil;
+import org.apache.geronimo.corba.codeset.CharConverter;
import org.apache.geronimo.corba.ior.InternalIOR;
import org.apache.geronimo.corba.util.IntegerToObjectHashMap;
import org.apache.geronimo.corba.util.IntegerToObjectMap;
@@ -45,7 +47,7 @@
/**
* Return our ORB implementation
*/
- protected abstract AbstractORB __orb();
+ public abstract AbstractORB __orb();
public ORB orb() {
return __orb();
@@ -54,6 +56,7 @@
private IntegerToObjectMap valueMap;
private CharConverter char_converter;
private CharConverter wchar_converter;
+ private ClientInvocation clientInvocation;
IntegerToObjectMap __get_value_map() {
if (valueMap == null) {
@@ -62,6 +65,17 @@
return valueMap;
}
+ public int computeAlignment(int pos, int align) {
+ if (align > 1) {
+ int incr = pos & (align - 1);
+ if (incr != 0) {
+ return align - incr;
+ }
+ }
+ return 0;
+ }
+
+
private void __register_value(int pos, Object value) {
__get_value_map().put(pos, value);
}
@@ -108,7 +122,7 @@
this.wchar_converter = converter;
}
- private CharConverter __get_char_converter() {
+ public CharConverter __get_char_converter() {
if (char_converter == null) {
char_converter = __orb().get_char_converter(getGIOPVersion());
}
@@ -121,7 +135,7 @@
return converter.read_char(this);
}
- private CharConverter __get_wchar_converter() {
+ public CharConverter __get_wchar_converter() {
if (wchar_converter == null) {
wchar_converter = __orb().get_wchar_converter(getGIOPVersion());
}
@@ -129,7 +143,7 @@
return wchar_converter;
}
- public final String read_string() {
+ public String read_string() {
int tag = read_long();
int tag_position = __stream_position() - 4;
if (tag == -1) {
@@ -265,7 +279,7 @@
}
- protected abstract GIOPVersion getGIOPVersion();
+ public abstract GIOPVersion getGIOPVersion();
protected SystemException translate_exception(IOException e) {
SystemException result;
@@ -275,6 +289,16 @@
return result;
}
+
+ public abstract boolean __isLittleEndian();
+
+ public ClientInvocation getClientInvocation() {
+ return clientInvocation;
+ }
+
+ public void setClientInvocation(ClientInvocation invocation) {
+ this.clientInvocation = invocation;
+ }
}
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/MinorCodes.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/MinorCodes.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/MinorCodes.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/MinorCodes.java Thu Dec 1 23:58:55 2005
@@ -23,6 +23,7 @@
public static final int BAD_MAJOR = 2 | FREEORB_ID;
public static final int BAD_MINOR = 3 | FREEORB_ID;
public static final int END_OF_ENCAPSULATION = 4 | FREEORB_ID;
+ public static final int REQUEST_START_FAILED = 5 | FREEORB_ID;
}
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/OutputStreamBase.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/OutputStreamBase.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/OutputStreamBase.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/OutputStreamBase.java Thu Dec 1 23:58:55 2005
@@ -32,7 +32,11 @@
import org.apache.geronimo.corba.AbstractORB;
import org.apache.geronimo.corba.ClientDelegate;
+import org.apache.geronimo.corba.ClientInvocation;
import org.apache.geronimo.corba.TypeCodeUtil;
+import org.apache.geronimo.corba.channel.MarkHandler;
+import org.apache.geronimo.corba.channel.OutputChannelMarker;
+import org.apache.geronimo.corba.codeset.CharConverter;
public abstract class OutputStreamBase extends OutputStream implements
@@ -51,6 +55,17 @@
return __orb();
}
+ public int computeAlignment(int pos, int align) {
+ if (align > 1) {
+ int incr = pos & (align - 1);
+ if (incr != 0) {
+ return align - incr;
+ }
+ }
+ return 0;
+ }
+
+
public InputStream create_input_stream() {
throw new NO_RESOURCES();
}
@@ -78,10 +93,7 @@
return wchar_writer;
}
- private GIOPVersion getGIOPVersion() {
- // TODO Auto-generated method stub
- return null;
- }
+ protected abstract GIOPVersion getGIOPVersion();
public void write(int value) throws IOException {
try {
@@ -343,4 +355,18 @@
throw translate_exception(e);
}
}
+
+ protected abstract OutputChannelMarker mark(MarkHandler handler);
+
+ private ClientInvocation clientInvocation;
+
+ public ClientInvocation getClientInvocation() {
+ return clientInvocation;
+ }
+
+ public void setClientInvocation(ClientInvocation inv) {
+ this.clientInvocation = inv;
+ }
+
+
}
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/SSLClientConnectionFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/SSLClientConnectionFactory.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/SSLClientConnectionFactory.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/SSLClientConnectionFactory.java Thu Dec 1 23:58:55 2005
@@ -16,6 +16,8 @@
*/
package org.apache.geronimo.corba.io;
+import org.apache.geronimo.corba.ORB;
+import org.apache.geronimo.corba.channel.TransportManager;
import org.apache.geronimo.corba.ior.IIOPTransportSpec;
@@ -23,8 +25,8 @@
implements ClientConnectionFactory
{
- public SSLClientConnectionFactory(IIOPTransportSpec transport) {
- super(transport);
+ public SSLClientConnectionFactory(ORB orb, IIOPTransportSpec transport, TransportManager sslTransportManager) {
+ super(orb, transport, sslTransportManager);
// TODO Auto-generated constructor stub
}
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/TCPClientConnectionFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/TCPClientConnectionFactory.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/TCPClientConnectionFactory.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/TCPClientConnectionFactory.java Thu Dec 1 23:58:55 2005
@@ -16,25 +16,43 @@
*/
package org.apache.geronimo.corba.io;
+import org.apache.geronimo.corba.ORB;
+import org.apache.geronimo.corba.channel.Transport;
+import org.apache.geronimo.corba.channel.TransportManager;
+import org.apache.geronimo.corba.giop.GIOPMessageTransport;
import org.apache.geronimo.corba.ior.IIOPTransportSpec;
public class TCPClientConnectionFactory implements ClientConnectionFactory {
- private final IIOPTransportSpec transport;
-
- public TCPClientConnectionFactory(IIOPTransportSpec transport) {
- this.transport = transport;
+ private final IIOPTransportSpec spec;
+ private ClientConnection connection;
+ private final ORB orb;
+ private TransportManager transportmanger;
+
+ public TCPClientConnectionFactory(ORB orb, IIOPTransportSpec spec, TransportManager manager) {
+ this.orb = orb;
+ this.spec = spec;
+ this.transportmanger = manager;
}
public ClientConnection getConnection() {
- // TODO Auto-generated method stub
- return null;
+
+ if (connection == null) {
+ connection = new DefaultClientConnection(this, transportmanger);
+ }
+
+ return connection;
+
}
public IIOPTransportSpec getTransportSpec() {
- return transport;
+ return spec;
}
+
+ public ORB getORB() {
+ return orb;
+ }
}
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/TLSClientConnectionFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/TLSClientConnectionFactory.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/TLSClientConnectionFactory.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/TLSClientConnectionFactory.java Thu Dec 1 23:58:55 2005
@@ -16,6 +16,8 @@
*/
package org.apache.geronimo.corba.io;
+import org.apache.geronimo.corba.ORB;
+import org.apache.geronimo.corba.channel.TransportManager;
import org.apache.geronimo.corba.ior.IIOPTransportSpec;
@@ -23,8 +25,8 @@
implements ClientConnectionFactory
{
- public TLSClientConnectionFactory(IIOPTransportSpec transport) {
- super(transport);
+ public TLSClientConnectionFactory(ORB orb, IIOPTransportSpec transport, TransportManager tlsTransportManager) {
+ super(orb, transport, tlsTransportManager);
// TODO Auto-generated constructor stub
}
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/ValueWriter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/ValueWriter.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/ValueWriter.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/ValueWriter.java Thu Dec 1 23:58:55 2005
@@ -235,7 +235,7 @@
//
// TODO: this was always true in Trifork codebase, find out why!
- boolean isChunked = valueHandler.isCustomMarshaled(clz);
+ boolean isChunked = true || valueHandler.isCustomMarshaled(clz);
// System.out.println ("write_value (2) "+ids[0]);
@@ -421,6 +421,7 @@
}
};
+
private void startChunk() {
if (currentValueIsChunked == false)
out.__fatal("not chunked");
@@ -428,6 +429,7 @@
out.align(4);
// TODO: revisit chunkMark = out.mark(chunkHandler);
startPosOfCurrentChunk = out.__stream_position();
+ chunkMark = out.mark(chunkHandler);
out.write_long(0);
}
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/IIOPProfile.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/IIOPProfile.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/IIOPProfile.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/IIOPProfile.java Thu Dec 1 23:58:55 2005
@@ -29,116 +29,131 @@
import org.apache.geronimo.corba.AbstractORB;
import org.apache.geronimo.corba.io.EncapsulationInputStream;
import org.apache.geronimo.corba.io.EncapsulationOutputStream;
-
+import org.apache.geronimo.corba.io.GIOPVersion;
public class IIOPProfile extends Profile {
- byte[] bytes;
+ byte[] bytes;
- ProfileBody_1_0 body;
- TaggedComponent[] tagged_components;
- Component[] components;
- private final AbstractORB orb;
- private IIOPTransportSpec saddr;
-
- IIOPProfile(AbstractORB orb) {
- super();
- this.orb = orb;
- }
-
- public int tag() {
- return TAG_INTERNET_IOP.value;
- }
-
- public Version getVersion() {
- return body.iiop_version;
- }
-
- public byte[] getObjectKey() {
- return body.object_key;
- }
-
- public int getComponentCount() {
- if (tagged_components == null) {
- return 0;
- } else {
- return tagged_components.length;
- }
- }
-
- public int getTag(int idx) {
- return tagged_components[idx].tag;
- }
-
- public TaggedComponent getTaggedComponent(int idx) {
- return tagged_components[idx];
- }
-
- public Component getComponent(int idx) {
-
- if (components == null) {
- components = new Component[getComponentCount()];
- }
-
- if (components[idx] == null) {
- components[idx] = Component.read(orb, tagged_components[idx].tag,
- tagged_components[idx].component_data);
- }
-
- return components[idx];
- }
-
-
- public static Profile read(AbstractORB orb, byte[] data) {
-
- EncapsulationInputStream ein = new EncapsulationInputStream(orb, data);
- IIOPProfile result = new IIOPProfile(orb);
- result.body = ProfileBody_1_0Helper.read(ein);
- if (result.body.iiop_version.major == 1
- && result.body.iiop_version.minor >= 1)
- {
- result.tagged_components = TaggedComponentSeqHelper.read(ein);
- }
-
- result.bytes = data;
- return result;
- }
-
- public IIOPTransportSpec getInetTransport() throws UnknownHostException {
- if (saddr == null) {
- saddr = new IIOPTransportSpec(getVersion(), getAddress(), getPort());
- }
- return saddr;
- }
-
- public InetAddress getAddress() throws UnknownHostException {
- return orb.getAddress(body.host);
- }
-
- public String getHost() {
- return body.host;
- }
-
- public int getPort() {
- return (body.port & 0xffff);
- }
-
- protected void write_content(OutputStream eo) {
- ProfileBody_1_0Helper.write(eo, body);
- if (body.iiop_version.major == 1 && body.iiop_version.minor > 0) {
- TaggedComponentSeqHelper.write(eo, tagged_components);
- }
- }
-
- protected byte[] get_encapsulation_bytes() {
- // TODO Auto-generated method stub
- return null;
- }
+ ProfileBody_1_0 body;
- protected void write_content(EncapsulationOutputStream eo) {
- // TODO Auto-generated method stub
+ TaggedComponent[] tagged_components;
- }
+ Component[] components_cache;
+ private final AbstractORB orb;
+
+ private IIOPTransportSpec saddr;
+
+ IIOPProfile(AbstractORB orb) {
+ super();
+ this.orb = orb;
+ }
+
+ public IIOPProfile(AbstractORB orb, Version version, InetAddress addr,
+ short port, byte[] keyData) {
+ this.orb = orb;
+ this.saddr = new IIOPTransportSpec(version, addr, port);
+ body = new org.omg.IIOP.ProfileBody_1_0(version, addr.getHostName(),
+ port, keyData);
+ }
+
+ public int tag() {
+ return TAG_INTERNET_IOP.value;
+ }
+
+ public Version getVersion() {
+ return body.iiop_version;
+ }
+
+ public byte[] getObjectKey() {
+ return body.object_key;
+ }
+
+ public int getComponentCount() {
+ if (tagged_components == null) {
+ return 0;
+ } else {
+ return tagged_components.length;
+ }
+ }
+
+ public int getTag(int idx) {
+ return tagged_components[idx].tag;
+ }
+
+ public TaggedComponent getTaggedComponent(int idx) {
+ return tagged_components[idx];
+ }
+
+ public Component getComponent(int idx) {
+
+ if (components_cache == null) {
+ components_cache = new Component[getComponentCount()];
+ }
+
+ if (components_cache[idx] == null) {
+ components_cache[idx] = Component.read(orb, tagged_components[idx].tag,
+ tagged_components[idx].component_data);
+ }
+
+ return components_cache[idx];
+ }
+
+ public static Profile read(AbstractORB orb, byte[] data) {
+
+ EncapsulationInputStream ein = new EncapsulationInputStream(orb, data);
+ IIOPProfile result = new IIOPProfile(orb);
+ result.body = ProfileBody_1_0Helper.read(ein);
+ if (result.body.iiop_version.major == 1
+ && result.body.iiop_version.minor >= 1) {
+ result.tagged_components = TaggedComponentSeqHelper.read(ein);
+ }
+
+ result.bytes = data;
+ return result;
+ }
+
+ public IIOPTransportSpec getInetTransport() throws UnknownHostException {
+ if (saddr == null) {
+ saddr = new IIOPTransportSpec(getVersion(), getAddress(), getPort());
+ }
+ return saddr;
+ }
+
+ public InetAddress getAddress() throws UnknownHostException {
+ return orb.getAddress(body.host);
+ }
+
+ public String getHost() {
+ return body.host;
+ }
+
+ public int getPort() {
+ return (body.port & 0xffff);
+ }
+
+ protected void write_content(OutputStream eo) {
+ ProfileBody_1_0Helper.write(eo, body);
+ if (body.iiop_version.major == 1 && body.iiop_version.minor > 0) {
+ TaggedComponentSeqHelper.write(eo, tagged_components);
+ }
+ }
+
+ protected byte[] get_cached_byte_encoding() {
+ return bytes;
+ }
+
+ public InternalTargetAddress getTargetAddress() {
+ return new InternalTargetAddress.ObjectKeyAddress(body.object_key);
+ }
+
+ public GIOPVersion getGIOPVersion() {
+ return GIOPVersion.get(getVersion());
+ }
+
+ protected byte[] get_encapsulation_bytes() {
+ return bytes;
+ }
}
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalExceptionDetailMessage.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalExceptionDetailMessage.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalExceptionDetailMessage.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalExceptionDetailMessage.java Thu Dec 1 23:58:55 2005
@@ -0,0 +1,65 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.ior;
+
+import org.apache.geronimo.corba.io.EncapsulationInputStream;
+import org.apache.geronimo.corba.io.GIOPVersion;
+import org.apache.geronimo.corba.io.InputStreamBase;
+import org.omg.CORBA.ORB;
+import org.omg.IOP.ExceptionDetailMessage;
+import org.omg.IOP.ServiceContext;
+
+public class InternalExceptionDetailMessage extends InternalServiceContext {
+
+ public static int VALUE = ExceptionDetailMessage.value;
+
+ private String msg;
+
+ private InputStreamBase in;
+
+ public InternalExceptionDetailMessage(InputStreamBase in,
+ ServiceContext ctx) {
+ super(ctx);
+ this.in = in;
+ }
+
+ public static InternalExceptionDetailMessage get(InternalServiceContextList lst)
+ {
+ InternalServiceContext context = lst.getContextWithID(VALUE);
+ return (InternalExceptionDetailMessage) context;
+ }
+
+ public String getMessage() {
+ if (msg == null) {
+ msg = decodeMessage();
+ if (msg == null) {
+ msg = "Unknown Exception";
+ }
+ }
+ return msg;
+ }
+
+ private String decodeMessage() {
+ EncapsulationInputStream ein = new EncapsulationInputStream(in.__orb(),
+ in.getGIOPVersion(), in.__get_char_converter(), in
+ .__get_wchar_converter(), ctx.context_data, 0,
+ ctx.context_data.length);
+
+ return ein.read_wstring();
+ }
+
+}
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalIOR.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalIOR.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalIOR.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalIOR.java Thu Dec 1 23:58:55 2005
@@ -28,68 +28,107 @@
import org.apache.geronimo.corba.AbstractORB;
import org.apache.geronimo.corba.ClientDelegate;
-
public class InternalIOR {
- static final boolean DIRECT = true;
-
- IOR ior;
-
- Profile[] profiles;
-
- public final AbstractORB orb;
-
- public InternalIOR(AbstractORB orb, IOR ior) {
- this.orb = orb;
- this.ior = ior;
- }
-
- public static InternalIOR read(AbstractORB orb, InputStream in) {
- return new InternalIOR(orb, IORHelper.read(in));
- }
-
- public int getProfileCount() {
- return ior.profiles.length;
- }
-
-
- public Profile getProfile(int idx) {
-
- if (profiles == null) {
- profiles = new Profile[getProfileCount()];
- }
-
- if (profiles[idx] == null) {
- profiles[idx] = Profile.read(orb, ior.profiles[idx].tag,
- ior.profiles[idx].profile_data);
- }
-
- return profiles[idx];
- }
-
- public static InternalIOR extract(Object forward) {
- if (forward instanceof ObjectImpl) {
- Delegate del = ((ObjectImpl) forward)._get_delegate();
- if (del instanceof ClientDelegate) {
- return ((ClientDelegate) del).getInternalIOR();
- }
- }
-
- // todo: better exception here?
- throw new NO_IMPLEMENT();
- }
+ static final boolean DIRECT = true;
- public int profileTag(int i) {
- return ior.profiles[i].tag;
- }
+ IOR ior;
- public String getType() {
- return ior.type_id;
- }
+ Profile[] profiles;
- public void write(OutputStream out) {
- // TODO: reconstruct IOR if changed
- IORHelper.write(out, ior);
- }
+ public final AbstractORB orb;
+ private String type;
+
+ public InternalIOR(AbstractORB orb, IOR ior) {
+ this.orb = orb;
+ this.ior = ior;
+ this.type = ior.type_id;
+ }
+
+ public InternalIOR(AbstractORB orb, String type, Profile[] profiles)
+ {
+ this.orb = orb;
+ this.type = type;
+ this.profiles = profiles;
+ }
+
+ public static InternalIOR read(AbstractORB orb, InputStream in) {
+ return new InternalIOR(orb, IORHelper.read(in));
+ }
+
+ public int getProfileCount() {
+ return ior.profiles.length;
+ }
+
+ public Profile getProfile(int idx) {
+
+ if (profiles == null) {
+ profiles = new Profile[getProfileCount()];
+ }
+
+ if (profiles[idx] == null) {
+ profiles[idx] = Profile.read(orb, ior.profiles[idx].tag,
+ ior.profiles[idx].profile_data);
+ }
+
+ return profiles[idx];
+ }
+
+ public static InternalIOR extract(Object forward) {
+ if (forward instanceof ObjectImpl) {
+ Delegate del = ((ObjectImpl) forward)._get_delegate();
+ if (del instanceof ClientDelegate) {
+ return ((ClientDelegate) del).getInternalIOR();
+ }
+ }
+
+ // todo: better exception here?
+ throw new NO_IMPLEMENT();
+ }
+
+ public int profileTag(int i) {
+ if (profiles != null) {
+ return profiles[i].tag();
+ }
+ return ior.profiles[i].tag;
+ }
+
+ public String getType() {
+ if (type != null) { return type; }
+ return ior.type_id;
+ }
+
+ public void write(OutputStream out) {
+ if (ior == null) {
+ throw new NO_IMPLEMENT();
+ }
+ // TODO: reconstruct IOR if changed
+ IORHelper.write(out, ior);
+ }
+
+ public boolean equals(Object other) {
+ if (super.equals(other)) {
+ return true;
+ }
+
+ if (other instanceof InternalIOR) {
+ InternalIOR oior = (InternalIOR) other;
+
+ if (!getType().equals(oior.getType())) return false;
+ if (getProfileCount() != oior.getProfileCount()) return false;
+
+ for (int i = 0; i < getProfileCount(); i++) {
+ Profile p1 = getProfile(i);
+ Profile p2 = oior.getProfile(i);
+
+ if (!p1.equals(p2)) { return false; }
+ }
+
+ return true;
+ }
+
+ return true;
+ }
+
}
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalServiceContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalServiceContext.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalServiceContext.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalServiceContext.java Thu Dec 1 23:58:55 2005
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.ior;
+
+import org.apache.geronimo.corba.io.InputStreamBase;
+import org.apache.geronimo.corba.io.OutputStreamBase;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.IOP.ExceptionDetailMessage;
+import org.omg.IOP.ServiceContext;
+import org.omg.IOP.ServiceContextHelper;
+
+public class InternalServiceContext extends TaggedValue {
+
+ protected ServiceContext ctx;
+
+ public InternalServiceContext(ServiceContext ctx) {
+ this.ctx = ctx;
+ }
+
+ public int tag() {
+ return ctx.context_id;
+ }
+
+
+ public byte[] get_cached_byte_encoding() {
+ return ctx.context_data;
+ }
+
+ protected void write_content(OutputStream eo) {
+ ServiceContextHelper.write(eo, ctx);
+ }
+
+ public static InternalServiceContext read(InputStreamBase in) {
+ ServiceContext ctx = ServiceContextHelper.read(in);
+
+ switch(ctx.context_id) {
+
+ case ExceptionDetailMessage.value:
+ return new InternalExceptionDetailMessage(in, ctx);
+
+ default:
+ return new InternalServiceContext(ctx);
+ }
+
+ }
+
+}
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalServiceContextList.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalServiceContextList.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalServiceContextList.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalServiceContextList.java Thu Dec 1 23:58:55 2005
@@ -16,13 +16,38 @@
*/
package org.apache.geronimo.corba.ior;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.geronimo.corba.io.InputStreamBase;
import org.apache.geronimo.corba.io.OutputStreamBase;
public class InternalServiceContextList {
+ List scl = new ArrayList();
+
public void write(OutputStreamBase out) {
out.write_long(0);
}
+
+ public void read(InputStreamBase in) {
+ int count = in.read_long();
+ for (int i = 0; i < count; i++) {
+ InternalServiceContext sc = InternalServiceContext.read(in);
+ scl.add(sc);
+ }
+ }
+
+ public InternalServiceContext getContextWithID(int value) {
+ for (int i = 0; i < scl.size(); i++) {
+ InternalServiceContext ctx = (InternalServiceContext) scl.get(i);
+ if (ctx.tag() == value) {
+ return ctx;
+ }
+ }
+
+ return null;
+ }
}
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalTargetAddress.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalTargetAddress.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalTargetAddress.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalTargetAddress.java Thu Dec 1 23:58:55 2005
@@ -24,13 +24,15 @@
public abstract class InternalTargetAddress {
- private AbstractORB orb;
-
- static class ObjectKeyAddress extends InternalTargetAddress {
+ public static class ObjectKeyAddress extends InternalTargetAddress {
byte[] key;
- public void writeObjectKey(OutputStream out) {
+ public ObjectKeyAddress(byte[] object_key) {
+ this.key = object_key;
+ }
+
+ public void writeObjectKey(OutputStream out) {
OctetSeqHelper.write(out, key);
}
@@ -43,6 +45,8 @@
static class ProfileAddress extends InternalTargetAddress {
IIOPProfile key;
+
+ public ProfileAddress(IIOPProfile profile) { this.key = profile; }
public void writeObjectKey(OutputStream out) {
OctetSeqHelper.write(out, key.getObjectKey());
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/Profile.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/Profile.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/Profile.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/Profile.java Thu Dec 1 23:58:55 2005
@@ -23,6 +23,7 @@
import org.omg.IOP.TaggedComponent;
import org.apache.geronimo.corba.AbstractORB;
+import org.apache.geronimo.corba.io.OutputStreamBase;
public abstract class Profile extends TaggedValue {
@@ -30,6 +31,15 @@
public Profile() {
}
+ public void write_encapsulated_content(OutputStreamBase out) {
+ byte[] bytes = get_encapsulation_bytes();
+ if (bytes == null) {
+ super.write_encapsulated_content(out);
+ } else {
+ out.write_octet_array(bytes, 0, bytes.length);
+ }
+ }
+
/**
* write content including tag
*/
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/SecurityMechanismListComponent.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/SecurityMechanismListComponent.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/SecurityMechanismListComponent.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/SecurityMechanismListComponent.java Thu Dec 1 23:58:55 2005
@@ -29,7 +29,7 @@
private final AbstractORB orb;
private final CompoundSecMechList mech_list;
- private CompoundSecurityMechanism[] mechs;
+ private CompoundSecurityMechanism[] mechs_cache;
public SecurityMechanismListComponent(AbstractORB orb2, CompoundSecMechList mech_list) {
this.orb = orb2;
@@ -59,15 +59,15 @@
}
public CompoundSecurityMechanism getSecurityMechanism(int j) {
- if (mechs == null) {
- mechs = new CompoundSecurityMechanism[mech_list.mechanism_list.length];
+ if (mechs_cache == null) {
+ mechs_cache = new CompoundSecurityMechanism[mech_list.mechanism_list.length];
}
- if (mechs[j] == null) {
- mechs[j] = new CompoundSecurityMechanism(orb, mech_list.mechanism_list[j]);
+ if (mechs_cache[j] == null) {
+ mechs_cache[j] = new CompoundSecurityMechanism(orb, mech_list.mechanism_list[j]);
}
- return mechs[j];
+ return mechs_cache[j];
}
}
Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TaggedValue.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TaggedValue.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TaggedValue.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TaggedValue.java Thu Dec 1 23:58:55 2005
@@ -29,15 +29,23 @@
public abstract int tag();
- public void write(OutputStreamBase out) {
+ public final void write(OutputStreamBase out) {
out.write_long(tag());
write_encapsulated_content(out);
}
protected void write_encapsulated_content(OutputStreamBase out) {
+ byte[] cached_bytes = get_cached_byte_encoding();
+ if (cached_bytes != null) {
+ out.write_long(cached_bytes.length);
+ out.write_octet_array(cached_bytes, 0, cached_bytes.length);
+ return;
+ }
+
EncapsulationOutputStream eo = new EncapsulationOutputStream(out.__orb());
write_content(eo);
try {
+ out.write_long(eo.__stream_position());
eo.writeTo(out);
}
catch (IOException ex) {
@@ -47,6 +55,7 @@
}
}
+ protected byte[] get_cached_byte_encoding() { return null; }
protected abstract void write_content(OutputStream eo);
}
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/URLManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/URLManager.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/URLManager.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/URLManager.java Thu Dec 1 23:58:55 2005
@@ -0,0 +1,79 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.corba.ior;
+
+import org.apache.geronimo.corba.ClientDelegate;
+import org.apache.geronimo.corba.ORB;
+import org.apache.geronimo.corba.PlainObject;
+import org.apache.geronimo.corba.server.POA;
+import org.omg.CORBA.Object;
+
+public final class URLManager {
+ private final ORB orb;
+
+ public URLManager(ORB orb) {
+ this.orb = orb;
+ }
+
+ public Object createObject(InternalIOR ior) {
+ orb.__checkDestroy();
+ if (ior == null)
+ return null;
+ ClientDelegate delegate = new ClientDelegate(ior);
+ PlainObject result = new PlainObject(delegate);
+ return result;
+ }
+
+ public org.omg.CORBA.Object createObject(org.omg.IOP.IOR ior) {
+ orb.__checkDestroy();
+
+ if (ior == null)
+ return null;
+
+ if (ior.type_id.length() == 0 && ior.profiles.length == 0)
+ return null;
+
+ // construct delegate
+ ClientDelegate delegate = new ClientDelegate(orb, ior);
+
+ // construct a PlainObject
+ PlainObject result = new PlainObject(delegate);
+
+ return result;
+ }
+
+ public org.omg.CORBA.Object createObject(POA poa, byte[] oid,
+ String repository_id) {
+ orb.__checkDestroy();
+
+ if (repository_id.length() == 0)
+ return null;
+
+ ClientDelegate delegate = new ClientDelegate(orb, poa, oid,
+ repository_id, orb.getPolicies());
+
+ PlainObject result = new PlainObject(delegate);
+
+ return result;
+ }
+
+ public org.omg.CORBA.Object createObject(String url) {
+ URLParser handler = new URLParser(orb, url);
+ return createObject(handler.getIOR());
+ }
+}
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/URLParser.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/URLParser.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/URLParser.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/URLParser.java Thu Dec 1 23:58:55 2005
@@ -0,0 +1,353 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.corba.ior;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.corba.ClientDelegate;
+import org.apache.geronimo.corba.ORB;
+import org.apache.geronimo.corba.io.EncapsulationInputStream;
+import org.apache.geronimo.corba.io.InputStreamBase;
+import org.apache.geronimo.corba.util.HexUtil;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.INTERNAL;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.IOP.IOR;
+import org.omg.IOP.TaggedProfile;
+
+public class URLParser {
+
+ static Log log = LogFactory.getLog(URLParser.class);
+
+ protected InternalIOR ior;
+
+ protected ORB orb;
+
+ InternalIOR getIOR() {
+ return ior;
+ }
+
+ int schemeEnd;
+
+ private String getScheme(String url) {
+ schemeEnd = url.indexOf(':');
+ if (schemeEnd == -1)
+ throw new org.omg.CORBA.BAD_PARAM(url);
+
+ return url.substring(0, schemeEnd).toLowerCase();
+ }
+
+ URLParser(ORB orb, String url) {
+ String scheme = getScheme(url);
+ this.orb = orb;
+
+ if (log.isDebugEnabled()) {
+ log.debug("resolving " + url);
+ }
+
+ if (scheme.equals("ior"))
+ parseIOR(url);
+
+ else if (scheme.equals("iiop"))
+ parseIIOP(url);
+
+ else if (scheme.equals("corbaloc"))
+ parseCORBALOC(url);
+
+ else if (scheme.equals("corbaname"))
+ parseCORBANAME(url);
+
+ else
+ throw new org.omg.CORBA.BAD_PARAM(url);
+ }
+
+ private void parseIOR(String url) {
+ String hexString = url.substring(schemeEnd + 1);
+ byte[] data = HexUtil.hexToByteArray(hexString);
+
+ InputStreamBase in = new EncapsulationInputStream(orb, data);
+ IOR ior = org.omg.IOP.IORHelper.read(in);
+ this.ior = new InternalIOR(orb, ior);
+ }
+
+ private void parseIIOP(String url) {
+ if (!url.startsWith("iiop://"))
+ throw new org.omg.CORBA.BAD_PARAM();
+
+ int idx = url.indexOf('/', 7);
+ String hostAndPort = null;
+ String name = "";
+ if (idx == -1) {
+ hostAndPort = url.substring(7);
+ } else {
+ hostAndPort = url.substring(7, idx);
+ name = url.substring(idx + 1);
+ }
+
+ if (hostAndPort.length() == 0 || hostAndPort.charAt(0) == ':') {
+ hostAndPort = orb.getLocalHost() + hostAndPort;
+ }
+
+ if (hostAndPort.indexOf(':') == -1) {
+ hostAndPort = hostAndPort + ":2809";
+ }
+
+ if (name.equals("")) {
+ parseCORBALOC("corbaloc:iiop:" + hostAndPort + "/NameService");
+ return;
+ }
+
+ org.omg.CORBA.Object nsRef = orb.string_to_object("corbaloc:iiop:"
+ + hostAndPort + "/NameService");
+
+ org.omg.CosNaming.NamingContext ns = org.omg.CosNaming.NamingContextHelper
+ .narrow(nsRef);
+
+ String[] names = name.split("/");
+ org.omg.CosNaming.NameComponent[] nc = new org.omg.CosNaming.NameComponent[names.length];
+
+ for (int i = 0; i < names.length; i++) {
+ nc[i] = new org.omg.CosNaming.NameComponent(names[i], "");
+ }
+
+ try {
+ ObjectImpl obj = (ObjectImpl) ns.resolve(nc);
+ ClientDelegate delegate = (ClientDelegate) obj._get_delegate();
+
+ ior = delegate.getIOR();
+ } catch (Exception ex) {
+ throw new org.omg.CORBA.BAD_PARAM(ex.getMessage());
+ }
+ }
+
+ private void parseCORBALOC(String url) {
+ if (!url.startsWith("corbaloc:")) {
+ throw new org.omg.CORBA.BAD_PARAM("invalid url");
+ }
+
+ byte[] keyData;
+ String obj_addr_list;
+ int idx = url.indexOf('/');
+ if (idx != -1) {
+ keyData = decode(url.substring(idx + 1));
+ obj_addr_list = url.substring("corbaloc:".length(), idx);
+ } else {
+ obj_addr_list = url.substring("corbaloc:".length());
+ keyData = new byte[0];
+ }
+
+ String[] obj_addrs = obj_addr_list.split(",");
+
+ IIOPProfile[] profiles = new IIOPProfile[obj_addrs.length];
+
+ for (int profile_idx = 0; profile_idx < obj_addrs.length; profile_idx++) {
+ String obj_addr = obj_addrs[profile_idx];
+ String prot;
+ String iiop_addr;
+ if (obj_addr.startsWith(":")) {
+ prot = "iiop";
+ iiop_addr = obj_addr.substring(1);
+ } else if (obj_addr.startsWith("iiop:")) {
+ prot = "iiop";
+ iiop_addr = obj_addr.substring(5);
+ } else {
+ throw new org.omg.CORBA.BAD_PARAM("unknown protocol "
+ + obj_addr);
+ }
+
+ int major = 1;
+ int minor = 0;
+ String host;
+ short port = 2809;
+
+ idx = iiop_addr.indexOf('@');
+ if (idx != -1) {
+ String version = iiop_addr.substring(0, idx);
+ iiop_addr = iiop_addr.substring(idx + 1);
+
+ idx = version.indexOf('.');
+ if (idx == -1) {
+ throw new org.omg.CORBA.BAD_PARAM(
+ "invalid url, version has no '.'");
+ }
+
+ try {
+ major = Integer.parseInt(version.substring(0, idx));
+ minor = Integer.parseInt(version.substring(idx + 1));
+ } catch (NumberFormatException ex) {
+ throw new org.omg.CORBA.BAD_PARAM(
+ "invalid url, cannot parse version " + version);
+ }
+ }
+
+ org.omg.IIOP.Version version = new org.omg.IIOP.Version(
+ (byte) major, (byte) minor);
+
+ idx = iiop_addr.indexOf(':');
+ if (idx != -1) {
+ try {
+ port = Short.parseShort(iiop_addr.substring(idx + 1));
+ } catch (NumberFormatException ex) {
+ throw new org.omg.CORBA.BAD_PARAM(
+ "invalid url, cannot parse port "
+ + iiop_addr.substring(idx + 1));
+ }
+
+ host = iiop_addr.substring(0, idx);
+ } else {
+ host = iiop_addr;
+ }
+
+ try {
+ profiles[profile_idx] = new IIOPProfile(orb, version, orb
+ .getAddress(host), port, keyData);
+ } catch (UnknownHostException e) {
+ throw new org.omg.CORBA.BAD_PARAM("cannot decode "+host);
+ }
+
+ }
+
+ ior = new InternalIOR(orb, "IDL:omg.org/CORBA/Object:1.0", profiles);
+
+
+ }
+
+ public static byte[] decode(String s)
+ /* throws UnsupportedEncodingException */{
+
+ StringBuffer sb = null;
+ int length = s.length();
+
+ for (int i = 0; i < length; i++) {
+ char c = s.charAt(i);
+
+ switch (c) {
+ case '+':
+ if (sb == null) {
+ sb = new StringBuffer();
+ for (int j = 0; j < i; j++) {
+ sb.append(s.charAt(j));
+ }
+ }
+ sb.append(' ');
+ break;
+
+ case '%':
+
+ if (sb == null) {
+ sb = new StringBuffer();
+ for (int j = 0; j < i; j++) {
+ sb.append(s.charAt(j));
+ }
+ }
+
+ try {
+ sb.append(Byte.parseByte(s.substring(i + 1, i + 3), 16));
+ } catch (NumberFormatException ex) {
+ throw new org.omg.CORBA.BAD_PARAM(
+ "invalid url, cannot parse "
+ + s.substring(i + 1, i + 3));
+ }
+
+ i += 2;
+ break;
+ default:
+ if (sb != null) {
+ sb.append(c);
+ }
+ break;
+ }
+ }
+
+ if (sb != null) {
+ s = sb.toString();
+ }
+
+ try {
+ return s.getBytes("US-ASCII");
+ } catch (UnsupportedEncodingException e) {
+ throw new INTERNAL("unsupported encoding");
+ }
+ }
+
+
+ private void parseCORBANAME(String url) {
+ if (!url.startsWith("corbaname:")) {
+ throw new org.omg.CORBA.BAD_PARAM("invalid url");
+ }
+
+ int idx = url.indexOf('#');
+ String string_name = "";
+ String corbaloc_obj;
+ if (idx == -1) {
+ corbaloc_obj = url.substring("corbaname:".length());
+ } else {
+ corbaloc_obj = url.substring("corbaname:".length(), idx);
+ string_name = url.substring(idx + 1);
+ }
+
+ if (corbaloc_obj.indexOf('/') == -1) {
+ corbaloc_obj += "/NameService";
+ }
+
+ org.omg.CORBA.Object nsRef = orb.string_to_object("corbaloc:"
+ + corbaloc_obj);
+
+ org.omg.CosNaming.NamingContext ns = org.omg.CosNaming.NamingContextHelper
+ .narrow(nsRef);
+
+ try {
+ string_name = URLDecoder.decode(string_name, "iso-8859-1");
+ } catch (UnsupportedEncodingException e) {
+ throw new INTERNAL("unknown encoding iso-8859-1");
+ }
+
+ String[] names = string_name.split("/");
+ org.omg.CosNaming.NameComponent[] nc = new org.omg.CosNaming.NameComponent[names.length];
+
+ for (int i = 0; i < names.length; i++) {
+ nc[i] = new org.omg.CosNaming.NameComponent(names[i], "");
+ }
+
+ try {
+ ObjectImpl obj = (ObjectImpl) ns.resolve(nc);
+ ClientDelegate delegate = (ClientDelegate) obj._get_delegate();
+
+ ior = delegate.getIOR();
+ } catch (org.omg.CosNaming.NamingContextPackage.NotFound ex) {
+ throw new org.omg.CORBA.OBJECT_NOT_EXIST(url);
+
+ } catch (org.omg.CORBA.SystemException ex) {
+ // ex.printStackTrace ();
+ throw ex;
+
+ } catch (Exception ex) {
+ // ex.printStackTrace ();
+ throw new org.omg.CORBA.BAD_PARAM(ex.getMessage());
+ }
+
+ }
+
+}
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/DefaultServerManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/DefaultServerManager.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/DefaultServerManager.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/DefaultServerManager.java Thu Dec 1 23:58:55 2005
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.server;
+
+import org.apache.geronimo.corba.LocationForwardException;
+import org.apache.geronimo.corba.ORB;
+import org.apache.geronimo.corba.ServerManager;
+import org.apache.geronimo.corba.ior.InternalIOR;
+import org.omg.CORBA.Policy;
+
+public class DefaultServerManager implements ServerManager {
+
+ private final ORB orb;
+
+ public DefaultServerManager(ORB orb) {
+ this.orb = orb;
+ }
+
+ public ServantObject getServantObject(InternalIOR ior, Policy[] policies)
+ throws LocationForwardException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/POA.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/POA.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/POA.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/POA.java Thu Dec 1 23:58:55 2005
@@ -0,0 +1,249 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.server;
+
+import org.omg.CORBA.Object;
+import org.omg.CORBA.Policy;
+import org.omg.PortableServer.AdapterActivator;
+import org.omg.PortableServer.IdAssignmentPolicy;
+import org.omg.PortableServer.IdAssignmentPolicyValue;
+import org.omg.PortableServer.IdUniquenessPolicy;
+import org.omg.PortableServer.IdUniquenessPolicyValue;
+import org.omg.PortableServer.ImplicitActivationPolicy;
+import org.omg.PortableServer.ImplicitActivationPolicyValue;
+import org.omg.PortableServer.LifespanPolicy;
+import org.omg.PortableServer.LifespanPolicyValue;
+import org.omg.PortableServer.POAManager;
+import org.omg.PortableServer.RequestProcessingPolicy;
+import org.omg.PortableServer.RequestProcessingPolicyValue;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.ServantManager;
+import org.omg.PortableServer.ServantRetentionPolicy;
+import org.omg.PortableServer.ServantRetentionPolicyValue;
+import org.omg.PortableServer.ThreadPolicy;
+import org.omg.PortableServer.ThreadPolicyValue;
+import org.omg.PortableServer.POAPackage.AdapterAlreadyExists;
+import org.omg.PortableServer.POAPackage.AdapterNonExistent;
+import org.omg.PortableServer.POAPackage.InvalidPolicy;
+import org.omg.PortableServer.POAPackage.NoServant;
+import org.omg.PortableServer.POAPackage.ObjectAlreadyActive;
+import org.omg.PortableServer.POAPackage.ObjectNotActive;
+import org.omg.PortableServer.POAPackage.ServantAlreadyActive;
+import org.omg.PortableServer.POAPackage.ServantNotActive;
+import org.omg.PortableServer.POAPackage.WrongAdapter;
+import org.omg.PortableServer.POAPackage.WrongPolicy;
+
+public class POA extends org.omg.CORBA.LocalObject implements
+ org.omg.PortableServer.POA {
+
+ public org.omg.PortableServer.POA create_POA(String arg0, POAManager arg1,
+ Policy[] arg2) throws AdapterAlreadyExists, InvalidPolicy {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public org.omg.PortableServer.POA find_POA(String arg0, boolean arg1)
+ throws AdapterNonExistent {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void destroy(boolean arg0, boolean arg1) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public ThreadPolicy create_thread_policy(ThreadPolicyValue arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public LifespanPolicy create_lifespan_policy(LifespanPolicyValue arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IdUniquenessPolicy create_id_uniqueness_policy(
+ IdUniquenessPolicyValue arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IdAssignmentPolicy create_id_assignment_policy(
+ IdAssignmentPolicyValue arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ImplicitActivationPolicy create_implicit_activation_policy(
+ ImplicitActivationPolicyValue arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ServantRetentionPolicy create_servant_retention_policy(
+ ServantRetentionPolicyValue arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public RequestProcessingPolicy create_request_processing_policy(
+ RequestProcessingPolicyValue arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String the_name() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public org.omg.PortableServer.POA the_parent() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public org.omg.PortableServer.POA[] the_children() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public POAManager the_POAManager() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public AdapterActivator the_activator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void the_activator(AdapterActivator arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public ServantManager get_servant_manager() throws WrongPolicy {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void set_servant_manager(ServantManager arg0) throws WrongPolicy {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Servant get_servant() throws NoServant, WrongPolicy {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void set_servant(Servant arg0) throws WrongPolicy {
+ // TODO Auto-generated method stub
+
+ }
+
+ public byte[] activate_object(Servant arg0) throws ServantAlreadyActive,
+ WrongPolicy {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void activate_object_with_id(byte[] arg0, Servant arg1)
+ throws ServantAlreadyActive, ObjectAlreadyActive, WrongPolicy {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deactivate_object(byte[] arg0) throws ObjectNotActive,
+ WrongPolicy {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object create_reference(String arg0) throws WrongPolicy {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object create_reference_with_id(byte[] arg0, String arg1) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public byte[] servant_to_id(Servant arg0) throws ServantNotActive,
+ WrongPolicy {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object servant_to_reference(Servant arg0) throws ServantNotActive,
+ WrongPolicy {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Servant reference_to_servant(Object arg0) throws ObjectNotActive,
+ WrongPolicy, WrongAdapter {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public byte[] reference_to_id(Object arg0) throws WrongAdapter, WrongPolicy {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Servant id_to_servant(byte[] arg0) throws ObjectNotActive,
+ WrongPolicy {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object id_to_reference(byte[] arg0) throws ObjectNotActive,
+ WrongPolicy {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public byte[] id() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void __preinvoke(String operation, byte[] oid,
+ Servant original_servant, Object object) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void __postinvoke() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean __incrementRequestCount() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void __decrementRequestCount() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/POAManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/POAManager.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/POAManager.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/POAManager.java Thu Dec 1 23:58:55 2005
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.server;
+
+import org.omg.CORBA.LocalObject;
+import org.omg.PortableServer.POAManagerPackage.AdapterInactive;
+import org.omg.PortableServer.POAManagerPackage.State;
+
+/** A poa manager represents a set of servers.
+ *
+ * Each server is a logical "endpoint", so a single poa manager can manage
+ * both a plain and an ssl server socket. */
+
+public class POAManager extends LocalObject implements
+ org.omg.PortableServer.POAManager {
+
+ public void activate() throws AdapterInactive {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void hold_requests(boolean arg0) throws AdapterInactive {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void discard_requests(boolean arg0) throws AdapterInactive {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deactivate(boolean arg0, boolean arg1) throws AdapterInactive {
+ // TODO Auto-generated method stub
+
+ }
+
+ public State get_state() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void __checkActive() throws org.omg.CORBA.TRANSIENT {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/ServantObject.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/ServantObject.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/ServantObject.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/ServantObject.java Thu Dec 1 23:58:55 2005
@@ -0,0 +1,88 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.geronimo.corba.server;
+
+
+public class ServantObject
+ extends org.omg.CORBA.portable.ServantObject
+{
+
+ private POA poa;
+ private boolean deactivated;
+ private byte[] oid;
+ public org.omg.PortableServer.Servant original_servant;
+ boolean mediated;
+
+ ServantObject (POA poa, byte[] oid, Object servant)
+ {
+ this.poa = poa;
+ this.deactivated = false;
+ this.oid = oid;
+ this.original_servant = (org.omg.PortableServer.Servant) servant;
+ this.servant = servant;
+
+ if (servant instanceof org.omg.PortableServer.ServantManagerOperations)
+ mediated = false;
+ else
+ mediated = true;
+ }
+
+ public boolean isDeactivated ()
+ {
+ return deactivated;
+ }
+
+ public void setDeactivated (boolean value)
+ {
+ deactivated = value;
+ }
+
+ /**
+ * Returns true on a successful preinvoke.
+ */
+ public ServantObject preinvoke (String operation)
+ {
+ POAManager manager = (POAManager)poa.the_POAManager ();
+
+ // assert that the POAManager has been activated; this may cause a
+ // TRANSIENT exception if that is not the case.
+ manager.__checkActive ();
+
+ // This checks to make sure that the poa is not in the process
+ // of being destroyed before incrementing the ref count.
+ if (poa.__incrementRequestCount () == false)
+ return null;
+
+ // Now do the real thing...
+ poa.__preinvoke (operation, // name of operation
+ oid, // object id
+ original_servant, // the servant
+ null); // the cookie
+
+ return this;
+ }
+
+ public void postinvoke ()
+ {
+ poa.__postinvoke ();
+ poa.__decrementRequestCount ();
+ }
+}
+
+
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/HexUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/HexUtil.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/HexUtil.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/HexUtil.java Thu Dec 1 23:58:55 2005
@@ -0,0 +1,269 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.corba.util;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.nio.ByteBuffer;
+
+/** Utility routines for ascii-hex to binary convertion. */
+public class HexUtil
+{
+ public static byte[] hexToByteArray (String value)
+ {
+ return hexToByteArray (value, 0, value.length ());
+ }
+
+ public static byte[] hexToByteArray (String value, int offset, int len)
+ {
+ if ((len & 1) != 0)
+ throw new org.omg.CORBA.BAD_PARAM ();
+
+ byte[] result = new byte[len/2];
+
+ for (int i = 0; i < len/2; i++) {
+
+ char high = value.charAt (offset+(i*2));
+ char low = value.charAt (offset+(i*2)+1);
+
+ result[i] = (byte) ((charToInt (high) << 4) | charToInt (low));
+
+ // System.out.println ("["+i+"] " + high + "" + low + " = " + (int)result[i]);
+ }
+
+ return result;
+ }
+
+ static int charToInt (char ch)
+ {
+ if (ch >= '0' && ch <= '9')
+ return ch-'0';
+
+ if (ch >= 'A' && ch <= 'F')
+ return 10+ch-'A';
+
+ if (ch >= 'a' && ch <= 'f')
+ return 10+ch-'a';
+
+ throw new org.omg.CORBA.BAD_PARAM ();
+ }
+
+ public static String byteArrayToHex (byte[] data)
+ {
+ return byteArrayToHex(data, 0, data.length);
+ }
+
+ public static String byteArrayToHex (byte[] data, int off, int len)
+ {
+ StringBuffer buf = new StringBuffer ();
+ for (int i = 0; i < len; i++) {
+ byte b = data[off+i];
+ buf.append (intToChar ((b >> 4) & 0xf));
+ buf.append (intToChar (b & 0xf));
+ }
+ return buf.toString ();
+ }
+
+ static char intToChar (int val) {
+
+ switch (val) {
+ case 0: return '0';
+ case 1: return '1';
+ case 2: return '2';
+ case 3: return '3';
+ case 4: return '4';
+ case 5: return '5';
+ case 6: return '6';
+ case 7: return '7';
+ case 8: return '8';
+ case 9: return '9';
+ case 10: return 'A';
+ case 11: return 'B';
+ case 12: return 'C';
+ case 13: return 'D';
+ case 14: return 'E';
+ case 15: return 'F';
+ default:
+ throw new org.omg.CORBA.BAD_PARAM ();
+ }
+ }
+
+ public static String printArray (byte[] data, int off, int len)
+ {
+ return printArray("", data, off, len);
+ }
+
+ public static void printHex (PrintWriter out, String pfx, byte[] data)
+ {
+ out.print(printArray(pfx, data, 0, data.length));
+ }
+
+ /** Generate nice readable hex dump of a binary stream with both hex and printable chars. */
+ public static String printArray (String pfx, byte[] data, int off, int len)
+ {
+ StringBuffer result = new StringBuffer ();
+
+ int maxhex = Integer.toHexString (off+len).length ();
+ int maxnum = Integer.toString (off+len).length ();
+
+ for (int i = 0; i < len; i += 16) {
+ result.append(pfx);
+
+ int start = off+i;
+ int end = start+16;
+ if (end > off+len) {
+ end = off+len;
+ }
+
+ String pos = Integer.toHexString (start);
+ while (pos.length() < maxhex) {
+ pos = " " + pos;
+ }
+ result.append (pos); result.append (":");
+
+ pos = ""+start;
+ while (pos.length() < maxnum) {
+ pos = " " + pos;
+ }
+ result.append (pos); result.append (": ");
+
+ for (int k = start; k < start+16; k++) {
+
+ if (k < end) {
+ byte b = data[k];
+ result.append (intToChar ((b >> 4) & 0xf));
+ result.append (intToChar (b & 0xf));
+ } else {
+ result.append (" ");
+ }
+
+ result.append (' ');
+ }
+
+ result.append (' ');
+
+ for (int k = start; k < start+16; k++) {
+
+ if (k < end) {
+ byte b = data[k];
+ if ((int)b >= 32 && ((int)b) < 127) {
+ result.append ((char) b);
+ } else {
+ result.append ('.');
+ }
+ } else {
+ result.append (' ');
+ }
+ }
+
+ result.append ('\n');
+ }
+
+ return result.toString ();
+ }
+
+
+ static byte get(ByteBuffer[] buffers, int idx)
+ {
+ try {
+ for (int i = 0; i < buffers.length; i++) {
+ if (idx < buffers[i].remaining()) {
+ return buffers[i].get(buffers[i].position() + idx);
+ } else {
+ idx -= buffers[i].remaining();
+ }
+ }
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ throw e;
+ } catch (Error e) {
+ e.printStackTrace();
+ throw e;
+ }
+
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ public static void printHex(PrintStream out, String pfx, ByteBuffer[] data) {
+
+ int off = 0;
+ int len = 0;
+
+ for (int i = 0; i < data.length; i++) {
+ len += data[i].remaining();
+ }
+
+ StringBuffer result = new StringBuffer ();
+
+ int maxhex = Integer.toHexString (off+len).length ();
+ int maxnum = Integer.toString (off+len).length ();
+
+ for (int i = 0; i < len; i += 16) {
+ out.print(pfx);
+
+ int start = off+i;
+ int end = start+16;
+ if (end > off+len) {
+ end = off+len;
+ }
+
+ String pos = Integer.toHexString (start);
+ while (pos.length() < maxhex) {
+ pos = " " + pos;
+ }
+ out.print (pos); out.print (":");
+
+ pos = ""+start;
+ while (pos.length() < maxnum) {
+ pos = " " + pos;
+ }
+ out.print (pos); out.print (": ");
+
+ for (int k = start; k < start+16; k++) {
+
+ if (k < end) {
+ byte b = get (data, k);
+ out.print (intToChar ((b >> 4) & 0xf));
+ out.print (intToChar (b & 0xf));
+ } else {
+ out.print (" ");
+ }
+
+ out.print (' ');
+ }
+
+ out.print (' ');
+
+ for (int k = start; k < start+16; k++) {
+
+ if (k < end) {
+ byte b = get (data, k);
+ if ((int)b >= 32 && ((int)b) < 127) {
+ out.print ((char) b);
+ } else {
+ out.print ('.');
+ }
+ } else {
+ out.print (' ');
+ }
+ }
+
+ out.print ('\n');
+ }
+ }
+}
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/idl/HelloObject.idl
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/idl/HelloObject.idl?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/idl/HelloObject.idl (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/idl/HelloObject.idl Thu Dec 1 23:58:55 2005
@@ -0,0 +1,23 @@
+
+
+#pragma prefix "geronimo.apache.org"
+
+
+module corba {
+ module test {
+ interface HelloObject {
+
+ void hello0();
+ void hello1(in short s);
+ void hello2(in long l);
+ void hello3(in string s);
+ void hello4(in wstring s);
+
+ short hello10();
+ long hello11();
+ string hello12();
+ wstring hello13();
+
+ };
+ };
+};
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/CorbaTestSuite.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/CorbaTestSuite.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/CorbaTestSuite.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/CorbaTestSuite.java Thu Dec 1 23:58:55 2005
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.test;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class CorbaTestSuite extends TestCase {
+ public static Test suite() {
+
+ TestSuite ts = new TestSuite();
+ ts.addTest(new G2SHelloWorldTest());
+ return ts;
+
+ }
+}
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/G2SHelloWorldTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/G2SHelloWorldTest.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/G2SHelloWorldTest.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/G2SHelloWorldTest.java Thu Dec 1 23:58:55 2005
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.test;
+
+import java.util.Properties;
+
+public class G2SHelloWorldTest extends HelloWorldTest {
+
+ public G2SHelloWorldTest() {
+ super();
+ }
+
+ protected Properties getAgentProperties(String agent) {
+ Properties props = super.getAgentProperties(agent);
+ if ("client".equals(agent)) {
+
+ props.setProperty(ORBClassKey, "org.apache.geronimo.corba.ORB");
+ props.setProperty(ORBSingletonClassKey, "org.apache.geronimo.corba.SingletonORB");
+
+ }
+ return props;
+ }
+
+
+}
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/HelloObjectServant.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/HelloObjectServant.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/HelloObjectServant.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/HelloObjectServant.java Thu Dec 1 23:58:55 2005
@@ -0,0 +1,76 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.test;
+
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.DomainManager;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.SetOverrideType;
+
+public class HelloObjectServant extends HelloObjectPOA {
+
+ public void hello0() {
+ System.err.println("INSIDE HELLO0");;
+ }
+
+ public void hello1(short s) {
+ System.err.println("INSIDE HELLO1 "+Integer.toHexString(s));;
+ }
+
+ public void hello2(int l) {
+ System.err.println("INSIDE HELLO2 "+Integer.toHexString(l));;
+ }
+
+ public void hello3(String s) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void hello4(String s) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public short hello10() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int hello11() {
+ System.err.println("INSIDE HELLO 11");
+ // TODO Auto-generated method stub
+ return 0xcafebaba;
+ }
+
+ public String hello12() {
+ // TODO Auto-generated method stub
+ return "abc";
+ }
+
+ public String hello13() {
+ // TODO Auto-generated method stub
+ return "abc";
+ }
+
+
+}