Jump to content
Changes to the Jaspersoft community edition download ×

Custom Data Source for JasperServer?


greg.fenton

Recommended Posts

We have developed a custom data source so that iReports can go directly against our data model in our J2EE solution.

 

Will JasperServer support a similar approach or is it hard-coded to JDBC?

 

Any links to relevant docs would be greatly appreciated too!

 

Thanks in advance,

greg.fenton

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

martynhiemstra wrote:

You could create your own report bean. Fill it in advance with data from anywhere and send the bean to the report.

 

Would this approach be performant/scalable?

 

Would this approach lend itself to using JasperAnalytics if we decide to add OLAP capabilities to our solution?

 

Thanks,

greg.fenton

Link to comment
Share on other sites

I found that if you use a query to get information from a database you are extremly limited in the amount of information you can get from the database. If you can't get it in 1 query then you can't get it at all.

 

With beans that isnt a issue. There you can even get information from different databases.

 

Another advantage is that by using a bean, your front-end ( The report ) isnt directly in touch with the data ( Database ). The bean acts as a interface. The bean also acts as a database view. The report designer only sees what you want him/her to see. If the report designer can supply any query they want, they can print anything they want.

 

If the database changes then all your reports have to change as well. If you use a bean as datasource then you have to change the business logic and not your reports.

 

Concerning JasperAnalytics and OLAP I cant help out with that. I have no expierance with both.

 

Martyn

Post edited by: martynhiemstra, at: 2007/03/05 07:56

Link to comment
Share on other sites

  • 1 month later...

Yes, you can run custom data source in Jasperserver

 

You need to add the "CustomDataSourceServiceFactory" class and register it in the applicationContext.xml

 

 

public class CustomDataSourceServiceFactory {

public ReportDataSourceService plainDataSource() {

return new CustomDataSourceService(new CustomDataSource());

}

 

public ReportDataSourceService tableModelDataSource() {

return new CustomDataSourceService();

}

 

public ReportDataSourceService beanArrayDataSource() {

return new CustomDataSourceService(new JRBeanArrayDataSource(CustomBeanFactory.getBeanArray()));

}

 

public ReportDataSourceService beanCollectionDataSource() {

return new CustomDataSourceService(new JRBeanCollectionDataSource(CustomBeanFactory.getBeanCollection()));

}

}

 

 

You also need the CustomDataSourceService class:

 

public class CustomDataSourceService implements ReportDataSourceService {

 

JRDataSource ds;

 

public CustomDataSourceService() {

this.ds = new CustomDataSource();

}

 

public CustomDataSourceService(JRDataSource ds) {

this.ds = ds;

}

 

public void closeConnection() {

// Do nothing

}

 

public void setReportParameterValues(Map parameterValues) {

this.ds =new CustomDataSource(parameterValues);

parameterValues.put(JRParameter.REPORT_DATA_SOURCE, ds);

}

}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...