Athena Framework
Encyclopedia
The Athena Framework is an open source application framework for Java platform. Additionally, it supports remoting to Adobe Flex
.
Since 2008, Jack Li and other developers at AthenaSource have been developing quite a number of cloud SaaS applications for their clients. Initially, they tried many popular frameworks but gave up all of them due to performance issues and painful configurations. Naturally, they started to build a new framework that supports multi-tenancy natively. This was version 1.0 of Athena Framework. This framework was released open source under the LGPL license in Mar 2011.
(ORM) framework that employs metadata as mapping configuration. It simplifies Java web application
development by removing the requirement of manual mapping and manual database schema updating. In addition to features like Java object persistence, powerful EJBQL
querying execution and comprehensive code generation
, Athena has built-in support for multi-tenancy which enables developers to build cloud applications easily. Athena can be easily integrated with other libraries like Struts or Spring to provide full stacks of service.
, attributes and relationships in database modeling for the application. Any change made on metadata reflects immediately in the database schema and domain object classes. For example, when you add a new attribute named fullName to entity Employee, a new column will be automatically inserted to the corresponding table in the database and a new field will be available in the Employee's domain class when you generate the source code.
Athena realizes true rapid application development by allowing developers to implement changes easily and quickly. Let's say, we need to change Person.fullName's type from CHAR(100) to NVARCHAR(256). For those who use traditional ORM frameworks, they need to manually change database table's column type and to update XML or Java annotation mapping configuration, and updates the UI validation code. Such steps are time-consuming and error prone. Athena comes to rescue: you only need to change the attribute type and save it on the user friendly Athena Metadata Workbench. Athena automatically update the database schema and generate updated source code. Developers' productivity gets significant boost by Athena.
SELECT e FROM Employee e [e.department:J, e.projects:S]
The relationship prefetch rules in the square brackets specify that relationship department shall be resolved through join while projects through sub-select query.
. To turn an application to multi-tenancy, you simply set the multitenancy flag in the configuration file. For example, EJBQL SELECT e FROM Employee e LEFT JOIN FETCH e.dept results the following native SQLs when multitenancy is true and false respectively:
SELECT e.employee_ID, e.fullName, e.department_ID, d.department_ID, d.nameFull FROM Employee e LEFT OUTER JOIN Department d ON e.department_ID = d.department_ID
SELECT e.employee_ID, SELECT e.employee_ID, e.ORG_ID, e.fullName, e.department_ID, d.department_ID, d.ORG_ID, d.nameFull FROM Employee e
LEFT OUTER JOIN Department d ON e.department_ID = d.department_ID AND d.ORG_ID = 1 WHERE e.ORG_ID = 1
As Athena handles multi-tenancy automatically, you can focus on implementing business logic.
Athena offers a UnitOfWork on the client side for Flex which implements the Unit of Work pattern (plays the same role as an EntityManager in JPA
context). With Athena, you can implement the CRUD scenario with code shown below:
// Client side Flex code
var uow:UnitOfWork = ...;
var depts:ArrayCollection = ...;
// Edit an dept
Department(depts.getItemAt(0)).nameFull = "New Dept Name";
// Create a new dept with a new employee
var dept:Department = Department.createNewInstance;
dept.nameFull = "R & D";
var emp:Employee = Employee.createNewInstance;
emp.firstName = "Alan";
emp.lastName = "Turing";
emp.department = dept;
depts.addItem(dept);
// Persists all changes in one shot
eoService.invokeService("persistenceService", "save", [depts], onSaveSuccess, onSaveError, null);
A Unit of Work keeps track of everything you do during a business transaction that can affect the database. org.athenasource.framework.eo.core.UnitOfWork is Athena's implementation of the Unit of Work pattern. UnitOfWork ensures uniqueness of EOObject. Each database record results maximum one enterprise object in a UnitOfWork.
By default, enterprise objects (instances of entity classes) returned from the server are being put into a UnitOfWork. If no UnitOfWork is specified when you make the remote call, a new instance of UnitOfWork is created for the enterprise objects returned. If the same database record is loaded again to a UnitOfWork, the existing corresponding enterprise object will be returned instead of creating a new object. Existing enterprise objects will updated if they are outdated (version lower than db). A partial enterprise object will be updated with full properties when a complete loading is performed.
var uow:UnitOfWork = new UnitOfWork("myuow");
var ejbql:String = SELECT e FROM Employee e [e.department:S]{po_e='employee_ID, firstName, lastName, department_ID'}";
eoService.invokeService("empService", "executeQuery", [ejbql],
onQuerySuccess, onQueryError, uow); // returned objects will be merged into the specified unit of work.
eoService.invokeService("empService", "executeQuery", ["SELECT e FROM Employee e WHERE e.employee_ID = " +
selectedEmp.employee_ID], onLoadFullEmpSuccess, null, uow); // specifies the same unit of work.
Once the remote call returns, a full Employee object is returned and merged into the existing UnitOfWork. Once all the properties are available, the user can see the full details of the employee.
Adobe Flex
Adobe Flex is a software development kit released by Adobe Systems for the development and deployment of cross-platform rich Internet applications based on the Adobe Flash platform...
.
Since 2008, Jack Li and other developers at AthenaSource have been developing quite a number of cloud SaaS applications for their clients. Initially, they tried many popular frameworks but gave up all of them due to performance issues and painful configurations. Naturally, they started to build a new framework that supports multi-tenancy natively. This was version 1.0 of Athena Framework. This framework was released open source under the LGPL license in Mar 2011.
Athena Framework for Java
Athena Framework is an enterprise object-relational mappingObject-relational mapping
Object-relational mapping in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language...
(ORM) framework that employs metadata as mapping configuration. It simplifies Java web application
Web application
A web application is an application that is accessed over a network such as the Internet or an intranet. The term may also mean a computer software application that is coded in a browser-supported language and reliant on a common web browser to render the application executable.Web applications are...
development by removing the requirement of manual mapping and manual database schema updating. In addition to features like Java object persistence, powerful EJBQL
EJB QL
EJB QL or EJB-QL is a portable database query language for Enterprise Java Beans. It was used in Java EE applications. Compared to SQL, however, it is less complex but less powerful as well.-History:...
querying execution and comprehensive code generation
Code generation
In computer science, code generation is the process by which a compiler's code generator converts some intermediate representation of source code into a form that can be readily executed by a machine ....
, Athena has built-in support for multi-tenancy which enables developers to build cloud applications easily. Athena can be easily integrated with other libraries like Struts or Spring to provide full stacks of service.
Metadata as the Single Source of Truth
In Athena, metadata refers to the collection of all entitiesEntity-relationship model
In software engineering, an entity-relationship model is an abstract and conceptual representation of data. Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database, and its requirements...
, attributes and relationships in database modeling for the application. Any change made on metadata reflects immediately in the database schema and domain object classes. For example, when you add a new attribute named fullName to entity Employee, a new column will be automatically inserted to the corresponding table in the database and a new field will be available in the Employee's domain class when you generate the source code.
Athena realizes true rapid application development by allowing developers to implement changes easily and quickly. Let's say, we need to change Person.fullName's type from CHAR(100) to NVARCHAR(256). For those who use traditional ORM frameworks, they need to manually change database table's column type and to update XML or Java annotation mapping configuration, and updates the UI validation code. Such steps are time-consuming and error prone. Athena comes to rescue: you only need to change the attribute type and save it on the user friendly Athena Metadata Workbench. Athena automatically update the database schema and generate updated source code. Developers' productivity gets significant boost by Athena.
Fine Grained Control of EJBQL Querying
When performing EJBQL queries in Athena, you do not need to guess which relationships will be loaded and which will not be loaded. Instead, you can specify explicitly which relationships will be loaded and how they should be loaded. For example, the query below selects Employees with relationships of department and projects:SELECT e FROM Employee e [e.department:J, e.projects:S]
The relationship prefetch rules in the square brackets specify that relationship department shall be resolved through join while projects through sub-select query.
Developing Multi-Tenancy Cloud SaaS Applications With Athena
A multi-tenancy application enable a single instance of the software runs on a server, serving multiple client organizations (tenants). Athena allows you to easily develop shared schema multi-tenancy applications like salesforce.comSalesforce.com
Salesforce.com is an enterprise cloud computing company headquartered in San Francisco that distributes business software on a subscription basis. Salesforce.com hosts the applications off-site...
. To turn an application to multi-tenancy, you simply set the multitenancy flag in the configuration file. For example, EJBQL SELECT e FROM Employee e LEFT JOIN FETCH e.dept results the following native SQLs when multitenancy is true and false respectively:
SELECT e.employee_ID, e.fullName, e.department_ID, d.department_ID, d.nameFull FROM Employee e LEFT OUTER JOIN Department d ON e.department_ID = d.department_ID
SELECT e.employee_ID, SELECT e.employee_ID, e.ORG_ID, e.fullName, e.department_ID, d.department_ID, d.ORG_ID, d.nameFull FROM Employee e
LEFT OUTER JOIN Department d ON e.department_ID = d.department_ID AND d.ORG_ID = 1 WHERE e.ORG_ID = 1
As Athena handles multi-tenancy automatically, you can focus on implementing business logic.
Athena Framework for Flex
Athena Framework is a full fledged enterprise object-relational mapping (ORM) framework that employs metadata as mapping configuration. It simplifies Flex/Flash RIA application development by providing transparent object remoting - i.e., you can manipulate objects on the client side using Flex just like on the server side using ActionScript thanks to the unified object model provided by Athena.Manipulating Objects on the Client Side
For many rich Internet applications, objects needs to be loaded and manipulated on the client side. Consider a very common CRUD scenario: the UI loads and displays a list of Departments objects and let the user view employees under a selected department, create and edit Department/Employees; once the user finishes the editing, he or she clicks a button to save the changes. Without a decent object manager on the client side, such kind of operation is hard to implement.Athena offers a UnitOfWork on the client side for Flex which implements the Unit of Work pattern (plays the same role as an EntityManager in JPA
Java Persistence API
The Java Persistence API, sometimes referred to as JPA, is a Java programming language framework managing relational data in applications using Java Platform, Standard Edition and Java Platform, Enterprise Edition....
context). With Athena, you can implement the CRUD scenario with code shown below:
// Client side Flex code
var uow:UnitOfWork = ...;
var depts:ArrayCollection = ...;
// Edit an dept
Department(depts.getItemAt(0)).nameFull = "New Dept Name";
// Create a new dept with a new employee
var dept:Department = Department.createNewInstance;
dept.nameFull = "R & D";
var emp:Employee = Employee.createNewInstance;
emp.firstName = "Alan";
emp.lastName = "Turing";
emp.department = dept;
depts.addItem(dept);
// Persists all changes in one shot
eoService.invokeService("persistenceService", "save", [depts], onSaveSuccess, onSaveError, null);
Partial Object Loading
Partial objects are objects with only some of their properties loaded. For example, we only need to load the name and other essential properties of the Employee class if we want to display a list of employees on the UI. Only the when user clicks on a certain Employee object, we then fully load the selected object. Partial object loading significantly reduces CPU, memory and network usage. Before diving into the details, you need to understand how unit of work works.A Unit of Work keeps track of everything you do during a business transaction that can affect the database. org.athenasource.framework.eo.core.UnitOfWork is Athena's implementation of the Unit of Work pattern. UnitOfWork ensures uniqueness of EOObject. Each database record results maximum one enterprise object in a UnitOfWork.
By default, enterprise objects (instances of entity classes) returned from the server are being put into a UnitOfWork. If no UnitOfWork is specified when you make the remote call, a new instance of UnitOfWork is created for the enterprise objects returned. If the same database record is loaded again to a UnitOfWork, the existing corresponding enterprise object will be returned instead of creating a new object. Existing enterprise objects will updated if they are outdated (version lower than db). A partial enterprise object will be updated with full properties when a complete loading is performed.
Partial Object Loading Through EJBQL
To load partial objects, you simple execute EJBQLs with the special po_ attribute loading properties. For example,var uow:UnitOfWork = new UnitOfWork("myuow");
var ejbql:String = SELECT e FROM Employee e [e.department:S]{po_e='employee_ID, firstName, lastName, department_ID'}";
eoService.invokeService("empService", "executeQuery", [ejbql],
onQuerySuccess, onQueryError, uow); // returned objects will be merged into the specified unit of work.
Loading Full Object
If the user selects an employee to view the details, we need to load the full properties of the object:eoService.invokeService("empService", "executeQuery", ["SELECT e FROM Employee e WHERE e.employee_ID = " +
selectedEmp.employee_ID], onLoadFullEmpSuccess, null, uow); // specifies the same unit of work.
Once the remote call returns, a full Employee object is returned and merged into the existing UnitOfWork. Once all the properties are available, the user can see the full details of the employee.