--
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,
Whenever a user successfully a
boObject
aaa
boObjectList
aaa
ssss
boDefHandler
aaaa
___
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)
Figure JA.1 - Relations between
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