Article View: borland.public.cppbuilder.database.multi-tier
Article #312Re: Survey of using MIDAS with anything other than single-threading in BCB - Revisited
From: vavan
Date: Thu, 03 Jan 2002 14:01
Date: Thu, 03 Jan 2002 14:01
104 lines
3881 bytes
3881 bytes
On Thu, 27 Dec 2001 10:38:36 +0300, vavan <vavan@santel.ru> wrote:
OK, here's the magic.
You need to include following source file in the AppServer project
#include "raATLCOM.h"
HRESULT CRaComThreadModule::Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h,
const GUID* plibid)
{
CComApartment::ATL_CREATE_OBJECT =
RegisterWindowMessage(_T("ATL_CREATE_OBJECT"));
return CComModule::Init(p, h, plibid);
};
HRESULT CRaComThreadModule::CreateInstance(void* pfnCreateInstance,
REFIID riid, void** ppvObj)
{
_ATL_CREATORFUNC* pFunc = (_ATL_CREATORFUNC*)
pfnCreateInstance;
_AtlAptCreateObjData data;
data.pfnCreateInstance = pFunc;
data.piid = &riid;
data.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
data.hRes = S_OK;
CComApartment m_pApartment;
m_pApartment.m_hThread = CreateThread(NULL, 0,
CComApartment::_Apartment, (void*)&m_pApartment, 0,
&m_pApartment.m_dwThreadID);
while (!::PostThreadMessage(m_pApartment.m_dwThreadID,
CComApartment::ATL_CREATE_OBJECT, 0, (LPARAM)&data))
::Sleep(100);
AtlWaitWithMessageLoop(data.hEvent);
CloseHandle(data.hEvent);
if (SUCCEEDED(data.hRes))
data.hRes =
CoGetInterfaceAndReleaseStream(data.pStream, riid, ppvObj);
return data.hRes;
}
LONG CRaComThreadModule::Unlock()
{
LONG l = CComModule::Unlock();
DWORD dwThreadID = GetCurrentThreadId();
::PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
return l;
};
//****************************************************************
..and here's the header
#ifndef _RAATLCOM_H
#define _RAATLCOM_H
#include <utilcls.h>
#include <atl\atlbase.h>
#ifndef RA_SINGLETHREADED_DCOM
#define TRaATLModule TATLModule<CRaComThreadModule>
#define DECLARE_RA_CLASSFACTORY()
DECLARE_CLASSFACTORY_AUTO_THREAD()
#else
#define TRaATLModule TATLModule<CComModule>
#define DECLARE_RA_CLASSFACTORY() DECLARE_CLASSFACTORY()
#endif
class CRaComThreadModule : public CComModule
{
public:
HRESULT Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h, const GUID*
plibid = NULL);
HRESULT CreateInstance(void* pfnCreateInstance, REFIID riid,
void** ppvObj);
LONG Unlock();
};
#endif
in the YourAppServerObjectImpl.h file you should insert the line
DECLARE_RA_CLASSFACTORY() in the public section of class ATL_NO_VTABLE
TYourAppServerObjectImpl: REMOTEDATAMODULE_IMPL(...
...and the last but not the least...
you need to patch atlmod.h (sorry, borland)
just comment out
//typedef TATLModule<CComModule> TComModule;
and insert
#include <raATLCOM.h>
typedef TRaATLModule TComModule;
right before the line
extern TComModule &_Module;
that's all folks, and HTH
Any remarks and opinions very appreciated
--
Vladimir Ulchenko aka vavan
Technical Details
Message-ID:
<psn83ugr23tmn3r0h6p0ov5flc168ecv46@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!xmission!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<iljl2uon6vb5vnrj6cnahnepftu97ea1an@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcd2b,6b0ad0e101fc852c X-Google-Attributes: gidfcd2b,public X-Google-ArrivalTime: 2002-01-03 06:02:09 PST From: vavan <vavan@santel.ru> Newsgroups: borland.public.cppbuilder.database.multi-tier Subject: Re: Survey of using MIDAS with anything other than single-threading in BCB - Revisited Date: Thu, 03 Jan 2002 17:01:18 +0300 Organization: TAIF-TELCOM Message-ID: <psn83ugr23tmn3r0h6p0ov5flc168ecv46@4ax.com> References: <iljl2uon6vb5vnrj6cnahnepftu97ea1an@4ax.com> X-Newsreader: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 195.170.216.131 X-Trace: dnews 1010066463 195.170.216.131 (3 Jan 2002 06:01:03 -0800) Lines: 104 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!xmission!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews