BIRT2.1的部署与瘦身
2.1. 拷贝文件1
将/plugins, /configuration两个目录复制到webapp 根目录, 将lib复制到webapp/WEB-INF/lib
2.2. 瘦身
Birt实在太过庞大,如果将以上三个目录全拷的话几十M.因此,可以参考SS里对/lib/birt 和 webapp/plugins目录反复试验后的精简。
另外,/lib和/plugins有好多jar是重复的,只要在编译时把jar 从一个目录copy过去就行。又要注意两个目录里相同的jar的命名并不相同,而/plugins里面的文件名很严格,可参考build.xml里的这段复制命令
<copy file="lib/birt/com.ibm.icu-3.4.4.1.jar" tofile="${web.dir}/plugins/com.ibm.icu_3.4.4.1.jar"/>
<copy file="lib/birt/js-2.1.jar" tofile="${web.dir}/plugins/org.mozilla.rhino/lib/js.jar"/>
<copy file="lib/birt/chartengineapi-2.1.jar" tofile="${web.dir}/plugins/org.eclipse.birt.chart.engine_2.1.0.N20060628-1351.jar"/>
<copy todir="${web.dir}/plugins">
<fileset dir="lib/birt">
<include name="org.eclipse.emf.*"/>
</fileset>
</copy>
发表评论
2006-08-10 17:09
在生成饼状图的url是指向服务器本地文件目录的,在其它终端上无法浏览,不知是不是birt的bug呀
2006-08-10 20:51
问题终于找到了:)
由于birt的EngineConfig的构造函数
public EngineConfig( )
{
// set default configruation
HTMLEmitterConfig emitterConfig = new HTMLEmitterConfig( );
emitterConfig.setActionHandler( new HTMLActionHandler( ) );
emitterConfig.setImageHandler( new HTMLCompleteImageHandler( ) );
getEmitterConfigs( ).put( "html", emitterConfig ); //$NON-NLS-1$
}
使用了new HTMLCompleteImageHandler( ) 作为html图片的处理,然而HTMLCompleteImageHandler的handleImage方法只是将图片的生成路径输出,所以在网页上生成的url为在服务器上chart图片的url,
我的修改如下,主要是修改ss的BirtReportView这个类的renderMergedOutputModel方法,如下:
protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)
throws Exception {
ServletContext context = request.getSession().getServletContext();
OutputStream outputStream = response.getOutputStream();
EngineConfig birtConfig = new EngineConfig();
birtConfig.setEngineHome(context.getRealPath("/"));
HTMLEmitterConfig emitterConfig=(HTMLEmitterConfig)birtConfig.getEmitterConfigs( ).get("html");
emitterConfig.setImageHandler( new HTMLServerImageHandler() );
engine = new ReportEngine(birtConfig);
try {
run(outputStream, context,request);
}
catch (EngineException e) {
throw new Exception("the View not run() yet");
}
ByteArrayOutputStream baos = new ByteArrayOutputStream(OUTPUT_BYTE_ARRAY_INITIAL_SIZE);
response.setContentLength(baos.size());
baos.writeTo(outputStream);
outputStream.flush();
}
呵呵,读了一天源程序终于解决了这个问题 h.r
2006-08-11 08:23
这个方法也修改了一下:
private void run(OutputStream outputStream, ServletContext context,HttpServletRequest request) throws EngineException, Exception {
Assert.hasText(designFilePath, "Set designFilePath first!");
//config the htmlrendercontext
HTMLRenderContext renderContext = new HTMLRenderContext();
renderContext.setImageDirectory(context.getRealPath(imageDirectory));
renderContext.setBaseImageURL(request.getContextPath()+imageDirectory);
HashMap contextMap = new HashMap();
contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext);
IReportRunnable design = null;
design = engine.openReportDesign(context.getRealPath(designFilePath));
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
task.setAppContext(contextMap);
BirtDataSourceObject birtDataSourceObject = new BirtDataSourceObject();
HTMLRenderOption options = new HTMLRenderOption();
birtDataSourceObject.setResultList(resultList);
options.setOutputStream(outputStream);
task.setRenderOption(options);
task.addScriptableJavaObject(scriptableJOName, birtDataSourceObject);
task.run();
}
2006-08-16 09:54
我也遇到了这个问题,看到birt上的解释有的,参见这片文章
http://wiki.eclipse.org/index.php/Separate_Run_and_Render