Practicing the Chain of Responsibility Pattern
page 2 of 8
by Xianzhong Zhu
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 33834/ 73

Constructing an Service Explorer Application: Requirements Analyzing

Suppose that in one of our frame products, because of needing to support a distribute type processing, we have to adopt the .NET Remoting technique. Considering some special requests toward service objects by our frame product, we finally decide to develop a custom service explorer as the host of the Remoting service objects.

Well, since our target is to develop a service explorer, we need to write methods concerning the manipulation of the service objects, such as start or stop a service, etc. On the other hand, we have known that there are 3 kinds of methods to invoking service objects (which are based upon .NET Remoting technique): the Singleton mode, SingleCall mode, and client-side invoking mode, whose implementation logics are different in starting/stopping the service.

Author's Note: In this article we have leveraged .NET Remoting technique to establish the sample application, while for brevity we are not going to dwell upon it, so for more details about .NET Remoting you can refer here.

The service explorer is a Windows application (see Figure 1). It uses a ListView control to manifest all the detailed information of service objects, such as the service name, service description, and the related invoking mode, etc. For the sake of facilitating the administrator, we hope to provide a shortcut menu that will pop up when the user right-clicks each line of the item in the ListView control. The menu items in the shortcut menu should include common operations, such as start or stop services, etc.

Figure 1: The running-time snapshot of the service explorer application

OK, with the requirement analysis above, we can hold a few important points below:

·         Each service is a remote service object, which should include the service name, service description, service type, etc.

·         Different activating mode of the service object results in the dissimilarity in operating the remote object, but with the consistent operation definition.

·         The information of service objects can be obtained through the value of the ListViewltem item in the ListView control.

·         The user sends out a request through a menu item by clicking the shortcut menu, and the application can make corresponding operations according to the specified claim.

Because in this case we have adopted the third mode (i.e. client-side invoking mode) to activate a service object, we have to establish the instantiation of the service object. For this, we need to define the service object as shown in Listing 1 below.

Listing 1: Define the service object

namespace DonOfDesign.PracticeCORPattern.ServiceManagerLib
    public enum ActiveMode
        Singleton = 0, SingleCall, Activation
    public enum ServiceState
        Start = 0, Stop
    public class ServiceObject
        private object m_serviceInstance;
        private string m_serviceName;
        private string m_serviceDesc;
        private ActiveMode m_activeMode;
        private ServiceState m_currentState;
        private Type m_objType;
        public object ServiceInstance
            get { return m_serviceInstance; }
            set { m_serviceInstance = value; }
        public string ServiceName
            get { return m_serviceName; }
            set { m_serviceName = value; }
        public string ServiceDesc
            get { return m_serviceDesc; }
            set { m_serviceDesc = value; }
        public ActiveMode ActiveMode
            get { return m_activeMode; }
            set { m_activeMode = value; }
        public ServiceState CurrentState
            get { return m_currentState; }
            set { m_currentState = value; }
        public Type ObjectType
            get { return m_objType; }
            set { m_objType = value; }

In the definition of the service object for class ServiceObject, the Servicelnstance attribute is the instance of the service object to create. The ServiceName attribute is the name of the service object, it is the one and only; substantially, its value is just the class name of the service object. The ServiceDesc attribute relates to the description of the function of the service object. The ActiveMode attribute is an enum type which specifies the activating way of the service object. The CurrentState attribute represents the state of the existing service object, whose state needs to be updated when it is started/stopped. The last attribute ObjectType is very important, which is a "System.Type" type and the real type value of a service object, which will be used when starting the service.

Next, let us look at the ServiceManager class with which to manage the service objects.

View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2021  |  Page Processed at 2021-11-29 12:05:27 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search