Beispiel #1
0
        public void TestSlotModifyInClientRecContextAndServer()
        {
            try {
                int slotId = m_testInterceptorInit.RequestIntercept.SlotId;
                ORB orb    = OrbServices.GetSingleton();
                omg.org.PortableInterceptor.Current current =
                    (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
                int contextEntryVal = 4;
                current.set_slot(slotId, contextEntryVal);

                System.Int32 arg    = 1;
                System.Int32 result = m_testService.TestAddToContextData(arg);
                Assertion.AssertEquals(arg + contextEntryVal, result);

                Assertion.Assert("service context not present", m_testInterceptorInit.RequestIntercept.HasReceivedContextElement);
                Assertion.AssertEquals("service context content", arg + contextEntryVal,
                                       m_testInterceptorInit.RequestIntercept.ContextElement.TestEntry);

                current =
                    (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
                Assertion.AssertEquals("slot was modified", contextEntryVal, current.get_slot(slotId));
            } finally {
                m_testInterceptorInit.RequestIntercept.ClearInvocationHistory();
            }
        }
        private Connection SetCurrentConnection(Connection conn, out Object guid)
        {
            Connection previous = null;
            Current    current  = GetPICurrent();

            try {
                // tenta reaproveitar o guid
                guid = current.get_slot(_connectionIdSlotId);
                if (guid != null)
                {
                    previous = GetConnectionById(guid);
                    if (conn == null)
                    {
                        current.set_slot(_connectionIdSlotId, null);
                        SetConnectionById(guid, null);
                        return(previous);
                    }
                }
                else
                {
                    if (conn == null)
                    {
                        return(null);
                    }
                    guid = new Object();
                    current.set_slot(_connectionIdSlotId, guid);
                }
                SetConnectionById(guid, conn);
                return(previous);
            }
            catch (InvalidSlot e) {
                Logger.Fatal(ConnectionIdErrorMsg, e);
                throw;
            }
        }
Beispiel #3
0
        public bool NoValueInScope()
        {
            ORB orb = OrbServices.GetSingleton();

            omg.org.PortableInterceptor.Current current =
                (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
            return(current.get_slot(m_slotId) == null);
        }
        public void ExitChain()
        {
            Current current = GetPICurrent();

            try {
                current.set_slot(_joinedChainSlotId, null);
            }
            catch (InvalidSlot e) {
                Logger.Fatal("Falha inesperada ao acessar o slot da joined chain.", e);
                throw;
            }
        }
Beispiel #5
0
        public System.Int32 TestAddToContextData(System.Int32 arg)
        {
            ORB orb = OrbServices.GetSingleton();

            omg.org.PortableInterceptor.Current current =
                (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
            int contextData = (int)current.get_slot(m_slotId);
            int result      = contextData + arg;

            current.set_slot(m_slotId, result);
            return(result);
        }
        internal void UnignoreCurrentThread()
        {
            Current current = GetPICurrent();

            try {
                current.set_slot(_ignoreThreadSlotId, Boolean.FalseString);
            }
            catch (InvalidSlot e) {
                Logger.Fatal(
                    "Falha inesperada ao acessar o slot de interceptação ignorada.", e);
                throw;
            }
        }
        internal Current GetPICurrent()
        {
            Current current = ORB.resolve_initial_references("PICurrent") as Current;

            if (current == null)
            {
                const string message =
                    "Falha inesperada ao acessar o slot da thread corrente";
                Logger.Fatal(message);
                throw new OpenBusInternalException(message);
            }
            return(current);
        }
Beispiel #8
0
 public void receive_request(ServerRequestInfo ri)
 {
     // modify request scope after copy to the thread scope -> must not be propagated to the thread scope.
     if (ri.operation == "TestReceiveReqNotChangeThreadScope")
     {
         ri.set_slot(m_slotId, 2 * (int)ri.get_slot(m_slotId));
     }
     else if (ri.operation == "TestReceiveReqChangeThreadScope")
     {
         ORB orb = OrbServices.GetSingleton();
         omg.org.PortableInterceptor.Current current =
             (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
         current.set_slot(m_slotId, 3 * (int)current.get_slot(m_slotId));
     }
 }
        public void JoinChain(CallerChain chain)
        {
            if (chain == null)
            {
                chain = CallerChain;
            }
            Current current = GetPICurrent();

            try {
                current.set_slot(_joinedChainSlotId, chain);
            }
            catch (InvalidSlot e) {
                Logger.Fatal("Falha inesperada ao acessar o slot da joined chain.", e);
                throw;
            }
        }
Beispiel #10
0
        public void TestNoSlotSet()
        {
            // receive request modifies the thread scope slots
            try {
                int slotId = m_testInterceptorInit.RequestIntercept.SlotId;
                ORB orb    = OrbServices.GetSingleton();
                omg.org.PortableInterceptor.Current current =
                    (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
                current.set_slot(slotId, null);

                System.Boolean result = m_testService.NoValueInScope();
                Assertion.Assert("value in slot", result);

                Assertion.Assert("service context present", !m_testInterceptorInit.RequestIntercept.HasReceivedContextElement);

                current =
                    (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
                Assertion.AssertNull("slot was set", current.get_slot(slotId));
            } finally {
                m_testInterceptorInit.RequestIntercept.ClearInvocationHistory();
            }
        }