简体   繁体   中英

Wiring spring beans through custom reporting context in grails

I am using Jasper Reports for my Grails based web application and I have a ReportingContext.xml which has beans for each report like report id/name mapping with the report template (jrxml). I need to know the basic steps to configure and setup the context xmls and how to load them into my reportscontroller at application startup.

The old application was in java/j2ee which used this reporting xml. We have to develop a similar system on grails.

Most of the context contains the jrxml to report name mapping but I am not able to understand some of the beans in the context.

Here is the sample content of the reporting context.xml , for 1 report

 <beans> 
            <!-- ========================= REPORTING SERVICE WRAPPER ========================= -->
             <bean parent="baseTransactionProxy" name="myReportingService"> 
             <property name="proxyInterfaces" value="com.pack.my.reporting.service.myReportingService"/> 
             <property name="transactionAttributes">
                 <property name="target"> 
             <bean parent="baseServiceSupport" class="com.pack.my.reporting.service.impl.myReportingServiceImpl"> 
             <property name="reportManager" ref="reportManager"/> 
             <property name="mySecurityService" ref="mySecurityService"/> 
             <property name="businessUnitService" ref="businessUnitService"/> 
             </bean> 
             </property> 
             </bean> 
             <bean class="com.pack.my.reporting.manager.impl.ReportManagerImpl" id="reportManager"> 
             <property name="reportRenderers"> 
             <map> 
             <entry key="JasperPrint">
                 <entry key="siemJasperPrint">
             </map>
             </property>
             <property name="reportDefinitionDao" ref="reportDefinitionDao"/> 
             <property name="reportDao" ref="reportDao"/> 
             <property name="sequenceGeneratorService" ref="sequenceGeneratorService"/> 
             <property name="reportLocation" value="file:${my_HOME}/reports"/> 
             <property name="reportDefinitions">
                 <map> 
                 <entry key="businessUnitRoles"> 
                 <ref local="businessUnitRoles"/> 
                 </entry>
                 <entry key="businessUnitRoleUsers"> 
                 <ref local="businessUnitRoleUsers"/> 
                 </entry>
                 </map>
             </property>
             <property name="parameterPromptCodeMap">
                 <bean class="org.apache.commons.collections.map.CaseInsensitiveMap"> 
                 <constructor-arg> 
                 <map> 
                 <entry value="1" key="businessUnit"/> 
                 <entry value="1" key="businessUnitKey"/> 
                 <entry value="2" key="globaluser"/> 
                 <entry value="2" key="USERID"/> 
                 <entry value="2" key="USER_ID"/> 
                 <entry value="2" key="GLOBALUSERKEY"/> 
                 <entry value="3" key="identityCertification"/> 
                 <entry value="3" key="CERTIFICATIONID"/> 
                 <entry value="3" key="CERTIFICATION_ID"/> 
                 <entry value="4" key="startDate"/> 
                 </map> 
                 </constructor-arg> 
                 </bean> 
                 </property>
             </bean> 
            <!--- Report Groups Business Unit reports Group 1 Users reports -->
             <bean class="com.pack.my.reporting.domain.ReportDefinition" id="businessUnitRoles">
                 <property name="reportName" value="Business Unit Roles Report"/> 
                 <property name="reportFiles"> 
                 <map> 
                 <entry value="BusinessUnitRoles.jrxml" key="JasperPrint"/> 
                 </map> 
                 </property> 
                 <property name="promptForBusinessUnit" value="true"/> 
                 <property name="reportGroup" value="1"/> 
                 <property name="displayName" value="report.businessUnitRoles.name"/>
             <bean class="com.pack.my.reporting.domain.ReportDefinition" id="businessUnitUsers">

             </bean>
            </beans>
  1. Add dependencies to grails-app/conf/BuildConfig.groovy
  2. Copy the above file to /grails-app/conf/spring/resources.xml
  3. Read Grails and Spring - Reference Documentation

The resources.xml is not built by default anymore, as only resources.groovy exists in the spring dir. Just copy your spring context file to resources.xml.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM