Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Integration of BIRT into a C++ application
ak-tec
Hello,
i call from a c++ application a simple java application which renders a birt report from a design file. Everything works fine. I have figured out that in the java app the "Platform.startup" and the "Platform.shutdown()" calls takes the most time. Unfortunately I start the BIRT Platform for every report which costs too much time. Every report will be created by a user button click in my C++ application, which means that every button click starts the BIRT Platform in my java app.
How can I start the Birt Platform only once and use the already started Platform for every following request from my c++ application? I dont want to use a report server. Any Ideas?
I can call my java application from c++ with JNI or with an external java application call.
Find more posts tagged with
Comments
JasonW
Wrap your call to the birt engine in a singelton much like described for a webapp here:<br />
<a class='bbc_url' href='
http://wiki.eclipse.org/Servlet_Example_(BIRT)_2.1'>Servlet
Example (BIRT) 2.1 - Eclipsepedia</a><br />
<br />
Look at the BirtEngine class in the comments section. Only do the shutdown when your application is finished. If your app is public I would love to see it.<br />
<br />
Jason
ak-tec
Hello,<br />
<br />
now my both applications communicates through sockets. I have a Java ServerSocket whicht starts the Platform at the beginning and shut downs the platform at the end of ServerSocket lifetime. My C++ application sends some parameter by a QT "QTCPSocket" and the Java ServerSocket generates some content (html, pdf, etc.). If the Birt-engine generates some html content which is stored local,my C++ application shows this html content in a QT WebView (WebKit). This works fine for my test purposes. <br />
<br />
Some java sample code:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public class BirtReportServer {
private static final Logger log = Logger.getLogger(BirtReportServer.class);
private ServerSocket _server;
private EngineConfig _engineConfig;
private int _nCountOfRequests;
public BirtReportServer() throws IOException
{
_nCountOfRequests = 0;
}
public void startAndRunServer(int nPort, Map<String, String> startParams) throws Exception
{
log.debug("start");
try
{
try
{
_server = new ServerSocket(nPort);
log.debug("ServerSocket started successfully");
_engineConfig = BIRTReportManager.createEngineConfig(startParams);
Platform.startup(_engineConfig);
log.debug("after Platform.startup");
}
catch (IOException e1)
{
log.error("start of server failed", e1);
}
while (true)
{
try
{
Socket client = _server.accept();
_nCountOfRequests++;
log.debug("accept: count of requests=" + _nCountOfRequests);
BufferedReader input = new BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter output = new PrintWriter(client.getOutputStream());
List<String> liInputParams = new ArrayList<String>();
String line;
log.debug("log input arguments:");
int nIndex = 0;
while ((line = input.readLine()) != null)
{
if (line.length() == 0)
break;
StartParameterUtils.logArguments(nIndex, line);
liInputParams.add(line);
nIndex++;
}
ParameterMap parameterMap = new ParameterMap();
StartParameterUtils.fillStartParameterMap(liInputParams.toArray(new String[liInputParams.size()]), parameterMap);
// create report
if (!parameterMap.getStartParams().containsKey(StartParameter.shutDownBirtServer))
{
// validate parameterMap
StartParameterUtils.validateStartParameterMap(parameterMap, true);
BIRTReportManager reportManager = new BIRTReportManager();
reportManager.createReportOutput(parameterMap, _engineConfig);
output.write("ok");
output.flush();
}
// shut down server
else
{
// leave while loop and shut down Platform in finally area
break;
}
input.close();
output.close();
log.debug("after input output close");
}
finally
{
}
}
}
finally
{
log.debug("before shutdown");
_server.close();
Platform.shutdown();
log.debug("after shut down BIRT platform");
}
}
}
</pre>