COMS W4156: Advanced Software Engineering - PowerPoint PPT Presentation

1 / 67
About This Presentation
Title:

COMS W4156: Advanced Software Engineering

Description:

If you intend to make only one call at a time on a pooled object, it is a good ... class component sits between a publisher of information and any potential ... – PowerPoint PPT presentation

Number of Views:83
Avg rating:3.0/5.0
Slides: 68
Provided by: bankCsC
Category:

less

Transcript and Presenter's Notes

Title: COMS W4156: Advanced Software Engineering


1
COMS W4156 Advanced Software Engineering
  • Prof. Gail Kaiser
  • Kaiser4156_at_cs.columbia.edu
  • http//bank.cs.columbia.edu/classes/cs4156/

2
Topics covered in this lecture
  • Beginnings of Component Services COM MTS
  • COM beyond COM MTS
  • .NET includes new improved COM

3
COM MTS Component Services
4
COM Recap
  • Specification for how components and their
    clients interact.
  • A binary standard for function calling between
    components
  • A provision for strongly-typed groupings of
    functions into interfaces
  • A mechanism to uniquely identify components and
    their interfaces
  • COM is also an implementation contained in the
    Component Object Library.
  • API functions that facilitate the creation of COM
    applications
  • Implementation locator services through which COM
    determines from a class identifier which server
    implements that class and where that server is
    located.
  • Transparent remote procedure calls when a
    component object is running in a local or remote
    server

5
COM Recap
6
COM Limitations
  • Same as CORBA No support for common programming
    idioms (other than RPC)
  • Unlike CORBA Has one main implementation -
    from Microsoft for Windows, so by definition
    compatible
  • MTS and later COM add component services
    distributed transactions, resource pooling,
    disconnected applications, event publication and
    subscription, better memory and processor
    (threads) management,
  • COM 1993, DCOM 1996, (D)COM MTS 1998, COM
    2000, partially superseded by .NET 2002 (but
    compatible)

7
MTS (Microsoft Transaction Server) Recap
  • Enables the transactional requirements of each
    component to be set administratively, so
    components can be written separately and then
    grouped together as needed to form a single
    transaction

8
Just-In-Time (JIT) Activation
  • Also known as deferred activation
  • When a client makes a call to an object to create
    an instance, COM provides that client a
    reference to a context object instead of a
    reference to the object
  • Client gets a real reference to the object, and
    the object is activated, when client calls a
    method of that object
  • Object deactivated when method returns and
    reactivated when next method called
  • Deactivated object releases all resources,
    including locks on data stores
  • Allows server resources to be used more
    productively

9
Object Pooling
  • Recycling of objects
  • When a client releases an object that supports
    object pooling, or such an object is deactivated,
    instead of destroying that object completely,
    COM recycles it
  • When another client requests or reactivates the
    same kind of object, COM gives an instance from
    the pool
  • Since these component instances are already
    loaded in memory (up to maximum size of pool),
    they are immediately available for use
  • If you intend to make only one call at a time on
    a pooled object, it is a good idea to enable JIT
    activation with object pooling if you intend to
    get a reference and make multiple calls on it,
    using object pooling without JIT activation may
    result in better performance.

10
Connection Pooling
  • Opening and closing connections to a database can
    be time-consuming
  • Reuse existing database connections rather than
    create new ones
  • A resource dispenser caches resources such as
    ODBC (Open DataBase Connectivity) connections to
    a database, allowing components to efficiently
    reuse them

11
Role-Based Security
  • Role a logically related group of users that
    share the same permissions to access a defined
    subset of an applications functionalities
  • Assign different permissions for different roles
    on a class, interface or method
  • Can set either administratively or via
    programming
  • Dont need to write security-related logic into
    components (but can do so if desired)

12
So How Does MTS Fit With COM?
13
MTS Extends COM to 3-tier Architecture
14
Client-Server Architecture
Client
Server
15
2-tier Architecturewith Basic Component
Middleware
Client
Server
Component middleware
16
3-Tier Architecturewith Component Services
Middleware
Document Storage
Client
Database
Application logic components
LDAP
Component services middleware
17
COM
18
COM
19
Load Balancing
  • Scalability network traffic and number of
    clients should not affect performance of an
    application (e.g., response time, throughput)
  • Load balancing distributes client calls across
    server cluster transparently to the application
  • Components to be load-balanced configured on
    per-class basis at deployment

20
COM Router
  • When a client requests a specific component, it
    first connects to a load balancing router (itself
    possibly a cluster)
  • Router polls the cluster application servers for
    timing data (e.g., every 200ms)
  • Router chooses a server based on lightest server
    load and availability
  • Modified round-robin algorithm

21
Service Control Manager (SCM)
  • Routers SCM forwards the activation request to
    the selected server's SCM
  • If the instantiation of the object fails, the
    router moves to the next server in the
    round-robin list
  • Continues until a valid interface pointer is
    returned to the client
  • From this point, all communication occurs
    directly between the client and the server that
    handled the request

22
Microsoft Message Queue Server (MSMQ)
  • Client can execute (asynchronous) method calls,
    even if the server component is offline
  • MSMQ records and stores method calls
    automatically whenever the server object is
    available
  • Useful for online applications that must be
    completed (online banking, air reservation
    system, etc.)

23
Disconnected Applications
  • Increasing use of laptops, notebooks and palmtop
    computers has created a need for applications
    that service occasionally disconnected clients or
    mobile users
  • In a queued system, these users can continue to
    work when not connected to the application
    server, and later connect to the databases or
    servers to process their requests
  • For example, a salesperson can take orders from
    customers and later connect to the shipping
    department to process those orders

24
Component Availability
  • In synchronous processing applications, if just
    one component of a compound activity is not
    availableperhaps because of server overload or
    networking problemsthe entire process is blocked
    and cannot complete
  • An application using the Queued Components
    service separates the activity into actions that
    must be completed now and those that can be
    completed at a later time

25
Client/Server Decoupling
26
Message Queuing
  • A queue is a storage area that saves messages for
    later retrieval
  • Provides a mechanism for connectionless
    communication - sender and receiver are not
    connected directly and communicate only through
    queues
  • Previously, in-depth knowledge of marshaling
    needed to queue, send, and receive asynchronous
    messages
  • Queued Components service automatically marshals
    data as messages

27
Message Reliability
  • Message Queuing uses database techniques to help
    protect data in a robust way
  • Built-in support for transactions
  • In the event of a server failure, Message Queuing
    ensures that transactions are rolled back so that
    messages are not lost and data is not corrupted

28
Server Scheduling
  • An application using queued components is well
    suited to time-shifted component execution, which
    defers non-critical work to an off-peak period
  • Analogous to traditional batch mode processing
  • Similar requests can be deferred for contiguous
    execution by the server rather than requiring the
    server to react immediately to a wide variety of
    requests

29
Event-based computing
30
Original COM Events
  • Choice between two (similar) techniques
  • Interface callback mechanism
  • Connectable Objects

31
Interface Callbacks
  • Client implements a COM interface described by
    the event publisher component, and passes to the
    component a pointer to this interface
  • Client then receives notifications (i.e.,
    callbacks) when the component calls a method
    through the interface implemented by the client
    code
  • Callbacks is a technique used widely in GUI
    processing

32
Connectable Objects
  • Also known as connection points
  • Exchange of an interface pointer implemented by
    the client (invoked to notify of an event)
  • Uses COM's standard IConnectionPoint interface
    (and other related interfaces)
  • Connect (Advise) and disconnect (Unadvise)
  • Enumerate connections (EnumConnections)

33
Example
34
COM Events Problems
  • Only a series of interfaces - developers still
    have to write the code to implement these
    interfaces
  • Implementing a complex application making heavy
    use of events may require complex coding to
    handle multiplexing events, multiple connected
    clients, circular references, deadlock
    situations, etc.
  • Client and component lifetimes are tightly
    coupled through the exchanged interface pointer -
    the client must be running and connected to
    receive events
  • It is difficult to get between a component
    instance and its clients to monitor the
    connection, provide trace information, etc.

35
COM Events
  • Publish-subscribe model rather than request-reply
  • Publishers are not tightly bound to their
    subscribers and in most cases don't even know who
    they are
  • Publishers do not block when firing an event
  • Subscribers do not bind themselves directly to
    publishers - an intermediary object manages
    communication between a publisher and its
    subscribers

36
Event Class
  • An event class component sits between a publisher
    of information and any potential subscribers
  • COM Events system provides the actual
    implementation of this intermediate object
  • Eliminates the need to directly pass an interface
    pointer through an Advise method
  • Publisher and subscriber lifecycles no longer
    tightly coupled

37
Publisher
  • The event class looks like a subscriber to the
    publisher
  • When a publisher wants to fire an event, it
    creates an instance of the event class, calls the
    appropriate method, and then releases the
    interface (as in queued components)
  • The runtime then determines how and when to
    notify any subscribers

38
Subscriber
  • To receive events, need only implement the event
    interface
  • Registers with the COM Events service by
    creating a subscription object, through the
    IEventSubscription interface
  • The component will be (activated and) notified as
    events are published
  • Either persistent or transient subscriptions

39
Example
40
Example
41
Improved COM Events
  • Provides a third-party publish-subscribe
    environment Once an event class is created,
    anyone can become a publisher or subscriber of
    the events
  • Supports a rich filter mechanism one can filter
    at the publisher method level IPublisherFilter
    allows event class object to decide which
    subscribers receive a particular event, or at the
    method parameter level ISubscribeControl
    supports a complex criteria string per subscriber

42
Filtering Example
43
And more
44
COM Summary
  • COM-based services and technologies first
    released in Windows 2000
  • Automatically handles difficult programming tasks
    such as resource pooling, disconnected
    applications, distributed transactions, event
    notification, etc., often administratively
    (manually or scripted)
  • Also supports .NET developers and applications
    through .NETs Enterprise Services

45
What Is Meant By Administratively?
46
(No Transcript)
47
(No Transcript)
48
.NET
49
What is .NET?
  • An object-oriented software development platform,
    with
  • peer to peer multi-language interoperability
  • common intermediate language (CIL)
  • common language runtime (CLR)
  • common data representation based on XML
  • The C language is the most comfortable for .NET,
    but not the only one and not mandatory

50
Why do they call it .NET?
  • I don't know what they were thinking. They
    certainly weren't thinking of people using search
    tools. It's meaningless marketing nonsense.
    Andy McMullan

51
How Does Multi-Language Support Work?
  • A compiler from any supported language compiles
    an application into CIL (also referred to as MS
    IL Microsoft Intermediate Language)
  • The compiler also generates metadata in XML
    information on the types and named entities
    (classes, methods, fields, etc.) defined and used
    in the application
  • At runtime, the CIL code is Just-in-Time (JIT)
    compiled into the target platforms native code
  • The CLR uses the metadata to perform runtime
    checks for type-safety and security (managed
    code)

52
Attributes
  • Metadata attributes attach some data to a class
    or method, which can be accessed via reflection,
    e.g., serializable
  • Context attributes provide an interception
    mechanism whereby instance activation and method
    calls can be pre- and/or post- processed

53
Common Language RuntimeExecution Model
Source code
VB
C
C
Compiler
Compiler
Compiler
Assembly
Assembly
Assembly
MSIL
Common Language Runtime JIT Compiler
CLR
Native code
Managed Code
Managed Code
Managed Code
Unmanaged Code
CLR Services
Operating System Services
54
What does managed mean?
  • Managed code .NET provides several core run-time
    services to the programs that run within it,
    e.g., exception handling and security - for these
    services to work, the code must provide a minimum
    level of information to the runtime
  • Managed data Data that is allocated and freed by
    the .NET runtime's garbage collector
  • Managed classes A C class can be marked with
    the __gc keyword - then memory for instances of
    the class are managed by the garbage collector
    and the class can interoperate with classes
    written in other CLR languages, e.g., inherit
    from a VB class (also restrictions, e.g., a
    managed class can only inherit from one base
    class)

55
What is an assembly?
  • A logical .exe or .dll, can be an application
    (with a main entry point) or a library
  • Consists of one or more files (dlls, exes, html
    files, etc), and represents a group of resources,
    type definitions, implementations of those types,
    and references to other assemblies
  • These resources, types and references are
    described in a block of data called a manifest -
    part of the assembly making it self-describing
  • Assemblies often referred to as components, CLR
    in a sense replaces COM

56
Private vs. Shared Assemblies
  • A private assembly is normally used by a single
    application, and is stored in the application's
    directory
  • A shared assembly is intended to be used by
    multiple applications, and is normally stored in
    the global assembly cache (GAC) but can be stored
    elsewhere
  • Assemblies find each other (outside the GAC) by
    searching directory paths

57
Remoting
  • When a client creates an instance of the remote
    type, the .NET infrastructure creates a proxy
    object that looks exactly like the remote type to
    the client.
  • The client calls a method on that proxy, and the
    remoting system receives the call, routes it to
    the server process, invokes the server object,
    and returns the return value to the client proxy
    - which returns the result to the client.

58
Remoting
  • Send messages along channels, e.g., TCP or HTTP
  • Multiple serialization formats, e.g., SOAP (for
    HTTP) or binary (for TCP, replacing DCOM)
  • Distributed garbage collection of objects is
    managed by leased based lifetime when that
    time expires the object is disconnected from the
    .NET runtime remoting infrastructure unless in
    the interim renewed by a successful call from the
    client to the object (or explicit renewal by
    client)

59
Remote Invocations
  • SingleCall Each incoming request from a client
    is serviced by a new object
  • Singleton All incoming requests from clients are
    processed by a single server object
  • Client-activated object The client receives a
    reference to the remote object and holds that
    reference (thus keeping the remote object alive)
    until it is finished with it

60
So Wheres the Component Services?
61
.NET Serviced Components
  • Classes in the System.EnterpriseServices
    namespace wrap COM and make it much easier to
    build COM components
  • COM services can be used by .NET components
    derived from the ServicedComponent class using
    the System.EnterpriseServices namespace
  • Must be registered with the COM catalog
  • Can also use COM services outside components

62
Example
63
.NET vs. COM
  • No IDL (Interface Definition Language) files, the
    compiler generates the assembly metadata and
    dependencies are captured during compilation (in
    manifests)
  • No GUIDs (globally unique identifiers), instead
    uses scoping based on namespaces and strong
    names (unique digital signature using an
    encryption key)
  • Doesnt rely on registry, reduces DLL Hell

64
  • Final Notes

65
ReminderProject Concept due soon!
  • Teams posted on the website team page
  • Project concept due September 23rd
  • Each team submits one document as a group
  • Submit on courseworks

66
Upcoming Deadlines
  • Team project concept due September 23th
  • Project concept feedback by September 30th
  • First iteration begins September 30th

67
COMS W4156 Advanced Software Engineering
  • Prof. Gail Kaiser
  • Kaiser4156_at_cs.columbia.edu
  • http//bank.cs.columbia.edu/classes/cs4156/
Write a Comment
User Comments (0)
About PowerShow.com