Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

udapte:调整取得自定义报表存储器的方式,在不影响原Spring Bean方式情况下,可以兼容其他框架如nutz #353

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ureport2-core/src/main/java/com/bstek/ureport/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;
import java.util.Map;

import com.bstek.ureport.provider.report.ReportProvider;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
Expand All @@ -46,6 +47,7 @@ public class Utils implements ApplicationContextAware{
private static ApplicationContext applicationContext;
private static Collection<BuildinDatasource> buildinDatasources;
private static Collection<ImageProvider> imageProviders;
private static Collection<ReportProvider> reportProviders;
private static boolean debug;

public static boolean isDebug() {
Expand All @@ -70,7 +72,10 @@ public static Collection<ImageProvider> getImageProviders() {
return imageProviders;
}


public static Collection<ReportProvider> getReportProviders() {
return reportProviders;
}

public static Connection getBuildinConnection(String name){
for(BuildinDatasource datasource:buildinDatasources){
if(name.equals(datasource.name())){
Expand Down Expand Up @@ -223,5 +228,7 @@ public void setApplicationContext(ApplicationContext applicationContext)throws B
buildinDatasources.addAll(applicationContext.getBeansOfType(BuildinDatasource.class).values());
imageProviders=new ArrayList<ImageProvider>();
imageProviders.addAll(applicationContext.getBeansOfType(ImageProvider.class).values());
reportProviders=new ArrayList<ReportProvider>();
reportProviders.addAll(applicationContext.getBeansOfType(ReportProvider.class).values());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;

import com.bstek.ureport.Utils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
Expand All @@ -42,10 +43,9 @@
* @author Jacky.gao
* @since 2016年12月4日
*/
public class ReportRender implements ApplicationContextAware{
public class ReportRender {
private ReportParser reportParser;
private ReportBuilder reportBuilder;
private Collection<ReportProvider> reportProviders;
private DownCellbuilder downCellParentbuilder=new DownCellbuilder();
private RightCellbuilder rightCellParentbuilder=new RightCellbuilder();
public Report render(String file,Map<String,Object> parameters){
Expand Down Expand Up @@ -102,7 +102,7 @@ public ReportDefinition parseReport(String file){

private InputStream buildReportFile(String file){
InputStream inputStream=null;
for(ReportProvider provider:reportProviders){
for(ReportProvider provider:Utils.getReportProviders()){
if(file.startsWith(provider.getPrefix())){
inputStream=provider.loadReport(file);
}
Expand Down Expand Up @@ -137,8 +137,5 @@ public void setReportParser(ReportParser reportParser) {
public void setReportBuilder(ReportBuilder reportBuilder) {
this.reportBuilder = reportBuilder;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
reportProviders=applicationContext.getBeansOfType(ReportProvider.class).values();
}

}