Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 24305 invoked from network); 11 Dec 2005 00:15:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Dec 2005 00:15:26 -0000 Received: (qmail 72156 invoked by uid 500); 11 Dec 2005 00:15:21 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 72066 invoked by uid 500); 11 Dec 2005 00:15:19 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 71937 invoked by uid 99); 11 Dec 2005 00:15:17 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Dec 2005 16:15:17 -0800 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 10 Dec 2005 16:15:12 -0800 Received: (qmail 21657 invoked by uid 65534); 11 Dec 2005 00:14:51 -0000 Message-ID: <20051211001451.21639.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r355821 [1/2] - 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/giop/ src/main/java/org/apache/geronimo/co... Date: Sun, 11 Dec 2005 00:14:35 -0000 To: scm@geronimo.apache.org From: adc@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: adc Date: Sat Dec 10 16:14:16 2005 New Revision: 355821 URL: http://svn.apache.org/viewcvs?rev=355821&view=rev Log: PR: GERONIMO-1242 Submitted by: Kresten Krab Thorup Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/Policies.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/initials/ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/initials/InitialServicesManager.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/ClientRequestInfoImpl.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/CodecFactoryImpl.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/CodecImpl.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/IORInfoImpl.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/InterceptorManager.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/RequestInfoImpl.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/ServerRequestInfoImpl.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/policy/ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/policy/PolicyFactoryManager.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/ServerInvocation.java Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/pom.xml geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ClientDelegate.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ClientInvocation.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/Invocation.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/InvocationProfile.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/InvocationProfileSelector.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/LocationForwardException.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ORB.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/PlainObject.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/channel/RingByteBuffer.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPHelper.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPInputStream.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPMessageTransport.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationOutputStream.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/IIOPInvocationProfile.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/OutputStreamBase.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/CodeSetsComponent.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalExceptionDetailMessage.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalServiceContext.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalServiceContextList.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/MultiComponentProfile.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/Profile.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TaggedValue.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/UnknownProfile.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/DefaultServerManager.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/server/ServantObject.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntegerToObjectHashMap.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntegerToObjectMap.java geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/G2SHelloWorldTest.java Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/pom.xml URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/pom.xml?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/pom.xml (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/pom.xml Sat Dec 10 16:14:16 2005 @@ -3,7 +3,7 @@ org.apache.geronimo geronimo - 1.0-SNAPSHOT + 1.0 4.0.0 @@ -27,8 +27,8 @@ org.apache.geronimo.specs - geronimo-spec-corba - 2.3-rc4 + geronimo-corba_2.3_spec + 1.0 @@ -36,19 +36,6 @@ - org.codehaus.mojo - maven-idlj-plugin - - - - generate - generate-test - - - - - - maven-antrun-plugin @@ -91,7 +78,6 @@ - generate generate-test Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ClientDelegate.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ClientDelegate.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ClientDelegate.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ClientDelegate.java Sat Dec 10 16:14:16 2005 @@ -45,7 +45,7 @@ private final ORB orb; - private InternalIOR ior; + private InternalIOR effective_ior; private InvocationProfileSelector profileManager; @@ -63,13 +63,15 @@ private ThreadLocal retryState; + private Policies effective_policies; + /* @deprecated */ public ClientDelegate(InternalIOR ior) { this(ior, null); } public ClientDelegate(InternalIOR ior, Policy[] policies) { - this.ior = ior; + this.effective_ior = ior; this.policies = policies; this.orb = (ORB) ior.orb; } @@ -125,9 +127,9 @@ } catch (LocationForwardException lex) { - ior = lex.getIor (); + effective_ior = lex.getIor (); if (lex.isPermanent ()) { - orig_ior = ior; + orig_ior = effective_ior; } profileManager.reset(); @@ -175,7 +177,7 @@ // RequestHeader to output stream. OutputStreamBase result = manager.setupRequest(operation, - responseExpected); + responseExpected, effective_policies); if (result.getClientInvocation() == null) { throw new INTERNAL(); @@ -183,10 +185,14 @@ return result; - } catch (org.omg.PortableInterceptor.ForwardRequest ex) { - - setIOR(InternalIOR.extract(ex.forward)); + } catch (LocationForwardException ex) { + if (ex.isPermanent()) { + setOrigIOR(ex.getIor()); + } + + setIOR(ex.getIor()); + continue; } @@ -194,8 +200,14 @@ } } + private void setOrigIOR(InternalIOR ior2) { + this.orig_ior = ior2; + this.effective_ior = ior2; + this.profileManager = null; + } + private void setIOR(InternalIOR ior) { - this.ior = ior; + this.effective_ior = ior; this.profileManager = null; } @@ -226,7 +238,18 @@ InputStream in = inv.invoke(this, out); - inv.checkException(); + try { + inv.checkException(); + } catch (LocationForwardException e) { + + if (e.isPermanent()) { + setOrigIOR(e.getIor()); + } else { + setIOR(e.getIor()); + } + + throw new RemarshalException(); + } return in; } @@ -405,7 +428,7 @@ } public InternalIOR getInternalIOR() { - return ior; + return effective_ior; } public ORB getORB() { @@ -413,7 +436,7 @@ } public InternalIOR getIOR() { - return ior; + return effective_ior; } private synchronized void setRetry (boolean value) @@ -445,6 +468,10 @@ setRetry (value); return result; } + + public InternalIOR getOrigIOR() { + return orig_ior; + } } Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ClientInvocation.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ClientInvocation.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ClientInvocation.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ClientInvocation.java Sat Dec 10 16:14:16 2005 @@ -18,19 +18,23 @@ import java.util.List; +import org.omg.CORBA.INTERNAL; import org.omg.CORBA.SystemException; import org.omg.CORBA.portable.ApplicationException; import org.omg.CORBA.portable.InputStream; import org.omg.GIOP.ReplyStatusType_1_2; import org.omg.PortableInterceptor.ForwardRequest; -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.interceptor.ClientRequestInfoImpl; +import org.apache.geronimo.corba.interceptor.InterceptorManager; import org.apache.geronimo.corba.io.GIOPVersion; import org.apache.geronimo.corba.io.InputStreamBase; import org.apache.geronimo.corba.io.OutputStreamBase; +import org.apache.geronimo.corba.ior.InternalIOR; import org.apache.geronimo.corba.ior.InternalServiceContextList; +import org.apache.geronimo.corba.ior.Profile; public class ClientInvocation implements Invocation { @@ -48,17 +52,26 @@ private ReplyStatusType_1_2 reply_status; private SystemException systemException; private ApplicationException userException; + private final Policies policies; + private InterceptorManager im; + private ClientRequestInfoImpl ir; + private ORB orb; - public ClientInvocation(InvocationProfileSelector manager, + public ClientInvocation(ORB orb, + InvocationProfileSelector manager, String operation, boolean responseExpected, - InvocationProfile profile + InvocationProfile profile, + Policies policies ) { + this.orb = orb; + this.im = orb.getInterceptorManager(); this.manager = manager; this.operation = operation; this.responseExpected = responseExpected; this.profile = profile; + this.policies = policies; this.iscl = new InternalServiceContextList(); } @@ -67,21 +80,26 @@ } - public GIOPOutputStream startRequest() - throws ForwardRequest + public OutputStreamBase startRequest() + throws LocationForwardException { - return profile.startRequest(this); + if (im != null) { + ir = im.clientSendRequest(this); + } + + return profile.startRequest(this); } public String getOperation() { return operation; } - public byte getResponseFlags() { + public short getSyncScope() { + // TODO: in the future we may provide a way to set this if (responseExpected) { - return GIOPMessageTransport.SYNC_WITH_TARGET; + return Invocation.SYNC_WITH_SERVER; } else { - return GIOPMessageTransport.SYNC_NONE; + return Invocation.SYNC_NONE; } } @@ -94,30 +112,69 @@ } public boolean isResponseExpected() { - // TODO Auto-generated method stub - return true; + return responseExpected; } public void setRequestID(RequestID requestID) { this.requestID = requestID; } - public InternalServiceContextList getRequestServiceContextList() { + public InternalServiceContextList getRequestServiceContextList(boolean create) { + if (create && iscl == null) { + iscl = new InternalServiceContextList(); + } return iscl; } - public RequestID getRequestID() { + public int getRequestID() { + return requestID.value(); + } + + public RequestID getRequestIDObject() { return requestID; } public void releaseReply(InputStreamBase in) { - profile.releaseReply(in); + try { + // + // This is effectively what flushes the message + // to the underlying transport + // + profile.releaseReply(in); + } catch (SystemException ex) { + + setSystemException(ex); + try { + checkException(); + } catch (ApplicationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (LocationForwardException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + /** this is where we handle the "normal" case for client interceptors */ + if (im != null && ir != null && userException == null && systemException == null) { + im.clientReceiveReply(ir); + } } - public void setResposeServiceContextList (InternalServiceContextList scl) { + public void setResponseServiceContextList (InternalServiceContextList scl) { this.respose_scl = scl; } + public InternalServiceContextList getResponseServiceContextList(boolean create) { + if ( create && this.respose_scl == null) { + respose_scl = new InternalServiceContextList(); + } + + return respose_scl; + } + public void setReplyStatus(ReplyStatusType_1_2 reply_status) { this.reply_status = reply_status; } @@ -136,19 +193,46 @@ this.reply_status = ReplyStatusType_1_2.USER_EXCEPTION; } - public void checkException() throws ApplicationException { - if (this.systemException != null) { + public void checkException() throws ApplicationException, LocationForwardException { + + if (systemException != null) { + + if (im != null) { + im.clientReceiveException(ir, true, systemException, systemException.getClass().getName()); + } + throw systemException; } if (userException != null) { + + if (im != null) { + im.clientReceiveException(ir, false, userException, userException.getClass().getName()); + } + throw userException; } } - public InternalServiceContextList getReplyServiceContextList() { - return respose_scl; + + public InternalIOR getEffectiveIOR() { + return getDelegate().getIOR(); + } + + public InternalIOR getOrigIOR() { + return getDelegate().getOrigIOR(); } + public Policies getPolicies() { + return policies; + } + + public Profile getProfile() { + return profile.getProfile(); + } + + public ORB getORB() { + return orb; + } } Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/Invocation.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/Invocation.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/Invocation.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/Invocation.java Sat Dec 10 16:14:16 2005 @@ -16,6 +16,31 @@ */ package org.apache.geronimo.corba; +import java.util.List; + +import org.apache.geronimo.corba.ior.InternalServiceContextList; + public interface Invocation { + + static public final byte SYNC_NONE = 0; + static public final byte SYNC_WITH_TRANSPORT = 1; + static public final byte SYNC_WITH_SERVER = 2; + static public final byte SYNC_WITH_TARGET = 3; + + public abstract int getRequestID(); + + public abstract String getOperation(); + + public abstract short getSyncScope(); + + public abstract boolean isResponseExpected(); + + public abstract InternalServiceContextList getResponseServiceContextList(boolean create); + + public abstract InternalServiceContextList getRequestServiceContextList(boolean create); + + public abstract ORB getORB(); + + public abstract Policies getPolicies(); } Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/InvocationProfile.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/InvocationProfile.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/InvocationProfile.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/InvocationProfile.java Sat Dec 10 16:14:16 2005 @@ -19,6 +19,7 @@ import org.apache.geronimo.corba.giop.GIOPOutputStream; import org.apache.geronimo.corba.io.InputStreamBase; import org.apache.geronimo.corba.io.OutputStreamBase; +import org.apache.geronimo.corba.ior.Profile; import org.omg.CORBA.portable.InputStream; public interface InvocationProfile { @@ -29,5 +30,7 @@ OutputStreamBase out); void releaseReply(InputStreamBase in); + + Profile getProfile(); } Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/InvocationProfileSelector.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/InvocationProfileSelector.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/InvocationProfileSelector.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/InvocationProfileSelector.java Sat Dec 10 16:14:16 2005 @@ -47,12 +47,12 @@ return orb; } - public OutputStreamBase setupRequest(String operation, boolean responseExpected) - throws org.omg.PortableInterceptor.ForwardRequest + public OutputStreamBase setupRequest(String operation, boolean responseExpected, Policies policies) + throws LocationForwardException { while (true) { ClientInvocation invocation = createClientInvcation(operation, - responseExpected); + responseExpected, policies); try { @@ -63,10 +63,6 @@ return out; } - catch (org.omg.PortableInterceptor.ForwardRequest ex) { - throw ex; - - } catch (RuntimeException ex) { currentProfile++; @@ -75,13 +71,14 @@ throw ex; } - } + } } } private ClientInvocation createClientInvcation(String operation, - boolean responseExpected) + boolean responseExpected, + Policies policies) { if (currentProfile >= profiles.length) { @@ -90,7 +87,7 @@ InvocationProfile profile = profiles[currentProfile]; - return new ClientInvocation(this, operation, responseExpected, profile); + return new ClientInvocation(orb, this, operation, responseExpected, profile, policies); } public ClientDelegate getDelegate() { Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/LocationForwardException.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/LocationForwardException.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/LocationForwardException.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/LocationForwardException.java Sat Dec 10 16:14:16 2005 @@ -18,6 +18,8 @@ import org.apache.geronimo.corba.ior.InternalIOR; +/** LocationForwardException is used internally in the Geronimo ORB to handle redirects. */ + public class LocationForwardException extends Exception { private final InternalIOR ior; Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ORB.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ORB.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ORB.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ORB.java Sat Dec 10 16:14:16 2005 @@ -23,13 +23,15 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.geronimo.corba.dii.NVListImpl; +import org.apache.geronimo.corba.initials.InitialServicesManager; +import org.apache.geronimo.corba.interceptor.InterceptorManager; import org.apache.geronimo.corba.io.DefaultConnectionManager; import org.apache.geronimo.corba.io.EncapsulationInputStream; import org.apache.geronimo.corba.io.InputStreamBase; import org.apache.geronimo.corba.ior.InternalIOR; import org.apache.geronimo.corba.ior.URLManager; +import org.apache.geronimo.corba.policy.PolicyFactoryManager; import org.apache.geronimo.corba.server.DefaultServerManager; -import org.apache.geronimo.corba.server.ServantObject; import org.omg.CORBA.Context; import org.omg.CORBA.ContextList; import org.omg.CORBA.NO_IMPLEMENT; @@ -41,6 +43,7 @@ import org.omg.CORBA.WrongTransaction; import org.omg.CORBA.ORBPackage.InvalidName; import org.omg.CORBA.portable.OutputStream; +import org.omg.PortableInterceptor.ORBInitInfoOperations; import EDU.oswego.cs.dl.util.concurrent.Executor; import EDU.oswego.cs.dl.util.concurrent.ThreadedExecutor; @@ -57,6 +60,12 @@ private ServerManager sm; + private InitialServicesManager ism; + + private PolicyFactoryManager pfm; + + private InterceptorManager im; + protected void set_parameters(String[] args, Properties props) { sm = new DefaultServerManager(this); @@ -70,22 +79,32 @@ throw t; } } + + ism = new InitialServicesManager(this); + ism.init(args, props); + + pfm = new PolicyFactoryManager(this); + + im = new InterceptorManager(this, ism); + im.init(args, props); } protected void set_parameters(Applet app, Properties props) { // TODO Auto-generated method stub - + throw new NO_IMPLEMENT(); } public String[] list_initial_services() { - // TODO Auto-generated method stub - return null; + return getInitialServicesManager().list_initial_services(); + } + + private InitialServicesManager getInitialServicesManager() { + return ism; } public Object resolve_initial_references(String object_name) throws InvalidName { - // TODO Auto-generated method stub - return null; + return getInitialServicesManager().resolve_initial_references(object_name); } public String object_to_string(Object obj) { @@ -177,4 +196,17 @@ return sm; } + public Object createObject(InternalIOR forward_ior) { + PlainObject po = new PlainObject(); + po._set_delegate(new ClientDelegate(forward_ior)); + return po; + } + + public PolicyFactoryManager getPolicyFactoryManager() { + return pfm; + } + + public InterceptorManager getInterceptorManager() { + return im; + } } Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/PlainObject.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/PlainObject.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/PlainObject.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/PlainObject.java Sat Dec 10 16:14:16 2005 @@ -18,7 +18,10 @@ import org.omg.CORBA_2_3.portable.ObjectImpl; - +/** PlainObject is a simple ObjectImpl with implementations for set/get delegate + * + * @see org.omg.CORBA_2_3.portable.ObjectImpl + * */ public class PlainObject extends ObjectImpl { public PlainObject() { @@ -29,12 +32,12 @@ _set_delegate(delegate); } - ClientDelegate __get_delegate() { + /*package*/ ClientDelegate __get_delegate() { return (ClientDelegate) _get_delegate(); } public String[] _ids() { - return new String[]{__get_delegate().getIOR().getType()}; + return new String[]{ __get_delegate().getIOR().getType() }; } } Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/Policies.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/Policies.java?rev=355821&view=auto ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/Policies.java (added) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/Policies.java Sat Dec 10 16:14:16 2005 @@ -0,0 +1,40 @@ +/** + * + * 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; + +import org.omg.CORBA.Policy; + +public class Policies { + + private final Policy[] policies; + + public Policies(Policy[] policies) { + this.policies = policies; + } + + public Policy get(int type) { + for (int i = 0; i < policies.length; i++) { + if (type == policies[i].policy_type()) { + return policies[i]; + } + } + + return null; + } + +} Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/channel/RingByteBuffer.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/channel/RingByteBuffer.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/channel/RingByteBuffer.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/channel/RingByteBuffer.java Sat Dec 10 16:14:16 2005 @@ -38,8 +38,7 @@ /** - * @author Jeppe Sommer (jso@trifork.com) - * @author Kresten Krab Thorup (krab@trifotk.com) + * @version $Revision: $ $Date: $ */ public abstract class RingByteBuffer extends RingBuffer { Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPHelper.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPHelper.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPHelper.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPHelper.java Sat Dec 10 16:14:16 2005 @@ -28,6 +28,7 @@ import org.apache.geronimo.corba.util.StringUtil; import org.omg.CORBA.CompletionStatus; import org.omg.CORBA.SystemException; +import org.omg.CORBA.UserException; import org.omg.CORBA_2_3.portable.InputStream; public class GIOPHelper { @@ -37,7 +38,7 @@ static SystemException unmarshalSystemException( InternalServiceContextList scl, InputStream in) { - InternalExceptionDetailMessage msg = InternalExceptionDetailMessage + InternalExceptionDetailMessage msg = scl == null ? null : InternalExceptionDetailMessage .get(scl); String id = in.read_string(); @@ -226,6 +227,67 @@ for (int i = 0; i < words.length; i++) { keyWords.add(words[i]); + } + } + + public static void insertException(org.omg.CORBA.Any any, Exception ex) { + try { + Class exClass = ex.getClass(); + String helper = exClass.getName() + "Helper"; + Class c = classForName(helper); + final Class[] paramTypes = { org.omg.CORBA.Any.class, exClass }; + java.lang.reflect.Method m = c.getMethod("insert", paramTypes); + final java.lang.Object[] args = { any, ex }; + m.invoke(null, args); + } catch (ClassNotFoundException e) { + } catch (NoSuchMethodException e) { + throw new org.omg.CORBA.INTERNAL(); + } catch (IllegalAccessException e) { + throw new org.omg.CORBA.INTERNAL(); + } catch (IllegalArgumentException e) { + throw new org.omg.CORBA.INTERNAL(); + } catch (java.lang.reflect.InvocationTargetException e) { + throw new org.omg.CORBA.INTERNAL(); + } catch (SecurityException e) { + } + } + + public static String getExceptionID(Exception ex) { + if (ex instanceof SystemException) { + String exName = ex.getClass().getName(); + if (exName.startsWith("org.omg.CORBA")) { + return "IDL:omg.org/" + exName.substring(8).replace('.', '/') + + ":1.0"; + } else { + return "IDL:omg.org/CORBA/UNKNOWN:1.0"; + } + } else if (ex instanceof UserException) { + Class exClass = ex.getClass(); + String exName = exClass.getName(); + String id = null; + try { + Class c = classForName(exName + "Helper"); + java.lang.reflect.Method m = c.getMethod("id", null); + id = (String) m.invoke(null, null); + } catch (ClassNotFoundException e) { + } catch (NoSuchMethodException e) { + throw new org.omg.CORBA.INTERNAL(); + } catch (IllegalAccessException e) { + throw new org.omg.CORBA.INTERNAL(); + } catch (IllegalArgumentException e) { + throw new org.omg.CORBA.INTERNAL(); + } catch (java.lang.reflect.InvocationTargetException e) { + throw new org.omg.CORBA.INTERNAL(); + } catch (SecurityException e) { + } + + if (id == null) { + return "IDL:omg.org/CORBA/UserException:1.0"; + } else { + return id; + } + } else { + throw new org.omg.CORBA.INTERNAL("unknown exception"); } } Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPInputStream.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPInputStream.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPInputStream.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPInputStream.java Sat Dec 10 16:14:16 2005 @@ -68,6 +68,7 @@ private void check(int size) { if (position + size > limit) { size_of_previous_fragments += limit - message_start; + // who is responsible for skipping to end-of-message? controller.getNextFragment(this); } } Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPMessageTransport.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPMessageTransport.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPMessageTransport.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPMessageTransport.java Sat Dec 10 16:14:16 2005 @@ -29,6 +29,7 @@ import org.omg.GIOP.ReplyStatusType_1_2Helper; import org.apache.geronimo.corba.ClientInvocation; +import org.apache.geronimo.corba.Invocation; import org.apache.geronimo.corba.ORB; import org.apache.geronimo.corba.channel.InputHandler; import org.apache.geronimo.corba.channel.OutputChannel; @@ -40,14 +41,6 @@ public class GIOPMessageTransport implements InputHandler { - static public final byte SYNC_NONE = 0; - - static final byte SYNC_WITH_TRANSPORT = 1; - - static public final byte SYNC_WITH_SERVER = 2; - - static public final byte SYNC_WITH_TARGET = 3; - public boolean isAssignedHere(RequestID id) { return id.isAssignedHere(isClient); } @@ -278,8 +271,7 @@ InternalTargetAddress targetAddress, ClientInvocation inv, byte[] principal) throws IOException { InternalServiceContextList contextList = inv - .getRequestServiceContextList(); - byte response_flags = inv.getResponseFlags(); + .getRequestServiceContextList(true); String operation = inv.getOperation(); RequestID requestID = getNextRequestID(); @@ -306,16 +298,7 @@ { contextList.write(out); out.write_long(requestID.value()); - switch (response_flags) { - case SYNC_NONE: - case SYNC_WITH_TRANSPORT: - out.write_boolean(false); - break; - case SYNC_WITH_SERVER: - case SYNC_WITH_TARGET: - out.write_boolean(true); - break; - } + out.write_boolean(inv.isResponseExpected()); out.skip(3); targetAddress.writeObjectKey(out); if (principal == null) { @@ -330,7 +313,18 @@ // Write RequestHeader_1_2 { out.write_long(requestID.value()); - out.write_octet(response_flags); + switch(inv.getSyncScope()) { + case Invocation.SYNC_NONE: + case Invocation.SYNC_WITH_TRANSPORT: + out.write_octet((byte)0); + break; + case Invocation.SYNC_WITH_SERVER: + out.write_octet((byte)1); + break; + case Invocation.SYNC_WITH_TARGET: + out.write_octet((byte)3); + } + out.skip(3); // can be dropped, target address aligns anyway targetAddress.write(out); out.write_string(operation); @@ -366,7 +360,7 @@ public GIOPInputStream waitForResponse(ClientInvocation inv) { MessageHeader header = (MessageHeader) transport.waitForResponse(inv - .getRequestID()); + .getRequestIDObject()); GIOPInputStream in = new GIOPInputStream(orb, header.getGIOPVersion(), header, transport .getInputChannel()); @@ -381,7 +375,7 @@ case 2: // read reply (for GIOP 1.2 we have already read the request id) - int request_id = inv.getRequestID().id; + int request_id = inv.getRequestID(); ReplyStatusType_1_2 reply_status = ReplyStatusType_1_2Helper .read(in); @@ -390,7 +384,7 @@ InternalServiceContextList scl = new InternalServiceContextList(); scl.read(in); - inv.setResposeServiceContextList(scl); + inv.setResponseServiceContextList(scl); break; default: @@ -410,7 +404,7 @@ return null; case ReplyStatusType_1_2._SYSTEM_EXCEPTION: - sex = GIOPHelper.unmarshalSystemException(inv.getReplyServiceContextList(), in); + sex = GIOPHelper.unmarshalSystemException(inv.getResponseServiceContextList(false), in); inv.setSystemException(sex); return null; Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/initials/InitialServicesManager.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/initials/InitialServicesManager.java?rev=355821&view=auto ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/initials/InitialServicesManager.java (added) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/initials/InitialServicesManager.java Sat Dec 10 16:14:16 2005 @@ -0,0 +1,53 @@ +/** + * + * 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.initials; + +import java.util.Properties; + +import org.apache.geronimo.corba.ORB; +import org.omg.CORBA.Object; +import org.omg.CORBA.ORBPackage.InvalidName; + +public class InitialServicesManager { + + private final ORB orb; + + public InitialServicesManager(ORB orb) { + this.orb = orb; + } + + public String[] list_initial_services() { + // TODO Auto-generated method stub + return null; + } + + public Object resolve_initial_references(String object_name) throws InvalidName { + // TODO Auto-generated method stub + return null; + } + + public void register_initial_reference(String id, Object obj) throws InvalidName { + // TODO Auto-generated method stub + + } + + public void init(String[] args, Properties props) { + // TODO Auto-generated method stub + + } + +} Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/ClientRequestInfoImpl.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/ClientRequestInfoImpl.java?rev=355821&view=auto ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/ClientRequestInfoImpl.java (added) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/ClientRequestInfoImpl.java Sat Dec 10 16:14:16 2005 @@ -0,0 +1,209 @@ +/** + * + * 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.interceptor; + +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.ClientInvocation; +import org.apache.geronimo.corba.LocationForwardException; +import org.apache.geronimo.corba.ORB; +import org.apache.geronimo.corba.Policies; +import org.apache.geronimo.corba.giop.GIOPHelper; +import org.apache.geronimo.corba.ior.InternalIOR; +import org.apache.geronimo.corba.ior.InternalServiceContext; +import org.apache.geronimo.corba.ior.InternalServiceContextList; +import org.apache.geronimo.corba.ior.Profile; +import org.omg.CORBA.SystemException; +import org.omg.PortableInterceptor.ClientRequestInfo; +import org.omg.PortableInterceptor.ClientRequestInterceptor; +import org.omg.PortableInterceptor.ForwardRequest; +import org.omg.PortableInterceptor.LOCATION_FORWARD; +import org.omg.PortableInterceptor.SUCCESSFUL; +import org.omg.PortableInterceptor.SYSTEM_EXCEPTION; +import org.omg.PortableInterceptor.USER_EXCEPTION; + +public class ClientRequestInfoImpl extends RequestInfoImpl implements + ClientRequestInfo { + static final Log log = LogFactory.getLog(ClientRequestInfoImpl.class); + + InternalIOR effective_ior; + InternalIOR orig_ior; + + Profile pi; + + ClientRequestInterceptor[] clinterceptors; + + ClientRequestInfoImpl(ClientInvocation inv) { + super(inv); + + this.effective_ior = inv.getEffectiveIOR(); + this.orig_ior = inv.getOrigIOR(); + this.pi = inv.getProfile(); + + status = -1; + } + + public org.omg.CORBA.Object target() { + return getORB().createObject(orig_ior); + } + + public org.omg.CORBA.Object effective_target() { + return getORB().createObject(effective_ior); + } + + public org.omg.IOP.TaggedProfile effective_profile() { + return pi.asTaggedProfile(getORB()); + } + + public org.omg.CORBA.Any received_exception() { + if (received_ex instanceof org.omg.CORBA.UnknownUserException) { + return ((org.omg.CORBA.UnknownUserException) received_ex).except; + } + + org.omg.CORBA.Any any = getORB().create_any(); + GIOPHelper.insertException(any, received_ex); + return any; + } + + public java.lang.String received_exception_id() { + if (status != SYSTEM_EXCEPTION.value && status != USER_EXCEPTION.value) { + + throw new org.omg.CORBA.BAD_INV_ORDER(); + } + + if (received_ex_id == null) + received_ex_id = GIOPHelper.getExceptionID(received_ex); + + return received_ex_id; + } + + public org.omg.IOP.TaggedComponent get_effective_component(int id) { + for (int i = 0; i < pi.getComponentCount(); i++) { + if (pi.getTag(i) == id) + return pi.getTaggedComponent(i); + } + + throw new org.omg.CORBA.BAD_PARAM("no comonent id: " + id); + } + + public org.omg.IOP.TaggedComponent[] get_effective_components(int id) { + throw new org.omg.CORBA.NO_IMPLEMENT(); + } + + public org.omg.CORBA.Policy get_request_policy(int type) { + org.omg.CORBA.Policy p = inv.getPolicies().get(type); + + if (p == null) + throw new org.omg.CORBA.INV_POLICY(); + else + return p; + } + + public void add_request_service_context( + org.omg.IOP.ServiceContext service_context, boolean replace) { + + inv.getRequestServiceContextList(false).add(new InternalServiceContext(service_context), replace); + } + + // + // private members... + // + + void do_send_request(List interceptors) throws LocationForwardException { + clinterceptors = new ClientRequestInterceptor[interceptors.size()]; + + for (int i = 0; i < interceptors.size(); i++) { + ClientRequestInterceptor cli = (ClientRequestInterceptor) interceptors + .get(i); + + try { + if (log.isDebugEnabled()) { + log.debug("send_request " + cli.getClass().getName()); + } + + cli.send_request(this); + clinterceptors[i] = cli; + + } catch (org.omg.CORBA.SystemException ex) { + __setStatus(SYSTEM_EXCEPTION.value); + __setReceivedEx(ex, null); + do_receive_reply(); + } catch (ForwardRequest ex) { + ClientDelegate od = (ClientDelegate) ((org.omg.CORBA.portable.ObjectImpl) ex.forward) + ._get_delegate(); + + __setForwardIOR(od.getIOR()); + do_receive_reply(); + } + } + } + + void do_receive_reply() throws LocationForwardException { + for (int i = 0; i < clinterceptors.length; i++) { + try { + ClientRequestInterceptor cli = clinterceptors[i]; + + if (cli == null) { + log.debug("ClientRequestInterceptor [" + i + "] is null"); + if (received_ex != null) { + log.debug("received_ex", received_ex); + } + continue; + } + + if (log.isDebugEnabled()) { + log.debug("receive_reply " + cli.getClass().getName()); + } + + if (status == SUCCESSFUL.value) { + cli.receive_reply(this); + + } else if (status == SYSTEM_EXCEPTION.value + || status == USER_EXCEPTION.value) { + cli.receive_exception(this); + + } else { + cli.receive_other(this); + } + + } catch (SystemException ex) { + __setStatus(SYSTEM_EXCEPTION.value); + __setReceivedEx(ex, null); + + } catch (ForwardRequest ex) { + + ClientDelegate od = (ClientDelegate) ((org.omg.CORBA.portable.ObjectImpl) ex.forward) + ._get_delegate(); + + __setForwardIOR(od.getIOR()); + } + } + + if (status == SYSTEM_EXCEPTION.value) { + throw (SystemException) received_ex; + } + + if (status == LOCATION_FORWARD.value) { + throw new LocationForwardException(forward_ior, false); + } + + } +} Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/CodecFactoryImpl.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/CodecFactoryImpl.java?rev=355821&view=auto ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/CodecFactoryImpl.java (added) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/CodecFactoryImpl.java Sat Dec 10 16:14:16 2005 @@ -0,0 +1,86 @@ +/** + * + * 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.interceptor; + + +import org.apache.geronimo.corba.ORB; +import org.omg.CORBA.LocalObject; +import org.omg.IOP.Codec; +import org.omg.IOP.CodecFactory; +import org.omg.IOP.ENCODING_CDR_ENCAPS; +import org.omg.IOP.Encoding; +import org.omg.IOP.CodecFactoryPackage.UnknownEncoding; + + +/** + * @version $Revision: $ $Date: $ + */ +public class CodecFactoryImpl extends LocalObject implements CodecFactory { + + ORB orb; + Codec giop_1_0_codec = null; + Codec giop_1_1_codec = null; + Codec giop_1_2_codec = null; + + public CodecFactoryImpl(ORB orb) { + this.orb = orb; + } + + /** + * @see org.omg.IOP.CodecFactoryOperations#create_codec(Encoding) + */ + public Codec create_codec(Encoding enc) throws UnknownEncoding { + + if (enc.format != ENCODING_CDR_ENCAPS.value) { + throw new UnknownEncoding("only CDR Encapsulation supported"); + } + + if (enc.major_version != 1) { + throw new UnknownEncoding("Only GIOP major version 1 supported"); + } + + switch (enc.minor_version) { + case 0: + if (giop_1_0_codec == null) { + giop_1_0_codec = new CodecImpl (orb, enc); + } + + return giop_1_0_codec; + + case 1: + if (giop_1_1_codec == null) { + giop_1_1_codec = new CodecImpl (orb, enc); + } + + return giop_1_1_codec; + + case 2: + if (giop_1_2_codec == null) { + giop_1_2_codec = new CodecImpl (orb, enc); + } + + return giop_1_2_codec; + + default: + throw new UnknownEncoding("Only GIOP minor versions 0, 1, and 2 supported"); + + } + + } + +} Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/CodecImpl.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/CodecImpl.java?rev=355821&view=auto ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/CodecImpl.java (added) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/CodecImpl.java Sat Dec 10 16:14:16 2005 @@ -0,0 +1,111 @@ +/** + * + * 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.interceptor; + +import org.apache.geronimo.corba.ORB; +import org.apache.geronimo.corba.codeset.CharConverter; +import org.apache.geronimo.corba.io.EncapsulationInputStream; +import org.apache.geronimo.corba.io.EncapsulationOutputStream; +import org.apache.geronimo.corba.io.GIOPVersion; +import org.omg.CORBA.Any; +import org.omg.CORBA.LocalObject; +import org.omg.CORBA.TypeCode; +import org.omg.IOP.Codec; +import org.omg.IOP.Encoding; +import org.omg.IOP.CodecPackage.FormatMismatch; +import org.omg.IOP.CodecPackage.InvalidTypeForEncoding; +import org.omg.IOP.CodecPackage.TypeMismatch; + +/** + * @version $Revision: $ $Date: $ + */ +public class CodecImpl extends LocalObject implements Codec { + + Encoding enc; + + ORB orb; + + CodecImpl(ORB orb, Encoding enc) { + this.orb = orb; + this.enc = enc; + } + + /** + * @see org.omg.IOP.CodecOperations#encode(Any) + */ + public byte[] encode(Any data) throws InvalidTypeForEncoding { + + EncapsulationOutputStream out = new EncapsulationOutputStream(orb, getGIOPVersion()); + + out.write_any(data); + + return out.getBytes(); + + } + + /** + * @see org.omg.IOP.CodecOperations#decode(byte[]) + */ + public Any decode(byte[] data) throws FormatMismatch { + EncapsulationInputStream in = new EncapsulationInputStream(orb, + getGIOPVersion(), getCharConverter(), getWCharConverter(), + data, 0, data.length); + + return in.read_any(); + } + + /** + * @see org.omg.IOP.CodecOperations#encode_value(Any) + */ + public byte[] encode_value(Any data) throws InvalidTypeForEncoding { + + EncapsulationOutputStream out = new EncapsulationOutputStream(orb, getGIOPVersion()); + + data.write_value(out); + + return out.getBytes(); + } + + /** + * @see org.omg.IOP.CodecOperations#decode_value(byte[], TypeCode) + */ + public Any decode_value(byte[] data, TypeCode tc) throws FormatMismatch, + TypeMismatch { + EncapsulationInputStream in = new EncapsulationInputStream(orb, + getGIOPVersion(), getCharConverter(), getWCharConverter(), + data, 0, data.length); + Any any = orb.create_any(); + + any.read_value(in, tc); + + return any; + } + + private CharConverter getWCharConverter() { + return orb.get_wchar_converter(getGIOPVersion()); + } + + private CharConverter getCharConverter() { + return orb.get_char_converter(getGIOPVersion()); + } + + private GIOPVersion getGIOPVersion() { + return GIOPVersion.get(enc.major_version, enc.minor_version); + } + +} Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/IORInfoImpl.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/IORInfoImpl.java?rev=355821&view=auto ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/IORInfoImpl.java (added) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/IORInfoImpl.java Sat Dec 10 16:14:16 2005 @@ -0,0 +1,72 @@ +/** + * + * 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.interceptor; + +import org.apache.geronimo.corba.Policies; +import org.omg.CORBA.LocalObject; + +class IORInfoImpl + extends LocalObject + implements org.omg.PortableInterceptor.IORInfo +{ + java.util.Map profileMap; + java.util.List allComponents; + Policies policies; + String name; + + public String toString () { return "IORInfo for "+name; } + + IORInfoImpl (String name, + java.util.Map profileMap, + java.util.List allComponents, + Policies policies) + { + this.name = name; + this.profileMap = profileMap; + this.allComponents = allComponents; + this.policies = policies; + } + + public org.omg.CORBA.Policy get_effective_policy(int type) + { + org.omg.CORBA.Policy p = policies.get (type); + if (p == null) { + // try ORB policy? + throw new org.omg.CORBA.INV_POLICY (); + } else { + return p; + } + } + + public void add_ior_component(org.omg.IOP.TaggedComponent component) + { + allComponents.add (component); + } + + public void add_ior_component_to_profile + (org.omg.IOP.TaggedComponent component, int profile_id) + { + java.util.List profile = (java.util.List) + profileMap.get (new Integer (profile_id)); + + if (profile == null) { + throw new org.omg.CORBA.BAD_PARAM ("no profile "+profile_id); + } + + profile.add (component); + } +} Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/InterceptorManager.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/InterceptorManager.java?rev=355821&view=auto ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/InterceptorManager.java (added) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/InterceptorManager.java Sat Dec 10 16:14:16 2005 @@ -0,0 +1,355 @@ +/** + * + * 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.interceptor; + +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.ClientInvocation; +import org.apache.geronimo.corba.LocationForwardException; +import org.apache.geronimo.corba.ORB; +import org.apache.geronimo.corba.Policies; +import org.apache.geronimo.corba.giop.GIOPHelper; +import org.apache.geronimo.corba.initials.InitialServicesManager; +import org.apache.geronimo.corba.ior.InternalIOR; +import org.apache.geronimo.corba.ior.InternalServiceContextList; +import org.apache.geronimo.corba.server.POA; +import org.apache.geronimo.corba.server.ServerInvocation; +import org.omg.CORBA.INTERNAL; +import org.omg.CORBA.LocalObject; +import org.omg.CORBA.OBJECT_NOT_EXIST; +import org.omg.IOP.CodecFactory; +import org.omg.PortableInterceptor.ClientRequestInterceptor; +import org.omg.PortableInterceptor.IORInterceptor; +import org.omg.PortableInterceptor.ORBInitInfo; +import org.omg.PortableInterceptor.ORBInitializer; +import org.omg.PortableInterceptor.PolicyFactory; +import org.omg.PortableInterceptor.SUCCESSFUL; +import org.omg.PortableInterceptor.SYSTEM_EXCEPTION; +import org.omg.PortableInterceptor.ServerRequestInterceptor; +import org.omg.PortableInterceptor.USER_EXCEPTION; +import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName; +import org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName; +import org.omg.PortableServer.Servant; + +public class InterceptorManager extends LocalObject implements ORBInitInfo { + static Log log = LogFactory.getLog(InterceptorManager.class); + + ORB orb; + + List clientRequestInterceptors; + + List serverRequestInterceptors; + + List iorInterceptors; + + CodecFactory codec_factory; + + boolean initialized; + + String[] args; + + private final InitialServicesManager im; + + private boolean isDestroyed; + + public InterceptorManager(ORB orb, InitialServicesManager im) { + this.orb = orb; + this.im = im; + clientRequestInterceptors = new ArrayList(); + serverRequestInterceptors = new ArrayList(); + iorInterceptors = new ArrayList(); + } + + public org.omg.CORBA.ORB getORB() { + return orb; + } + + private void checkDestroy() + { + if (isDestroyed) { + throw new OBJECT_NOT_EXIST("ORBInitInfo has been destroyed"); + } + } + + // + // ORBInitInfo API + // + + public void add_client_request_interceptor(ClientRequestInterceptor cri) throws DuplicateName { + checkDestroy(); + + if (cri == null) { + throw new org.omg.CORBA.BAD_PARAM("null interceptor"); + } + + if (cri.name() == null) { + throw new org.omg.CORBA.BAD_PARAM("null name for interceptor"); + } + + for (int i = 0; i < clientRequestInterceptors.size(); i++) { + ClientRequestInterceptor ri = (ClientRequestInterceptor)clientRequestInterceptors.get(i); + if (ri.name().equals(cri.name())) { + throw new DuplicateName(); + } + } + + clientRequestInterceptors.add(cri); + } + + public void add_server_request_interceptor(ServerRequestInterceptor sri) { + checkDestroy(); + if (sri == null) { + throw new org.omg.CORBA.BAD_PARAM("null interceptor"); + } + + serverRequestInterceptors.add(sri); + } + + public java.lang.String[] arguments() { + checkDestroy(); + return args; + } + + public java.lang.String orb_id() { + checkDestroy(); + // TODO: Grab this value from somewhere + return "Apache Geronimo CORBA ORB 1.x"; + } + + public void register_initial_reference(java.lang.String id, + org.omg.CORBA.Object obj) throws InvalidName { + + checkDestroy(); + try { + im.register_initial_reference(id, obj); + } catch (org.omg.CORBA.ORBPackage.InvalidName ex) { + throw new InvalidName(ex.getMessage()); + } + } + + public org.omg.CORBA.Object resolve_initial_references(java.lang.String id) + throws InvalidName { + checkDestroy(); + try { + return orb.resolve_initial_references(id); + } catch (org.omg.CORBA.ORBPackage.InvalidName ex) { + throw new InvalidName(ex.getMessage()); + } + } + + public void add_ior_interceptor(IORInterceptor interceptor) + throws DuplicateName { + checkDestroy(); + iorInterceptors.add(interceptor); + } + + public int allocate_slot_id() { + checkDestroy(); + throw new org.omg.CORBA.NO_IMPLEMENT(); + } + + public void register_policy_factory(int type, PolicyFactory policy_factory) { + checkDestroy(); + orb.getPolicyFactoryManager().register_policy_factory(type, + policy_factory); + } + + public org.omg.IOP.CodecFactory codec_factory() { + checkDestroy(); + if (codec_factory == null) { + codec_factory = new CodecFactoryImpl(orb); + } + + return codec_factory; + } + + // + // Internal API + // + + public ClientRequestInfoImpl clientSendRequest(ClientInvocation inv) + throws LocationForwardException { + ClientRequestInfoImpl ri = new ClientRequestInfoImpl(inv); + + ri.do_send_request(clientRequestInterceptors); + return ri; + } + + public void clientReceiveReply(ClientRequestInfoImpl ri) { + ri.__setStatus(SUCCESSFUL.value); + try { + ri.do_receive_reply(); + } catch (LocationForwardException e) { + throw new INTERNAL("cannot handle forwards in reveive_reply"); + } + } + + public void clientReceiveLocationForward(ClientRequestInfoImpl ri, + InternalIOR forwardIOR) throws LocationForwardException { + ri.__setForwardIOR(forwardIOR); + ri.do_receive_reply(); + } + + public void clientReceiveException(ClientRequestInfoImpl ri, boolean system, + Exception ex, String exId) throws LocationForwardException { + ri.__setStatus(system ? SYSTEM_EXCEPTION.value : USER_EXCEPTION.value); + + ri.__setReceivedEx(ex, exId); + ri.do_receive_reply(); + } + + public ServerRequestInfoImpl serverCreateReceiveRequest( + ServerInvocation inv, byte[] poa_id, byte[] object_id) { + if (log.isDebugEnabled()) { + log.debug("creating ServerRequestInfo for " + inv.getOperation()); + } + + ServerRequestInfoImpl si = new ServerRequestInfoImpl(inv, poa_id, object_id); + + return si; + } + + public void serverSetupServant(ServerRequestInfoImpl si, Servant servant, + POA poa) { + si.setServantAndPOA(servant, poa); + } + + public void serverReceiveRequestServiceContexts(ServerRequestInfoImpl si) + throws LocationForwardException { + if (log.isDebugEnabled()) { + log.debug("[server] requestServiceContext " + si.operation()); + } + + si.do_receive_request_service_contexts(serverRequestInterceptors); + } + + public void serverReceiveRequest(ServerRequestInfoImpl si) + throws LocationForwardException { + if (log.isDebugEnabled()) { + log.debug("[server] request " + si.operation()); + } + + si.do_receive_request(); + } + + public void serverSendReply(ServerRequestInfoImpl si) { + si.__setStatus(SUCCESSFUL.value); + si.do_send_reply(); + } + + public void serverSendException(ServerRequestInfoImpl si, boolean system, + Exception ex) throws LocationForwardException { + si.__setStatus(system ? SYSTEM_EXCEPTION.value : USER_EXCEPTION.value); + + si.__setReceivedEx(ex, null); + si.do_send_exception(); + } + + public void serverSendLocationForward(ServerRequestInfoImpl si, + InternalIOR ior) throws LocationForwardException { + si.__setForwardIOR(ior); + si.do_send_other(); + } + + public boolean haveClientInterceptors() { + return initialized && clientRequestInterceptors.size() > 0; + } + + public boolean haveServerInterceptors() { + return initialized && serverRequestInterceptors.size() > 0; + } + + public boolean haveIORInterceptors() { + return initialized && iorInterceptors.size() > 0; + } + + public void init(String[] args, java.util.Properties props) { + + this.args = args; + + ORBInitializer[] inits = initializers(props); + for (int i = 0; i < inits.length; i++) { + inits[i].pre_init(this); + } + + for (int i = 0; i < inits.length; i++) { + inits[i].post_init(this); + } + + initialized = true; + } + + private ORBInitializer[] initializers(java.util.Map props) { + ArrayList iters = new ArrayList(); + java.util.Iterator it = props.keySet().iterator(); + String prefix = "org.omg.PortableInterceptor.ORBInitializerClass."; + + while (it.hasNext()) { + String key = (String) it.next(); + + if (key.startsWith(prefix)) { + String name = key.substring(prefix.length()); + + try { + Class cls = GIOPHelper.classForName(name); + java.lang.Object obj = cls.newInstance(); + iters.add((ORBInitializer) obj); + // orb.log.info ("loaded ORBInitializer "+name); + + } catch (ClassNotFoundException ex) { + log.warn("can't find initializer class " + name); + + } catch (IllegalAccessException ex) { + log.warn("can't instantiate initializer class " + name); + + } catch (InstantiationException ex) { + log.warn("can't instantiate initializer class " + name); + + } + } + } + + ORBInitializer[] result = new ORBInitializer[iters.size()]; + iters.toArray(result); + return result; + } + + public void establishComponents(String name, java.util.Map componentMap, + java.util.List components, Policies policies) { + if (!haveIORInterceptors()) + return; + + IORInfoImpl ii = new IORInfoImpl(name, componentMap, components, + policies); + + for (int i = 0; i < iorInterceptors.size(); i++) { + IORInterceptor interceptor = (IORInterceptor) iorInterceptors + .get(i); + + try { + interceptor.establish_components(ii); + } catch (org.omg.CORBA.SystemException ex) { + // ignore // + } + } + } + +} Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/RequestInfoImpl.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/RequestInfoImpl.java?rev=355821&view=auto ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/RequestInfoImpl.java (added) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/RequestInfoImpl.java Sat Dec 10 16:14:16 2005 @@ -0,0 +1,156 @@ +/** + * + * 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.interceptor; + +import org.apache.geronimo.corba.Invocation; +import org.apache.geronimo.corba.ORB; +import org.apache.geronimo.corba.Policies; +import org.apache.geronimo.corba.ior.InternalIOR; +import org.apache.geronimo.corba.ior.InternalServiceContext; +import org.apache.geronimo.corba.ior.InternalServiceContextList; +import org.omg.CORBA.LocalObject; +import org.omg.PortableInterceptor.LOCATION_FORWARD; +import org.omg.PortableInterceptor.RequestInfo; + +class RequestInfoImpl + extends LocalObject + implements RequestInfo +{ + + short status; + InternalIOR forward_ior; + Exception received_ex; + String received_ex_id; + protected Invocation inv; + + void __setStatus (short status) { + this.status = status; + } + + void __setForwardIOR (InternalIOR forward) { + + __setStatus (LOCATION_FORWARD.value); + + forward_ior = forward; + } + + void __setReceivedEx (Exception ex, String id) { + received_ex = ex; + received_ex_id = id; + } + + RequestInfoImpl (Invocation inv) + { + this.inv = inv; + } + + + public int request_id() + { + return inv.getRequestID(); + } + + public java.lang.String operation() + { + return inv.getOperation(); + } + + public org.omg.Dynamic.Parameter[] arguments() + { + throw new org.omg.CORBA.NO_IMPLEMENT (); + } + + public org.omg.CORBA.TypeCode[] exceptions() + { + throw new org.omg.CORBA.NO_IMPLEMENT (); + } + + public java.lang.String[] contexts() + { + throw new org.omg.CORBA.NO_IMPLEMENT (); + } + + public java.lang.String[] operation_context() + { + throw new org.omg.CORBA.NO_IMPLEMENT (); + } + + public org.omg.CORBA.Any result() + { + throw new org.omg.CORBA.NO_IMPLEMENT (); + } + + public boolean response_expected() + { + return inv.isResponseExpected(); + } + + public short sync_scope() + { + return inv.getSyncScope(); + } + + public short reply_status() + { + return status; + } + + public org.omg.CORBA.Object forward_reference() + { + if (status != LOCATION_FORWARD.value) { + + throw new org.omg.CORBA.BAD_INV_ORDER (); + } + + if (forward_ior == null) + inv.getORB().fatal ("no forward ior"); + + return inv.getORB().createObject (forward_ior); + } + + public org.omg.CORBA.Any get_slot(int id) + throws org.omg.PortableInterceptor.InvalidSlot + { + throw new org.omg.CORBA.NO_IMPLEMENT (); + } + + public org.omg.IOP.ServiceContext get_request_service_context(int id) + { + InternalServiceContext sc = inv.getRequestServiceContextList(false).getContextWithID(id); + if (sc != null) { + return sc.asServiceContext(); + } + + throw new org.omg.CORBA.BAD_PARAM ("no service context id: "+id); + } + + public org.omg.IOP.ServiceContext get_reply_service_context(int id) + + { + InternalServiceContext sc = inv.getResponseServiceContextList(false).getContextWithID(id); + if (sc != null) { + return sc.asServiceContext(); + } + + throw new org.omg.CORBA.BAD_PARAM ("no service context id: "+id); + } + + public ORB getORB() { + return inv.getORB(); + } +} Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/ServerRequestInfoImpl.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/ServerRequestInfoImpl.java?rev=355821&view=auto ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/ServerRequestInfoImpl.java (added) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/interceptor/ServerRequestInfoImpl.java Sat Dec 10 16:14:16 2005 @@ -0,0 +1,257 @@ +/** + * + * 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.interceptor; + +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.LocationForwardException; +import org.apache.geronimo.corba.ORB; +import org.apache.geronimo.corba.Policies; +import org.apache.geronimo.corba.giop.GIOPHelper; +import org.apache.geronimo.corba.ior.InternalServiceContext; +import org.apache.geronimo.corba.ior.InternalServiceContextList; +import org.apache.geronimo.corba.server.POA; +import org.apache.geronimo.corba.server.ServerInvocation; +import org.omg.PortableInterceptor.ForwardRequest; +import org.omg.PortableInterceptor.LOCATION_FORWARD; +import org.omg.PortableInterceptor.SUCCESSFUL; +import org.omg.PortableInterceptor.SYSTEM_EXCEPTION; +import org.omg.PortableInterceptor.ServerRequestInfo; +import org.omg.PortableInterceptor.ServerRequestInterceptor; +import org.omg.PortableInterceptor.TRANSPORT_RETRY; +import org.omg.PortableInterceptor.USER_EXCEPTION; +import org.omg.PortableServer.Servant; + +public class ServerRequestInfoImpl extends RequestInfoImpl implements + ServerRequestInfo { + static final Log log = LogFactory.getLog(ServerRequestInfoImpl.class); + + byte[] object_id; + + byte[] poa_id; + + POA poa; + + Servant servant; + + ServerRequestInterceptor[] svinterceptors; + + ServerRequestInfoImpl(ServerInvocation inv, + // extra ... + byte[] poa_id, byte[] object_id) { + super(inv); + + this.poa_id = poa_id; + this.object_id = object_id; + + status = -1; + } + + // + // Public API methods + // + + public org.omg.CORBA.Any sending_exception() { + if (status != SYSTEM_EXCEPTION.value && status != USER_EXCEPTION.value) { + throw new org.omg.CORBA.BAD_INV_ORDER(); + } + + if (received_ex == null) + throw new org.omg.CORBA.NO_RESOURCES("exception unavailable"); + + if (received_ex instanceof org.omg.CORBA.UnknownUserException) { + return ((org.omg.CORBA.UnknownUserException) received_ex).except; + } + + org.omg.CORBA.Any any = getORB().create_any(); + GIOPHelper.insertException(any, received_ex); + return any; + } + + public byte[] object_id() { + byte[] id = new byte[object_id.length]; + System.arraycopy(object_id, 0, id, 0, object_id.length); + return id; + } + + public byte[] adapter_id() { + byte[] id = new byte[poa_id.length]; + System.arraycopy(poa_id, 0, id, 0, poa_id.length); + return id; + } + + public java.lang.String target_most_derived_interface() { + if (servant == null) + throw new org.omg.CORBA.BAD_INV_ORDER("no servant"); + + if (poa == null) + getORB().fatal("no POA"); + + return servant._all_interfaces(poa, object_id)[0]; + } + + public org.omg.CORBA.Policy get_server_policy(int type) { + org.omg.CORBA.Policy p = inv.getPolicies().get(type); + + if (p == null) + throw new org.omg.CORBA.INV_POLICY(); + else + return p; + } + + public void set_slot(int id, org.omg.CORBA.Any data) + throws org.omg.PortableInterceptor.InvalidSlot { + throw new org.omg.CORBA.NO_IMPLEMENT(); + } + + public boolean target_is_a(java.lang.String id) { + if (servant == null) + throw new org.omg.CORBA.BAD_INV_ORDER(); + + return servant._is_a(id); + } + + public void add_reply_service_context( + org.omg.IOP.ServiceContext service_context, boolean replace) { + + inv.getResponseServiceContextList(false).add(new InternalServiceContext(service_context), replace); + } + + void do_receive_request_service_contexts(List interceptors) + throws LocationForwardException { + svinterceptors = new ServerRequestInterceptor[interceptors.size()]; + + try { + for (int i = 0; i < interceptors.size(); i++) { + ServerRequestInterceptor svi = (ServerRequestInterceptor) interceptors + .get(i); + + svi.receive_request_service_contexts(this); + svinterceptors[i] = svi; + } + } catch (ForwardRequest ex) { + ClientDelegate od = (ClientDelegate) ((org.omg.CORBA.portable.ObjectImpl) ex.forward) + ._get_delegate(); + + throw new LocationForwardException(od.getIOR(), false); + } + } + + void do_receive_request() throws LocationForwardException { + status = -1; + + try { + for (int i = 0; i < svinterceptors.length; i++) { + ServerRequestInterceptor svi = svinterceptors[i]; + + if (svi != null) { + if (log.isDebugEnabled()) { + log + .debug("receive_request " + + svi.getClass().getName()); + } + + svi.receive_request(this); + } + } + } catch (ForwardRequest ex) { + + if (log.isDebugEnabled()) { + log.debug("sending_forward"); + } + + ClientDelegate od = (ClientDelegate) ((org.omg.CORBA.portable.ObjectImpl) ex.forward) + ._get_delegate(); + + throw new LocationForwardException(od.getIOR(), false); + } + } + + void do_send_reply() { + if (status != SUCCESSFUL.value) + getORB().fatal("status is not successful"); + + servant = null; + + for (int i = 0; i < svinterceptors.length; i++) { + ServerRequestInterceptor svi = svinterceptors[i]; + if (svi != null) { + + if (log.isDebugEnabled()) { + log.debug("send_reply " + svi.getClass().getName()); + } + + svi.send_reply(this); + } + } + } + + void do_send_exception() throws LocationForwardException { + if (!(status == SYSTEM_EXCEPTION.value || status == USER_EXCEPTION.value)) { + getORB().fatal("not exception state"); + } + + servant = null; + + try { + for (int i = 0; i < svinterceptors.length; i++) { + ServerRequestInterceptor svi = svinterceptors[i]; + if (svi != null) { + svi.send_exception(this); + } + } + } catch (ForwardRequest ex) { + ClientDelegate od = (ClientDelegate) ((org.omg.CORBA.portable.ObjectImpl) ex.forward) + ._get_delegate(); + + throw new LocationForwardException(od.getIOR(), false); + } + + } + + void do_send_other() throws LocationForwardException { + if (!(status == LOCATION_FORWARD.value || status == TRANSPORT_RETRY.value)) { + getORB().fatal("not \"other\" state"); + } + + servant = null; + + try { + for (int i = 0; i < svinterceptors.length; i++) { + ServerRequestInterceptor svi = svinterceptors[i]; + if (svi != null) { + svi.send_other(this); + } + } + } catch (ForwardRequest ex) { + ClientDelegate od = (ClientDelegate) ((org.omg.CORBA.portable.ObjectImpl) ex.forward) + ._get_delegate(); + + throw new LocationForwardException(od.getIOR(), false); + } + + } + + void setServantAndPOA(Servant servant, POA poa) { + this.servant = servant; + this.poa = poa; + } +} Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationOutputStream.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationOutputStream.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationOutputStream.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationOutputStream.java Sat Dec 10 16:14:16 2005 @@ -32,9 +32,11 @@ private final AbstractORB orb; private ByteArrayOutputStream barr; private DataOutputStream dout; + private GIOPVersion giop_version; - public EncapsulationOutputStream(AbstractORB orb) { + public EncapsulationOutputStream(AbstractORB orb, GIOPVersion version) { this.orb = orb; + this.giop_version = version; this.barr = new java.io.ByteArrayOutputStream(); this.dout = new java.io.DataOutputStream(barr); @@ -138,8 +140,12 @@ throw new NO_IMPLEMENT(); } - protected GIOPVersion getGIOPVersion() { - return GIOPVersion.V1_0; + public GIOPVersion getGIOPVersion() { + return giop_version; + } + + public byte[] getBytes() { + return barr.toByteArray(); } } 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=355821&r1=355820&r2=355821&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 Sat Dec 10 16:14:16 2005 @@ -28,6 +28,7 @@ import org.apache.geronimo.corba.ior.IIOPProfile; import org.apache.geronimo.corba.ior.InternalServiceContextList; import org.apache.geronimo.corba.ior.InternalTargetAddress; +import org.apache.geronimo.corba.ior.Profile; import org.omg.CORBA.CompletionStatus; import org.omg.CORBA.MARSHAL; import org.omg.CORBA.TRANSIENT; @@ -82,7 +83,7 @@ GIOPOutputStream gout = (GIOPOutputStream) out; if (invocation.isResponseExpected()) { - mt.registerResponse(invocation.getRequestID()); + mt.registerResponse(invocation.getRequestIDObject()); } // push message @@ -100,6 +101,10 @@ public void releaseReply(InputStreamBase in) { GIOPInputStream gin = (GIOPInputStream) in; gin.finishGIOPMessage(); + } + + public Profile getProfile() { + return profile; } } 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=355821&r1=355820&r2=355821&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 Sat Dec 10 16:14:16 2005 @@ -40,8 +40,7 @@ public abstract class OutputStreamBase extends OutputStream implements - org.omg.CORBA.DataOutputStream -{ + org.omg.CORBA.DataOutputStream { private CharConverter char_writer; @@ -93,7 +92,7 @@ return wchar_writer; } - protected abstract GIOPVersion getGIOPVersion(); + public abstract GIOPVersion getGIOPVersion(); public void write(int value) throws IOException { try { @@ -279,8 +278,7 @@ } public void write_value(java.io.Serializable value, - org.omg.CORBA.portable.BoxedValueHelper helper) - { + org.omg.CORBA.portable.BoxedValueHelper helper) { getValueWriter().writeValue(value, helper); } @@ -344,7 +342,8 @@ } public EncapsulationOutputStream __open_encapsulation() { - return new EncapsulationOutputStream(__orb()); + EncapsulationOutputStream eos = new EncapsulationOutputStream(__orb(), getGIOPVersion()); + return eos; } public void __close_encapsulation(EncapsulationOutputStream eout) { @@ -355,18 +354,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; - } + 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/ior/CodeSetsComponent.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/CodeSetsComponent.java?rev=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/CodeSetsComponent.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/CodeSetsComponent.java Sat Dec 10 16:14:16 2005 @@ -47,4 +47,20 @@ CodeSetComponentInfoHelper.write(eo, info); } + public int getNativeCharCS() { + return info.ForCharData.native_code_set; + } + + public int[] getCharConversionCS() { + return info.ForCharData.conversion_code_sets; + } + + public int[] getWCharConversionCS() { + return info.ForWcharData.conversion_code_sets; + } + + public int getNativeWCharCS() { + return info.ForWcharData.native_code_set; + } + } Modified: 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=355821&r1=355820&r2=355821&view=diff ============================================================================== --- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalExceptionDetailMessage.java (original) +++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/InternalExceptionDetailMessage.java Sat Dec 10 16:14:16 2005 @@ -39,6 +39,7 @@ public static InternalExceptionDetailMessage get(InternalServiceContextList lst) { + if (lst == null) return null; InternalServiceContext context = lst.getContextWithID(VALUE); return (InternalExceptionDetailMessage) context; }