Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Component Models and Technology Component--based Software Engineering Component Ivica Crnkovic [email protected] Component models Page 1 Overview q Introduction q ACME Architectural Description Language q Java Bean Component Model q COM, DCOM, MTS and COM+ q CORBA Component Model (CCM) q .NET Component Model q OSGI Component Model Component models Page 2 Architecture Definition Languages q ADLs primarily address the issues related to the early phases of software engineering: l Design l Analysis q They identify a number of concepts, such as: l Architecture, configurations, connectors, bindings, properties, hierarchical models, style, static analysis and behavior. Component models Page 3 1 ACME Architectural Description Language q Components and Ports q Connectors and Roles q Systems and Attachments q Representations and Bindings q Properties, Constraints, Types and Styles Component models Page 4 Components and Ports q Components l Represent the computational elements and data stores of a system. q Ports l Are the points of interaction between a component and its environment. Component Port Component models Page 5 Connectors and Roles q Connectors l Represent interactions between components such as method calls or an SQL connection between a client and a database server. q The interface of a connector is defined as a set of roles Connector Role Component models Page 6 2 Systems and Attachments q The structure of a system is specified by a set of components, a set of connectors, and a set of attachments. q Attachment l Links a component port to a connector role. Attachement Component models Page 7 Representations and Bindings Component Connector Port Role Attachement Binding Component models Page 8 Component Interactions Iteractions with traditionalsoftware entities Interactions with other components Traditional software entities Interactions with other components Components Component Infrastructure Interactions with component infrastructure Component models Page 9 3 Terms in Components Components-- based technologies Interface that satisfies contracts Component -type Specific interface Component implementation Independent deployment Component model Coordination Services (transactions, persistence..) Component Framework Component models Page 10 Java Bean Component Model Component models Page 11 Key Features "A Java Bean is a reusable software component that can be manipulated visually in a builder tool” . q The Java Bean was designed for the construction of graphical user interface (GUI). q Explicitly tailored to interact in two different contexts: l At composition time, within the builder tool. l At execution time, with the runtime environment. q Any Java class that adheres to certain conventions regarding property and event interface definitions can be a JavaBean . q Properties of a compiled bean can be obtained by introspection mechanism Component models Page 12 4 Interface of a Component q This model defines four types of port: l methods, l properties, l event sources (generate an event) l event sinks called listeners (they receive event) Property ro Read -only property Method wo Write-only property Event source 1 Unicasteventsource Event sink (listener ) Boundedproperty v Vetoable property Ports Component models Page 13 Implementation of a Component q Most bean components are implemented by a simple Java object by naming convention Object Method Properties public void set<Property_name> (PropertyType value) public PropertyType get<Property_name> () A simple implementation Events public viod add< ListenerType> (<ListenerType> listener); public viod remove<ListenerType> (<ListenerType> listener); public class Y implements <Y>Listener { public viod <YoccuranceName> (<YObjectType> evt); } Component models Page 14 Components Assembly q Assembly is one of the key features of Java Bean though no not specific solution is provided. l Composition tools (Bean Box) l No composition language q Different ways of assembling components are supplied. Component - based assembly Component models Heterogeneous assembly Page 15 5 Packaging and Deployment q Java Beans define a model for packaging components into archives. l Includes the definition of dependency relationships between the package items. q Each package item can be marked "Design Only", so that they can be removed in a final application. Component models Page 16 An example q Example of a Cannibal bean, e.g as a part of a computer game q The Example contains: l A simple bean with a simple property and a boolean bound property l A simple test class for the bean l A class which do an introspection on the bean (similar to what a builder tool will do) showing the bean’s services, properties and events Component models import java.beans.*; Page 17 //for PropertyChangeListener class Cannibal { private String name; //r simple property private boolean saved; //rw bound boolean property //change listeners list private PropertyChangeSupport change; public Cannibal() { this("Eddy Merx", false); } public Cannibal(String n, boolean s) { name=n; saved=s; change=new PropertyChangeSupport(this ); } public String getName() {//property name, get method return name; } public boolean isSaved() {//property saved, isXxx method, bound return saved; } Component models Page 18 6 //property saved, set method public void setSaved(boolean s) { boolean old=saved; saved=s; change.firePropertyChange( "saved", new Boolean(old), new Boolean(s) ); } //bean services //… // Property Change Listener Support Methods public synchronized void addPropertyChangeListener( PropertyChangeListener listener) { change.addPropertyChangeListener(listener ); } public synchronized void removePropertyChangeListener( PropertyChangeListener listener) { change.removePropertyChangeListener(listener); } } Component models Page 19 public class Foo implements PropertyChangeListener { private Cannibal can; public static void main(String[] args) { new Foo(); } public Foo() { can=new Cannibal(); // create a Cannibal // add self to the Cannibal's listener list can.addPropertyChangeListener(this); // change the cannibal to saved can.setSaved(true); // fires property change event } public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("saved ") ) { System.out.println( "The cannibal "+can.getName()+" has been converted.“ ); System.out.println("old saved status was: "+event.getOldValue()); System.out.println("new saved status is: "+event.getNewValue()); } } } Component models Page 20 Output from execution of Foo The cannibal Eddy has been converted old saved status was: false new saved status is: true Component models Page 21 7 import java.lang.reflect.*; public class IntrospectCannibal { public static void main(String[] args) { try { // obtain class object for class Cannibal Class classObject = Class.forName("Cannibal "); // get Constructor, Field and Method objects Constructor[] cons=classObject.getDeclaredConstructors(); Field[] fields = classObject.getDeclaredFields(); Method[] methods = classObject.getDeclaredMethods(); System.out.println("Class Cannibal"); System.out.println(" \nConstructors: \n"); for (int i=0; i<cons.length; ++i) System.out.println(cons[i]); System.out.println ("\nFields:\n"); for (int i=0; i<fields.length; ++i) System.out.println(fields[i]); System.out.println(" \nMethods:\n"); for (int i=0; i<methods.length; ++i) System.out.println(methods[i]); } catch(Exception e) {e.printStackTrace(System.out);} } } Component models Page 22 Output from IntrospectCannibal Class Cannibal Constructors: public Cannibal(java.lang.String,boolean ) public Cannibal() Fields: private java.lang.String Cannibal.name private boolean Cannibal.saved private java.beans.PropertyChangeSupport Cannibal.change Methods: public java.lang.String Cannibal.getName () public boolean Cannibal.isSaved() public void Cannibal.setSaved(boolean) public void Cannibal.hunt(java.lang.Object) public synchronized void Cannibal.addPropertyChangeListener(java.beans.PropertyChangeListener) public synchronized void Cannibal.removePropertyChangeListener(java.beans.PropertyChangeListener) Component models Page 23 Java Remote Method Invocation (Java RMI) q RMI is an interface used over two protocols l Java Remote Method Protocol (JRMP) l Internet Inter -ORB Protocol (IIOP) Java Client CORBA Object Java Object RMI JRMP, IIOP Component models Page 24 8 Java RMIRMI- Based Technologies Machine X Client Machine Y Java Bean RMI Remote Java Application Java App. EJB Container RMI EJB RMI Component models Page 25 Enterprise JavaBeans q Architecture for distributed applications (distributed components) q Framework for creating middleware EJB Server EJB Container EJB client Enterprise bean Clients accesses JBs via containers Component models Page 26 Calling an Enterprise Bean EJB Container/Server Client Application Home Object 4. Return to client 1. Call a method EJB Object 3.Return result Enterprise Bean 2. Acquire a bean and delegate the call to the bean Component models Page 27 9 Creating the EJB Object EJB Container/Server 3. Return EJB Obj. Ref. Client Application 1. Create EJB Obj. Home Object 2. Create EJB Object EJB Object Enterprise Bean Component models Page 28 Java Naming and Directory Interface Client Application 1. Retrive home object 2. Return reference JNDI Naming Service Component models Page 29 One More Time EJB Container/Server 5. Return EJB Obj. Ref. Client Application 3. Create EJB Obj. 1. Retrive home object 9. Return to client 2. Return 6. Call a method reference Home Object 4. Create EJB Object EJB Object 8.Return result Enterprise Bean JNDI 7. Acquire a bean and delegate the call to the bean Naming Service Component models Page 30 10 Java Application Server Technologies Various JSP Tools Browser Client DBMS HTTP HTTP Listener JSP JDBC Applications Servlets RMI/IIOP Rich Client JDBC DBMS EJB JDBC Applications EJB Various Java Tools DBMS Windows NT, Unix, Others Component models Page 31 J2EE (Java 2 Platform, enterprise edition) q Defines an architecture for building large scale multi-tier distributed applications l Uses standardized modular components l Provides standard services for those components l Automatically replaces many aspects of the application programming from the developer l Thinner clients Component models Page 32 J2EE architecture components q J2EE Platform Specification l Specification of the APIs to be provided l Descriptions of the support levels expected for containers, clients, and components q J2EE Sun’s Reference Implementation l Free implementation of the specified technologies, sample applications, tools, and documentation q J2EE Compatibility Test Suite l Test implementations of the platform q J2EE Sun BluePrint l Documentation, examples, and design guidelines Component models Page 33 11 J2EE application model q Business logic in Enterprise JavaBeans components q Client interaction presented through different technologies l Plain Html l Java applets l Java servlets l JSP q Components communicates transparently using different standards l Html l XML l RMI Component models Page 34 The J2EE architecture (Pic. Sun Microsystem, http://java.sun.com/j2ee/overview3.html) Component models Page 35 COM/DCOM Component models Page 36 12 Interfaces and Assembly q A COM interface is seen as a C++ virtual class and takes the form of a list of data and function declarations without associated code. q All interfaces are descendants of the IUnknown interface. Interface Component interface Component implementation Component models Page 37 A Simple COM Object q A COM interfaces can have methods and properties l Language independent – binary standard q All Access is through the interface l Supports multiple interfaces l Each interface has a GUID Component models Page 38 IUnkown q All COM objects must implement IUnknown l AddRef l Release l QueryInterface IUnknown Component models Page 39 13 IUnknown q Contains onlythree methods l HRESULT QueryInterface(GUID iid, void **iptr ); l ULONG AddRef(); l ULONG Release(); q QueryInterface is used for Interface Navigation q AddRef and Release is used for reference counting l A form of collaborative carbage collection Component models Page 40 IDL Example interface ISpellCheck : IUnknown { HRESULT check( [in] BSTR *word, [out] bool *correct); }; interface ICustomSpellCheck : IUnknown { HRESULT add( [in] BSTR *word); HRESULT remove( [in] BSTR *word); }; library SpellCheckerLib { coclass SpellChecker { [default] interface ISpellCheck ISpellCheck; ; interface ICustomSpellCheck ICustomSpellCheck; ; }; }; Component models Page 41 Invocation of a method q Remote Procedure Call (RPC) is used q The RPC in DCOM is called Object RPC l Based on Microsoft RPC l Which is itself based on DCE RPC COM DCOM COM COM/Win32 Operating System Operating System Component models Page 42 14 COM-- Based Technologies COM Machine X Client Machine Y ActiveX COM Remote Server Local Server DCOM MTS Container MTS DCOM Component models Page 43 Creating a local object Client Application 4. Invoke methods Object Server 1. CoCreateInstance 3. Return pointer to interface 2. Locate server object COM Library CLSID_X Path to server X CLSID_Y Path to server Y Registry Component models Page 44 Creating a local object using a class factory Client Application 4. Invoke methods Object 3. Return pointer to interface 1. IClassFactory::CreateInstance 2. Create Object and get interface pointer Class Factory Server Component models Page 45 15 Creating a remote object 4. Invoke methods Client Application Object Server 3. Return pointer to interface 1. CoCreateInstance COM Library CLSID_X Idt.mdh.se CLSID_Y D:\Y.exe 2. Locate server object CLSID_X C:\X.exe ... ... Registry Registry mrtc.mdh.se Idt.mdh.se Component models Page 46 Microsoft Application Server Technologies Visual InterDev Browser Client DBMS HTTP IIS ASP ADO Applications DBMS COM ADO Applications DCOM Rich Client MTS VB VC++ VJ++ DBMS Windows NT Component models Page 47 CORBA and Component Model (CCM) Component models Page 48 16 CORBA q Common Object Request Broker Architecture q Standard for writing distributed object systems : Language independent : Not controlled by one company : Optional value added services Component models Page 49 OMA Overview OMA–Object Management Architecture CORBAapps CORBAdomains CORBAfacilities CORBA (Common Object Request Broker Architecture) Transactions Event Security Naming CORBAservices Component models Page 50 Component models Page 51 17 Remote invocation Component models Page 52 CORBA 3.0 q Internet Integration l Firewall Specification l Interoperable Name Service q Quality of Service Control l Asynchronous Messaging and Quality of Service Control l Minimum, Fault-Tolerant, and Real -Time CORBA q The CORBAcomponent architecture l Components l Scripting Component models Page 53 Component models Page 54 18 CORBA ORB architecture q q q q q q q q q Object -- This is a CORBA programming entity that consists of an identity, an interface , and an implementation, which is known as a Servant. Servant- - This is an implementation programming language entity that defi nes the operations that support a CORBA IDL interface. Servants can be written in a variety of languages, including C, C++, Java, Smalltalk, and Ada . Client- - This is the program entity that invokes an operation on an object implementation. Accessing the services of a remote object should be transparent to the caller. Ideally, it should be as simple as calling a method on an object, i.e., obj- >op(args ). The remaining components in Figure 2 help to support this level of transparency. Object Request Broker (ORB)- - The ORB provides a mechanism for transparently communicating client requests to target object implementations. The ORB simplifies distributed programming by decoupling the client from the details of the method invocations. This makes client requests appear to be local procedure calls. When a client invokes an operation, the ORB is responsible for finding the object implementation, transparently activating it if necessary, delivering the request to the object, and returning a ny response to the caller. ORB Interface -- An ORB is a logical entity that may be implemented in various ways (such as one or more processes or a set of libraries). To decouple applications from implementation details, the CORBA specification defines an abstract interface for an ORB. This interface provides various helper functions such as converting object references to strings and vice versa, and creating argument lists for requests made through the dynamic invocation interface described below. CORBA IDLstubs and skeletons - - CORBA IDL stubs and skeletons serve as the ``glue'' between theclient and server applications, respectively, and the ORB. The transformation between CORBA IDL definitions and the target programming language is automated by a CORBA IDL compiler. The use of a compiler reduces the potential for inconsistencies between client stubs and server skeletons and in creases opportunities for automated compiler optimizations. Dynamic Invocation Interface (DII)- - This interface allows a client to directly access the underlying request mechanisms provided by an ORB. Applications use the DII to dynamically issue requests to objects without requiring IDL interface- specific stubs to be linked in. Unlike IDL stubs (which only all ow RPC- style requests), the DII also allows clients to make non- blocking deferred synchronous(separate send and receive operations) and oneway (send-only) calls. Dynamic Skeleton Interface (DSI) -- This is the server side's analogue to the client side's DII. Th e DSI allows an ORB to deliver requests to an object implementation that does no t have compile- time knowledge of the type of the object it is implementing. The client making the request has no idea whether the implementation is using the typespecific IDL skeletons or is using the dynamic skeletons. Object Adapter - - This assists the ORB with delivering requests to the object and with activating the object. More importantly, an object adapter associates object implementationswith the ORB. Object adapters can be specialized to provide support for certain object implementation styles (suc h as OODB object adapters for persistence and library object adapters for non -remote objects). Component models Page 55 CORBA Component Model q A Framework for Server Applications q Built on the Portable Object Adaptor q Provides interfaces for CORBA Services l transactions l security l events l persistence q Uses Callbacks for instance management q Empty container for user-defined frameworks Component models Page 56 CORBA Component Model q A component interface is made of ports divided into: l Facets - for interaction with clients l Receptacles – references o external code l Event sources l Event sinks Attribute Facet Segment Receptacle Event source Event sink Component interface Ports Component implementation Component models Page 57 19 Defined Container Frameworks External Interfaces Component Container Callback Interfaces Internal Interfaces ORB/POA Transaction Security Persistence Events Component models Page 58 Real--Time CORBA Real q See RT-CORBA page 18… Component models Page 59 Portable EndEnd-to to--End Priorities • Problem: How can we map global priorities onto heterogeneous native OS host thread priorities consistently end-to-end? • Solution: Use Standard RT CORBA priority mapping interfaces Component models Page 60 20 Obtaining Portable ORB EndEnd-system Priorities lOS-independent design supports heterogeneous real -time platforms lCORBA priorities are “globally” unique values that range from 0 to 32767 lUsers can map CORBA priorities onto 25% ( 1 ' 6 <6 7( 0 $ native OS priorities in custom ways lNo silver bullet, but rather an ``enabling technique' ‘ Fi.e., can’t magically turn a general-purpose OS into a realtime OS! 25% ( 1 ' 6 <6 7 ( 0 % Component models Page 61 Preserving Priorities End-to-End • Problem: How can we ensure requests don’t run at the wrong priority on the server? • e.g., this can cause major problems if edge_alarm() operations are processed too late!!! • Solution: Use RT CORBA priority model policies Component models Page 62 Preserving Priorities EndEnd-to to-- End qRT CORBA priority model policies lSERVER_DECLARED FServer handles requests at the priority declared when object was created lCLIENT_PROPAGATED FRequest is executed at the priority requested by client FPriority is encoded as part of client request Component models Page 63 21 Problems that RTRT- CORBA solves • Problem: How can RT-CORBA client application change the priority of operations? • Problem: How to ensure that certain operations always run at a fixed priority? • Problem: How can we prevent bursts or long -running requests from exhausting maximum number of static & dynamic threads in the lane? • Problem: How can we support real -time applications that need more buffering than is provided by the OS I/O subsystem • Problem: An ORB & application may need to use the same type of mutex to avoid priority inversions l e.g., using priority ceiling or priority inheritance protocols Component models Page 64 Problems that RTRT- CORBA solves • Problem: How can we minimize priority inversions, so that high-priority operations are not queued behind low-priority operations? • Problem: How can we handle the fact that CORBA one-way operation semantics aren’ t precise enough for real -time applications? q Problem: How can we simultaneously l Prevent clients from blocking while long -duration requests complete & l Allow many requests to be issued concurrently Component models Page 65 Concluding Remarks RTRT- CORBA qRT CORBA 1.0 is a major step forward for QoS -enabled middleware l e.g., it introduces important capabilities to manage key ORB end-system/network resources qWe expect that these new capabilities will increase interest in--and applicability of--CORBA for distributed real-time & embedded systems • Our work on TAO has had the following impact: •Advanced middleware for distributed real-time & embedded systems by implementing RT CORBA in an opensource ORB •Provide feedback to users & OMG •Provide affordable access to RT CORBA qRT CORBA 1.0 doesn’t solve all realtime development problems, however l It lacks important features: FStandard priority mapping manager FDynamic scheduling – Addressed in RT CORBA 2.0 l Portions R&D User Needs of spec are under-specified FThus, developers must be familiar with the implementation decisions made by their RT ORB Standard COTS R&D Component models Page 66 22 minimumCORBA q minimumCORBA defines a profile (or subset) of CORBA, whereas CORBAservices, CORBAsecurityetc. define optional extensions to the CORBA specification. Component models Page 67 Component models Page 68 .NET What is .NET? q NET is a platform that enables: l Software as services, especially over the web l Distributed computing l Componentization l Enterprise services Component models Page 69 23 .NET Platform VB C++ C# JScript … ASP.NET Windows Forms ADO.NET and XML Base Class Library Common Language Runtime Visual Studio.NET Common Language Specification Operating Systems Component models Page 70 .NET Framework Components q Common Language Runtime (CLR) l Common type system for all languages l Runtime environment q Class libraries (.NET Framework) l Base class libraries, ADO.NET and XML l Windows Forms for, Win32 applications q Web application platform ASP.NET l Interactive pages l Web services that are SOAP enabled Component models Page 71 .NET Component Model - Implementation q A component (assembly) is made of modules, which are traditional executable files (DLL). q Modules cannot be assemblies, thus the .NET model is not hierarchical. Attribute Method Event source Component interface Ports Component models Modules Component implementation Page 72 24 Framework q .NET relies on the traditional programming approach : the framework is seen as the language run-time support. l MISL – Microsoft Intermediate language (similar to Java Byte code) l Common Runtime Language (similar to Java Virtual Machine) q Transaction control relies on MTS. Component models Page 73 Lifecycle q Assemblies (and their modules) are local to an application, and thus different DLLs with same name can run simultaneously. q Each assembly has a versioning information about itself and about the assemblies it depends on. l Version control is delegated to the dynamic loader, which selects the “right” version. q Significantly improve the application packaging and deployment. Component models Page 74 Other component models q OSGI Component Model q KOALA component model q IEC 61131-3 standard languages (functional blocks) q Real-time components Component models Page 75 25 A Koala Component Subcomponent Interfaces A switch CC C1 s C2 m C3 A module Component models Page 76 OSGI Component Model q Components q Interface of a Bundle Component q Assembly of Bundle Components q Implementation of a Bundle Component Component models Page 77 Components q A bundle use three kinds of ports to express its interactions with l Traditional technology l Other components l The run-time environment q Bundles may listen to events published by the framework such as the insertion of a new component in a system. Component models Page 78 26 Interface of a Bundle Component Package export Package import static Service interface Serviceuse Interface of a bundle component dynamic Ports Component models Page 79 Assembly of Bundle Components q A system is an evolving set of bundle components. q A bundle component publishes a service interface l It can attach to it a set of properties describing its characteristics. q A component requires an interface for its use, l It will select one via a query expression based on these properties. q This flexibility also has its counterpart l There is no guarantee than the service will continue to be available Component models Page 80 Implementation of a Bundle Component q JAR archive containing: l Service components l Java packages l Other resources files Package Resource Servicecomponent Activator Component models Page 81 27