13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 12-5: The IIS application mapp<strong>in</strong>g table <strong>for</strong> .rem and .soap URIs.When IIS detects a remot<strong>in</strong>g call, it passes the call to the ad hoc HTTP handlerregistered to handle .soap and .rem resources. Although the object URI gives theimpression of be<strong>in</strong>g a URL—that is, a true server-side resource—it is only a name andshould <strong>in</strong> no way correspond to a physical file. Whether the URI should be a str<strong>in</strong>g orthe name of a physical resource depends on the expectations of the handler. Theremot<strong>in</strong>g handler uses .soap and .rem URIs as str<strong>in</strong>gs to retrieve the proxy <strong>for</strong> the type.S<strong>in</strong>gleton ObjectsWhen an object declares itself as a S<strong>in</strong>gleton type, the host application uses only as<strong>in</strong>gle <strong>in</strong>stance of the object to service all <strong>in</strong>com<strong>in</strong>g calls. So when a call arrives, thehost attempts to locate the runn<strong>in</strong>g <strong>in</strong>stance of the object. If such an <strong>in</strong>stance exists, therequest <strong>for</strong> execution is processed. Otherwise, the host creates the unique <strong>in</strong>stance ofthe remote class (us<strong>in</strong>g the default constructor) and <strong>for</strong>wards the request to it.What happens if two requests arrive at the same time? The .<strong>NET</strong> Remot<strong>in</strong>g subsystemarranges <strong>for</strong> them to be automatically serviced by dist<strong>in</strong>ct threads. This requires thatS<strong>in</strong>gleton objects be thread-safe. Note that this is not a mandatory programm<strong>in</strong>g rulebut is more of a practical guidel<strong>in</strong>e <strong>for</strong> real-world scenarios.State management <strong>for</strong> S<strong>in</strong>gleton objects is certa<strong>in</strong>ly possible <strong>in</strong> theory, but it must becoded <strong>in</strong> the body of the object <strong>in</strong> much the same way as you do with Active ServerPages (ASP) and <strong>Microsoft</strong> ASP.<strong>NET</strong> pages and even Web services. The idea is thatyou use a shared cache that all clients can access (a sort of ASP.<strong>NET</strong> Applicationobject), unless you apply a filter on a per-client basis (a sort of ASP.<strong>NET</strong> Sessionobject).The lifetime of a S<strong>in</strong>gleton well-known object is managed by the .<strong>NET</strong> Remot<strong>in</strong>g systemthrough a special module called the lease manager (LM). (See the section "MemoryManagement," on page 551, <strong>for</strong> more <strong>in</strong><strong>for</strong>mation.)444

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!