CORBA-omniORB

 view release on metacpan or  search on metacpan

server.cc  view on Meta::CPAN

    PortableServer::POA_ptr adptr = PortableServer::POA::_duplicate(adapter);
    sv_setref_pv(tmp, "PortableServer::POA", (void *)adptr);
    XPUSHs(tmp);

    PUTBACK;

    exception = pomni_call_method (aTHX_ "incarnate", 1, forward_request_seq);

    if (!exception) {
	SPAGAIN;
	
	retval = pomni_sv_to_servant (aTHX_ POPs);

	PUTBACK;
    }
    else {
	throw exception;
    }

    return retval;
}

void
POmniServantActivator::etherealize (const PortableServer::ObjectId& oid,
				    PortableServer::POA_ptr         adapter,
				    PortableServer::Servant         serv,
				    CORBA::Boolean                  cleanup_in_progress,
				    CORBA::Boolean                  remaining_activations)
{
    CORBA::Exception *exception;

    POmniPerlServerContext psc(this->thx);
    dTHXa(psc.context());
    dSP;

    PUSHMARK(SP);

    XPUSHs(sv_2mortal(newRV_inc(perlobj)));
    
    XPUSHs(sv_2mortal(pomni_oid_to_sv (aTHX_ &oid)));
    SV *tmp = sv_newmortal();
    PortableServer::POA_ptr adptr = PortableServer::POA::_duplicate(adapter);
    sv_setref_pv(tmp, "PortableServer::POA", (void *)adptr);
    XPUSHs(tmp);
    XPUSHs(sv_2mortal(pomni_servant_to_sv (aTHX_ serv)));
    XPUSHs(cleanup_in_progress ? &PL_sv_yes : &PL_sv_no);
    XPUSHs(remaining_activations ? &PL_sv_yes : &PL_sv_no);

    PUTBACK;

    exception = pomni_call_method (aTHX_ "etherealize", 0, NULL);

    if (exception)
	throw exception;
}

PortableServer::Servant
POmniServantLocator::preinvoke (const PortableServer::ObjectId& oid,
				PortableServer::POA_ptr   adapter,
				const char *                    operation,
				PortableServer::ServantLocator::Cookie& the_cookie)
{
    PortableServer::Servant retval;
    CORBA::Exception *exception;

    POmniPerlServerContext psc(this->thx);
    dTHXa(psc.context());
    dSP;

    init_forward_request();

    PUSHMARK(SP);

    XPUSHs(sv_2mortal(newRV_inc(perlobj)));
    
    XPUSHs(sv_2mortal(pomni_oid_to_sv (aTHX_ &oid)));
    SV *tmp = sv_newmortal();
    PortableServer::POA_ptr adptr = PortableServer::POA::_duplicate(adapter);
    sv_setref_pv(tmp, "PortableServer::POA", (void *)adptr);
    XPUSHs(tmp);
    XPUSHs(sv_2mortal(newSVpv((char *)operation, 0)));


    PUTBACK;

    exception = pomni_call_method (aTHX_ "preinvoke", 2, forward_request_seq);

    if (!exception) {
	SPAGAIN;
	
	retval = pomni_sv_to_servant (aTHX_ POPs);
	the_cookie = (void *)SvREFCNT_inc (POPs);

	PUTBACK;
    }
    else {
        throw exception;
    }

    return retval;
}

void
POmniServantLocator::postinvoke (const PortableServer::ObjectId& oid,
 				 PortableServer::POA_ptr   adapter,
				 const char *                    operation,
				 PortableServer::ServantLocator::Cookie the_cookie,
				 PortableServer::Servant         serv)

{
    CORBA::Exception *exception;

    POmniPerlServerContext psc(this->thx);
    dTHXa(psc.context());
    dSP;

    PUSHMARK(SP);

    XPUSHs(sv_2mortal(newRV_inc(perlobj)));
    
    XPUSHs(sv_2mortal(pomni_oid_to_sv (aTHX_ &oid)));
    SV *tmp = sv_newmortal();
    PortableServer::POA_ptr adptr = PortableServer::POA::_duplicate(adapter);
    sv_setref_pv(tmp, "PortableServer::POA", (void *)adptr);
    XPUSHs(tmp);
    XPUSHs(sv_2mortal(newSVpv((char *)operation, 0)));
    XPUSHs(sv_2mortal(pomni_servant_to_sv (aTHX_ serv)));
    // We gave "cookie" an extra refcount in preinvoke, we take
    // it back here.
    XPUSHs(sv_2mortal((SV *)the_cookie));

    PUTBACK;

    exception = pomni_call_method (aTHX_ "postinvoke", 0, NULL);
    if (exception)
	throw exception;
}

// 
// POmniServant 
//
 

POmniServant::POmniServant (SV *_perlobj)
{
    assert (SvROK(_perlobj));

    this->thx = (PerlInterpreter*)PERL_GET_THX;
    dTHXa(this->thx);

    std::string repoid = pomni_get_repoid (aTHX_ _perlobj);
    POmniIfaceInfo *info
	= pomni_find_interface_description (aTHX_ repoid.c_str());
    
    if (!info)
	info = pomni_load_contained (aTHX_ NULL, NULL, repoid.c_str());

    perlobj = SvRV(_perlobj);
    desc = info->desc;

    CM_DEBUG(("creating POmniServant %p for %p, name=%s, id=%s\n",
	      this, _perlobj, (char *) desc->name, (char *) desc->id));
}

POmniServant::~POmniServant ()
{
    CM_DEBUG(("finalizing POmniServant %p, name=%s, id=%s\n",



( run in 0.727 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )