Hi,
I myself Kishore and I am having performance issue while running BO4.1 SDK from the legacy code as below, would you be able to help
attached Leak Suspects from Heap Dump.
Thanks,
Kishore
code:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import com.businessobjects.rebean.wi.*;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.framework.ISessionMgr;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import java.sql.Timestamp;
public class BusinessObjectsReportGenerator
{
public static void main(String[] args)
{
if (args.length < 1) {
System.out.println("Use:");
System.out.println
(" BusinessObjectsReportGenerator <username> <password> <CMS> <authentication> <filename> <Document Name> <Report[xls,pdf,xml,xlsDataCentric,csv,mhtml,html,dhtml]>");
System.exit(1);
}
new BusinessObjectsReportGenerator(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
}
public BusinessObjectsReportGenerator(String username, String password, String CMS, String authentication, String filename, String docName, String reportList)
{
IEnterpriseSession enterpriseSession = null;
OutputStream os = null;
BinaryView docView = null;
CSVView csvView= null;
HTMLView htmlView = null;
ReportEngine reportEngine = null ;
DocumentInstance doc = null;
try {
IInfoObject riverDocument = null;
System.out.println("Report " +docName + " started executing " );
ISessionMgr mySessionMgr = CrystalEnterprise.getSessionMgr();
enterpriseSession = mySessionMgr.logon(username, password, CMS, authentication);
if (enterpriseSession != null){
IInfoStore iStore = (IInfoStore)enterpriseSession.getService("InfoStore");
System.out.println("Report " +docName + " RETRIEVING INFOOBJECTS");
String reportQuery = "SELECT SI_ID, SI_NAME, SI_PARENTID FROM CI_INFOOBJECTS WHERE SI_NAME='"+docName+"' and SI_INSTANCE = 0 " ;
IInfoObjects reportObjects = iStore.query(reportQuery);
if (reportObjects.size() > 0){
riverDocument = (IInfoObject) reportObjects.get(0);
}
if (riverDocument == null) {
System.out.println("Couldn't find " + docName + " report in business objects");
System.exit(1);
}
ReportEngines reportEngines = (ReportEngines)enterpriseSession.getService("ReportEngines");
if (riverDocument.getKind().equals("Webi"))
reportEngine = reportEngines.getService
(ReportEngines.ReportEngineType.WI_REPORT_ENGINE);
else {
reportEngine = reportEngines.getService
(ReportEngines.ReportEngineType.FC_REPORT_ENGINE);
}
doc = reportEngine.openDocument(riverDocument.getID());
System.out.println("\nTimeStamp Before Doc Refresh " + new Timestamp(System.currentTimeMillis()));
doc.refresh();
System.out.println("TimeStamp After Doc Refresh " + new Timestamp(System.currentTimeMillis())+"\n");
Reports riverReports = doc.getReports();
Report riverReport = riverReports.getItem(0);
riverReport.setPaginationMode(PaginationMode.Listing);
if (reportList.contains("xls")) {
docView = (BinaryView)riverReport.getView(OutputFormatType.XLS);
os = new FileOutputStream(filename + ".xls");
docView.getContent(os);
os.flush();
os.close();
}
if (reportList.contains("xml")) {
docView = (BinaryView)riverReport.getView(OutputFormatType.XML);
os = new FileOutputStream(filename + ".xml");
docView.getContent(os);
os.flush();
os.close();
}
if (reportList.contains("pdf")) {
docView = (BinaryView)riverReport.getView(OutputFormatType.PDF);
os = new FileOutputStream(filename + ".pdf");
docView.getContent(os);
os.flush();
os.close();
}
if (reportList.contains("csv")) {
csvView = (CSVView)doc.getDataProviders().getView(OutputFormatType.CSV);
os = new FileOutputStream(filename + ".csv");
os.write(csvView.getContent().getBytes());
os.flush();
os.close();
}
if (reportList.contains("xlsDataCentric")) {
docView = (BinaryView)riverReport.getView(OutputFormatType.XLSDataCentric);
os = new FileOutputStream(filename + ".xlsDataCentric");
docView.getContent(os);
os.flush();
os.close();
}
if (reportList.contains("html")) {
htmlView = (HTMLView)riverReport.getView(OutputFormatType.DHTML); //#1
os = new FileOutputStream(filename + ".html");
os.write(htmlView.getContent().getBytes());
os.flush();
os.close();
}
if (reportList.contains("dhtml")) {
htmlView = (HTMLView)riverReport.getView(OutputFormatType.DHTML); //#1
os = new FileOutputStream(filename + ".dhtml");
os.write(htmlView.getContent().getBytes());
os.flush();
os.close();
}
if ((reportList.contains("mhtml"))) {
htmlView = (HTMLView)riverReport.getView(OutputFormatType.MHTML); //#1
os = new FileOutputStream(filename + ".mhtml");
os.write(htmlView.getContent().getBytes());
os.flush();
}
}
doc.closeDocument();
reportEngine.close();
enterpriseSession.logoff();
}
catch (IOException ioe)
{
ioe.printStackTrace();
System.out.println("Report " + docName +" IOException Error : " + ioe.getMessage());
System.exit(1);
} catch (SDKException se) {
se.printStackTrace();
System.out.println("Report " + docName + " SDKException Error : " + se.getMessage());
System.exit(1);
}
finally {
if (doc!= null)
{
try
{
doc.closeDocument();
System.out.println("Report "+ docName +" DocumentInstance Closed");
}
catch (Exception e2)
{
System.out.println(e2.getMessage());
}
}
if (reportEngine != null)
{
try
{
reportEngine.close();
System.out.println("Report " +docName +" ReportEngine Closed");
}
catch (Exception e3)
{
System.out.println(e3.getMessage());
}
}
if (enterpriseSession != null)
{
try
{
enterpriseSession.logoff();
System.out.println("Report " +docName + " EnterpriseSession Closed");
}
catch (Exception e4)
{
System.out.println(e4.getMessage());
}
}
}
}
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------