Documente Academic
Documente Profesional
Documente Cultură
Build-in User-
defined
• COM+ uses,
COM apartments
MTS (Microsoft Transaction Server)contexts
• COM apartments separate objects by threading model
• COM classes configured for use with MTS carry declarative requests in new or non-
existing transactional contexts.
• DTC (Distributed Transaction Coordinator) creates transactional domains and each
domain is considered as a single thread.
Create,find,
remove
The CTS ensures that all code is self-describing.Having the .NET compiler insert
metadata that carry information about the resources needed like types, references and
member variables. The runtime uses metadata to .nd and load classes and to be able to
(layout) done space for instances. The CLR handles automatic memory management, like
garbagecollection, this eliminates common errors like invalid memory references and
memory leaks.
To handle interoperability between programming languages, the .NET Framework
types are CLS compliant and can therefore be used from any programming language that
targets the CLR and supports the CLS. Code written in different .NET languages can be
combined.
CLR is an implementation of the Common Language Infrastructure (CLI)
speci.cation, adding COM+ interoperability and Windows platform access services.In
particular CLR over dynamic loading and unloading, garbage collection, context interception,
metadata rejection, remoting, persistence and other runtime services that are fully language
independent.
CLI defines a language neutral platform and an intermediate Language (IL) and
deployment .le format (assemblies). CLI also includes support for extensible metadata. The
CLR is the implementation of the CLI speci.cation.
Application domain :
In .NET the primary application boundary is the AppDomain and not a process. CLR
partitions a process into one or more application domains (AppDomain). An AppDomain
isolates a set of objects from all objects in other AppDomains, but is more lightweight and
thus cheaper than a process. Communications across AppDomain boundaries requires
marshalling (Communication through proxy objects that handle the communication channel).
.NET managed code must be verified by the CLR. This means that the code is type safe and
that the CLR can provide equal level of isolation as the operating system process through
application domains. This increases performance. The application domains do not have to
make cross-process calls or switch between processes. Additional benefits are that individual
applications can be stopped or unloaded without stopping the entire process. The CLR uses
threads to execute code.
Context
Finer execution space beyond AppDomains is provided by Contexts. An App- Domain can
contain many contexts and must contain at least one called default context. A context
provides an environment with a set of properties shared by all objects that exist in the
context. It provides an interception boundary for the runtime to apply pre and post processing
to all method calls from outside the context. The Context is a home for objects with similar
runtime requirements such as synchronisation or just-in-time activation. shows how a process
can be divided into application domains, which in turn will contain one or more contexts.
• Edit mode
• Layout mode
• Brower mode
• Mask mode
• Cascade Message Multicasting Services
– Message objects are used to decouple to MVC
5.6.DIRECTORY OBJECTS:
BLACKBOX PATTERNS
BlackBox uses four major creational patterns:
1) prototypes
2) factory methods
3) directory objects
4) factory managers
PROTOTYPES
• Sometimes it is necessary to create an object of the same type as some other already
existing object.
• In this case, the existing object is called a prototype, which provides a factory
function or initialization method.
• BlackBox models can act as prototypes.
• For example, it is possible to clone a prototype and to let the prototype initialize its
clone.
• This makes sure that the newly created object has exactly the same concrete type as
the prototype, and it allows the prototype and its clone(s) to share caches for
performance reasons.
• For example, a BlackBox text model and its clones share the same spill file that they
use for buffering temporary data. Sharing avoids the proliferation of open files
Var t,t1:TextModels.Model
…
t:=…;
t1:=TextModels.Clone(t);
t1.InsertCopy(t,0,42);
…
FACTORY METHOD
• Sometimes there exists an object that can be used to create an object of another type.
• For this purpose, the existing object provides a factory function, a factory method.
• Possibly, the object may provide different factory methods which support different
initialization strategies or which create different types of concrete objects.
• In BlackBox, a text model provides the procedures NewReader and NewWriter, which
generate new readers and writers.
• They are rider objects that represent access paths to a text.
• Factory methods are appropriate for objects that are implemented simultaneously
("implementation covariance"). This is always the case for riders and their carriers
DIRECTORY OBJECTS
• In black box abstraction not even the name of the implementation are made public.
• So use of NEW statement is not helpful
• New objects are created using factory methods or factory objects
• These factory objects are termed as the directory objects
• In BlackBox, factory objects are used in a particular way:
• They are installed in global variables and may be replaced at run-time, without
affecting client code.
For historical reasons, we call factory objects which are used for configuration
purposes directory objects.
For example
• module TextModels exports
the type Directory which contains a New function,
the two variables dir and stdDir
and the procedure SetDir.
• By default, TextModels.dir is used by client code to allocate new empty text models.
• TextModels.stdDir contains the default implementation of a text model,
• which is mostly useful during the debugging of a new text model implementation.
• For example, you could use the old directory while developing a new text model
implementation.
• When the new one is ready you install its directory object by calling SetDir, thereby
upgrading the text subsystem to the new implementation.
• From this time, newly created texts will have the new implementation.
• Texts with the old implementation won't be affected.
• If the new implementation has errors, the default implementation can be reinstalled by
calling TextModels.SetDir(TextModels.stdDir).
Var t1:TextModels.Model
…
t1:=TextModels.Clone(t);
t1.InsertCopy(t,0,42);
…
t.Replace(0,42,t1,t1.Length())
• Note that objects allocated via directories are often persistent and their
implementation thus long-lived.
• For this reason, several different implementations appear over time which have to be
used simultaneously.
• Typically, the normal default directory objects of a subsystem are installed
automatically when the subsystem is loaded.
• If other directory objects should be installed, a Config module is used to set up the
desired directory object configuration upon startup.
• The name "directory object" comes from another use of the directory design pattern:
in module Files, a file can be created by using the directory object Files.dir.
• But a Files.Directory also provides means to find out more about the current
configuration of the file system (e.g., procedure Files.Directory.FileList.)
VAR f:Files.File;
…..
f:=Files.dir.old(Files.dir.This(“/dev”),”null”);
• File directories are interesting also because they show that a replacement directory
may sometimes need to forward to the replaced directory object.
• For example, if the new directory implements special memory files, which are
distinguished by names that begin with "M:\", then the new directory must check at
each file lookup whether the name begins with the above pattern.
• If so, it is a memory file.
• If not, it is a normal file and must be handled by the old directory object.
• There may exist several directory objects simultaneously. For example, if a service
uses files in a particular way, it may provide its own file directory object which by
default forwards to the file system's standard directory object
• Multiple directory objects and chaining of directory objects are part of the directory
design pattern. This chaining part of the pattern is cascadable, if a new directory
object accesses the most recent old one, instead of stdDir.
• Note that unlike typical factory classes, directories are rarely extended.
Forwarding between two directory objects
client code
performs allocation
via dir variable
new default
directory directory
object object
dir stdDir
REALTIME SCHEDULER
JBED
• A Java version of Portos called JBed is largely identical to Portos ,but provides Java
interfaces to the kernel’s services.
• Esmertec's Jbed Micro Edition CLDC is a Java virtual machine (JVM) for PDAs
(Personal Digital Assistants), mobile phones, and Internet appliances
• The scheduler,class loader,heap manager,,and the realtime garbage collector for
Component Pascal and Java are identical.
• JBed is fast because the kernel directly implements the runtime environment needed
for Java-there is no inefficient translations or expensive kernel calls.
• The Portos/JBed core is the virtual machine ,except Java byte code is translated by
across –compiler before downloading into the embedded system.
5.7.COMPONENT ORIENTED PROGRAMMING
Introduction:
Component-oriented programming has now become a recognised software development
method. This follows a move away from large, monolithic, difficult-to-maintain software
systems to be replaced by systems comprising multiple binary components.
Such systems achieve greater
reusability
extensibilty, and
Maintainability
and also benefit from being
faster to market
more robust
highly scalable, and have
lower development and long-term maintenance costs
Component technologies:
There are several technologies available to implement component-oriented applications,
E.g.
• DCOM - Distributed Component Object Model is based on the COM providing a set
of interfaces to allow clients and servers to communicate within the same computer
• CORBA - Common Object Request Broker Architecture is an architecture and
specification for creating, distributing, and managing distributed program objects in a
network.
• JavaBeans - is an object oriented programming interface from sun micro system that
facilitates the building of re-usable applications or components that can be used in a
network on any major operating system platform.
• . Net -
Terminology :
• A component provides the business logic to clients.
• A client is any entity that uses the component.
• An object is an instance of a component; similar to the classic OO definition of an
object as an instance of a class.
• The object is also referred to as the server and the relationship existing between the
client and the object as the client/server model.
A client creates an object and accesses its functionality via a publicly available entry point: a
public method or, preferably, an interface.
COP vs OOP :
Essentially
• OOP focuses on the relationship between classes that are combined into one large
binary executable, whereas
• COP focuses on interchangeable code module that work independently and does not
require familiarity with their inner workings to use them.
In OO, the business logic many well be achieved using numerous classes, but when they are
combined the result is monolithic binary code. Although developers may work on individual
classes to agreed APIs, eventually the classes are tested and linked. Each subsequent class
change will require the entire application being re-linked, and retesting and re-deployment of
all the other classes.
A component-oriented application comprises a collection of interacting binary application
modules, i.e. the components and the calls that bind them.
-- components Call that binds component
• No existing clients of the component requires recompilation or redeployment. In fact
components may be updated while the client is running , provided the client is making
use of the component at the time.
• Improvements, enhancements and fixes to components becomes available
immediately whether on the same machine or across a network.
Principles of COP:
The more important are:
• Separation of interface and implementation
• Binary compatibility
• Language independence
• Location transparency
• Version control
• Concurrency management
• Component-base security
Interface separation:
Versioning support:
• COP allows clients and components to evolve separately. Hence developers are able
to deploy new versions (or just fixes) of existing components without affecting
existing client applications.
• Further client development expect to be able to develop new versions of a client
application and expect them to work with the older (familiar) versions of the
components.
• Incompatibility of components to client are signalled.
Let us consider an example
• Consider a typical DLL Hell scenario involves two client applications:
• Suppose application A1.0 and B1.0, each use version C1.0 of a component held in the
mydll.dll file.
• Both A1.0 and B1.0 install a copy of mydll.dll in some global location, such as the
System directory.
• Subsequently, when a version A1.1 is installed, it also install version C1.1 of the
component, providing new functionality in addition to the functionality defined in
C1.0. mydll.dll can still contain C1.1 and serve both old and new client application
versions. Old clients will be unaware of the new functionality available
• A problem arises when application B1.0 is reinstalled. As part of the reinstallation,
C1.0 is reinstalled, overriding C1.1 and consequently A1.1 is broken and will no
longer execute.
Concurrency management:
• It is not possible in advance to know all the ways in which a component might be
used or, in fact, whether several applications will use it simultaneously.
• Incorporating a synchronisation mechanism within a component, however, might lead
to deadlocks if each component has its own or if two components attempt to access
each other.
• This is overcome by providing a concurrency management service such that
components participate in an application-wide synchronisation mechanism even when
components are developed separately.
Component-based security:
• Component developers have no way of knowing how a client application or end user
will attempt to use their work, whether above-board or malicious.
• Similarly, a client application does not know whether it is interacting with a malicious
component. Even if client and component have no ill intent, damage can still be
caused inadvertently.
• Consequently a component technology provides a security infrastructure to deal with
such situations. This is kept to a minimum and is detached from the code itself.
• Systems administrators are still able to customise and manage the application security
policy without requiring changes to the code.