[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mico-devel
Subject:    Re: [mico-devel] Problem with nested OBV
From:       "Valentino Ignoti" <Valentino.Ignoti () marconi ! com>
Date:       2005-09-28 8:07:45
Message-ID: OF8B5BE5D9.CD024E96-ONC125708A.002C93E2-C125708A.002CB614 () uk ! marconicomms ! com
[Download RAW message or body]


Hi. Thanks for your response. This is the code:

/*******/ IDL /*******/

#ifndef __OBVService_idl__
#define __OBVService_idl__

valuetype Nested
{
  public long n;
};

valuetype Base
{
  public Nested nested;
};

interface OBVService
{
  void sendNested(in Base b);
};

#endif

/*********/ Implements OBVService /**********/

#ifndef __OBVServiceImpl_h__
#define __OBVServiceImpl_h__

#include <OBVService.h>

class OBVServiceImpl : virtual public POA_OBVService
{
public:
  OBVServiceImpl();
  ~OBVServiceImpl();
  void sendNested(Base *b);
};

#endif

#include <OBVServiceImpl.h>

OBVServiceImpl::OBVServiceImpl()
{
}

OBVServiceImpl::~OBVServiceImpl()
{
}

void OBVServiceImpl::sendNested(Base *b)
{
  printf("OBVServiceImpl::sendNested\n");
}

/*********/ Implements Base valuetype for MICO  /**********/

#ifndef __BaseImpl_h__
#define __BaseImpl_h__

#include <CORBA.h>
#include <OBVServiceImpl.h>

class BaseImpl :
  virtual public OBV_Base,
  virtual public CORBA::DefaultValueRefCountBase
{
public:
  BaseImpl();
  BaseImpl(Nested *nested);
};

class Base_factory : public CORBA::ValueFactoryBase
{
public:
  CORBA::ValueBase *create_for_unmarshal();
};

#endif

#include <BaseImpl.h>

BaseImpl::BaseImpl()
: OBV_Base()
{
}

BaseImpl::BaseImpl(Nested *n)
: OBV_Base(n)
{
}

CORBA::ValueBase* Base_factory::create_for_unmarshal()
{
  return new BaseImpl;
}

/*********/ Implements Nested valuetype for MICO /**********/

#ifndef __NestedImpl_h__
#define __NestedImpl_h__

#include <CORBA.h>
#include "OBVService.h"

class NestedImpl :
  virtual public OBV_Nested,
  virtual public CORBA::DefaultValueRefCountBase
{
public:
  NestedImpl();
  NestedImpl(int val);
};

class Nested_factory : public CORBA::ValueFactoryBase
{
public:
  CORBA::ValueBase *create_for_unmarshal();
};

#endif

#include "NestedImpl.h"

NestedImpl::NestedImpl()
: OBV_Nested()
{
}

NestedImpl::NestedImpl(int val)
: OBV_Nested(val)
{
}

CORBA::ValueBase *Nested_factory::create_for_unmarshal()
{
  return new NestedImpl;
}

/*********/ This is the ServerApp /*********/

#include <iostream>
#include <string.h>
#include "NestedImpl.h"
#include "BaseImpl.h"
#include "OBVServiceImpl.h"
#include <coss/CosNaming.h>
#include <mico/util.h>

using namespace std;

int main (int argc, char *argv[])
{
  MICO::Logger::Log(MICO::Logger::All, 1, "./popolog");
  try
  {
    CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

    //register factories
    orb->register_value_factory("IDL:Nested:1.0", new Nested_factory);
    orb->register_value_factory("IDL:Base:1.0", new Base_factory);

    CORBA::Object_var nsobj = orb->resolve_initial_references
("NameService");

    OBVServiceImpl *service = new OBVServiceImpl();

    CORBA::Object_var poa_obj = orb->resolve_initial_references
("RootPOA");
    PortableServer::POA_var rootPOA = PortableServer::POA::_narrow
(poa_obj);
    PortableServer::POAManager_var mgr = rootPOA->the_POAManager ();

    CORBA::PolicyList policy;
    policy.length(2);
    policy[0] = rootPOA->create_lifespan_policy
(PortableServer::PERSISTENT);
    policy[1] = rootPOA->create_id_assignment_policy
(PortableServer::USER_ID);
    PortableServer::POA_var fsPoa = rootPOA->create_POA( "OBVService",
                                                              mgr, policy
);

    PortableServer::ObjectId_var oid =
      PortableServer::string_to_ObjectId ("OBVService");

    fsPoa->activate_object_with_id (*oid, service);
    CORBA::Object_var ref = fsPoa->id_to_reference (oid.in());

    CosNaming::NamingContext_var nc = CosNaming::NamingContext::_narrow
(nsobj);

    if (CORBA::is_nil (nc))
    {
      cerr << "Cannot access the Naming Service!" << endl;
      exit (1);
    }

    CosNaming::Name name;
    name.length (1);
    name[0].id = CORBA::string_dup ("OBVService");
    name[0].kind = CORBA::string_dup ("");

    cout << "Binding OBVService in the Naming Service ... " << flush;
    nc->rebind (name, ref);
    cout << "done." << endl;

    printf ("Running.\n");

    mgr->activate ();
    orb->run();
  }
  catch (const CORBA::Exception& e)
  {
    cout << "CORBA::Exception" << endl << flush;
  }
}

/********/ Implements Base valuetype for JDK /*********/

public class BaseImpl extends Base
{
  public BaseImpl()
  {
    super.nested = null;
  }

  public BaseImpl(Nested n)
  {
    super.nested = n;
  }
}

/********/ Implements Nested valuetype for JDK /*********/

public class NestedImpl extends Nested
{
  public NestedImpl()
  {
    super.n = (int)0;
  }

  public NestedImpl(int val)
  {
    super.n = val;
  }
}

/********/ This is the ClientApp  /*********/

import org.omg.CosNaming.*;
import java.util.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.PortableServer.POA;

public class TestClient
{
  public static void main(String[] args)
  {
    ORB orb = ORB.init(args, null);
            try
    {
        org.omg.CORBA.Object objRef =
        orb.resolve_initial_references("NameService");
                  // Root naming context
      NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

      POA rootPOA =
        POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
      rootPOA.the_POAManager().activate();
      String n = "OBVService";

      OBVService service = OBVServiceHelper.narrow(ncRef.resolve_str(n));

      System.out.println("\n*\n*\tBind OBVService in NS\n*");

      service.sendNested(new BaseImpl(new NestedImpl(0)));
    }
    catch (Exception ex)
    {
      System.out.println("\n*\n*\tTestClient::main Failed" +
                         ex.getMessage() + "\n*");
      ex.printStackTrace();
    }
  }
}

/********/ And this is the MICO log  /********/

IIOP: new connection opened from inet:172.16.246.121:62190
GIOPCodec::GIOPCodec(): 4003fd60
   In Data  47 49 4f 50 01 00 00 00 00 00 01 38 00 00 00 02
GIOP.......8....
            00 00 00 06 00 00 00 a4 00 00 00 00 00 00 00 28
.......¤.......(
            49 44 4c 3a 6f 6d 67 2e 6f 72 67 2f 53 65 6e 64
IDL:omg.org/Send
            69 6e 67 43 6f 6e 74 65 78 74 2f 43 6f 64 65 42
ingContext/CodeB
            61 73 65 3a 31 2e 30 00 00 00 00 01 00 00 00 00
ase:1.0.........
            00 00 00 68 00 01 02 00 00 00 00 0f 31 37 32 2e
...h........172.
            31 36 2e 32 34 36 2e 31 32 31 00 00 f2 ed 00 00
16.246.121..òí..
            00 00 00 19 af ab cb 00 00 00 00 02 9b a6 22 a4
....¯«Ë.....'¦"¤
            00 00 00 08 00 00 00 00 00 00 00 00 0a 00 00 00
................
            00 00 00 01 00 00 00 01 00 00 00 20 00 00 00 00  ...........
....
            00 01 00 01 00 00 00 02 05 01 00 01 00 01 00 20
...............
            00 01 01 09 00 00 00 01 00 01 01 00 4e 45 4f 00
............NEO.
            00 00 00 02 00 0a 00 00 00 00 00 08 01 00 00 00
................
            00 00 00 1d 44 65 66 61 75 6c 74 2f 4f 42 56 53
....Default/OBVS
            65 72 76 69 63 65 2f 4f 42 56 53 65 72 76 69 63
ervice/OBVServic
            65 00 00 00 00 00 00 0b 73 65 6e 64 4e 65 73 74
e.......sendNest

            65 64 00 00 00 00 00 00 7f ff ff 0a 00 00 00 0d
ed.......ÿÿ.....
            49 44 4c 3a 42 61 73 65 3a 31 2e 30 00 00 00 00
IDL:Base:1.0....
            7f ff ff 0a 00 00 00 0f 49 44 4c 3a 4e 65 73 74
.ÿÿ.....IDL:Nest
            65 64 3a 31 2e 30 00 00 00 00 00 04 00 00 00 00
ed:1.0..........
            ff ff ff ff                                      ÿÿÿÿ
MICO::Server::input_callback (GIOPConn *conn, CORBA::Buffer *inp)
   conn: 40082920
    inp: 40011088
IIOP: incoming data from inet:172.16.246.121:62190
GIOP: incoming Request from inet:172.16.246.121:62190 with msgid 8
IIOPServer::add_invoke (id=4)
void MICOPOA::POACurrent_impl::set( poa=40073338,
POAObjectReference=4000a1c8, Servant=4002fa74 )
Error: cannot decode args in StaticServerRequest
CORBA::Exception::ctor called
ERROR: backtrace support functions are not available
void MICOPOA::POACurrent_impl::unset()
GIOP: sending Reply to inet:172.16.246.121:62190 for msgid 8 status is 2
  Out Data  47 49 4f 50 01 00 00 01 00 00 00 38 00 00 00 00
GIOP.......8....
            00 00 00 08 00 00 00 02 00 00 00 1e 49 44 4c 3a
............IDL:
            6f 6d 67 2e 6f 72 67 2f 43 4f 52 42 41 2f 4d 41
omg.org/CORBA/MA
            52 53 48 41 4c 3a 31 2e 30 00 00 00 00 00 00 00
RSHAL:1.0.......
            00 00 00 01                                      ....
IIOPServer::del_invoke (id=4)
IIOP: connection to inet:172.16.246.121:62190 closed or broken
GIOPCodec::~GIOPCodec: 4003fd60

Thanks for all ...





_______________________________________________
Mico-devel mailing list
Mico-devel@mico.org
http://www.mico.org/mailman/listinfo/mico-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic