Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

Creating a bean based on XML template conditionally, populate outside of app context

$
0
0
All, I have a project requirement that has the applicationContext, and beans configuration context XML (jpa-context):
This is a stand alone project that initializes the applicationContext, and the beans defined in jpa-context.

The problem is, that this is all initialized in the applicationContext, and some beans I would like to somehow "defer" the initialization. My IoC is more like a "script" to execute the application, and this seems like a not so good approach

For example, I am selecting a bean XML template on a value being passed to the application (see the second bolded line, below. I then create JPA entities based on the query parameters that are being passed to the main method.
Once the entities are populated, I populate a properties bean from the information in the entity instance, and then populate the bean XML template from the properties bean. This is all being done in the application context. See the bolded section at the end of the jpa-context xml.

What I would really like to do is initialize all the DAO beans in the application context. The next step would be to create entities based on variable parameters, as many times as desired (queries with varying parameter information) Then, initialize the properties bean from the populated JPA entities that will be used to initialize the one of many XML template beans that would be dynamically selected by some property value. In other words, the section bolded at the end of my XML would not live in the IoC, but would rather be managed somewhere else, so that the logic to populate the properties bean which in turn populates the variant XML bean could be done elsewhere. This is where I am "stuck" (context file names are underlined)


jpa-context:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<context:annotation-config />
<import resource="classpath:/META-INF/spring/emails/${email.xmlFile}" />
<bean id="containerTrackingImpl" class="com.summitholdings.vendor.prepays.Container TrackingImpl">
</bean>
<bean id="claimImpl" class="com.summitholdings.vendor.prepays.ClaimImpl ">
</bean>
<bean id="employeeImpl" class="com.summitholdings.vendor.prepays.EmployeeI mpl">
</bean>
<bean id="employeeAddressImpl" class="com.summitholdings.vendor.prepays.EmployeeA ddressImpl">
</bean>
<bean id="claimAuxiallaryImpl" class="com.summitholdings.vendor.prepays.ClaimAuxi allaryImpl">
</bean>
<bean id="claimInvestigationImpl"
class="com.summitholdings.vendor.prepays.ClaimInve stigationImpl">
</bean>
<bean id="claimMedicalProvidersImpl"
class="com.summitholdings.vendor.prepays.ClaimMedi calProvidersImpl">
</bean>
<bean id="policyMemberImpl" class="com.summitholdings.vendor.prepays.PolicyMem berImpl">
</bean>
<bean id="policyMemberLocationImpl"
class="com.summitholdings.vendor.prepays.PolicyMem berLocationImpl">
</bean>
<bean id="emailBodyService" class="com.summitholdings.vendor.prepays.EmailBody Impl">
</bean>
<bean id="queryParameters" class="com.summitholdings.vendor.prepays.QueryPara meters">
<property name="containerName" value="#{systemProperties.containerName}" />
<property name="containerUser" value="#{systemProperties.containerUser}" />
<property name="claim" value="#{systemProperties.claim}" />
<property name="providerSequenceNumber">
<bean class="com.summitholdings.vendor.prepays.IntegerFa ctoryBean">
<property name="data" value="#{systemProperties.providerSequenceNumber}" />
</bean>
</property>
<property name="dateTimeMaintained">
<bean class="com.summitholdings.vendor.prepays.Timestamp FactoryBean">
<property name="data" value="#{systemProperties.dateTimeMaintained}" />
</bean>
</property>
<property name="createDateTime">
<bean class="com.summitholdings.vendor.prepays.Timestamp FactoryBean">
<property name="data" value="#{systemProperties.createDateTime}" />
</bean>
</property>
<property name="claimYear">
<bean class="com.summitholdings.vendor.prepays.IntegerFa ctoryBean">
<property name="data" value="#{systemProperties.claimYear}" />
</bean>
</property>
<property name="caseNumber">
<bean class="com.summitholdings.vendor.prepays.LongFacto ryBean">
<property name="data" value="#{systemProperties.caseNumber}" />
</bean>
</property>
</bean>
<bean id="claimDataAccessor" class="com.summitholdings.vendor.prepays.ClaimData Accessor">
<property name="claim" value="#{claimImpl.getClaim(queryParameters.claimY ear,queryParameters.caseNumber)}" />
<property name="employee" value="#{employeeImpl.getEmployee(queryParameters. claimYear,queryParameters.caseNumber)}" />
<property name="containerTracking" value="#{containerTrackingImpl.getContainerTrackin g(
queryParameters.containerName,
queryParameters.createDateTime,
queryParameters.claim,
queryParameters.dateTimeMaintained,
queryParameters.containerUser)}" />
<property name="claimMedicalProviders" value="#{claimMedicalProvidersImpl.getClaimMedical Provider(
queryParameters.claimYear,
queryParameters.caseNumber,
queryParameters.providerSequenceNumber)}" />
<property name="surgeries" value="#{containerTrackingImpl.getContainerTrackin gByClaim(
queryParameters.claim)}"/>
</bean>
<bean id="policyDataAccessor" class="com.summitholdings.vendor.prepays.PolicyDat aAccessor">
<property name="policyMember" value="#{policyMemberImpl.getPolicyMember(
claimDataAccessor.claim.fundNumber,
claimDataAccessor.claim.memberNumber,
claimDataAccessor.claim.unitNumber)}" />
<property name="policyMemberLocation" value="#{policyMemberLocationImpl.getPolicyMemberL ocation(
claimDataAccessor.claim.fundNumber,
claimDataAccessor.claim.memberNumber,
claimDataAccessor.claim.unitNumber,
</bean>
<bean id="emailPropertyValues" class="com.summitholdings.vendor.prepays.EmailProp ertyValues">
<constructor-arg index="0" ref="claimDataAccessor" />
<constructor-arg index="1" ref="policyDataAccessor" />
</bean>
</beans>

Viewing all articles
Browse latest Browse all 297

Trending Articles