Professional Documents
Culture Documents
Unit I INTRODUCTION
1. Introduction
A self-contained unit of software code consisting of its own data and logic,
with well-defined connections or interfaces exposed for communication.
It is designed for repeated use in developing application, either with or
without customization.
A software component is a loosely defined term for software technology for
encapsulating software functionality. It is an object written to a
specification (i.e. COM, Java Bean, etc.)
A component is a reusable piece of software that can be assembled easily to
create applications. The basic idea of developers is to build small reusable
components once and reuse them as many times needed.
Marshalling is employed to turn the component or one of its interfaces into
a bit stream.
1.1.1. Definition
1
COMPONENT BASED TECHNOLOGY
1. Provides a middle path between the two extremes of traditional software development.
2
COMPONENT BASED TECHNOLOGY
Software
Component Based
Custom_Made Traditional
1.2. Objects
Identity
State
Behaviour
The definition of an object is a piece of software that contains the functions that represent
what the object can do and associated state information for those functions.
A. It is a unit of instantiation
B. It may have state; can be a persistent, so it has a unique identity;
C. It encapsulates its state and behaviour.
3
COMPONENT BASED TECHNOLOGY
A construction plan needs to be exists before the object can come into existence. If that
plan is explicitly available and then it is called as class. If that plan is implicitly available
in the form of an object that already exists is called as prototype object.
Components gets life through objects and hence can contain one or more classes
or immutable prototype objects
Component could contain procedures and global static variables
Objects created in a component could leave the component and become visible to
the component’s client.
A component may contain multiple classes, but classes are restricted to be part of
a single component.
Components may depend on other component.
Super class need not reside in the same component as the class itself
Inheritance relation could cross component boundaries
In the world many of the key technologies are available for better use. But overall
understanding of knowledge of software is still lacking. From different sources
components are developed. And they are integrated by third parties. In the absence of
critical measurements a component system is only as strong as its weakest component.
For the safety of individual components fault is important.
The following are the some examples for above said integration issues.
i Java Applets
Until a webpage is requested by a browser, the applet code will not be integrated into the
requesting browser.
4
COMPONENT BASED TECHNOLOGY
ii IC Chip
Even though the late version checks are very helpful for user, it does not help to improve
the quality of the components used. A component vendor faces the issues of combination
of system configuration to which test a components.
The CLR provisions for establishing type safety, module safety, and security integrity
across all supported languages show that the choice of language is second to the
establishment of underlying principles compatible with many languages.
1.4. Modules
A component has to specify explicitly which services- from the system or other
components – it needs to access. This is done in the form of module that import lists. The
language and system do not allow access to any non – imported module. Hence, if that
list contains only permissible module; then it is safe to load and execute the new
component.
Due to the idea of a module implementing Abstract Data Type (ADT) with the properties
of inheritance and polymorphism. It was claimed that class is a better module. Modules
can be used to package multiple entities like classes or ADTs into one unit.
Modules do not have concept of instantiation whereas classes have. This frequently leads
to the introduction of “static” classes in module – less languages that essentially serve as
simple modules.
In languages such as Java, Oberon, Modula - 3, Pascal and C#, classes are kept separate.
In Java we don’t have separate module concept. Class inheritance can cross module
boundaries.
Modularity
Thus modularity is certainly not a new concept. But today, the vast majority of software
solutions are not modular. Component technology leads to modular solutions that
requires adoption principles of independence and controlled explicit dependencies.
5
COMPONENT BASED TECHNOLOGY
1.5. Interfaces
Interfaces are used to connect components. It is a set of named operations that can be
invoked by clients. A component may either directly provides an interface or implement
object that, if made available to client, provide interface.
Direct interfaces
Provided directly by a component corresponding to interfaces of traditional
libraries. Definition and implementation belong to one component.
Indirect interfaces
Provided by objects implemented by a component, corresponding to object
interfaces. Definition and implementation might sit in different components.
6
COMPONENT BASED TECHNOLOGY
3 1 4
<<interface>>
Text Services 2 ICheck Grammar
“has a”
Implements
1.5.3. Versions
In the component world, component versions can be prolific. Many vendors will provide
various enhanced versions of a successful component. The management of version
numbers becomes a subtle problem in component field.
When moving from direct to indirect interfaces (i.e.) object interfaces, the version checks
are done at bind time. A care must be taken to avoid version conflict when coupling
different systems.
1.6. Callbacks
A procedure passed to a library at one point and called by the library at some later point
is called call backs.
Generally normal calls always originate in higher layer and then stay in their layer or
move to lower layer. A call back usually reverses the direction of the flow control. So a
lower layer calls a procedure in higher layer.
7
COMPONENT BASED TECHNOLOGY
A critical region exits for the library in which its state has to remain valid as long
as callback is active
Callback returns
Library returns
Time
Calls
Results
8
COMPONENT BASED TECHNOLOGY
The directory service supports callbacks to notify clients of changes in the managed
directory. Such a notification service is useful, for instance, to keep a visual
representation of the directory up to date. Consider a system that provides a basic
directory service as part of a simple file system.
1. File lookup
2. Addition or removal of named files
3. Modeling a single flat directory.
System architecture is the pivotal basis of any large-scale software technology and is of
utmost importance for component based systems.
An architecture is needed when asking for guidelines and rules for complex
system design and implementation.
An architecture needs to create simultaneously the basis for independence and
cooperation. Independence of system aspects is required to enable multiple
sources of solution parts.
Architecture is about a holistic view of a system, often one that is yet to be
developed. An architecture defines properties that characterize any system built
following this particular architecture.
An Architecture categorizes central resources to enable independence in the
presence of competition for resources.
9
COMPONENT BASED TECHNOLOGY
First-Tiered Architecture
The layers formed by a meta-architecture are called tiers Example: Muti tier Client –
server application.
The architecture itself needs to be layered to show the complexity of larger component
systems.
Three-Tier Architecture
10
COMPONENT BASED TECHNOLOGY
Component
Component System
(Component framework)
Component Instance
i. Directly (by using Com connectable objects, COM messaging service messages,
CORBA events, Java Beans events)
ii. Indirectly (by using a component framework)
When component framework instance interact the mediator a three-tier instance recurs.
CFFI
CFI
CI
11
COMPONENT BASED TECHNOLOGY
Middleware is a name for the set of software that sits between various operating systems
and distributed programming platform. Middleware is categorized into message-oriented
versus object oriented. However, most modern middleware uses both MON and OOM.
However, most modern middleware uses both MOM and OOM. Nowadays traditional
operating systems incorporate direct support from middleware.
1.8. Middleware
The term middleware is used to describe a board array of tools and data that help
applications use networked resources and services. Some tools, such as authentication
and directories, are in all categorization.
Application Server
It combines application management, data transaction, load balancing and other
functions (E.g. .Net/COM + Server, J2EE server implementations)
Integration servers
It combines protocol conversion, data translation, routing, and other functions.
(E.g., Crosswords, Web sphere B2B integrator (IBM), Integrator (Sybase) etc)
The emergence and rapid growth of the internet, beginning in the 1970s, brought forth the
need for distributed applications. For years, however, these applications were hard to
develop due to a paucity of methods, tools, and platforms.
Various technologies have emerged over the past 20+ years to alleviate complexities
associated with developing software for distributed applications and to provide and
advanced software infrastructure to support it.
12
COMPONENT BASED TECHNOLOGY
To support distributed real time and embedded applications (E.g., Real time
CORBA)
The success of the middleware technologies outlined above has added the middleware
paradigm to the familiar operating system, programming language, networking, and
database offerings used by previous generations of software developers.
13
COMPONENT BASED TECHNOLOGY
Summary
14
COMPONENT BASED TECHNOLOGY
1. Define Component.
2. List the requirements of a component.
3. Benefit of Components
4. Uses of Modules.
5. What is Directory Service?
6. Benefits of Component architecture.
7. What is Middleware?
8. What are the middleware technologies that use IDL for defining the interface?
9. What are the three types of servers supported by COM for implementing
Components?
10. Explain Callbacks
15
COMPONENT BASED TECHNOLOGY
2. Introduction
2.1. Threads
At runtime, threads in a program exist in a common memory space and can therefore,
share both data and code, that is, they are light weight compared to process, they also
share the process running the program. The running instance of a program is called a
process. It is program execution. Now the system resources and the CPU time are
allocated to the various running process. When the time slice is allocated to a process, the
various threads in the process make use of the available to the particular process. The
difference between a thread and a process is that a thread cannot exit on its own, whereas
a process can.
Every thread in Java is created and controlled by unique object of the java.lang.Thread
class. Often the thread and its associated Thread object are thought of a being
synonymous. Threads make the runtime environment asynchronous, allowing different
tasks to be performed concurrently. Using this powerful paradigm in java centers around
understanding the following aspects of multithreaded programming.
Creating threads and providing the code that gets executed by a thread.
Accessing common data and code through synchronization.
Transitioning between thread states
16
COMPONENT BASED TECHNOLOGY
Prototype declaration:
The code in the run ( ) method defines an independent path of execution and thereby the
entry and the exists for the thread. The thread ends when the run ( ) method ends, either
by normal completion or by throwing an uncaught exception.
The procedure for creating threads based on the Runnable interface is as follows:
1. A class implements the Runnable interface, providing the run ( ) method that will be
executed by the thread. An object of this class is a Runnable object.
3. The start ( ) method is invoked on the Thread object created in the previous step. The
start ( ) method returns immediately after a thread has been spawned.
17
COMPONENT BASED TECHNOLOGY
The run ( ) method of the Runnable object is eventually executed by the thread
represented by the Thread object on which the Start ( ) method was invoked.
Current Thread
Create
Creates a runnable object
Runner
The argument thread Target is the object whose run ( ) method will be executed when the
thread is started. The argument threadName can be specified to give an explicit name for
the thread, rather than an automatically generated one. A thread’s name can be retrieved
by using the getName ( ) method.
18
COMPONENT BASED TECHNOLOGY
Void run ( ): The Thread class implements the Runnable interface by providing
an implementation of the run ( ) method. This implementation does nothing.
Subclasses of the Thread class should override this method. If the current thread
is created using a separate Runnable object, then the Runnable object’s run ( )
method is called.
Void Start ( ): This method spawns a new thread, that is, the new thread will
begin execution as child thread of the current thread. The spawning is done
asynchronously as the call to this method returns immediately. It throws an
illegal ThreadStateException if the thread was already started.
19
COMPONENT BASED TECHNOLOGY
The Client class uses the Counter class. It creates an object of class counter at (5) and
retrieves its value in a loop at (6). After each retrieval, it sleeps for 1,000 milliseconds at
(7), allowing other threads to run.
Current Thread
<<Create>>
runner
Creates an object of
a class that extends <<Thread>>
the Thread class Start ( )
……
<<subclass>>
run ( )
Starts new thread Start ( ) ………
calls returns
immediately run ()
20
COMPONENT BASED TECHNOLOGY
1. A class extending the Thread class overrides the run( ) method from the Thread
Class to define the code executed by the thread.
2. This subclass may call a Thread constructor explicitly in its constructors to initialize
the thread, using the super ( ) call.
3. The start ( ) method inherited from the Thread class is invoked on the object of the
Class to make the thread eligible for running.
21
COMPONENT BASED TECHNOLOGY
There are other ways of starting a thread. The call to the start ( ) method can be factored
out of the constructor, and the method can be called later, using a reference that denotes
the thread object.
2.1.4. Synchronization
Threads share the same memory space, that is, they can share resources, however, there
are critical situations where it is desirable that only one thread at a time has access to
shared resource.
2.1.4.1. Locks
In java, all objects have a lock – including arrays. This means that the lock from any java
object can be used t o implement mutual exclusion. By associating a shared resource with
a java object and its lock, the object can act as a guard, ensuring synchronized access to
the resource.
A thread must acquire the object lock associated with a shared resource,
before it can enter the shared resource. The runtime system ensures that no
other thread can enter a shared resource if another thread already holds the
object lock associated with the shared resource. If a thread cannot
immediately acquire the object lock, it is blocked, that is, it must wait for the
lock to become available.
When a thread exits a shared resource, the runtime system ensures that the
object lock is also relinquished. If another thread is waiting for this object
lock, it can proceed to acquire the lock in order to gain access to the shared
resource.
22
COMPONENT BASED TECHNOLOGY
The keyword synchronized and the lock forms the basis for implementing synchronized
execution of code.
Synchronized methods
Synchronized blocks
This is simply achieved by calling the method. If the lock is already held by another
thread, the calling thread waits. No particular action on the part of the program is
necessary. Synchronized methods are useful in situations where methods can manipulate
the state of an object in ways that can corrupt the state if executed concurrently. A stack
implementation usually defines the two operations push and pop as synchronized, so that
pushing and popping of elements are mutually exclusive operations.
Understanding the life cycle of a thread is valuable when programming with threads.
Threads can exist in different states.
23
COMPONENT BASED TECHNOLOGY
terminated
new
runnable running
Suspended
A thread inherits the priority of its parent thread. Priority of a thread can be set using the
setpriority() method and read using the getpriority() method, both of which are defined in
the Thread class.
24
COMPONENT BASED TECHNOLOGY
Schedulers in JVM implementation usually employ one of the two following strategies:
Preemptive scheduling
If the thread with a higher priority than the current running thread moves to the Ready-to-
run state, then the current running thread can be preempted to let the higher priority
thread execute.
A running thread is allowed to execute for a fixed length of time, after which it moves to
the Ready-to-run state to await its turn to run again.
It should be pointed out that thread schedulers are implementation and platform
dependent; therefore, how threads will be scheduled is unpredictable, at least from
platform to platform.
A thread can transit to the dead state from the running or the Ready-to-run states. The
thread dies when it completes its run() method, either by returning normally or by
throwing exception.
Once in this state, the thread cannot be resurrected. There is no way to thread can be
enabled for running again, not even by calling the start() method once more on the thread
object.
25
COMPONENT BASED TECHNOLOGY
}
Public void run() {
While (theThread == Thread.currentThread()) {
System.out.println(“ inside loops.”);
}
}
}
Public class controller {
Public static void main(String[] args) {
Worker worker = new Worker();
worker.kickStart();
Thread.yield();
Worker.terminate();
}
}
2.1.5.5. Deadlocks
A deadlock is a situation where a thread is waiting for an object lock that another thread
holds, and this second thread is waiting for an object lock that the first thread holds.
Since each thread is waiting for the other thread to relinquish a lock, they both remain
waiting forever in the Blocked-for-lock-acquisition state. The threads are said to be
deadlock.
thread t1
lock acquired
O1
thread t2
thread t1 now waiting
to acquire lock on O2 lock acquired
O2
thread t2 now waiting cannot acquire lock
to acquire lock on O1
Dead lock
26
COMPONENT BASED TECHNOLOGY
Java beans is a set of java objects that objects that provides the infrastructure for the
components to be written in java language. Java beans include objects for customizing,
introspecting and event handling. It provides the component frame work from which
reusable components can be built.
Using the bean development kit, the users can implement their own component as well as
describe the interface specifications to their own components. It also enables the users to
define the event mechanisms, properties and public methods.
2.2.1. Overviews
Java beans mission statement is “ Write once, Run anywhere, Reuse everywhere”.
A bean, like an object in object oriented technology, is comprised of primary things data
and methods that act on the data.
Data Methods
Private
methods
Data
Protected
methods
Interface A
Public
methods Interface B
Basic structure of Bean
27
COMPONENT BASED TECHNOLOGY
Private methods
Protected methods
Public methods
Accessible internally, from derived beans and from other applications and components.
Public methods have unique importance because they form the primary means by which
the beans can communicate outside through events.
The JavaBeans API makes it possible to write components software in the Java
programming language. Components are self-contained, reusable software units that can
be visually composed into composite component, applets, application, and servlets using
visual application builder tools. Java Bean components are known as beans.
A “Java Bean-enabled” builder tool can then examines the bean’s patterns, discern its
feature, and expose those features for visual manipulation. A builder tool maintains beans
in a palette or tool box.
Although Beans are designed to be understood by builder tool, all key API’s including
support for events, properties and persistence, have been designed to be easily read and
understood by human programmers as well.
It is a tool that allows the user to configure and interconnect a set of beans.
It provides an easy way to test the beans that the user writes and to explore the
capabilities of beans written by others. BDK also includes a set of demonstration
components and their source code.
Bean box - Window that provides an area in which the user can connect the components.
Properties - Window that provides an interface through which the user configure a bean.
28
COMPONENT BASED TECHNOLOGY
1. Orange button: default orange color. Like explicit button changing its background
color and serializing it to a file.
3. Explicit button: is a subclass of our button it simply adds a Bean info class to
specify the beans behaviour and icons.
4. Event monitor: monitor all the events fired by a source bean. It does this by
analyzing the source bean and crating event adaptors for all the different kinds of
events fired by the bean.
5. Jelly bean: draws an oval and supports a bound property “color” and a constrained
properly “pricelncents”. Provides a mono and color icon in 16 x 16 and 32 x 32 the
16 x 16 is displayed in tool box
6. Juggler: it has very simple JugglerBeanInfo class that defines a 16x16 color icon
for the juggler that gets displayed in the toolbox. Two explicit button to the start
and stop juggling animation method by push events.
7. Tick tock: “invisible bean when the user selects it form the tool box and drops it’s
onto the composition window it will come up as a small rectangle showing the bean
name. The user can hide this using the “hide invisible beans”, item under the “view
menu”.
9. Change reporter: it is a small text window that can be used to display changes to
bound properties.
29
COMPONENT BASED TECHNOLOGY
10. JDBC Select: the JDBC capital bean contacts a target data box at a specified
JDBC URL and runs a SQL select statement to display specified columns for a
target table.
11. Transitional bean: it follows the JDK 1.0.2 compatibility rules, so that it will run
on JDK 1.0.2 as well as JDK 1.1 or higher.
Events in java and in java beans –are objects created by an event source and propagated
to all currently registered event listeners. Thus, event-based communication generally has
multicast semantics. However, it is possible to flag an event source as requiring unicast
semantics-such a source accepts at most one listener at any one time.
Listeners need to implement an interface that extends the empty “marker” interface
java.beans.Evenlistener and it has a receiving method for each event the listener listens.
Marker interfaces are also known as tagging interfaces
Example:
If it is registered with multiple event sources that can all fire the same event, the listener
has to determine where an event came from before handling it. This can be simplified by
interposing an event adapter. An event adapter implements a listener interface and holds
references to listeners.
Each adapter then calls a different method of the listener. Thus, event adapters can be
used to demultiplex events. In principle, event adapters can perform arbitrary event-
filtering functions.
30
COMPONENT BASED TECHNOLOGY
An event source needs to provide pairs of listener register and unregister methods
Public void addUserSleepsListener(UserSleepsListener i);
Public void removeUserSleepsListener(UserSleepsListener i);
Event ordering issues are aggravated in multithreaded environment such as Java. This is
clearly subtle. For one problems only arise if the event listener uses additional threads
besides the one carrying the event notification, because the notifying thread continues to
hold all the locks held by the event source, which would prevent dead locks.
Also, it is not even clear if this recipe can be followed generally with out breaking
encapsulation. It may not be at all easy to determine whether and which locks the event
source holds.
2.4. Properties
Simple properties
Bound properties
Constrained properties
Indexed properties
Properties are aspects of a Bean’s appearance and behavior that are changeable at design
time. Properties are private values accessed through getter and setter methods. Property
getter and setter method names follow specific rules, called design patterns.
By using these design pattern-based method names, JavaBeans- enabled builder tools
can.
31
COMPONENT BASED TECHNOLOGY
For examples, a builder tool, on introspecting your bean, discovers two methods:
from this the builder tool infers that a property named color exists, That it is readable and
writeable, and that it’s type is color. Further, the builder tool can attempt to locate a
property editor for that type, and display the property so it can be edited.
Sometimes when a Bean property changes, another object may want to be notified of the
change, and react to the change. Whenever a bound property changes, notification of the
change is sent to interested listeners.
A bean containing a bound property must maintain a list of property change listeners, and
alert those listeners when the bound property changes.
To listen for property change events, your listener Bean must implement the
PropertyChangeListener interface. This interface contains one method:
This is the notification method that the source bean calls on all property changes listeners
in its property change listener list.
32
COMPONENT BASED TECHNOLOGY
A bean property is constrained when any change to that property can be vetoed. Usually
an outside object exercises the right to veto, but the bean itself can also veto a property
change. The javaBean API provides an event mechanism, very similar to the bound
property mechanism, that allows objects to veto a bean’s property changes.
To listen for property change events, your listener bean must implement the
VetoableChangeListener interface. This interface contains one method:
Listener Class
Indexed properties represent collections of values accessed, like an array, by index. The
indexed property design patterns are.
33
COMPONENT BASED TECHNOLOGY
The BDK provides editors for the primitive data types like int, boolean, and float and
Color and font class types.
All the “number” properties are represented as string objects. The IntEditor
overrides PropertyEditorSupport. setAsText.
The Boolean property editor is a menu of discrete choices that overrides the
PropertyEditorSupport. getTags method to return a String[] containing “ True”
and “False”.
public String[] getTags () {
String result[] = { “True”, “False”};
Return result;
}
The color and font property editors implement custom property editors. Because
these objects require a more sophisticated interface to be easily edited a separate
Component pops up to do the property editing. Overriding supportsCustomEditor
to return true signals the property sheet that this property’s editor is a custom
component. The isPaintable and paintValue methods are also overridden to
provide color and font painting in the editor property sheet sample areas.
2.5. Introspection
Java events and properties are major supported by a combination of new standard
interfaces and classes.
I. EventListener
II. EventObject
III. EventSetDescriptor
IV. PropertyDescriptor
The use of interfaces such as EventListener allows an assembly tool using the reflection
services to discover support of certain features by a given bean. In addition, JavaBeans
introduces the new notion of method patterns.
34
COMPONENT BASED TECHNOLOGY
A method pattern is combination of rules for the formation of a method’s signature, its
return type, and even its name. method pattern allow for the lightweight classification of
individual methods of an interface or class
For example, here is the method pattern used to indicate a pair of getter and setter
methods for specific property.
Example
For a property “background” of type java.awt.Color, this pattern yields the following two
methods.
The use of conventional names in method patterns can be avoided – a bean can
implement interface java.bears.Beaninfo.
If this interface is implemented, an assembly tool will use it to query a bean instance
explicitly for the names of
I. Property getters
II. Property setters
III. Event source registration methods.
Jar is:
Jar consists of zip archive, containing a manifest file and potentially signature files.
35
COMPONENT BASED TECHNOLOGY
Java archive files provide a standard mechanism to compress and package a set of files
for distribution to users. JAR is a platform independent file format that aggregates many
files into one.
To create a single JAR file that contains several beans and any associated files.
Many java applets and their requisite components. Can be bundled in a JAR file
and subsequently downloaded to a browser in a single HTTP transaction, greatly
improving the download speed.
for instance, the developer creates a set of beans to receive and transmit streaming audio
and video on the internet.
I. The beans
II. Any supporting class files
III. Text and html files that provides help to the user
IV. Static images
V. Audio and video clips
VI. Configuration data
VII. Any other file required for the software to operate.
JAR format supports compression, which reduces file size, further improving the
download time.
First element in JAR file is always a manifest file. This is a plain text file that contains
information about all the other files in the archive. The manifest file indicates which of
the class files are java beans.
Changing the APPLET tag in your HTML page to accommodate a JAR file is simple.
The jar file on the server is identified by the ARCHIVE parameter, where the directory
location of the jar file should be relative to the location of the html page:
Note that the familiar CODE=myAppplet.class parameter must still be present. The
CODE parameter, as always, identifies the name of the applet where execution begins.
However, the class file for the applet and all of its helper classes are loaded from the jar
file.
JAR utility provided with the JDK is used create and manage JAR files.
36
COMPONENT BASED TECHNOLOGY
Syntax
A JAR file is essentially a zip file that contains an optional META-INF directory. A JAR
file can be created by the command-line jar tool, or by using the java.util.jar API in the
java platform. There is no restriction on the name of a JAR file, it can be any legal file
name on a particular platform.
2.7. Reflection
Reflection enables java code to discover information about the fields, methods and
constructors of loaded classes, and to use reflected fields, methods and constructors to
operate on their underlying counterparts on objects, within security restrictions.
2.7.1. Applications
I. One category is comprised of applications that need to discover and use all of the
public members of the target object on its run-time class. These applications
require run-time access to all the public fields, methods, and constructors of an
object.
II. The second category consists of sophisticated applications that need to discover
and use the member declared by a given class. These application need run-time
access to the implementation of a class at the level provided by a class file.
The three classes field, method, and constructor are final. Only the java virtual machine
may instances of these classes; these objects are used to manipulate the underlying
objects; that is, to:
The final uninstantiable class Array provides static methods that permit creating new
arrays, and getting and setting the elements of array.
37
COMPONENT BASED TECHNOLOGY
The java security manager controls access to the core reflection API on a class-by-class
basis.
The methods of class that give reflective access to a member or a set of member
of a class are the only source for instance of field, method, and constructor.
Once the system security manager grants initial reflective access to a member any
code may query the reflected member for its identifying information.
There are two types of automatic data conversions. Wrapping conversions convert from
values of primitive types to objects of class types. Unwrapping conversions convert
objects of class types to values of primitive types. The rules for these conversions are
defined in “wrapping and unwrapping conversions.”
Serialization is used for lightweight persistence and for communication via sockets or
Remote method invocation. The default encoding of objects protects private and transient
data, and supports the evolution of the classes. A class may implement its own external
encoding and is then solely responsible for the external format.
The Serializable fields of a class can be defined two different ways. Default serializable
fields of a class are defined to be the non-transient and non-static fields.
This default computation can be overridden by declaring a special field in the serializable
class, serialPersistentFields. This field must be initialized with an array of
ObjectStreamField objects that list the names and types of the serializable fields. The
modifiers for the field are required to be private, static and final.
For example:
38
COMPONENT BASED TECHNOLOGY
By using SerialPersistentFields to define the serialzable fields for class, thread no longer
is a limitation that a serializable field must be a field with in the current definition of the
serializable class
Object serialization produces a stream with information about the JAVA classes for the
objects which are being saved. For serializable objects, sufficient information is kept to
restore those objects even if a different version of the implementation of the class is
present.
The serializable interface is defined to identify classes which implement the serializable
protocol:
Package java.io;
For externalizable objects, only the identify of the class of the object is saved by the
container; the class must save and restore the comments. The Externalizable interface is
defined as follows.
Package java.io;
39
COMPONENT BASED TECHNOLOGY
{
Public void writeExternal(ObjectOutput out) throws IOException.
Public void readExternal (ObjectInput in) throws IOException,
java.lang.ClassNotFoundExcetpion;
}
Sun Microsystems introduced the J2EE application server and the Enterprise
JavaBean(EJB) specifications as a venture into multitier server-side component
architecture market.
It is important to note that thought EJB and JavaBeans are both component models they
are not same. EJBs are interprocess components and JavaBeans are intraprocess
components. EJB is a specification for creating server-side components that enables and
simplifies the task of creating distributed objects.
40
COMPONENT BASED TECHNOLOGY
2.9.2.EJB Server
The EJB server provides some low-level services, such as network connectivity to the
container. It also provide the following services:
Instance passivation
If a container needs a resource, it can decide to temporarily swap out a bean from
memory storage. This is called instance passivation.
Instance pooling
The EJB server enables multiple clients to share instances of enterprise beans. If an
instance of the requested bean exists in the memory, the bean is reassigned to another
client. This is called instance pooling.
When an enterprise bean wants to access a database, it does not create a new database
connection if the database connection already exists in the pool. Instead, it obtains a
database connection from the pool. When the bean releases the database connection, it
can be reused by another enterprise bean.
41
COMPONENT BASED TECHNOLOGY
Precached instances
The cache contains information about the state of the enterprise bean. When an enterprise
bean is created, it might require loading some state information. The enterprise bean can
use precached instance to load the information. This increases the speed of creating an
EJB.
The EJB container acts as an interface between an enterprise bean and the clients. Clients
communicate with the enterprise bean through he remote and home interfaces provided
by the container.
The client communicating to the enterprise bean through the container enables the
container to service the client’s request with great flexibility.
Container Services
Security
Transaction management
Persistence
The EJB class implements all business methods declared in the remote interface. To write
an EJB class:
1. Import interfaces:
Java.rmi.RemoteException
Javax.ejb.SessionBean
Javax.ejb.SessionContext
Example
import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContect;
public myEJBClass() {}
42
COMPONENT BASED TECHNOLOGY
Entity Bean
Entity beans are enterprise beans that persist across multiple sessions and multiple
clients. There are two types of entity bean:
Bean-managed persistence
Container-managed persistence
In a bean-managed persistence, the programmer has to write the code for database calls.
On the other hand, in container-managed persistence, the container takes care of database
calls.
Session Bean
Session beans perform business tasks without having a persistent storage mechanism,
such as a database and can use the shared data. There are two types of session beans.
A stateful session bean can store information in an instance variable to be used across
various method calls. Some of the applications require information to be stored across
various method calls.
The enterprise bean can be deployed using products such as WebSphere, WebLogic,
J2EE server, and Oracle 9i provided by vendors like IBM, BEA, Sun Microsystems, and
Oracle.
43
COMPONENT BASED TECHNOLOGY
Java 2 SDK, enterprise edition (J2EE SDk) is platform for developing and deployment
enterprise and multi-tier applications in a distributed environment. To create a J2EE
application, you must understand the J2EE architecture.
J2EE Server
EJB Container
Enterprise bean
Enterprise bean
Web Container
JSP file
Servelet
J2EE Server
The J2EE server contains the EJB container and the web container.
EJB Container
The EJB container contains the enterprise bean. The container provides remote and home
interfaces through which clients communicate with the enterprise bean. It also provides,
such as transaction management, security, life cycle management and persistence.
Web Container
The web container is a runtime environment for servlets and Java Server pages (JSP)
files.
44
COMPONENT BASED TECHNOLOGY
The .jar, .war, and EJB.jar files are assembled into a J2EE application, which is an .ear
file. The .ear file is then deployed on the J2EE server.
Under the term distributed objects, we usually understand objects which reside in
separate address spaces and methods of which can be subject of remote method calls (a
remote call is issued in an address space separate to the address space where the target
object resides). By convention, the code issuing the call is referred to as the client; the
target object is referred to as the server object (or simply remote object); the set of
methods which implements one of the server object’s interfaces is sometimes designated
as a service that this object provides. Similarly, the process in which the server object is
located is referred to as a server.
An important goal of the client and server abstractions is to make it transparent how "far"
the client and server spaces actually are - whether they reside on the same machine, are
on different nodes of a local network, or even reside on different Internet URLs (thus
being "intergalactic"); as a special case, client and server may share the same address
space.
One of the key issues of remote method calls is referencing of remote objects.
Classically, in a "local" case, in a method call rro.m(p1,p2, ..., pn) , rro contains a
reference to the target object, m identifies the method called, and some of the parameters
can contain references to other objects as well; let us suppose only one of the parameters,
say pj, contains a reference. However, in a distributed environment we face the following
issue: rro should identify a remote object over the network, and so should pj. It is obvious
that classical addresses will not do as the references, at least for the following reasons: in
addition to the data record of the target object, a reference has also to identify the node
and the server in which the target object resides. Moreover, the target object may
implement more (non polymorphic) interfaces; thus, rro should also identify the
particular interface which the target object implements, and to which m belongs. By
convention, a reference that contains all this information is termed a remote reference.
45
COMPONENT BASED TECHNOLOGY
The system consists of three basic layer: the Stub /skeleton layer, remote reference layer,
and transport. A specific interface and protocol defines the boundary at each layer.
Thus, each layer is independent of the next and can be replaced by an alternate
implementation without affecting the other layers in the system.
Architecture Overview
Client Server
Application
Stubs Skeletons
This figure is an illustration of the layers of RMI system. A remote method invocation
from a client to a remote server object travels down through the layer of the RMI system
to the Client- side transport, then up through the Server- side transport to the server.
46
COMPONENT BASED TECHNOLOGY
RMI –IIOP is an extension of traditional Java RMI that uses the IIOP protocol. This
protocol allows RMI objects to communicate with CORBA objects. Java programs can
therefore interoperate transparently with objects that are written in other programming
languages, provided that those objects are CORBA-compliant. Objects can still be
exported to traditional RMI(JRMP) however, and the two protocols can communicate.
Development procedure
RMI Java
Interface File
(MYObject.java)
Tie_Myobject_ Tie_Myobject_
Tie.Class Tie.Class
IIOP
ORB ORB
IIOP
A difference is the – iiop parameter of rmic compiler. This option used to make rmic
generate the stubs and tie that support the iiop protocol. Without this-iiop option, rmic
generates a stub and a skeleton for the JRMP protocol
Although the development procedure for RMI-IIOP is close to that for RMI the runtime
environment is different in that communication is made through CORBA.
Using java IDL, you can access any CORBA object from Java. Sun’s recommendation
for usage of RMI-IIOP and java IDL. If want to use java to access existing CORBA
resources. Java IDL is recommended.
47
COMPONENT BASED TECHNOLOGY
Java IDL
Java’s CORBA’S
World World
RMI-IIOP
CORBA’S
RMI’S
World
World
RMI-IIOP supports both the JRMP and IIOP protocols, there has been much speculation
that RMI (JRMP) will be integrated into RMI –IIOP. However, it would continue
supporting all three protocols, i.e., Java IDL, RMI (JRMP), and RMI-IIOP.
48
COMPONENT BASED TECHNOLOGY
Summary
49
COMPONENT BASED TECHNOLOGY
50
COMPONENT BASED TECHNOLOGY
Java and CORBA – interface Definition language-object Request Broker – System object
model – portable object adapter – CORBA Component model – Containers – application
server – model driven architecture.
3. Introduction:
Today Java and CORBA usually coexists in almost all application server products. When
implementing for the application server tier, it is reasonable to assume the presence of
CORBA mechanisms that is for interoperation.
An important reason to incorporate CORBA into Java projects is to enable the use of
IIOP for communication with non-java subsystems.
RMI is normally implemented using java Remote Method protocol which limits
the use of RMI to Java to Java communication.
The RMI over IIOP was introduced in 1999. it is the part of the java Development
kit (JDK) since J2SE 1.3 introduced. It supports a restricted RMI-Over-CORBA
IIOP protocol.
RMI-Over-IIOP does not support the RMI distributed garbage collection method.
So it falls back on CORBA’s life cycle management approach to deal with the
lifetime of remote objects explicitly.
In 2004 J2SE 1.4 was introduced. It supports POA(Portable object adapter),
portable interceptors, INS(Interoperable Naming Service), GIOP (General
interoperability Protocol).
One of the features of J2SE 1.4 is, it enables clients to remotely manage, locate
and invoke persistent objects in CORBA-supporting servers.
Now J2SE 1.5 is released and it supports many CORBA services with flexibility.
The OMG Interface Definition Language (IDL) is the language used to describe the
interfaces that client objects call and object implementations provide. An interface
definition Written in OMG IDL completely defines the interface and fully specifies each
operation’s parameters.
51
COMPONENT BASED TECHNOLOGY
An OMG IDL interface provides the information needed to develop clients that use the
interface’s operations.
Clients are not written in OMG IDL, which is purely a descriptive language, but in
languages for which mappings from OMG IDL concepts have been defined
The mapping of an OMG IDL concept to a Client language construct will depend on the
facilities available in the client language. A source file containing interface
specifications written in OMG IDL must have an “.idl” extension. The file orb.idl
contains OMG IDL type definitions and is available on every ORB implementation.
The implementation details of the ORB are generally not important to developers
building distributed systems. The developers are only concerned with the object interface
details. This form of information hiding enhances system maintainability since the object
communication details are hidden from the developers and isolated in the ORB.
ORB technology promotes the goal of object communication across machine, software,
and vendor boundaries. The relevant functions of an ORB technology are.
Interface definition.
Location and possible activation of remote objects.
Communication between clients and object.
The ORB must support many functions in order to operate consistently and effectively,
but many of these functions are hidden from the user of the ORB.
It is the responsibility of the ORB to provide the illusion of locality, in other words, to
make it appear as if the object is local to the client, while in reality it may reside in a
different process or machine.
Thus the ORB a frame work for cross –system communication between objects. This is
the first technical step toward interoperability of object systems.
52
COMPONENT BASED TECHNOLOGY
ORB
Activate
Locate Service
Service Establish
Connection
Client Remote
application Service(object)
Communicate
The next technical step toward object system interoperability is the communication of
objects across platforms. An ORB allows objects to hide their implementation details
from clients.
System Object Model (SOM) is an IBM technology that is being licensed to other
companies in anticipation of extending its benefits to heterogeneous environments. In
addition, a number of language vendors are working on providing native SOM capability
for their compilers.
53
COMPONENT BASED TECHNOLOGY
The SOM metaprogramming model largely follows the Smalltalk, so every class is itself
an object and as such an instance of a metaclass. All metaclasses are instances of a single
class, metaclass, which is its own metaclass.
SOM goes beyond the reflective capabilities of CORBA as SOM allows classes to be
constructed or modified dynamically.
SOM comes with precise rules as to which changes in a release maintain, and which other
changes break, binary compatibility with previous releases. Binary compatibility is a very
important issue in a component world.
3.4.3. Object
SOM objects are derived from a root object which defines the essential behavior common
to all SOM objects. Factory methods are used to create SOM objects at run time. These
factory methods are invoked on a class object, in the SOM run-time.
1. Operations
2. Requests
Client requests are invoked on objects by specifying the name of an object and the
name of the operation along with parameters to invoke on it. An object can support
multiple operations.
3. Methods
54
COMPONENT BASED TECHNOLOGY
The semantics of the operations on an object are defined by the methods that
implement these operations.
5. Methods
Methods are invoked on SOM objects. Methods can be relocated upward in the
class hierarchy without requiring the client to be re-compiled. SOM supports three
different method dispatching mechanisms; offset, name resolution, and dispatch
function resolution.
6. State
7. Object lifetime
SOM objects are created by invoking a create operation on a factory object in the
SOM runtime. Once created, the object will exist until explicitly deleted or until the
process that created it no longer exists.
8. Behavior/State grouping
SOM uses the classical object model in that a target object must be specified for
each operation.
9. Communication model
A class library based on SOM is used to provide SOM with distributed access to
remote SOM objects.
An object Adapter is an integral part of the Common Object Request Broker Architecture
(CORBA). An object Adapter assists an object Request Broker (ORB) in delivering client
request to server object implementations (Servants)
55
COMPONENT BASED TECHNOLOGY
3.5.1. Overview
ORBs eliminate many tedious, error-prone, and non-portable aspects of developing and
maintaining distributed applications by automating common network programming tasks
such as object location, object activation, parameter marshaling, fault recovery, and
security.
It allows developers to construct CORBA server application that are portable between
heterogeneous ORB implementations.
In args
Operation ()
Clients Object (Servant)
Out args+return value
CORBA Object Request Broker (ORBs) allow clients to invoke operations on distributed
objects without concern for:
Object location
CORBA objects can be collocated with the client or distributed on a remote server,
without affecting their implementation or use.
56
COMPONENT BASED TECHNOLOGY
Programming language
The languages supported by CORBA include C,C++, Java, Ada95, COBOL, and
Smalltalk, among others.
OS platform
CORBA runs on many OS platforms, including Win32, UNIX, MVS, and real-time
embedded systems like VxWorks, Chorus, and LynxOS.
The communication protocols and interconnects that CORBA can run on include TCP/IP,
IPX/SPX, FDDI, ATM, Ethernet, Fast Ethernet, embedded system backplanes, and
shared memory.
Hardware
The CORBA services are the set of fundamental enabling interfaces for globally
applicable service capabilities. To success with CORBA a good familiarity with each of
the CORBA services is essential.
Large CORBA based systems frequently use only a few CORBA services. The CORBA
services are reasonably small specifications that can be proto typed quickly and later
upgraded to vendor-supplied implementation if that becomes on option.
3.6.1. OMA
The object management architecture, it contains the details of the CORBA services,
CORBA facilities, CORBA domains and application interfaces. In this OMA, CORBA is
the central component through which all other objects communicate.
CORBA services
CORBA services are enabling services. They are primitive fundamental and globally
applicable. It is useful for all kinds of applications and are domain- independent in that
they are intended to be reused and specialized by applications.
57
COMPONENT BASED TECHNOLOGY
CORBA facilities
The other interface is the CORBA facilities. It acts as an intermediater between CORBA
services and CORBA domains. It relates to the CORBA domains interfaces.
CORBA domains
Application interfaces
It uses interfaces from CORBA services, CORBA facilities and CORBA domains.
It provides an organization for the services and infrastructure elements. It comprises four
categories of service elements. They are
I. Infracture services: it includes services elements that are tightly coupled to the
ORB mechanism such as messaging and interoperability.
II. Task management services: it includes enabling services for managing
distributed object events, transactions and concurrency.
III. Information management Services: it includes basic services for manipulation
and retrieval of data such as properties, relationship and collections.
IV. System management services: it includes basic services for enabling the
management of meta-data, naming and object lifecycle.
enables the user to obtain current time together with an error estimate associated
with it.
58
COMPONENT BASED TECHNOLOGY
59
COMPONENT BASED TECHNOLOGY
1. Identification and authentication of principals to verify they are who they claim to
be.
2. Authorization and access control – deciding whether a principal can access an
object.
3. Security auditing to make users accountable for their security related actions.
4. Security of communication between objects.
5. Non-repudiation provides irrefutable evidence of actions such as proof of origin
of data to the recipient, or proof of receipt of data to the sender to protect against
subsequent attempts to falsely deny the receiving or sending of the data.
6. Administration of security information.
7. Extends the structure of the ORB to allow for security mechanisms and protocols
8. Does not define cryptographic protocols – an Encryption protocol for secure
interoperability is being specified separately.
3.7.1. Introduction
Like EJB, it focuses on the services needed for server applications and leaves most of the
implementation details to the container, not application.
1. CCM Containers
2. CORBA components that run in these containers
3. The Portable Object Adapter (POA)
4. The Object Request Broker(ORB)
5. Other CORBA object services like CORBA Transactions, CORBA Security
CORBA Persistence, CORBA Events, etc.
60
COMPONENT BASED TECHNOLOGY
Buy offers
Price change
Event
Even Sell offers source
sink
Application Servers
These provide the system services like raw execution environment multiprocessing, load-
balancing, device access, provide naming and transaction services and make containers
visible.
CCM Container
These act as the interface between a CORBA Component and the outside world. A CCM
Client never accesses a CORBA Component directly. Any component access is done
through container-generated methods which in turn invoke the component’s methods
there are basically two basic types of containers.
They are,
I. Transient containers
II. Persistent containers
Transient Containers
It may contains transient, non-persistent components whose states are not saved at all.
61
COMPONENT BASED TECHNOLOGY
Persistent Containers
It contains persistent components whose states are saved between invocations. Depending
upon the types of components that they can execute, CCM Containers may be divided
into:
I. Service Containers
II. Session Containers
III. Entity Containers
IV. Other Containers
CCM Clients
These make use of the CCM Components for their operations. They find the CCM
container that contains the component through COSNaming and create, or obtain a
reference to the component’s container through the component’s Home interface. They
then make use of the CCM container to invoke the component methods.
In args
Operation ()
Client Object (Servant)
ORB CORE
The traditional OMG Common Object Broker Architecture (CORBA) enables software
applications to invoke operations on distributed objects without concern for object
location, programming language, OS platform, communication protocols,
interconnections, or hardware.
To provide higher-level reusable components, the OMG also specifies a set of CORBA
Object Services that define standard interfaces to access common distribution services,
such as naming, trading, and event notification.
62
COMPONENT BASED TECHNOLOGY
To address the limitations with the earlier CORBA object model, the OMG adopted the
CORBA Component Model(CCM) to extend and subsume the CORBA Object Model.
The CCM extends the CORBA object model by defining features and services that enable
application developers to implement, manage, configure, and deploy components that
integrate commonly used CORBA services, such as transaction, security, persistent state,
and event notification services, in a standard environment.
In addition the CCM standard allows greater software reuse for servers and provides
greater flexibility for dynamic configuration of CORBA applications. With the increasing
acceptance of CORBA in a wide range of application domains, CCM is well positioned
for use in scalable, mission-critical client/server applications.
CCM Components can expose multiple interfaces. While defining the IDL for each
component, the interfaces that it provides and the interfaces that it uses have to be
specified.
Similarly, the events that it emits and the events that it consumes have to be defined in
the IDL. The interfaces that it provides are called facets. The ability to use an interface is
facilitated by declaring it as a receptacle.
Event emition and publication declarations are used to define an event source. Event
consumption declarations are used to describe event sinks.
Facets, receptacles, event sources and event sinks are collectively called ports.
1. Service Components
2. Session Components
3. Process Components
4. Entity Components
1. Service Components
Each Service component is usually associated with one CCM Client and its lifetime is
restricted to that of one single operation request. Each service component is created and
destroyed by the particular CCM client that it is associated with. Service components do
not survive a system shutdown.
63
COMPONENT BASED TECHNOLOGY
2. Session Components
Each session component is usually associated with one CCM Client. Each session
component is created and destroyed by the particular CCM Client that it is associated
with. A session component can either have states or they can be stateless. However,
session components do not survive a system shutdown. A session component is very
similar to a session EJB.
They are.
These types of components have no internal state. Since they do not have any states,
they need not be passivated. Because of the fact that they are stateless, they can be pooled
in to service multiple clients.
These types of components possess internal states. Hence they need to handle
persistence. These types of components can be saved and restored across client sessions.
3. Process Components
Process components always have states. Each p rocess Components may however be
shared by multiple CCM Clients. Their states can be persisted and stored across multiple
invocations. Hence they can survive system shutdowns.
4. Entity Components
Entity components always have state. Each entity component may however be shared
by multiple CCM clients. Their states can be persisted and stored across multiple
invocations. Hence they can survive system shutdowns.
Each Entity Components can be uniquely identified by its primary key. An Entity
components is very similar to an Entity EJB.
3.8. Container
3.8.1. Overview
64
COMPONENT BASED TECHNOLOGY
The container offers series of local interfaces for establishing component’s context and
allows component to implement series of callback method.
Home
Transaction
interfaces
Container
External
POA
PSS
ORB
Client
CORBA
Component Security
Call back
Notification
Internal
As shown in the figure above, the container manages a component. It creates and uses a
POA with requested features for specific component category.client can use external
interfaces of a component to interact with component and home interfaces to manage life
cycle of a component.
The external API types of a Component are the Contract between the component
developer and the component client. It consists of two types of interfaces mainly home
interface and application interface. Home interface allows client to obtain reference to
one of the application interfaces the component implements.
From client’s prospective two design patterns are supported namely factory patterns for
creating new components and finder patterns for existing components. These patterns are
distinguished by the presence of primary key on home declaration.
The container API defines a API framework, i.e. contract between specific component
and container. It defines two types of container APIs namely session APIs.
65
COMPONENT BASED TECHNOLOGY
A CORBA usage model specifies the required interaction pattern between the container,
the POA and the CORBA services. It defines three types of usage model that are
distinguished by reference persistence and servant to object id mapping.
A service component has behavior, but no state and no identity. It’s useful for modeling
things that provide single independent execution of an operation.
A session component has a behavior, a transient state and but no persistent identity. It’s
useful for modeling a client session such as login, iterate or shopping cart.
An entity component has behavior, persistent state which is not visible to client and
persistent identity which is visible through explicit user defined operations. It’s useful to
model a business process rather than entities.
The container provides interfaces to component to access CORBA services and to other
elements of component model. Component defines these features using deployment
description for runtime container. In addition to object services the component can
specify servant lifetime policy to optimize memory usage.
Servant are programming language object which the POA uses to dispatch operation
requests based on object identification. The server programming model for CORBA
components include facilities to efficiently manage the memory associated with these
programming objects. The servant lifetime policies are defined as follows.
66
COMPONENT BASED TECHNOLOGY
Method: This policy causes the container to activate the component on every operation
request and to passivate when that operation is completed.
Transaction: This policy causes the container to activate the component on the first
operation of request within transaction and leave it until transaction completes.
Component: This policy causes the container to activate the component on the first
operation and remains active until component implementation requests to passivate.
Container: This policy causes the container to activate component on the first operation
request and leave it active until container decides to passivate it.
2. Transaction
NEVER: The Component required that client not be in current transaction before this
operation is invoked.
3. Security
67
COMPONENT BASED TECHNOLOGY
4. Events
CORBA components use a simple subset of the CORBA notification service to emit
and consume events. Event can be transactional as well as can contain access control lists
5. Persistence
The entity container API type supports the use of persistence mechanism for making
component state durable. Container API defines two types of persistence support.
Container-managed persistence the component developer simply defines the state that is
to be made persistent and container automatically saves and restores state as required.
3.9.1. Overview
It’s about integration. It’s about interoperability. For eleven years, the Object
Management Group (OMG) has focused on making sure that you can integrate what
you’ve built, with what you’re building, with what you’re going to build.
Proven in the marketplace with the standardization of CORBA, the CORBA services
Domain Facilities, UML, the MOF, and OMG’s other Modeling standards, the process is
one of our group’s major assets.
68
COMPONENT BASED TECHNOLOGY
The Meta-Object Facility (MOF) standardizes a model repository facility and the
foundation for a company’s common reference model. The common Warehouse Meta
model (CWM) standardizes how to represent a database schema for data warehouses,
improving data mining results by matching up concepts common to multiple warehouses
even where they go by different names.
Complementing, but not limited to, CORBA, OMG’s modeling specifications are being
used in virtually every development environment including Java/EJB,
COM/DCOM/.NET and XML/SOAP. Extending the usefulness of OMG’s modeling
standards, forthcoming specifications will lead to automation of design flow UML
models, through coding, to running application.
1. Directory
2. Persistence
3. Event handling
4. Messaging
are usually included
At the beginning of the 21st century, OMG has a middleware solution that works:
CORBA. Today CORBA is widely used to communicate over the internet, integrating
applications 24 hours a day, seven days a week. OMG’s layered services and vertical
market specifications build on CORBA , and are strongly established through the OMG
community process.
69
COMPONENT BASED TECHNOLOGY
Finally OMG’s modeling environment has spawned universally- recognized standards for
object modeling, repositories, data modeling and data warehousing.
Finance
Manufacturing E-Commerce
CORBA
UML
XMI/XML
WEB
MOF
CWM
JAVA NET
Transportation Healthcare
More…
Mappings
Mappings couple generic elements in each core model with their specific counterparts in
a model of each supported platform.
70
COMPONENT BASED TECHNOLOGY
Automation
Maximizing automation of the mapping step is a goal; however, in most cases some hand
cooling will be required, especially in the absence of MDA tools. As users and tool
builders gain experience, and techniques for modeling application semantics become
better developed, the amount of intervention required will decrease.
Many of today’s connection technologies will be integrated by the MDA, with room for
tomorrow’s “next best thing”. CORBA provides the best middleware choice because it is
vendor-and language-neutral, and bridges easily to all of the other middleware
environment.
Interoperability
Because the MDA is based on platform-independent core model, adding new middleware
platforms to our interoperability environment is straightforward: After identifying the
way a new platform represents and implements common middleware concepts and
functions, OMG members will incorporate this information in to the MDA as a mapping.
71
COMPONENT BASED TECHNOLOGY
SUMMARY
72
COMPONENT BASED TECHNOLOGY
1. what is an exception? List any three CORBA system exceptions and their mapping to
java exception.
2. In CORBA, how do you cast an object reference to a more specific type?
3. In a distributed CORBA application, how do you pass a list as a parameter using ;
IDL ? Give an example.
4. What is a IDL programming model?
5. Define transaction with its properties.
6. What is the purpose of creating five more .java files while compiling an IDL file
through a broker?
7. What are the equivalent in Java for the following in OMG IDL?
(a) Short
(b) Module
8. Differentiate between the naming and trading services offered by OMG.
9. What are the features of SOM?
10. What is POA?
73
COMPONENT BASED TECHNOLOGY
COM – Distributed COM – object reuse – interfaces and versioning – dispatch interfaces
– connectable objects – OLE containers and servers – Active X controls - .NET
component – assemblies – app domains – contexts – reflection – remoting.
COM is used in application such as the Microsoft office family of products. COM is the
basis of a number of windows services such as COM+, distributed COM(DCOM),
MSMQ, and ActiveX controls.
4.1.1. Introduction
The Component Object Model (COM) is a component software architecture that permits
applications and systems to be built from components supplied by different software
vendors. COM is the fundamental architecture that forms the foundations for higher-level
software services, like those provided by OLE.
Benefit of COM
74
COMPONENT BASED TECHNOLOGY
COM works by having any chunk of software implement its services as one or
more COM objects.
Each of these COM object supports one or more interfaces, each including a
number of methods.
Each COM objects runs within a Server.
Interface
Interface
COM Object
Interface
Server
The Component object model defines several fundamental concepts that provide the
model’s structural underpinnings. These include:
75
COMPONENT BASED TECHNOLOGY
The double indirection allows for vtable sharing among multiple instances of the same
object class. On a system with hundreds of objects instances, vtable sharing can reduce
memory requirements considerably.
Component object
Client
variable VTBL
VTBL Pointer
A Vtable
The word object tends to mean something different to everyone. To clarify, in COM, an
object is some piece of compiled code that provides some service to the rest of the
system. To avoid confusion, it is probably best to refer to a COM objects with source –
code object- oriented programming(OOP) objects such as those defined in C++.
Component objects support a base interface called IUnknown along with any
combination of other interfaces, depending on what functionality the component object
chooses to expose.
4.1.2.3. Interfaces
In COM, application interact with each other and with the system through collections of
functions called interfaces. Note that all OLE services are simply COM interfaces. A
COM interface is a strongly-typed contract between software components to provide a
small but useful set of semantically related operations.
Interface name begin with “I” by convention. OLE provides a number of useful general
purpose interfaces, but because anyone can define custom interfaces as well, we expect
developers will develop their own interfaces as they as they deploy component-based
applications.
76
COMPONENT BASED TECHNOLOGY
4.2.1 Introduction
Microsoft® Distributed COM (DCOM) extends the components object model (COM) to
support communication among objects on different computers- on a LAN, a WAN, or
even the internet.
With DCOM, your application can be distributed at locations that make the most sense to
your customer and to the application, because DCOM is a seamless evolution of COM,
the world’s leading component technology.
COM defines how components and their clients interact. This interaction is defined such
that the client and the component can connect without the need of any intermediary
system component.
When client and component reside on different machines, DCOM simply replaces the
local inter process communication with a network protocol. Neither the client nor the
component is aware that the wire that connects them has just become a little longer.
77
COMPONENT BASED TECHNOLOGY
The COM run-time provides object-oriented services to clients and components and uses
RPC and the security provider to generate standard network packets that conform to the
DCOM wire-protocol standard
COM COM
Client run-time run-time Component
Protocol stack
Protocol stack
DCOM network
protocol
78
COMPONENT BASED TECHNOLOGY
An important goal of any object model is that component author can reuse and external
objects provided by others as pieces of their own component implementations.
IUnknown knows
A,B and C
IUnknown
A Controls
Inner objects
Cuter Object uses Lifetime
Inner Objects C
B Implementation
As any client
Inner Object
Contained inside
C Outer Object
Reusable components is black box reuse which means the piece of code attempting to
reuse another component knows nothing and does not need to know anything about the
internal structure or implementation of the component being used.
COM interfaces can be derived from other COM interfaces using single interface
inheritance. All COM interface inherit from IUnknown interface directly or indirectly.
IUnknown is the common base type of the interface hierarchy.
IUnknown
IDispatch IPersist
79
COMPONENT BASED TECHNOLOGY
Automation
Why not make applications programmable, so that they can be driven by both people and
software.
Macro languages are an attempt to offer this, but they are generally cryptic, and each
application offers its own macro language, i.e. there is no standard.
4.6.1. Overview
The COM technology known as connectable objects supports a generic ability for any
object, called in this context a “connectable” object, to express these capabilities
The connectable object is only one piece of the overall architecture of connectable
objects. This technology includes the following elements:
Connectable Object
Client
Sink object
Connection point object
The OLE compound documents approach distinguishes between document container and
document server.
A document server provides some content model and the capabilities to display
and manipulate that content.
80
COMPONENT BASED TECHNOLOGY
4.8.1. Overview
The original specification for ActiveX controls was very rigid. This led to code bloat, as
many controls didn’t need all of the features, such as being able to display a user
interface.
Control Container
ActiveX controls must run within a control container. A control container is client
software that knows how to use an ActiveX control.
Examples:
Visual basic
Internet Explorer
When the HTML viewer loads document, that document might contain one or more
scripts. These scripts can make use of programmable objects exposed by the viewer. The
script executes in a component called the scripting engine.
As the script executes, it can invoke methods in the viewer’s objects and receive events
from those objects.
Load a Control
In order to load a control that is already present on the system from a web page, use the
OBJECT tag in html. The following sample shows how.
Sample code:
<OBJECT
CLASSID=”clsid:99B42120-6EC7-11CF-A6C7-00AA00A47DD2”
81
COMPONENT BASED TECHNOLOGY
ID=label1
WIDTH=150
HEIGHT=500
>
</OBJECT>
These two technologies are essentially competing with each other. Each reflects the
philosophies and goals of their creators. The following table compares the two
technologies
ActiveX JavaBeans
Windows only Multiple platforms
Multiple languages Java only
Limited to DCOM Can use RMI or CORBA
Faster, since it is native code Slower, but platform independent
Security is based on user’s trust Supports Java’s security model
4.9.1. Assemblies
Overview
An important aspect of assemblies is that they are part of the identity of a type. The
identity of a type is the assembly that houses it combined with the type name. This means
for example, that if assembly A exports a type called T, and assembly B exports a type
called T, the .NET runtime sees these as two completely different types.
Assemblies are also important in .NET with respect to security – many of the security
restrictions are enforced at the assembly boundary.
Win32 processes provide isolation by having distinct memory address spaces. This is
effective, but it is expensive and doesn’t scale well.
82
COMPONENT BASED TECHNOLOGY
AppDomain Creation
AppDomains are usally created by hosts. Examples of hosts are the windows shell,
ASP.NET and IE. When you run a .NET application from the command-line, the host is
the shell. The shell creates a new AppDomain for every application.
using System;
using System.Runtime.Remoting;
public class CAppDomaininfo : MarshalByRefObject{
return “AppDomain=”+AppDomain.CurrentDomain.FriendlyName;}}
4.9.3. Contexts
The term ‘managed’ is the cause of much confusion. It is used in various places within
.NET, meaning slightly different things.
Managed Code:
The .NET framework provides several core run-time services to the a programs that run
within it- for example exception handling and security.
Managed Classes:
This is usually referred to in the context of managed extensions (ME) for C++. When
using ME C++, a class can be marked with the _gc keyword.
83
COMPONENT BASED TECHNOLOGY
4.9.4. Reflection
All .NET compliers produce metadata about the types defined in the modules they
produce. This metadata is packaged along with the module, and can be accessed by a
mechanism called reflection. The System. Reflection namespace contains classes that can
be used to interrogate the types for a module/ assembly.
4.9.5. Remoting
.NET remoting involves sending messages along channels. Two of the standard channels
are HTTP and TCP.
TCP is intended for LAN only – HTTP can be used for LANs or WANs(internet).
Support
Examples are,
by default,
Objects have a default renew time- the lease is renewed when a successful call is made
from the client to the object. The client can also explicitly renew the lease.
84
COMPONENT BASED TECHNOLOGY
Summary
85
COMPONENT BASED TECHNOLOGY
86
COMPONENT BASED TECHNOLOGY
Connectors – contexts – EJB containers – CLR context and channels – Black Box
component framework - directory objects – cross – development environment –
component – oriented programming – component design and implementation tools –
testing tools – assembly tools
5.1. Connectors
5.1.1. Introduction
A few years ago, the trend to construct software systems as a collection of cooperating
reusable components emerged and has become widely accepted since. Influenced by the
academic research projects focused on components, several industrial systems on the
market advertise support of component technology.
The Darwin language is a typical representative of ADLs that use implicit connections.
The connections among components are specified via direct bindings of their requires and
provides interfaces.
To understand the connector concept properly, it is useful to identify and analyze the
basic tasks a connector should perform; here, the taxonomy of software connectors
presented in can be used for guidance.
From the main service categories and the basic connector types of this taxonomy, we
have selected the connector tasks listed below that we generally consider the key ones.
87
COMPONENT BASED TECHNOLOGY
A connector specifies the mechanisms on which possible control and/or data transfer is
based. Each of these mechanisms has specific characteristics and properties, e.g., a
procedure call can be local or remote.
As to RPC, various kinds of middleware can be used to implement it. Similarly event
handling can be based on an event channel, a centralized event queue, etc.
Connector Architecture
For every primitive element type, in addition to functional specification in plain English,
a precise specification of its semantics is given by mappings to underlying environments.
5.2. Contexts
Context is one of the current contextual composition approaches.
Context uses.
1) COM apartments
88
COMPONENT BASED TECHNOLOGY
Client
Methods Enterprise bean
EJB Object
(Client view)
EJB object provides a client view of the
Enterprises bean. It intercepts all calls and
Performs transaction, state, persistence
and security services for the bean
The CLR contexts offers a opportunity to populate the new context’s boundary with
properties, when need to construct a new context. A particular context property can be
added when some property requested for creating a new context.
CLR Objects
I. Values types
II. Pass-by-value types
III. Pass-by-reference types
IV. Context-bound types
The Black Box component framework is part of the Black Box component builder.
89
COMPONENT BASED TECHNOLOGY
Each module introducing a new abstraction also provides a configurable directory object.
It is default for all cases for which no specific directory object is available.
DEFINITION Files;
TYPE
Locator = ….;
Name = ….;
File = ….;
Directory = POINTER TO ABSTRACT RECORD
(d: Directory) This(Path: ARRAY OF CHAR): Locator, NEW, ABSTRACT;
(d: Directory) New(loc : Locator) : File, NEW, ABSTRACT;
(d: Directory) Old(loc : Locator; name: Name) :File, NEW, ABSTRACT;
….
END;
VAR dir-: Directory; (*read-only variable*)
90
COMPONENT BASED TECHNOLOGY
END Files.
A file directory object can be asked to open an existing “old” file by name or create a
new one that initially has no name.
Portos IDE
Various servers
for remote control,
debugging , etc
PortosThreads
Commstreams Subset of the
Black box component
frameworks with serial
communication facilities
META
PortosTasks
The rectangles represent individual component pascal modules. Rectangles with thicker
outlines are complete subsystems consisting of several modules or open collections of
component implementations.
91
COMPONENT BASED TECHNOLOGY
Polymorphism
Modular encapsulation
Late binding and loading
Safety
All existing methodologies work only with in a component. The issues regarding
complex interactions can be addressed at the level of programming languages and
approaches. So a proper methodology for COP needs to be found.
Component design
Component development
Component construction process is guided and helped by the support of the following
These models are used to construct a document. In application servers the components
are very helpful to develop a software. By using there models components can be
developed by adding little bit effort of developers.
5.10. Component Testing tools
First Strategy
It avoids the errors wherever possible. For example a compiler or analyzing tools are
allowed to catch substantial errors statically by a safe and expressive language. A
carefully crafted language can rule out entire classes of errors.
92
COMPONENT BASED TECHNOLOGY
Second Strategy
It makes sure that components are deployed in such a way that faults leave logged traces.
In this way, a failure in a production component system can at least be traced.
So, it is useful to assume that all component instances have a visual representation at
assembly time.
Software assembly holds different aspect of assembly processes. When new version of
components released the assembly process can be repeated.
93
COMPONENT BASED TECHNOLOGY
Summary
94
COMPONENT BASED TECHNOLOGY
1. What is ATL? Explain in detail the steps in building and testing a COM
component using ATL.
2. Explain the following concepts with an example:
(i) CLR Contexts and channels (ii) Cross Development Environment.
3. Explain the following concepts with an example:
(i) Component – oriented programming (ii) Assembly and Testing tools.
95