If you ever thought of parsing any of the ADF Business Components (BC) metadata XML files for the sake of extracting various metadata information, you might want to think twice. The ADF framework offers higher level APIs to do this routine job. Case in point: take a look at the
findDefObject() methods available in a number of definition classes such as
oracle.jbo.server.EntityDefImpl and
oracle.jbo.server.ViewDefImpl for example. By calling this method, the metadata is parsed and loaded for you into the corresponding
EntityDefImpl or
ViewDefImpl. Neat! Then extracting metadata information is as easy as calling the corresponding methods. For example, to get all the attributes defined for a View Object, you can call V
iewDefImpl.getAttributeDefs(). When calling
findDefObject() ensure that the location of your BC definition files is listed in the class path. Here is an example:
Example:
import oracle.jbo.AttributeDef;
import oracle.jbo.server.AttributeDefImpl;
import oracle.jbo.server.EntityDefImpl;
import oracle.jbo.server.ViewDefImpl;
public class ADFMetaDataTester {
public static void main(String[] args) {
// load EO definition from Employee.xml
EntityDefImpl eoDef = EntityDefImpl.findDefObject("Employee");
// now, you can for example get the unique keys defined by the EO
AttributeDefImpl[] uniqueKeys = eoDef.getUniqueKeys();
// load VO definition from EmployeesVO.xml
ViewDefImpl voDef = ViewDefImpl.findDefObject("EmployeesVO");
// get the VO attributes
AttributeDef[] attributes = voDef.getAttributeDefs();
}
}
Context:
ADF Business Components (BC)