Object Integration FrameworkThis document describes the basic architecture and usage of the JLense Object Integration Framework. It also demonstrates how the JLedger GUI uses the JLense Object Integration Framework to access and change objects provided by the JLedger engine. IntroductionThe Object Integration Framework...
The Object Integration Framework consists of two APIs:
In addition, the org.jlense.zone plugin also defines extention points for registering connection factories. What Does the Object Integration Client API Do?In simplest terms, the Object Integration Client API makes it possible to do three things:
This list of capabilities is really no different than what is normally provided by a traditional object-oriented storage mechanism, like an ODMG-compliant object database or an object-relational mapping tool like TopLink. What makes the Object Integration Client API different is:
ConceptsZone ArchitectureThe basic purpose of the JLense Application Framework core is to provide an environment in which applications may be assembled from plugins. In order to achieve this vision is is necessary to provide a framework in which plugins may share thier data and services without being tightly coupled to each other. For instance, one plugin may be responsible for creating and managing Account objects while another plugin may be responsible for creating a user interface for manipulating Account objects. The plugin that creates a user interface for manipulating Account objects should be reusable in any application that shares the same notion of what an Account object is, regardless of how Account objects are actually implemented, persisted, or transmitted. The Object Integration Framework helps us do that. Conceptually, data clients and data providers are integrated together into an Object Integration Zone. An object integration zone is a central hub where clients and providers can hook up with each other. The JLense Application Framework serves as this hub where data clients and data providers meet.
The concept of a is central to the Object Integration Framework and the word "Zone" is used frequently in the interface names in the Object Integration Framework package. For instance there is ZoneConnection which conveys the idea of connecting to an object zone where many objects of different types are being served up by object providers. Data ModelThe data/objects that can be exchanged via the Object Integration Framework are defined as Java interfaces. Object clients query for instance of these interfaces and can set and get objects properties using methods defined by the object interfaces. ExampleThe following code fragment gives a simple example of these five steps:
/* Get a connection, select all accounts and add an 'X' to the end of all thier names. */ ZoneConnection connection= ZoneConnections.getZoneConnection("org.jledger", new Properties()); Properties queryProperties= new Properties(); queryProperties.put(ZoneConstants.PROP_QUERY_TYPE, ZoneConstants.QUERY_TYPE_OQL); ZoneQuery query= connection.createQuery(queryProperties); query.create("select a from org.jledger.model.IAccount"); Collection allAccounts= connection.getCollectionByQuery(query); connection.beginTransaction(); for (Iterator i= allAcounts.iterator(); i.hasNext(); ) { IAccount account= (IAccount)i.next(); System.out.println("Account Selected:" + account.getName()); account.setName(account.getName()+'X'); connection.store(account); } connection.commitTransaction(); /* listen for new accounts */ ZoneListener listener= new ZoneNotificationListener { public void onNotificationMessage(ZoneEvent e) { if (e.getAction().equals(ZoneConstants.ACTION_ADD)) { IAccount account= (IAccount)e.getValue(); System.out.println("Account Added:" + account.getName()); } } }; connection.addZoneListener("org.jledger.model.IAccount", listener); /* invoke a remote service call to create an entire chart of accounts */ query.create("call org.jledger.model.IChartOfAccounts.createChartOfAccounts($1)"); query.bind(IChartOfAccount.DEFAULT_CHART_FOR_SERVICE_PROVIDERS); IChartOfAccounts chart= (IChartOfAccounts)connection.getObjectByQuery(query); |