commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Goodwin <mgood...@metalexis.com>
Subject [digester] Digester pinning objects in memory
Date Tue, 05 Jul 2005 21:48:53 GMT
I am using commons-digester for creating some objects from some xml 
files.  When I look at this with JProbe Digester (and some other 
internal stuff are still referencing the object that is parsed.  The 
code is as follows, any help would be greatly appreciated: 

Digester digester = initializeDigester();
CommissionStatement commissionStatement = 
(CommissionStatement)digester.parse(new 
StringReader(FileUtils.readFile(file.getAbsolutePath())));
digester.clear();
digester=null;
...snip
clearCommissionStatement(commissionStatement);

private Digester initializeDigester() {
    Digester digester = new Digester();
    digester.setValidating(false);
    
digester.addObjectCreate("CommissionStatementVO",CommissionStatement.class);
    
digester.addObjectCreate("CommissionStatementVO/AgentStatementVO",AgentStatement.class);
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/StatementDate","statementDate");
    
digester.addObjectCreate("CommissionStatementVO/AgentStatementVO/AgentInfoVO",AgentInfo.class);
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentInfoVO/FirstName","firstName");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentInfoVO/Name","lastName");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentInfoVO/AgentId","agentId");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentInfoVO/Address1","address1");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentInfoVO/Address2","address2");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentInfoVO/City","city");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentInfoVO/State","state");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentInfoVO/Zip","zip");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentInfoVO/AgentType","agentType");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentInfoVO/DisbursementSource","disbursementSource");
    
digester.addSetNex("CommissionStatementVO/AgentStatementVO/AgentInfoVO","setAgentInfo","com.equitrust.commissionloader.beans.AgentInfo");
    
digester.addObjectCreate("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO",AgentStatementDetail.class);
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/AgentNumber","agentNumber");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/ProductType","productType");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/FirstName","firstName");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/Name","lastName");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/EffectiveDate","effectiveDate");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/ProcessDate","processDate");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/OwnerName","ownerName");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/PolicyNumber","policyNumber");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/InitialPremium","initialPremium");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/CommissionRate","commissionRate");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/CommissionPremium","commissionPremium");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/Type","commissionType");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO/AmountDue","amountDue");
    
digester.addSetNext("CommissionStatementVO/AgentStatementVO/AgentStatementLineVO","addAgentStatementDetail","com.equitrust.commissionloader.beans.AgentStatementDetail");
    
digester.addObjectCreate("CommissionStatementVO/AgentStatementVO/AgentEarningsVO",AgentEarning.class);
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentEarningsVO/TaxableIncome","taxableIncome");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentEarningsVO/TaxableIncomeYTD","taxableIncomeYTD");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentEarningsVO/PositivePolicyEarnings","positiveEarnings");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentEarningsVO/NegativePolicyEarnings","negativeEarnings");
    
digester.addBeanPropertySetter("CommissionStatementVO/AgentStatementVO/AgentEarningsVO/NetPolicyEarnings","netEarnings");
    
digester.addSetNext("CommissionStatementVO/AgentStatementVO/AgentEarningsVO","setAgentEarning","com.equitrust.commissionloader.beans.AgentEarning");
    
digester.addSetNext("CommissionStatementVO/AgentStatementVO","addAgentStatement","com.equitrust.commissionloader.beans.AgentStatement");
    return digester;
}

private void clearCommissionStatement(CommissionStatement 
commissionStatement) {
        Iterator itr = commissionStatement.getAgentStatements().iterator();
        while(itr.hasNext()) {
            AgentStatement agentStatement = ((AgentStatement)itr.next());
            AgentEarning agentEarning = agentStatement.getAgentEarning();
            agentEarning=null;
            AgentInfo agentInfo = agentStatement.getAgentInfo();
            agentInfo=null;
            clearAgentStatementDetails(agentStatement);
        }
       
    }

Thanks,

Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message