You can display statistics related to your Application Module Pools by calling dumpPoolStatistics() on a oracle.jbo.common.ampool.ApplicationPool object. You can acquire an ApplicationPool object by calling getResourcePool() on a oracle.jbo.common.ampool.PoolMgr object and specifying the name of the application module pool name. So, how do you get a PoolMgr object? Just call the static PoolMgr.getInstance(). Finally, you can get the pool name by calling getResourcePoolKeys() on the PoolMgr and enumerating the pools managed by the pool manager. Here is an example:
Example:
// helper to dump pool statistics to log
private void dumpAMPoolStatistics() {
// get the pool manager
PoolMgr poolMgr = PoolMgr.getInstance();
// get the pools managed
Enumeration keys = poolMgr.getResourcePoolKeys();
if (keys != null) {
if (keys.hasMoreElements()) {
// may manage many pools, we will get the name of first one managed
String poolname = (String)keys.nextElement();
System.out.println("AM pool name: " + poolname);
// get the AM pool
ApplicationPool pool =
(ApplicationPool)poolMgr.getResourcePool(poolname);
// log AM pool diagnostics
PrintWriter out = new PrintWriter(System.out, true);
pool.dumpPoolStatistics(new PrintWriter(out));
out.flush();
}
}
}
The helper function above, when added to your application module will display - upon calling it, the AM statistics in the log window as it is shown below.
Context:
BC Implementation Class
References:
83. Dump Application Module Pooling Statistics Servlet
Bits of code related to Oracle's Application Development Framework (ADF). Some of the posts in this blog may seem elementary. They are. Nevertheless, you will be amazed to find out how many beginner ADF practitioners are struggling with basic concepts and sample code. Hopefully they will find some here.
Showing posts with label Application Module. Show all posts
Showing posts with label Application Module. Show all posts
Thursday, November 18, 2010
Saturday, June 26, 2010
Bit #21 - Overriding prepareSession() to do session-specific initializations
You can override prepareSession() in your custom Application Module class to do session-specific initializations, such as invoking a stored procedure to initialize the database state for the specific user, store user information, set application-wide configuration parameters based on the user and so on. The framework invokes prepareSession() when the Application Module is first checked-out from the Application Module pool for a new user session.
Example:
@Override
protected void prepareSession(Session session) {
super.prepareSession(session);
// do session-specific initializations
}
Context:
Application Module Implementation Class
Example:
@Override
protected void prepareSession(Session session) {
super.prepareSession(session);
// do session-specific initializations
}
Context:
Application Module Implementation Class
Wednesday, June 23, 2010
Bit #20 - Overriding beforeCommit() to execute custom code before commit
Override the Application Module beforeCommit() method in your custom Application Module implementation class to execute any custom code that depends on data already posted to the database. Such code may include - but not limited to - validations done in the database via a stored procedure for example. The framework calls this method after doDML() which means that posted data are available but not yet committed.
Example:
// in your Application Module Implementation class
@Override
public void beforeCommit(TransactionEvent transactionEvent) {
// call some stored procedure here
super.beforeCommit(transactionEvent);
}
Context:
Application Module Implementation Class
Example:
// in your Application Module Implementation class
@Override
public void beforeCommit(TransactionEvent transactionEvent) {
// call some stored procedure here
super.beforeCommit(transactionEvent);
}
Context:
Application Module Implementation Class
Tuesday, May 4, 2010
Bit #16 - Removing a row from a query collection without deleting it from the database
There are times when you want to remove a row from a query collection (the query result) without actually removing it from the database. The query collection - oracle.jbo.server.QueryCollection - gets popullated each time the View is executed - when the View's associated query is run, and represents the query result. While the Row.remove() will remove the query collection row it will also remove the underlying Entity row - for an Entity-based View - and post a deletion to the database. If your programming task requires that the row is removed from the query collection only, i.e. removing a table row in the UI without actually posting a delete to the database, use the Row method removeFromCollection() instead. Just be aware that each time the View is re-executed the Row will show up once again!
Example:
// in the context of the ApplModuleImpl
// remove the current row from the query collection
EmployeesRowImpl employee = (EmployeesRowImpl)(this.getEmployees().getCurrentRow());
employee.removeFromCollection();
// the employee row has been removed from the result set and cannot be used anymore
Context:
Application Module Implementation Class
View Object Implementation Class
Example:
// in the context of the ApplModuleImpl
// remove the current row from the query collection
EmployeesRowImpl employee = (EmployeesRowImpl)(this.getEmployees().getCurrentRow());
employee.removeFromCollection();
// the employee row has been removed from the result set and cannot be used anymore
Context:
Application Module Implementation Class
View Object Implementation Class
Sunday, May 2, 2010
Bit #15 - Using a Key to locate a Row in a View Object, Pt. 2
Instead of using the findByKey() method to locate a number of rows in the View Object identified by a Key attribute - explained in Bit #14 - Using a Key to locate a Row in a View Object, you can use the View Object getRow() method supplying the Key as an argument. This method will return the Row identified by the Key supplied as an argument to it. An example follows.
Example:
// in the context of the ApplModuleImpl
// locate the employee's department
Number departmentId =
((EmployeesRowImpl)(this.getEmployees().getCurrentRow())).getDepartmentId();
Key keyDepartment = new Key(new Object[] { departmentId });
// get the department based on the department identifier
DepartmentsRowImpl department =
(DepartmentsRowImpl)this.getDepartments().getRow(keyDepartment);
if (department != null) {
// you can access the Department's attributes here....
}
Context:
Application Module Implementation Class
View Object Implementation Class
Example:
// in the context of the ApplModuleImpl
// locate the employee's department
Number departmentId =
((EmployeesRowImpl)(this.getEmployees().getCurrentRow())).getDepartmentId();
Key keyDepartment = new Key(new Object[] { departmentId });
// get the department based on the department identifier
DepartmentsRowImpl department =
(DepartmentsRowImpl)this.getDepartments().getRow(keyDepartment);
if (department != null) {
// you can access the Department's attributes here....
}
Context:
Application Module Implementation Class
View Object Implementation Class
Wednesday, April 21, 2010
Bit #14 - Using a Key to locate a Row in a View Object
Instead of iterating a View Object using a RowSetIterator - as described in Bit #4 - Iterating a View Object using a secondary RowSetIterator, you can locate a row directly using the ViewObject method findByKey(). This will work as long as you indicate a View Object attribute as a Key Attribute. To use this method, you will need to first instantiate a jbo.Key object and then pass it as an argument to findByKey(). findByKey() will return an array of rows that match the Key object. Special attention should be given when constructing Key objects for multi-part keys and for View Objects that are based on more than one Entity Objects. These cases are explained in detail in the Oracle Fusion Middleware Java API Reference for Oracle ADF Model documentation referenced below.
Example:
// in the context of the ApplModuleImpl
// locate the employee's department
Number departmentId =
((EmployeesRowImpl)(this.getEmployees().getCurrentRow())).getDepartmentId();
Key keyDepartment = new Key(new Object[] { departmentId });
// the second argument indicates the maximum number of rows to return
Row[] departments = this.getDepartments().findByKey(keyDepartment, 1);
if (departments != null && departments.length > 0) {
DepartmentsRowImpl department = (DepartmentsRowImpl)departments[0];
// you can access the Department's attributes here....
}
Reference:
Oracle Fusion Middleware Java API Reference for Oracle ADF Model, findByKey
Example:
// in the context of the ApplModuleImpl
// locate the employee's department
Number departmentId =
((EmployeesRowImpl)(this.getEmployees().getCurrentRow())).getDepartmentId();
Key keyDepartment = new Key(new Object[] { departmentId });
// the second argument indicates the maximum number of rows to return
Row[] departments = this.getDepartments().findByKey(keyDepartment, 1);
if (departments != null && departments.length > 0) {
DepartmentsRowImpl department = (DepartmentsRowImpl)departments[0];
// you can access the Department's attributes here....
}
Context:
Application Module Implementation Class
View Object Implementation Class
Oracle Fusion Middleware Java API Reference for Oracle ADF Model, findByKey
Subscribe to:
Posts (Atom)