How to implement a factory object



Hi, all
    I want to implement a factory class , with which
I can construct a flexible Object to use, in CORBA world
with ORBit.
    the factory class constructor's code like this:

    ------------------------NEW A Servant------------------------
    113         POA_DC_DC__epv                  * dc_epv;
    114         POA_DC_DC__vepv                 * dc_vepv;
    115         PortableServer_ServantBase__epv * dc_base_epv;
    116         POA_DC_DC                       * dc_servant;
    117
    118         dc_epv  =(POA_DC_DC__epv *)malloc (sizeof
(POA_DC_DC__epv) );
    119         if (dc_epv==NULL) return NULL;
    120
    121         dc_vepv =(POA_DC_DC__vepv*)malloc (sizeof
(POA_DC_DC__vepv) );
    122         if (dc_vepv==NULL) {
    123                 free (dc_epv);
    124                 return NULL;
    125         }
    126
    127         dc_base_epv =(PortableServer_ServantBase__epv *)malloc
(sizeof (PortableServer_ServantBase__epv) );
    128         if (dc_base_epv==NULL) {
    129                 free (dc_epv);
    130                 free (dc_vepv);
    131                 return NULL;
    132         }
    133
    134         dc_servant =(POA_DC_DC *)malloc (sizeof (POA_DC_DC) );
    135         if (dc_servant==NULL) {
    136                 free (dc_epv);
    137                 free (dc_vepv);
    138                 free (dc_base_epv);
    139                 return NULL;
    140         }
    141
    142
    143         dc_epv->_private        =NULL;
    144         dc_epv->Setpm           =dc_setpm;
    145         dc_epv->Setpmstring     =dc_setpmstring;
    146         dc_epv->Getvl           =dc_getvl;
    147         dc_epv->Getvlstring     =dc_getvlstring;
    148         dc_epv->StartDC         =dc_startdc;
    149         dc_epv->StopDC          =dc_stopdc;
    150         dc_epv->DCtype          =dc_dctype;
    151
    152
    153         dc_base_epv->_private   =NULL;
    154         dc_base_epv->finalize   =NULL;
    155         dc_base_epv->default_POA=NULL;
    156
    157         dc_vepv->_base_epv      =dc_base_epv;
    158         dc_vepv->DC_DC_epv      =dc_epv;
    159
    160         dc_servant->_private    =NULL;
    161         dc_servant->vepv        =dc_vepv;
    162


    and then with that servant, we active it in the POA. (The objid is a
valid parameter,and servant is dc_servant above
and obj's type is CORBA_Object * obj)

    196         POA_DC_DC__init (servant,&ev);
    197         PortableServer_POA_activate_object_with_id
(poa,&objid,servant,&ev);
    198
    199         *obj    =PortableServer_POA_servant_to_reference
(poa,servant,&ev);
    200         CORBA_Object_release (*obj,&ev);
    201
    202
PortableServer_POAManager_activate(PortableServer_POA__get_the_POAManager(po
a,&ev),&ev);

    But when we use the object that constructed by that class, the client
core dumped like this:

    ** WARNING **: IOP_TAG_MULTIPLE_COMPONENTS decoding needs finishing
    Message: demarshal_profile(): IIOP major is 0
    Message: demarshal_profile(): IIOP major is 0
    Message: demarshal_profile(): IIOP major is 0
    Message: demarshal_profile(): IIOP major is 0
    Message: demarshal_profile(): IIOP major is 0

    ** WARNING **: IOP_TAG_MULTIPLE_COMPONENTS decoding needs finishing
    Message: demarshal_profile(): IIOP major is 0
    Message: demarshal_profile(): IIOP major is 0
    Message: demarshal_profile(): IIOP major is 0
    Message: demarshal_profile(): IIOP major is 0

    ** WARNING **: IOP_TAG_MULTIPLE_COMPONENTS decoding needs finishing
    Segmentation fault (core dumped)

    So, I need help to make this class working.

Thanks for any help.






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]