Choosing an Activation Model

In Chapter 2, we discussed the two types of activation for marshal-by-reference objects: server activation and client activation. For our application, we want the client to create the remote object once, and we want the remote object to remain instantiated, regardless of which client created it. Recall from Chapter 2 that the client controls the lifetime of client-activated objects. We clearly don't want our object to be client activated. This leads us to selecting server activation. We have one more decision to make: selecting an activation mode, Singleton or SingleCall. In Chapter 2, we learned that in SingleCall mode, a separate instance handles each request. SingleCall mode won't work for our application because it persists data in memory for a particular instance. Singleton mode, however, is just what we want. In this mode, the application creates a single JobServerlmpl instance when a client first accesses the remote object.

The .NET Remoting infrastructure provides a class named RemotingConfiguration that you use to configure a type for .NET Remoting. Table 3-2 lists the public members of the

RemotingConfiguration class.

Table 3-2: Public Members of System.Runtime.Remoting.RemotingConfiguration

Member

Member Type

Description

ApplicationId

Read-only property

A string containing a globally unique identifier (GUID) for the application.

ApplicationName

Read/write property

A string representing the application's name. This name forms a portion of the Uniform Resource Identifier (URI) for remote objects.

Configure

Method

Call this method to configure the .NET Remoting infrastructure by using a configuration file.

GetRegisteredActivatedClientTypes

Method

Obtains an array of all currently registered client-activated types consumed by the application domain.

GetRegisteredActivatedServiceTypes

Method

Obtains an array of all currently registered server-activated types published by the application domain.

GetRegisteredWellKnownClientTypes

Method

Obtains an array of all currently registered server-activated types consumed by the application domain.

GetRegisteredWellKnownServiceTypes

Method

Obtains an array of all currently registered server-activated types published by the application domain.

IsActivationAllowed

Method

Determines whether the currently configured application domain supports client activation for a specific type.

IsRemotelyActivatedClientType

Method

Returns an ActivatedClientTypeEntry instance if the currently configured application domain has registered the specified type for client activation.

IsWellKnownClientType

Method

Returns a WellKnownClientTypeEntry instance if the currently configured application domain has registered the specified type for server activation.

ProcessId

Read-only property

A string in the form of a GUID that uniquely identifies the process that's currently executing.

RegisterActivatedClientType

Method

Registers a client-activated type consumed by the application domain.

RegisterActivatedServiceType

Method

Registers a client-activated type published by the application domain.

RegisterWellKnownClientType

Method

Registers a server-activated type consumed by the application domain.

RegisterWellKnownServiceType

Method

Registers a server-activated type published by the application domain.

The following code snippet demonstrates configuring the JobServerImpl type as a server-activated type, published with a URI of JobURI and published by using the Singleton activation mode:

RemotingConfiguration.RegisterWellKnownServiceType( typeof( JobServerImpl ), "JobURI",

WellKnownObjectMode.Singleton );

0 0

Post a comment