1 // server.cpp : Defines the class behaviors for the application.
6 // Demospecific includes
7 #include "w32_test_impl.h"
8 // Demospecific includes end!
11 #include "serverDoc.h"
12 #include "serverView.h"
15 #include "ace/Init_ACE.h"
20 static char THIS_FILE
[] = __FILE__
;
24 /////////////////////////////////////////////////////////////////////////////
27 BEGIN_MESSAGE_MAP(CServerApp
, CWinApp
)
28 //{{AFX_MSG_MAP(CServerApp)
29 ON_COMMAND(ID_APP_ABOUT
, OnAppAbout
)
30 // NOTE - the ClassWizard will add and remove mapping macros here.
31 // DO NOT EDIT what you see in these blocks of generated code!
33 // Standard file based document commands
34 ON_COMMAND(ID_FILE_NEW
, CWinApp::OnFileNew
)
35 ON_COMMAND(ID_FILE_OPEN
, CWinApp::OnFileOpen
)
36 // Standard print setup command
37 ON_COMMAND(ID_FILE_PRINT_SETUP
, CWinApp::OnFilePrintSetup
)
43 spawn_my_orb_thread (void *)
47 CORBA::ORB_var the_orb
= CORBA::ORB_init (__argc
, __argv
);
49 CORBA::Object_var orb_obj
=
50 the_orb
->resolve_initial_references ("RootPOA");
52 PortableServer::POA_var the_root_poa
=
53 PortableServer::POA::_narrow (orb_obj
.in ());
55 PortableServer::POAManager_var the_poa_manager
=
56 the_root_poa
->the_POAManager ();
58 the_poa_manager
->activate ();
60 // Initializing the NamingService
61 W32_Test_Impl myservant
;
62 W32_Test_Interface_var orb_servant
=
65 CORBA::String_var ior
=
66 the_orb
->object_to_string (orb_servant
.in ());
68 FILE *output_file
= ACE_OS::fopen ("ior.txt", "w");
69 ACE_OS::fprintf (output_file
,
72 ACE_OS::fclose (output_file
);
76 catch (const CORBA::Exception
& ex
)
78 ex
._tao_print_exception ("Caught exception:");
85 /////////////////////////////////////////////////////////////////////////////
86 // CServerApp construction
88 CServerApp::CServerApp()
90 // TODO: add construction code here,
91 // Place all significant initialization in InitInstance
95 CServerApp::~CServerApp()
99 CORBA::ORB_var the_shutdown_orb
;
102 ACE_TCHAR
**argv
= 0;
103 const ACE_TCHAR
*orb_name
= ACE_TEXT("");
105 // Retrieving a reference to the ORB used inside the thread
107 CORBA::ORB_init (argc
,
111 the_shutdown_orb
->shutdown (false);
113 ACE_Thread_Manager::instance ()->wait ();
115 catch (const CORBA::Exception
& ex
)
117 ex
._tao_print_exception ("Caught exception:");
124 /////////////////////////////////////////////////////////////////////////////
125 // The one and only CServerApp object
129 /////////////////////////////////////////////////////////////////////////////
130 // CServerApp initialization
132 BOOL
CServerApp::InitInstance()
136 AfxEnableControlContainer();
138 // Standard initialization
139 // If you are not using these features and wish to reduce the size
140 // of your final executable, you should remove from the following
141 // the specific initialization routines you do not need.
144 From MFC 5.0, Enable3dControls and Enable3dControlsStatic are obsolete
145 because their functionality is incorporated into Microsoft's 32-bit
146 operating systems. Basically no need to call with VC5.0 and above.
148 #if !defined (_WIN32_WCE)
150 Enable3dControls(); // Call this when using MFC in a shared DLL
152 Enable3dControlsStatic(); // Call this when linking to MFC statically
157 // Change the registry key under which our settings are stored.
158 // TODO: You should modify this string to be something appropriate
159 // such as the name of your company or organization.
160 SetRegistryKey(_T("Local AppWizard-Generated Applications"));
162 LoadStdProfileSettings(); // Load standard INI file options (including MRU)
164 // Register the application's document templates. Document templates
165 // serve as the connection between documents, frame windows and views.
167 CSingleDocTemplate
* pDocTemplate
;
168 pDocTemplate
= new CSingleDocTemplate(
170 RUNTIME_CLASS(CServerDoc
),
171 RUNTIME_CLASS(CMainFrame
), // main SDI frame window
172 RUNTIME_CLASS(CServerView
));
173 AddDocTemplate(pDocTemplate
);
175 // Parse command line for standard shell commands, DDE, file open
176 CCommandLineInfo cmdInfo
;
177 ParseCommandLine(cmdInfo
);
179 // Dispatch commands specified on the command line
180 if (!ProcessShellCommand(cmdInfo
))
183 // The one and only window has been initialized, so show and update it.
184 m_pMainWnd
->ShowWindow(SW_SHOW
);
185 m_pMainWnd
->UpdateWindow();
187 ACE_Thread_Manager::instance()->spawn (spawn_my_orb_thread
);
193 /////////////////////////////////////////////////////////////////////////////
194 // CAboutDlg dialog used for App About
196 class CAboutDlg
: public CDialog
202 //{{AFX_DATA(CAboutDlg)
203 enum { IDD
= IDD_ABOUTBOX
};
206 // ClassWizard generated virtual function overrides
207 //{{AFX_VIRTUAL(CAboutDlg)
209 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
214 //{{AFX_MSG(CAboutDlg)
215 // No message handlers
217 DECLARE_MESSAGE_MAP()
220 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD
)
222 //{{AFX_DATA_INIT(CAboutDlg)
226 void CAboutDlg::DoDataExchange(CDataExchange
* pDX
)
228 CDialog::DoDataExchange(pDX
);
229 //{{AFX_DATA_MAP(CAboutDlg)
233 BEGIN_MESSAGE_MAP(CAboutDlg
, CDialog
)
234 //{{AFX_MSG_MAP(CAboutDlg)
235 // No message handlers
239 // App command to run the dialog
240 void CServerApp::OnAppAbout()
246 /////////////////////////////////////////////////////////////////////////////
247 // CServerApp message handlers