TWiki> WebXEO Web>XeoPrimer>XeoPrimerJavaAPI (revision 8)EditAttach
Tags:
create new tag
, view all tags
-- PedroRio - 22 Dec 2010

XEO Java API

The XEO Java API allows direct interaction with a XEO Application (instances of Object Models and Object Model definitions). It can be used in the following situations:

  • Custom Behavior definition (for Object Model Events, Methods, Attribute Events and Attribute Logic (requirement, validation, etc...)
  • To create Schedules and Threads that perform background operations on instances of Object Models
  • Custom developing around a XEO Application (ex. Java Server Pages, Servlets, Java Server Faces)
  • Creating XEO Modules
  • Applications sharing the same J2EE server as the XEO application who want to access information in Object Model instances.

Basic Concepts

A XEO application is all about creating instances of Object Models, setting values for their attributes, processing lists of Object Model instances, handling events generated for those instances and executing methods. To be able to reach that step

Recall from the Object Behavior chapter the basics for the Java API.

A XEO application has a entry point which is an instance of the boApplication. The boApplication instance provides access to most features of the XEO Java API, however most of the the extension points (such as Object Model Behavior) are located inside classes which have direct access to some of classes which are required to use the Java API

VOLTAR AQUI QUE TEM COISAS MAL

boApplication

The boApplication class represents the point of entry in a XEO Application and has methods to reach most of the manager classes to deal with boObjects, boObjectLists, Lists of Values and Object Model definition handlers. The list of relevant methods to retrieve the classes mentioned before is the following:

Method Signature Description Return Type Note
getDefaultApplication() Retrieves the default application instance boApplication (static)
getObjectManager() Retrieves an instance of the boManagerBean to load/create object instances boManagerBean  
getObjectListManager() Retrieve an instance of ObjectListManager to create boObject lists ObjectListManager  
getLovManager() Retrieve the Lov Manager to load lov instances LovManager  
getModelDefinition(String name) Retrieve the Model definition handler for a specific model boDefHandler  
getInterfaceDefinition(String name) Retrieve the Interface definition handler for a specific model boDefInterface  
createContext(boSession session) Create an EboContext from a session EboContext  

When creating custom Java code to define behavior for a given Object Mode, as seen in the Object Behavior chapter, most of the times

boSession and EboContext

Whenever a user successfully logs into a XEO Application, a boSession instance is created to represent the user session withthin the application and it's in that boSession instance that several information regarding the user is stored. Transactional control can also be done at the context level, to read more about these classes to the boSession and EboContext pages.Read more about those classes in the boSession and EboContext API Page

boManagerLocal & boObject

The boObject represent an instance of a particular Object Model and is the most important class in XEO's Java API as it allows access to an instance's attributes and its definition.

To know more about the boObject class, read the boObject API page.

The boManagerLocal interface represents the manager of boObject instances, which allows to create and load those instance, read more in the boManagerLocal API page.

ObjectListManager & boObjectList

The ObjectListManager class allows to create instances of boObjectList which are lists of boObject (as the name implies). boObjectList instances are created by issuing BOQL (XEOQL) queries against the datasource (typically a DBMS) and its results are paginated (default value: 50 results per page). boObjectList instances are much like (paged) iterators, to know more about the API regarding check the ObjectListManager API page and the boObjectList API page.

AttributeHandler & BridgeHandler

Interactions with Object Model attributes can be done using the AttributeHandler (all but collection attributes) and BridgeHandler (collection attributes) classes. These classes allow to retrieve and set the value(s) of the attribute as well as reaching the attribute definition. Read more about AttributeHandler and BridgeHandler.

boDefHandler

The bodefHandler class is a programmatic way to have access to an Object Model definition. Read more about boDefHandler.

Relations between XEO Java Classes

To help understand the relation between the most important Java classes of the XEO API and how to have access them, see the two following figures (separated due to their size)

JavaAPI - Part1

Figure JA.1 - Relations between

JavaAPI - Part2

Figure JA.2 - Relations between Java class

aaa

Sample Workflow Code - Creating an instance, set attribute values and save the instance

The XEO Java API can be used arbitrarily to fit your needs, but to illustrate a situation where one needs to create an instance of Object Model A, set the value of two attributes (att1 and att2) and save the instance see the following code.

try{
            //Get the application instance
            boApplication app = boApplication.getDefaultApplication();
            //Login a user
            boSession session = app.boLogin("SYSUSER", "ABC");
            //Create a context
            EboContext ctx = app.createContext(session);
            //Retrieve the Object Manager
            boManagerBean objectManager = (boManagerBean) app.getObjectManager();
            //Create a new instance object for Class "A"
            boObject obj = objectManager.createObject(ctx, "A");
            //Retrieve attributes and set their value
            obj.getAttribute("att1").setValueString("my Value");
            obj.getAttribute("att2").setValueBoolean(true);
            //In the end, update the object
            obj.update();
            //Close all resources
            ctx.close();
            session.close();
        }
catch (boLoginException e) {
   //Log login error
} catch (boRuntimeException e) {
   //Write to log, or somethin
}

_

aa


Topic attachments
I Attachment Action Size Date Who Comment
PNGpng JavaAPI-Part1.png manage 39.3 K 2010-12-29 - 16:45 PedroRio XEO Java API Relations
PNGpng JavaAPI-Part2.png manage 30.9 K 2010-12-29 - 16:45 PedroRio XEO Java API Relations Part2
Edit | Attach | Print version | History: r14 | r10 < r9 < r8 < r7 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r8 - 2010-12-31 - PedroRio
 

No permission to view TWiki.WebTopBar

This site is powered by the TWiki collaboration platform Powered by Perl

No permission to view TWiki.WebBottomBar