Technology
OA Overview

"OA", pronounced "O" "A", stands for Object Automation
OA consists of Objects, Components and Tools.

OA allows applications to be built around a core object model that is responsible for controling the data and rules for an application. These objects can then be used with any database/datasource, with any visual components that are used for building JSP/HTML, JSP/Swing user interfaces, and across tiers.


Red arrows represent the areas where programming
has been automatted to connect with your objects




Connecting your Objects ...
... Together ... creating object relationships
... To Databases/DataSources ... creating persistent data
... To Java Foundation Classes ... creating client user interfaces
... To Java Server Pages ... creating web interfaces
... To Other Applications ... creating synchronized Client/Server systems


Model Controls the Application

OAObject was designed ...

... to connect with other Objects and Collections

  • Hub is a Java Collection Class for storing groups of objects.
  • Hub is observable: it sends events to registered listeners.
  • The Hub Collection helps manage objects and object events.
  • Methods for sorting, finding
  • Object relationships like one2one, one2many, many2many, and recursive. The Hub Collection has functionality to create Master/Detail, Master/Linking relationships between Objects and Hubs.
  • Hub allows for multiple Hubs to share the same objects for different purposes.

    How OAObject works with Hub

  • OAObject "knows" which Hubs it is a member of and notifies each Hubs listeners on events.
  • Built-in methods for sending events on property changes.
  • Built-in functionality to allow for canceling of property changes.
  • ObjectKey for uniquely identifying an Object.
  • OAObject includes functionality to keep calculated properties updated based on property paths of parameters needed for calculation. Object properties are automatically updated when object is assigned to different Hub.

    ... to communicate with any Database/Datasource: OADataSource
    OADataSource is an interface used to connect Objects to any source of data.
    Examples: RDBMS using JDBC, Object-Relational engines, XML, legacy, etc.

  • Methods for Selecting, Saving, Deleting, Pass Thru.
  • OADataSource engines are self-registering and do not have to be referenced in programs.
  • OASelect is an object for building and running queries without knowing the OADataSource.
  • Queries are based on object structure using property paths and not structure of datasource.
  • OADataSource interfaces handle transactions, connection pooling and other features seamless to applications.

    How OAObject interacts with OADataSource

  • Calls OADataSource for object initialization.
  • Save, Delete methods.
  • Methods for hooking before,during,and after: Save, Delete, Cancel methods.
  • Hide fkeys: object references are used and foreign keys are used internally by OADataSource.
  • Many2Many relationships using link tables is managed by OADataSource.
  • Cascading saves and deletes.
  • Allows OADataSource to update object and for assigning values to unique properties.
  • Manages which properties are assigned NULL value.
  • Flags object to know if it is "New".
  • Manages changed properties.

    How Hub interacts with OADataSource

  • Allows for prefetching instead of loading all at one time
  • Allows for max size of objects to be loaded, similar to a stack.
  • Methods for selecting objects. Uses an OASelect to get objects and get counts.
  • Makes sure object is not already loaded in memory so that duplicate objects will not exist.

    ... to connect with JFC/Swing components for Client Applications:

  • Subclass JFC Components to add functionality so that they are Object Aware.
  • Added new features and made it easier to use.

    How OAObject & Hub interact with OA Swing/JFC

  • OAObject and Hub serve as the Model of the MVC pattern used by JFC.
  • All JFC Components automatically work with application OAObjects and Hubs by using property names and property paths.
  • Uses property paths and Java Reflection to set and get properties.
  • Uses custom mapping objects for converting property values to and from Strings.
  • Uses Master/Detail Hub relationships to automatically update components.
  • Uses Master/Linking Hub relationships.
  • Uses Sharing Hub relationships.

    ... to connect with JSP/Servlet for Web Applications:

  • Functionality similar to OA Swing/JFC from previous section.
  • Created objects to represent building HTML pages and forms using visual components.
  • Includes objects for storing and sharing objects between applications, users and forms.
  • Includes components to manage Framesets and Frames.
  • Clear separation of Java and HTML, CSS, Javascript, XML, etc.
  • Methods to allow for various levels of HTML generation.
  • Integration with JavaScript.
  • Central controller handles all form submits and automatically sets form components and calls event listeners.

    ... to work with other Applications: "OASync"

  • Uses RMI to have multiple OAClients kept in sync by an OAServer.
  • Only information that is needed is transmitted so that traffic can be kept at a minimum.
  • Object collisions and deadlocks are managed.
  • Publish/Subscribe messaging

    How OAObject & Hub work with other Applications

  • OAObject and Hub will automatically work with OASync when an OAClient is created.
  • Object Locking will automatically work with OAServer to share locks by all applications.




    Simple Example to explain the basic concepts
    This section will use an example to explain the simple concepts used to build OA.

    Step 1: Objects
    Everything in Java is represented as an Object. An Object has properties (data) and methods (code that uses data). In our example, we will be using two objects: an Employee Object that contains the name of an Employee and a TextField Object that is used for displaying and editing text.

    Step 2: Connecting
    To have the TextField display and change the Employee name, we have to build a program that will automatically update the TextField whenever the name is changed and update the Employee name whenever the text on the TextField is changed.

    Step 3: Connecting the Wrong way
    The wrong to do this would be to build the functionality into each object so that it would update the other object. By doing it this way, the Employee and TextField will be setup to only work together. If another object needs to work with them, then they have to be added. Also, the TextField and Employee Objects will need to have a reference to each other.


    Step 4: Using Listeners
    A Listener is a type of Object that is built to receive events. An Object can include a Listener Interface. This Interface defines the events that it will send. Whenever an event happens, the Object can then notify the Listeners without regard to what they are or how they are being used.
    The example now shows how both the Employee and TextField send events without regard to each other.


    Step 5: Connecting the Right way
    A Connector Object can be created that will Listen to both the Employee and TextField. Whenever an event is received from one object, this Connector can perform the required action on the other object.
    The example shows the Connector object managing events.


    Step 6: Connecting ANY Object
    The example has shown how to use a Connector Object to connect two unrelated objects so that they automatically work together. The next step would be to have the Connector Object work with a TextField and the property of ANY Object.


    Final Results:
    By using a Connector Object, two unrelated object can automatically work together. Just as the example showed how a TextField could work with ANY Object, any Object can be set up to work with ANY Object.




    Object Automation - Objects and Collections
    This section will describe the two Core Objects that form the cornerstone of OA.

    Basic Principle:

    All Programming in Java involves using objects.
    Either as individual objects or collections of objects.
    Each object can then have references to other objects.


    Step 1: Two Core Objects
    OAObject: Individual Object
    Hub: Object Collection
    OAObject can have references to other OAObjects, or collections of OAObjects using the collection class Hub. This allows you to create relationships like one-2-one, one-2-many, many-2-many, etc.

    Result: OAObject and the Hub can be used for any Java Programs.


    Step 2: Object Events
    OAObject has the ability to send events whenever changes occur. A Listener can then be registered and will be notified when changes happen. Instead of requiring Listeners to register with each individual object, Listeners can register with a Hub to be notified when any of the Hub's OAObjects send an event.


    Result: The Hub Collection manages the objects within it.



    Step 3: Hub Collection Events
    The Hub Collection sends events whenever any changes are made to it. These include add, insert, remove, move, and other events. A Listener can register with the Hub and be notified whenever a change is made.

    Result: Hub is an observable collection class.


    Step 4: Active Object
    There is a property in the Hub Collection that is used to mark the OAObject that has the "focus". This is similar to a cursor in a recordset. This is useful when working with a Hub Collection one object at a time.


    Result: The Hub Collection has a way of marking which object is currently active.


    Step 5: Object navigation using property names
    OA has simplified navigating through your objects by using what is called "Property Paths". By supplying an OAObject and the name or path of a Property, the value of the property can be called.

    Example: an Emp has a Dept and the Dept has a Manager. From the Emp, you can use the Property Path "dept.manager.lastName" to get the last name of Manager.


    Result: Using an OAObject or Hub, and a Property Path, OA can navigate to get to the value for the object's property.


    Step 6: Collection Relationship (Master/Detail)
    A Hub Collection (Master) can be configured to create what is called Master/Detail relationship with another Hub (Detail). The Master Hub's Active Object controls the list of objects that the Detail Hub contains. Whenever the Active Object in the Master Hub changes, the list of objects in the Detail Hub is automatically updated to show the list of objects that are related to the Active Object.

    For example: a collection of "Dept" objects, where each "Dept" object has a collection of "Emp" objects. The Detail Hub will always have the Emp Objects of the Active Dept Object.


    Result: A "Detail" Hub can be created from a "Master" Hub. This "Detail" Hub will automatically be populated with the objects from the Active Object of the "Master" Hub. The "Detail" Hub's Listeners will be notified whenever the list changes and do not need to be registered with each individual Hub.


    Step 7: Collection Relationship (Linking)
    Two Hubs can be Linked where one is the Master Hub and the other is a Link Hub. These two Hubs keep each other in sync. Each object in the Master Hub has a reference to an object in the Link Hub.

  • When the Master Hub's Active Object is changed, the object that it references in the Link Hub is automatically made the Active Object in the Link Hub.
  • When the Active Object in the Link Hub is changed, the reference of the Active Object in the Master Hub is changed to the Link Hub's Active Object.

    Example:
  • if the (A) Active Object in the Master Hub is changed to "Emp 2", the (B) Active Object in the Link Hub is changed to "Dept B", since that is the Dept for "Emp 2".
  • If the (C) Active Object in Link Hub is changed to "Dept C", the (D) Dept for the Active Object in the Master Hub will be set to "Dept C".

    Result: By linking two Hubs together, the Link Hub will stay in sync with and be able to update a property in the Master Hub.


    Step 8: Collection Relationship (Sharing)
    Hubs can be created so that it they are Shared with a Master Hub. This Shared Hub "shares" the same collection of objects that the Master Hub contains. The Shared Hub will have it's own Active Object and group of Listeners.

    Result: By setting up a Shared Hub, the same collection of objects can be used for different purposes.


    Results:
    OAObject and the Hub Collection give you the core structure to automate your programming. We have shown how objects and collections can be easily set up to handle complex relationships. We will show in the following sections how other APIs are integrated into these.





    JFC/Swing Objects - Object Aware Components for Client Application

    All OA JFC components work directly with OAObjects by using Hubs and Property Paths.

    Model/View/Control (MVC)
    MVC is a very clean and powerful way for separating the data from the view. The Java Foundation Classes are all built using these principles. With OA, OAObjects and Hub Collections act as the model/data and a connector object (described next) acts as the controller.

    Connecting OA to JFC
    OAObject and Hub Collection both are observable and have methods that can be called to access data. The JFC components have the same type of functionality. With OA JFC, we have sub classed the JFC components so that they will work (be connected) with any OAObject or Hub Collection. If a change is made to the JFC component, then the OAObject or Hub is updated. As an OAObject/Hub is changed, the JFC component is updated. OA PropertyPaths are used extensively by the OA JFC components to define the OAObject Properties that the component is to use.

    Since visual components use Strings to display and edit data, OA includes a conversion class named OAConverter that is used to convert property values to String and from a String back to the required type.

    All OA JFC Components work directly with OAObjects and Hub Collections and use a property path to "know" which property to use. All components are enabled based on the status of the OAObject or Hub that it is working with.

    OA JFC Components are set up to use a property for an image file name that is used to display an icon with the component.

    OACheckBox: JCheckBox subclass. Values for on and off can be set to any value that property type can accept.

    OAComboBox: JComboBox subclass. The selected object for ComboBox is the Active Object for the Hub that is used. To have the ComboBox update another property, then the Hub needs to be Linked to another Hub.

    OACommand: JButton subclass with built in commands. Example: new, save, delete, next, previous, etc.

    OADateChooser: popup calendar that is used to update a date property.

    OALabel: JLabel subclass used to display a property value.

    OAList: JList subclass to display list of objects.

    OAMenuItem: JMenuItem subclass with same functionality as OACommand.

    OAPasswordField: JPasswordField subclass.

    OARadioButton: JRadioButton subclass. Values for on and off can be set to any value that property type can accept.

    OATable: JTable subclass that uses OAComponent for columns that can be used as the cell editor. Allows for custom renderer.

    OATextArea: JTextArea subclass.

    OATextField: JTextField subclass.

    OATree: JTree subclass that use custom nodes that make it easy to define tree.
    OATreeTitleNode used to add a title to the tree
    OATreeNode - for root nodes, uses a Hub to populate and a property path for the display property. Nodes can be added to other nodes to form child nodes, where only the property path is needed.
    OATree makes it easy to add custom renderers and is set up to notify a listener when nodes are selected.

    OAPopup Components: used to provide popup OA JFC components.




    JSP/HTML Objects - Object Aware Components for Web Applications

    OA includes components similar to the same components used for JFC, that are used for building web pages and forms. OA allows you to build web pages that are easy to manage and require very little programming to use. All form components are able to output their own html. These objects are included in the package com.viao.html

    OA JSP includes three objects that are used for managing at different levels: System, Application, Session. All of these objects are subclasses of OABase, which allows for storing Hubs and other objects. It is also used to store messages.

    OASystem: shared by all applications on a computer system
    OAApplication: used to represent an application
    OASession: used for to represent an individual users session.

    OA JSP automates frames and framesets.

    OAFrame, OAFrameSet: automates many shortcomings and complexities with frame to frame communications. For example: a button in one frame can automatically submit any other frame that has been changed.

    OA JSP has components to automate web forms in using visual components. All forms and components will automatically work with OAObjects and Hub Collections. Forms and components automatically include JavaScript. Most of the components are similar to the OA JFC components.

    OAButtonGroup: used to manage toggle buttons, so that only one can be selected at a time.

    OACheckBox: Values for on and off can be set to any value that property type can accept.

    OAComboBox: The selected object for ComboBox is the Active Object for the Hub that is used. To have the ComboBox update another property, then the Hub needs to be Linked to another Hub.

    OACommand: button with built in commands. Example: new, save, delete, next, previous, etc.

    OAFileInput: allows uses to upload file.

    OAForm: represents an individual form, that can contain components.

    OAImage: subclass of OALink that is used with images.

    OALabel: JLabel subclass used to display a property value.

    OALink: used to submit data and execute a built-in command and/or go to a new page.

    OAList: list box

    OAMail: component used to send mail.

    OANav: navigation component used to control scrolling lists/tables, includes next & prev buttons and page location.

    OAPasswordField: used for password textfields

    OARadio: Values for on and off can be set to any value that property type can accept.

    OATextField, OATextArea: works with textfield and textarea

    OATree: similar to the OATree JFC tree.

    OAWindow: used for popup window. Works with OACommand

    OAToggleButton: group of buttons, where only one can be selected at a time.




    Datasource Objects - RDBMS/XML/Etc.

    OA includes an interface that is used for creating DataSource/Database independent applications. OAObjects and Hub Collections automatically work with any OADataSource for storing, querying, and retrieving objects without regards to the database/datasource structure. Everything is done based on Object Model structure. OADataSource is totally separated from OAObjects, making it easy to change the datasource without changing objects or the application.

    Queries
    OADataSource supports queries based on object model/structure and not on datasource structure. These queries use object property paths, instead of something like "joins". This makes queries portable between datasources.

    OASelect
    Object used for creating and executing OA Queries. It accepts a query string and returns objects. The Hub Collection "select()" methods use OASelect. To create a new OASelect, all that is required is the type of object (class) that is being used.

    How it works with OAObject


    OADataSource is created and registers with the OADataSource static object. A reference to the datasource is never needed after that. OAObject calls the static OADataSource for the following:

    • To initialize a new object
    • To assign unique identifier
    • To save object - resulting in an update or insert, depending on if the object is new or not.
    • To delete an object.
    • To validate a change to an object id. OADataSource is responsible for checking datastore to make sure id is not being used.
    • To update links to other objects. OA allows objects to have a many-to-many relationship with other objects. Some datasources will need to create a link table or similar structure to maintain this relationship.
    • OAObject methods that have references to other objects use OAObject getObject() and getHub() to get the reference objects. OADataSource supports queries that use the master object to get reference objects.
    • When two new objects have references to each other, OAObject perform an insert/update.

    No Duplicate Objects
    Different queries could result in retrieving the same object more then once. OADataSources use HubController to make sure that object is only created once, eliminating duplicate objects from being created.

    Conflicts / Dirty Data
    OADataSource uses HubController to check to see if an object exists before it is created. If it is in memory, then the datasource can check to see if the object has been modified outside of the application and then resolve changes.

    OADataSources included with OA
    Since OADataSource is an interface, it was designed to work with any datasource. This includes products like Object/Relational Mapping Tools.

    OADataSourceJDBC
    DataSource that uses JDBC to work with Relational Database. Tested databases include Access and Sql Server. Other databases include Oracle and MySql, both have been used but need additional testing. Since each vendors database product has it's various unique ways of working, this datasource is parameter driven - you define the type of database and it's capabilities.

    This datasource uses a mapping object to map database to object model. OABuilder can be used to generate Objects, Sql Script to generate database, and to create mapping object. To use this datasource in an application, all that is needed is to create a new map object, which will register and "kick-start" the database. OADataSourceJDBC supports connection pooling and has admin capabilities to monitor its activity.

    OADataSourceJDBC assigns auto numbered property id either using the Max id or by using an internal table - created by OABuilder sql script.

    All foreign key values are stored as name/value pairs in OAObject. This is then used when reference object is requested.

    OADataSourceNextNumber
    OADataSource that implements a dummy datasource. The only real functionality that it will do is to assign auto numbered id to object id properties.

    OADataSourceClient
    Used by OASync (OAClient/OAServer) to send all datasource method calls to OAServer - which could be using an OADataSourceJDBC.


    OA Utilities
    OA includes utility objects to that help automate and simplify various functionality.

    OAConverter: used to convert from String to property type and from string back to property type. Includes option for defining format string.

    OADate, OATime, OADateTime: simplifies working with dates and times. Allows for formatting string. Uses defaults used by computer that is running applications.

    OAFile: extends the functionality of File. Includes method to copy a file.

    OAString: various String conversions and formatting methods.

    OA Exceptions
    On errors, OA will throw OAExceptions. The OAException class allows listeners so that logging and error messages can be displayed to users without requiring all exceptions to be caught. OAExceptionDialog: dialog box that can be used to display error messages.




    Extending OA
    OA allows for integrating legacy and new technologies. The very design of OA, where the OA Object Model controls the application, makes it easy to work with other objects and APIs.