Sunday, 7 May 2017

ADF Applicaiton Module

Application Module:
The interface for Application Modules. An Application Module is a logical container for coordinated objects related to a particular task with optional programming logic.

Root Application Module and Nested Application Module:
An Application Module may be a root Application Module or a nested Application Module.
A root Application Module is not contained in another Application Module. It provides transaction context for all objects contained in it. It may optionally contain nested Application Modules. A root Application Module is created through JDNI calls.

A nested Application Module is contained in another Application Module. The containing Application Module is referred to as the parent Application Module. If one traverses this containership ancestry, one will eventually find the root Application Module (which does not have a parent Application Module). A nested Application Module uses the transaction context provided by the root Application Module. Thus, data modifications performed in Application Modules parented by one root Application Module will commit or rollback together.

Transaction:
Associated with the root Application Module is the Transaction object, which provides this transaction context. From any (root or nested) Application Module, the user can retrieve the transaction object through a call to getTransaction(). In reality, getTransaction() first locates the root Application Module and then returns the transaction object from it.

The Transaction object manages connection to database and Entity caches. Thus, changes made through one View Object are visible to other View Objects as long as these View Objects all parented by the one root Application Module. In contrast, if two View Objects are parented by two separate root Application Modules, then changes made through the View Object will not be seen by the second View Object until the changes are committed to database through the first root Application Module and the second VO executes query (to retrieve the most up-to-date data from database).

Creating Application Module
A root Application Module is created by:

Finding the Application Module home through JNDI.
Calling create() on the Application Module home.
Here is a sample code to create a root Application Module:

    java.util.Hashtable env = new java.util.Hashtable();

    // Add environment entries into env...

    javax.naming.Context ic = new InitialContext(env);

    // 'defName' is the JNDI name for the Application Module
    // definition from which the root Application Module is to
    // be created
    String defName = ...;

    oracle.jbo.ApplicationModuleHome home = ic.lookup(defName);
    oracle.jbo.ApplicationModule am = home.create();

One creates a nested Application Module by calling createApplicationModule on the parent Application Module.

Application Module definitions are managed by oracle.jbo.server.MetaObjectManager. One can find a specific definition object by issuing:

    String defName = ...;
    oracle.jbo.server.ApplicationModuleDefImpl def;

    def = oracle.jbo.server.ApplicationModuleDefImpl.findDefObject(defName);


Client applications connect to databases and manage transactions by using the oracle.jbo.Transaction interface. Some useful methods of the Transaction interface with regard to Application Modules are:

  • commit - Commit the transaction; saves all changes to the database. If the database connection is established, the transaction is implicitly started.
  • connect - Attempt to establish a connection to the given database URL.
  • disconnect - Disconnect the server from the database.
  • getLockingMode - Get the preferred locking mode for this transaction. Currently the locking mode defaults to LOCK_PESSIMISTIC.
  • rollback - Rollback the transaction; discard all changes.
  • setLockingMode - Set the preferred locking mode for this transaction. Changing the locking mode affects only subsequent locks that are placed.
 The following code example shows how an Application Module provides a context for transactions. The code assumes that an Application Module represented by the variable appMod has been declared and initialized elsewhere, and the transaction is started using the connect() method. It also assumes that a method named updateAttr has been implemented to update a row of a View Object vo with the value newAttrVal. If updateAttr succeeds (returns true), the code commits the transaction; otherwise, it rolls the transaction back.
// Assume that appMod has been declared and initialized elsewhere.
try {
  if (updateAttr(vo, newAttrVal)) {
    // Commit changes to the database, making
    // updated data available to other Application Modules.
    appMod.getTransaction().commit();
    System.out.println("\n Transaction committed. \n");
  }
  else {
    appMod.getTransaction().rollback();
    System.out.println("\n Transaction rolled back. \n");
  }
} catch (Exception e) {
  e.printStackTrace();
}
 
Entity Objects are not directly exposed to the client tier. Instead, 
clients access an Entity Object's data through a View Object in an 
Application Module. All View Objects within the transaction share the 
same Entity Object caches. View Objects and Entity Objects communicate 
via events and/or Java calls (not by using remote interface proxies).
 
A View Object, expressed as a query on top of underlying Entity Objects,
 shapes the result set for presentation. Because data is cached at the 
Entity Object level and all View Object references within the same 
transaction share the Entity Objects, changes made through one View 
Object are immediately available through other View Objects in the same 
transaction.

The following code example shows the interaction between Application 
Modules, View Objects, and the database as values are changed, posted, 
and committed.
 
package amdemo;
import oracle.jbo.*;
import java.util.Hashtable;
import javax.naming.*;
public class TestAm {
  public static void main(String[] args) {
    final String amName1 = "am1.AppMod1";
    final String amName2 = "am2.AppMod2";
    final String voName1 = "am1.DeptView1";
    final String voName2 = "am1.DeptView2";
    final String voName3 = "am2.DeptView3";
    final String voName4 = "am2.DeptView4";
    final String connStr = "jdbc:oracle:thin:scott/tiger@jtora815:1521:ORCL";
    // Set environment for local deployment.
    Hashtable env = new Hashtable(2);
    env.put(Context.INITIAL_CONTEXT_FACTORY, JboContext.JBO_CONTEXT_FACTORY);
    env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
    ApplicationModule appMod1 = null;
    ApplicationModule appMod2 = null;
    try {
      javax.naming.Context ic = new InitialContext(env);
      ApplicationModuleHome home1 =
        (ApplicationModuleHome)ic.lookup(amName1);
      appMod1 = home1.create();
      appMod1.getTransaction().connect(connStr);
      ApplicationModuleHome home2 =
        (ApplicationModuleHome)ic.lookup(amName2);
      appMod2 = home2.create();
      appMod2.getTransaction().connect(connStr);
    } catch(Exception e){
      e.printStackTrace();
    }
    ViewObject vo1 = appMod1.createViewObject("vo1", voName1);
    ViewObject vo2 = appMod1.createViewObject("vo2", voName2);
    ViewObject vo3 = appMod2.createViewObject("vo3", voName3);
    //ViewObject vo4 = appMod2.createViewObject("vo4", voName4);
    Row r1 = vo1.first();
    r1.setAttribute("Loc", "asdf");
    System.out.println("vo1 before AppMod1 post " + r1.getAttribute("Loc"));
    Row r2 = vo2.first();
    System.out.println("vo2 before AppMod1 post " + r2.getAttribute("Loc"));
    vo3.executeQuery();
    Row r3 = vo3.first();
    System.out.println("vo3 before AppMod1 post " + r3.getAttribute("Loc"));
    //Row r4 = vo4.first();
    //System.out.println("vo4 before AppMod1 post " + r4.getAttribute("Loc"));
    appMod1.getTransaction().postChanges();
    System.out.println("vo1 after AppMod1 post " + r1.getAttribute("Loc"));
    r2 = vo2.first();
    System.out.println("vo2 after AppMod1 post " + r2.getAttribute("Loc"));
    r3 = vo3.first();
    System.out.println("vo3 after AppMod1 post " + r3.getAttribute("Loc"));
    //r4 = vo4.first();
    //System.out.println("vo4 after AppMod1 post " + r4.getAttribute("Loc"));
  try {
    appMod1.getTransaction().commit();
    System.out.println("Commit succeeded.");
  } catch (oracle.jbo.JboException e) {
    System.out.println("Commit failed. " + e);
  }
    System.out.println("vo1 after AppMod1 commit " + r1.getAttribute("Loc"));
    r2 = vo2.first();
    System.out.println("vo2 after AppMod1 commit " + r2.getAttribute("Loc"));
    vo3.executeQuery();
    r3 = vo3.first();
    System.out.println("vo3 after AppMod1 commit " + r3.getAttribute("Loc"));
    //r4 = vo4.first();
    //System.out.println("vo4 after AppMod1 commit " + r4.getAttribute("Loc"));
    // Keep the console window open so you can see what happened.
    System.out.println("\n Press Enter to close this window.");
    try { System.in.read(); } catch (Exception e) {}
  }
}
 
http://myexpwithoracleadf.blogspot.in/2013/04/oracle-adf-application-module-basics.html?view=sidebar

http://myexpwithoracleadf.blogspot.in/2013/04/oracle-adf-manage-transaction-using.html

Wednesday, 3 May 2017

AM Pooling

Application Module Responsibilities
  • Manage transaction against a data source
  • Manage session's state
Root vs Nested vs Shared AMs
  • Root AM
    • Created for each user session
    • Stored in the pool
    • Handles transactions, connections, state
  • Nested AM
    • A logical construct only for grouping VOs
    • Are themselves nested under a root AM
    • Delegates all responsibilities to the root AM
    • reference to a nested AM in the pool is really reference to it's parent
  • Shared AM
    • They are shared across all user sessions
Settings
  • AppModule(AppModule.xml) -> Configurations -> 
    • The settings are stored in bc4j.xcfg 
  • Common Passivation Mistakes
  • Variables in AppModuleImpl & ViewObjectImpl
    • Override passivateState() and activateState()
  • ADF BC VO transient attributes to be passivated if needed.
Application Module lifecycle
  • AM statuses are Available, Unavailable or referenced
    • Available - Ready for use
    • Unavailable - Processing, currently checked out to a servlet thread
    • Referenced - Processing complete, Checked into pool, Pinned for session future request
  • Available - All AMs are initially marked available for use in the pool when instantiated
  • Unavailable - Upon new request any available AM will be "checked out" for a servlet thread
  •  

Passivation
  • Offloads AM state to a persistent store -  maintained in table ps_txn in XML format
    • Transactional data - new, modified and deleted entities
    • Non-Transactional data 
      • Current row indicator
      • new rows and their position
      • View Criteria and parameters
      • Flag indicating whether the rowset had been executed 
      • Range start and size
      • Access mode
      • Fetch mode and size
      • Any view object custom data
      • Transient view object attributes if configured
      • Select, from, where and order by clauses if created dynamically
    • Doesn't passivate
      • Query rows - They are passivated only if modified, deleted or new row created
      •  
  • Alternate reasons for Passivation
    • Fail over support
    • Or jbo.ampool.doampooling=false
      • For testing passivation by eagerly turning it on
    • Or jbo.doconnectionpooling=true & jbo.txt.disconnect_level=0(but not 1)
 
Cleaning the Applicaiton Module pool

Passivation Mistakes
  • Using member variables in AppModuleImpl or ViewObjectImpl
    • Adf bc doesn't automatically passivate above member variables by default
    • One need to override passivateState() & activateState() to ensure they are read and written
  • View Object Transient attributes
    • Explictly set VO transient attributes to be passivated if needed

Saturday, 18 February 2017

BI Publisher

BI Publisher - It is part of the middleware reporting stack in the family of Oracle Business Intelligence tools and is used as reporting solution.

It can be used for:
  • generate highly formated documents
  • electronic funds transfer documents
  • government pds forms
  • shipping labels, checks, sales and marketing letters and much more.
BIP is integrated with Oracle Business Intelligence, and is also available for use as standalone tool or integrated with e-business suite or people soft.

Installation: http://www.oracle.com/technetwork/middleware/bi-ublisher/downloads/index.html
  • Install Oracle database 12c
    • Choose 'character set' to Unicode during installation.  
    • Uncheck 'create as container database'
  • Install (database) instant client software
    • Create folder 'InstantClient'
    • extract the downloaded files to the 'InstantClient' folder
      • instantclient-basic & instantclient-odbc
    • Modify env variables
      • Modify path variable to add location of 'InstantClient'  eg: c:\InstantClient\instantclient_12_1
      •  Add new system variable TNS_ADMIN and set the value  to location of Instant client.
    • Run setup for ODBC Install
      • run odbc_install file in 'InstantClient' location as Administrator
    • restart the system 
    • Copy 'listner.ora' & 'tnsnames.ora' files from <DB_HOME>/Network/Admin to 'InstantClient' directory and change the Oracle_Home(until parent of BIN directory) & .DLL patch and file name appropriately  in listener.ora
    • Also ensure tnsnames.ora has entry for new db
  • Install repository creation utility software(Downloads->Middleware-> Business Intelligence Suite EE-> Oracle Business Intelligence (11g) downloads -> all supported platforms ->RCU
    • give 'Sys' as Username & 'SYSDBA' as role
    • Select Oracle Business Intelligence as Component 
  • Install Oracle Business Intelligence publisher 11g
    •  select 'skip software updates' 
    • simple install
    • uncheck 'Business Intelligence Enterprise Edition' & 'Real-time decisions'
How to start BI publisher 11g on windows 
  • c:\Middleware\user_projects\domains\bifoundation_domain\bin\startWeblogic.cmd
  • login/Open em(enterprise manager) from browser using weblogic user  <host:7001>/em
    • bipublisher server  -> Application deployment -> control -> startup
  • login/open bipublisher <host:7001>/xmlpserver using weblogic user
  • login/open console <host:7001>/console using weblogic user
    • Deployments -> verify if bipublisher health is OK & start it
How to stop BI publisher 11g on windows
  • Method1: stopWeblogic.cmd from bin directory
  • Method2: Enterprise manager -> Business Intelligence -> core application -> Availability -> processes -> stop all
BI Publisher User Interface
  • Login to <host:7001>/xmlpserver (Eg: admin)
  • Create a New folder in catalog
    • Click catalog from global header -> My Folders -> New folder(use this to save files, reports and other objects)
  • Upload resource to catalog(xdmz file which is a datamodel file). We upload datamodel, template or report here
  • Configuring Data Source
    • Click Administration link in global header -> Data Sources-> JDBC connection -> add data source
  • Creating a data model
    • Global header -> new -> data model-> Dataset -> Create
      • select type as SQL and provide SQL
      • Update Alias
      • Conditions using bind variables
      • See the results

    • Properties - xml output options -> select/check Include parameter tags
    • Dataset-> new dataset  of type sql query -> provide name & 
  • Create BIP Report
    • It is made of data model, layout, properties, and translation(optional). 
    • New Report -> Use existing Data model -> select  the created datamodel -> save it
    • Select a Layout -> Edit layout -> save it
    • To view the create report-> navigate to reports -> The report shows the datamodel & associated layouts -> View Report
    • Click Parameter button/link on Report editor 
  • Report Job
    • New -> Report Job-> Select the report -> Scheduling ->  This has following tabs
      • General
      • Output
      • Schedule
      • Notification
  • Manage Reports Job
    • To delete/pause/resume/edit Report Jobs
OBIEE
Dashboard
analysis
filters
    Created in Answers dashboard -> Criteria tab
answers
    Tool to modify existing components as well as to create new components line analysis, dashboards, filters.


Subject areas