390 likes | 519 Views
Components. Lecture Six. Component Technologies. Interfaces. Ways of Providing Interfaces. Contracts. JavaBeans Architecture. Integrating JavaBeans. Serialization. Introspection. Design Pattern for Event Listerners. Event Source. Component Architecture.
E N D
Components Lecture Six
Component Architecture • Pivotal basis for any large scale software technology • utmost important for component-based systems • foundation for software maintenance and evolution
Elements in Component Architecture • Interactions between components and their environment • Roles of components • Tool interfaces • User interface for end users and assemblers
Component System Architecture • Consists of • a set of platform decisions • a set of component frameworks • an interoperation design for the component frameworks
Platforms • Base for installing, instantiating and activating components and component frameworks • Can be concrete or virtual • concrete: direct support from hardware • virtual: platform abstract/emulation
Component Frameworks • A dedicated and focused architecture, usually around a few key mechanisms, and a fixed set of policies for mechanisms at the component level • protocols for connecting participating components • enforcing policies
Interoperation Design • Rules of interoperation among all the frameworks joined by the system architecture
Components and Atomic Components • A component is a set of simultaneously deployed atomic components • An atomic component is a module and a set of resources • A module is a set of classes and possibly non-OO procedures • dependency graph must be acyclic • A resource is a ‘frozen’ collection of typed items
Component Frameworks • A software entity that supports components conforming to certain standards and allows instances of these components to be plugged into the framework. • Establishes environment conditions • Regulate component interactions • Implementation inheritance is not normally used, compared with App. Frameworks
Component Frameworks: OpenDoc • OpenDoc • Compound Document Framework • ODPart (60 methods)
Component Oriented Programming • Requires support of • Polymorphism (Substitutability) • Modular encapsulation (Higher level information hiding) • Late binding and loading (independent deployability) • safety (type and module safety)
Problems in Component Wiring by Event Dispatching • Invariants: the system is in an inconsistent state while a multicase in is progress • Relative ordering of multicast • The recipient set could change during multicast • Recipients could raise exceptions
Multithreading • Critical area needs locking • Could introduce deadlock • Handling asynchronous exceptions • Hard to debug
Living without Implementation Inheritance • Severe problems caused by implementation inheritance across component boundaries • Fragile Base Class Problem • syntactic (RRBC) • semantic:
JavaBeans • A Bean is a reusable component that can be manipulated as a live object from within an application builder, is associated with a BeanInfo object that defines the Bean, its customizer, properties,property editor, events, and methods.
Minimum Requirements • Instantiable • Has a default constructor • Implements Serializable or Externalizable
BeanInfo • A Bean is separate from its BeanInfo • A Bean ABC may have ABCBeanInfo • Not directly accessed • Only accessed by Introspector • Introspector takes BeanInfo and information collected by Core Reflection API
OurButton • Compare the code with options from BeanBox
ExplicitButton package sunw.demo.buttons; import java.beans.*; public class ExplicitButton extends OurButton { }
BeanInfo and Customizer • ExplicitButtonBeanInfo.java • ExplicitButtonCustomizer.java
OrangeButton and BlueButton • What are they? • How were they created?
COM • Component Object Model • A binary object interoperability standard • Use cases for using a Binary Component
IUnknown • Interface • HRESULT QueryInterface(REFIID iid,void** ppvObject) • HLONG AddRef() • HLONG Release()
Interfaces • Client of a COM object shlaa interact with the object only via its interfaces • All COM interfaces are based on Iunknown • Given any interface pointer to an object instance, you can get the pointer to any other interface implemented by the object via QueryInterface() method
COM runtime • Create an instance • Partially platform dependent • GUID(UUID) for identifying • classes CLSIDs and • Interfaces IIDs and • … • Uuidgen.exe
Create an instance • CoGetClassObject() for a class factory IClassFactory • Support CreateInstance()
Object Containment and Delegation • Delegation: action of calling a method in the worker object, in response to a method call on one of our own interfaces
Object Agreegation • COM provides a mechanism called aggregation, which allows an aggregator to expose interfaces of its aggregates (worker objects)
Component Frameworks: Blackbox • Focus on compound document based applications • principles/patterns • carrier-rider-mapper • directory object (abstract factory, factory method) • HMVC • cascaded message multicasting • reuse through object composition