Re: [digester] Digester pinning objects in memory
Thanks for the reply. Since I have the option of moving to 1.7 I think I will. I'll keep searching for the answer, but it's not immediately clear to me how I am holding a reference to Digester since I am declaring it locally in a method (so it should go out of scope). Also, I'm a little concerned because the code I wrote is pretty basic and it basically follows all the tutorials out on the web. I'm creating and using the digester in the loop and so I'm curious if I'm seeing stuff that others aren't because I'm reading multiple files and creating objects from them while others are just reading one config file and the memory problem isn't manifesting itself. Following occam's razor though your explanation is probably what is really going on. Thanks, Matt Simon Kitching wrote: On Tue, 2005-07-05 at 16:48 -0500, Matt Goodwin wrote: 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 does keep a reference to the root object it creates. You can clear this via a call to: Digester.resetRoot (since 1.7 only). I don't see any other way that Digester could retain references to created objects. However this shouldn't be relevant; after you use the Digester object, there shouldn't be any references to it. So the Digester will get garbage-collected and therefore the root object isn't prevented from being garbage-collected. It would therefore appear that your code is holding on to the Digester reference after it has been used; if you fix this then your problem should go away anyway. Regards, Simon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[digester] Digester pinning objects in memory
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);
Re: [betwixt] dynabean with betwixt
Thanks for the response. I'll take a stab at it. Matt robert burrell donkin wrote: hi matt On Tue, 2005-05-03 at 12:45 -0500, Matt Goodwin wrote: I am trying to write out a class that implements DynaBean. When I do this it does not write out any of the dynaproperties. I looked at the TestDynaBeanSupport test case. It does not appear to be writing out the dynaproperty either. When I changed the betwixt file to print out the dynaproperty it did not print it out. Does anyone know how to implement this functionality? if this last sentence means you're volunteering to create a patch, then once you've added some integration tests for the whole writing process, i'd suggest taking a look at XMLIntrospector.DynaClassBeanType. otherwise, if you're willing to contribute a unit test to apache post it on bugzilla and i'll take a look at fixing up that area of code. - robert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Metalexis Transcending the Ordinary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Slightly OT] JNDI question
I don't have a slick trick, but what I do is get my datasources from a dbhelper class. In that class I try to read from jndi, if I can't get access to jndi I read from a config file that sits on the classpath. In Tomcat it gets the connection from jndi, for tests i create it from the config file. Of course you can use a filesystem jndi implementation that does the same thing (so I've read), but I guess I took the easy way out. Wish I had some slick way of doing this. Matt WHIRLYCOTT wrote: I'm wondering if somone has any creative ideas here. I'm working on a project that gets javax.sql.DataSource instances via Tomcat's JNDI provider. This works fine, except when we are developing code and need to run Junit tests. Because the tests need to run outside Tomcat, getting access to a DataSource via JNDI becomes a pain in the neck. I'm assuming that this is a very common situation and I'm wondering if anybody has slick tricks for your dev environments that allow you do get DataSource objects via JNDI...? phil. -- Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Metalexis Transcending the Ordinary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[betwixt] dynabean with betwixt
I am trying to write out a class that implements DynaBean. When I do this it does not write out any of the dynaproperties. I looked at the TestDynaBeanSupport test case. It does not appear to be writing out the dynaproperty either. When I changed the betwixt file to print out the dynaproperty it did not print it out. Does anyone know how to implement this functionality? Thanks, Matt -- Matt Goodwin [EMAIL PROTECTED] Metalexis Transcending the Ordinary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [validator] Resource bundle with standalone validation
There is a good discussion of that on the Commons-Validator site. If you're in a web environment you basically initilalize your resource bundle in an initialization servlet. Check out this link. http://wiki.apache.org/jakarta-commons/ValidatorStandalone. If you need an example of the code I can send you what I've done. If you're outside the web environment there are a few other things that you can do, but I will let others speak on that as I have not done that. Thanks, Matt Ben Avery wrote: I want to use a resource bundle to generate meaningful error messages, using Validator in a standalone, non-Struts environment. What do I need to put in the Java class which instantiates and calls the Validator, so it understands which resourcebundle file to look up references like xml config file: ... global validator name=email classname=org.youthnet.ben.ValidatorWrapper method=doValidEmail methodParams=java.lang.Object, org.apache.commons.validator.Field msg=errors.email/ ... /global formset form name=simpleform field property=startDate depends=required arg position=0 key=Start date/ /field ... /form /formset ... the resource file would look like: errors.required={0} is required. errors.maxlength={0} cannot be greater than {1} characters. errors.email={0} is an invalid email address. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Metalexis Transcending the Ordinary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [httpclient] Sending serialized object from httpclient to servlet.
From the Java Developers Almanac site http://javaalmanac.com/egs/java.io/SerializeObj.html // Serialize to a byte array ByteArrayOutputStream bos = new ByteArrayOutputStream() ; out = new ObjectOutputStream(bos) ; out.writeObject(object); out.close(); // Get the bytes of the serialized object byte[] buf = bos.toByteArray(); Hope that's what you were looking for. Matt Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Transcending the Ordinary Sanjeev Tripathi wrote: Thanks Wendy. I know how to serialize object to file or socket. But How I can convert object to bytes so I can use byte[] encodedData = Base64.encodeBase64( binaryData ); could you give a example of it. I used this for strings but I am stuck for object String encodedPassword = new sun.misc.BASE64Encoder().encode(password.getBytes()) Thanks. Sanjeev Tripathi -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 08, 2005 10:23 AM To: commons-user@jakarta.apache.org Cc: Jakarta Commons Developers List Subject: Re: [httpclient] Sending serialized object from httpclient to servlet. From: Sanjeev Tripathi [EMAIL PROTECTED] Can any one tell me how send serialized object to servlet from httpclient. Colin already gave you one option, (base 64 encoding the binary data): http://www.mail-archive.com/commons-dev%40jakarta.apache.org/msg57055.ht ml For general information on base 64 encoding: http://www.google.com/search?q=java+base64+encoding Here's Jakarta Commons Codec, which includes a base 64 encoder: http://jakarta.apache.org/commons/codec/ http://jakarta.apache.org/commons/codec/apidocs/org/apache/commons/codec /binary/Base64.html Without actually trying it, it looks like all you need to do is: byte[] encodedData = Base64.encodeBase64( binaryData ); Then turn the byte[] into a String and POST it to the server as the value of a request parameter. If it's not too big, it should work the same way as sending a big string from a text area. The 'commons-dev' list is usually reserved for questions about the development of the libraries themselves, so I'm replying to commons-user (and copying dev). - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [betwixt] object-string conversion .betwixt file
Thanks for the response. I briefly took a look at flavour, but it appeared to be something that wasn't supported currently and not having looked at a roadmap or anything I was a little nervous to use it since I didn't know what the actual intended use was (outside of one post that briefly discussed flavour). Sorry to hear about your development machine, best wishes with that. I took your advice and worked up something. It's kind of a combination of what you suggested. I've got it working. Basically, I'm setting 2 options variables. 1) The classname of the objectStringConverter and 2) the classname of a Converter class that ConvertUtils will use. I did this because it seemed to stick as close to the current implementation as I could. I modified the Updater interface to take a 3rd parameter - an instance of an ObjectStringConverter. I use that to do the conversion. I pass the Converter class through in a context variable and use that with ConvertUtils. I'm hoping that the ConvertUtils.register and ConvertUtils.deregister isn't too much of a performace drag. I will try to put a patch out there tomorrow (or asap - wife is 1 week overdue with a little one so it's anyday). Take a look and let me know what you think. Thanks, Matt robert burrell donkin wrote: hi matt this kind of scenario was intended to be supported by the flavour parameter passed into the converter. the idea was that the flavour is an arbitrary string which could be set either in a betwixt file or by some course grained strategy. if the converter understood the flavour then it could perform the appropriate conversion. my main development machine recently blew up on me and i'm still in the process of configuring my secondary machine for apache development. so i'm not really in a position to do much development right now. there's a chance that support for flavours in dot betwixt files has already been added. if not, then perhaps you'd like to replace your workaround with an implementation that allows the flavour of the conversion to be set by an attribute in the betwixt file. i'd be very happy to review any such contribute if you'd like to donate it to apache. (the best way is by submitting a patch through bugzilla). please consider adding unit tests and documentation. i do agree that it would be cool to be able to interrogate the options for the current element within the converter. perhaps it would be possible to add this information to the context (perhaps through a magic variable) or just by adding an extra signature to the ObjectStringConverter. that would allow a default implementation to instantiate a converter to delegate to based on a magic option (just as you had it). i like this solution but suspect that it would probably require a little more effort that adding flavour support. i'd probably support both mechanisms and be willing to review contributed patchs. on a more general note, i'm now wondering whether it might be a good idea to allow the binding configuration to be specified within a betwixt file (possibly by use of a factory class). comments welcomed :) - robert On Fri, 2005-01-28 at 19:35, Matt Goodwin wrote: I have been able to be able to write out a bean with a date to a format other than the default by specifying an options parameter and doing a quick hack to the betwixt source. Here is the .betwixt file. ?xml version='1.0' ? info element name='ActivitySummary' element name='CommissionsYTD' property='commissionsYTD'/ element name='LastCommissionAmt' property='lastCommissionAmt'/ element name='LastCommissionDate' property='lastCommissionDate' option nameorg.apache.commons.betwixt.object-string-converter/name valuecom.equitrust.util.betwixt.strategy.SegDateObjectStringConverter/value /option /element element name='PremiumYTD' property='premiumYTD'/ /element /info I modded the source in the AbstractBeanWriter in the convertToString method by just simply checking of the existence of the option for object-string-converter and then instantiating the converter specified. Real ugly hack, but it works. However, this does not work for string to object conversion because digester just uses the objectStringConverter on the BindingConfiguration. I've been trying to trace through and see where the objectStringConverter is set on the BindingConfiguration and see what ways I can override this with the .betwixt file. Does anyone see a way I can do this? I'd like to be able to specify everything in the .betwixt file so I don't have to specify my converter in code, and also in case I need to use a different format for a different element (it appears that the converter when registering it will convert all elements of the type - in my case date - using the same converter). Open to any ideas. Thanks, Matt p.s. If you see a better way to do the ObjectToString conversion besides my hack, please input that as well
[betwixt] object-string conversion .betwixt file
I have been able to be able to write out a bean with a date to a format other than the default by specifying an options parameter and doing a quick hack to the betwixt source. Here is the .betwixt file. ?xml version='1.0' ? info element name='ActivitySummary' element name='CommissionsYTD' property='commissionsYTD'/ element name='LastCommissionAmt' property='lastCommissionAmt'/ element name='LastCommissionDate' property='lastCommissionDate' option nameorg.apache.commons.betwixt.object-string-converter/name valuecom.equitrust.util.betwixt.strategy.SegDateObjectStringConverter/value /option /element element name='PremiumYTD' property='premiumYTD'/ /element /info I modded the source in the AbstractBeanWriter in the convertToString method by just simply checking of the existence of the option for object-string-converter and then instantiating the converter specified. Real ugly hack, but it works. However, this does not work for string to object conversion because digester just uses the objectStringConverter on the BindingConfiguration. I've been trying to trace through and see where the objectStringConverter is set on the BindingConfiguration and see what ways I can override this with the .betwixt file. Does anyone see a way I can do this? I'd like to be able to specify everything in the .betwixt file so I don't have to specify my converter in code, and also in case I need to use a different format for a different element (it appears that the converter when registering it will convert all elements of the type - in my case date - using the same converter). Open to any ideas. Thanks, Matt p.s. If you see a better way to do the ObjectToString conversion besides my hack, please input that as well -- Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Metalexis Transcending the Ordinary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [betwixt] Collection property question
Thanks. It's really weird because the RSS example in the sample code works fine and my code is almost identical. Matt Jason Wood wrote: I'm afraid I miss understood your original question and am not sure what the best approach is. Sorry J -Original Message- From: Matt Goodwin [mailto:[EMAIL PROTECTED] Sent: Thursday, January 13, 2005 5:12 PM To: Jakarta Commons Users List Subject: Re: [betwixt] Collection property question public void testReadBean() { try { File file = new File(FILE1); BeanReader beanReader = new BeanReader(); beanReader.registerBeanClass(AgentStatement.class); AgentStatement statement = (AgentStatement)beanReader.parse(file); } catch(Exception e) { fail(e.getMessage()); } } xml file: AgentStatementVO StatementDate2004/10/08/StatementDate AgentInfoVO FirstName/ Name/Name AgentId/AgentId Address1/Address1 Address2/Address2 City/City Statexx/State Zipx/Zip AgentType/AgentType DisbursementSource/DisbursementSource /AgentInfoVO AgentStatementLineVO AgentNumber/AgentNumber ProductType/ProductType FirstName/FirstName Name/Name EffectiveDate2004/10/04/EffectiveDate ProcessDate2004/10/05/ProcessDate OwnerName/OwnerName PolicyNumber0/PolicyNumber InitialPremium0/InitialPremium CommissionRate0.0/CommissionRate CommissionPremium0/CommissionPremium Type/Type AmountDue0/AmountDue /AgentStatementLineVO AgentStatementLineVO AgentNumber/AgentNumber ProductType/ProductType FirstName/FirstName Name/Name EffectiveDate2004/10/04/EffectiveDate ProcessDate2004/10/05/ProcessDate OwnerName/OwnerName PolicyNumber0/PolicyNumber InitialPremium0/InitialPremium CommissionRate0.0/CommissionRate CommissionPremium0/CommissionPremium Type/Type AmountDue0/AmountDue /AgentStatementLineVO AgentEarningsVO TaxableIncome0.0/TaxableIncome TaxableIncomeYTD0.0/TaxableIncomeYTD PositivePolicyEarnings0/PositivePolicyEarnings NegativePolicyEarnings0/NegativePolicyEarnings NetPolicyEarnings0/NetPolicyEarnings /AgentEarningsVO /AgentStatementVO reads all non-plural elements fine. when i change AgentStatementLineVO to non-plural (regular getter/setter for the object) it works fine as well. Thanks, Matt Tim O'Brien wrote: Could you send the complete code you are using to read with? Tim -Original Message- From: Matt Goodwin [mailto:[EMAIL PROTECTED] Sent: Thu 1/13/2005 2:58 PM To: Jakarta Commons Users List Subject: Re: [betwixt] Collection property question I have that set. It appears that my class is not being recognized in the parse process. My add method on my class is never called. Matt Jason Wood wrote: I think you want this ... IntrospectionConfiguration.setWrapCollectionsInElement(false) Jason -Original Message- From: Matt Goodwin [mailto:[EMAIL PROTECTED] Sent: Thursday, January 13, 2005 11:02 AM To: Jakarta Commons Users List Subject: [betwixt] Collection property question I have xml I need to map to my bean. It is very similar to the CustomerBean example, except I am using Collection instead of and array of objects (i.e. Order[]). Here is a sample of the xml, followed by my class, followed by my .betwixt file. The problem I am having is the List is always null. How do you map objects in the .betwixt file if the collection has no surrounding element tag (i.e. orders/order/order/orders)? Example xml: AgentStatementVO StatementDate2004/10/08/StatementDate AgentInfoVO.../AgentInfoVO AgentStatementLineVO.../AgentStatementLineVO AgentStatementLineVO.../AgentStatementLineVO AgentEarningsVO.../AgentEarningsVO /AgentStatementVO Class: public class AgentStatement implements java.io.Serializable { private Date statementDate; private AgentInfo agentInfo; private Collection agentStatementDetails = new java.util.ArrayList(); private AgentEarning agentEarning; /* .. snip non-relevant getters/setters */ public Collection getAgentStatementDetails() { return agentStatementDetails; } public void setAgentStatementDetails(Collection agentStatementDetails) { this.agentStatementDetails = agentStatementDetails; } public void addAgentStatementDetail(AgentStatementDetail agentStatementDetail) { this.agentStatementDetails.add(agentStatementDetail); } } Betwixt file: ?xml version='1.0' ? info element name='AgentStatementVO' element name='StatementDate' property='statementDate'/ element name='AgentInfoVO' property='agentInfo'/ element name='AgentStatementLineVO' property='agentStatementDetails' class='com.equitrust.commissionloader.beans.AgentStatementDetail'/ element name='AgentEarningsVO' property='agentEarning'/ /element /info Everything except the agentStatementDetails are populated correctly. Thanks, Matt
[digester] internal object not populated
Hi, I am trying to simply populate an object from xml, but while some properties on the object (statementDate - a String and agentStatementDetails - an arraylist of AgentStatementDetail objects) populate 2 others are not populated (agentInfo - an AgentInfo object and agentEarning - an AgentEarning object). I have the following code: Digester digester = new Digester(); digester.setValidating(false); digester.addObjectCreate(AgentStatementVO,AgentStatement.class); digester.addBeanPropertySetter(AgentStatementVO/StatementDate,statementDate); digester.addObjectCreate(AgentStatementVO/AgentInfoVO,AgentInfo.class); digester.addBeanPropertySetter(AgentStatementVO/AgentInfoVO/FirstName,firstName); digester.addBeanPropertySetter(AgentStatementVO/AgentInfoVO/Name,lastName); digester.addBeanPropertySetter(AgentStatementVO/AgentInfoVO/AgentId,agentId); digester.addBeanPropertySetter(AgentStatementVO/AgentInfoVO/Address1,address1); digester.addBeanPropertySetter(AgentStatementVO/AgentInfoVO/Address2,address2); digester.addBeanPropertySetter(AgentStatementVO/AgentInfoVO/City,city); digester.addBeanPropertySetter(AgentStatementVO/AgentInfoVO/State,state); digester.addBeanPropertySetter(AgentStatementVO/AgentInfoVO/Zip,zip); digester.addBeanPropertySetter(AgentStatementVO/AgentInfoVO/AgentType,agentType); digester.addBeanPropertySetter(AgentStatementVO/AgentInfoVO/DisbursementSource,disbursementSource); digester.addObjectCreate(AgentStatementVO/AgentStatementLineVO,AgentStatementDetail.class); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/AgentNumber,agentNumber); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/ProductType,productType); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/FirstName,firstName); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/Name,lastName); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/EffectiveDate,effectiveDate); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/ProcessDate,processDate); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/OwnerName,ownerName); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/PolicyNumber,policyNumber); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/InitialPremium,initialPremium); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/CommissionRate,commissionRate); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/CommissionPremium,commissionPremium); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/Type,commissionType); digester.addBeanPropertySetter(AgentStatementVO/AgentStatementLineVO/AmountDue,amountDue); digester.addSetNext(AgentStatementVO/AgentStatementLineVO,addAgentStatementDetail,com.equitrust.commissionloader.beans.AgentStatementDetail); digester.addObjectCreate(AgentStatementVO/AgentEarningsVO,AgentEarning.class); digester.addBeanPropertySetter(AgentStatementVO/AgentEarningsVO/TaxableIncome,taxableIncome); digester.addBeanPropertySetter(AgentStatementVO/AgentEarningsVO/TaxableIncomeYTD,taxableIncomeYTD); digester.addBeanPropertySetter(AgentStatementVO/AgentEarningsVO/PositivePolicyEarnings,positiveEarnings); digester.addBeanPropertySetter(AgentStatementVO/AgentEarningsVO/NegativePolicyEarnings,negativeEarnings); digester.addBeanPropertySetter(AgentStatementVO/AgentEarningsVO/NetPolicyEarnings,netEarnings); AgentStatement statement = (AgentStatement)digester.parse(xmlReader); Does anyone see what would be causing this behavior. I am using the following test xml. AgentStatementVO StatementDate2004/10/08/StatementDate AgentInfoVO FirstName/ Name/Name AgentId/AgentId Address1/Address1 Address2/Address2 City/City Statexx/State Zipx/Zip AgentType/AgentType DisbursementSource/DisbursementSource /AgentInfoVO AgentStatementLineVO AgentNumber/AgentNumber ProductType/ProductType FirstName/FirstName Name/Name EffectiveDate2004/10/04/EffectiveDate ProcessDate2004/10/05/ProcessDate OwnerName/OwnerName PolicyNumber0/PolicyNumber InitialPremium0/InitialPremium CommissionRate0.0/CommissionRate CommissionPremium0/CommissionPremium Type/Type AmountDue0/AmountDue /AgentStatementLineVO AgentEarningsVO TaxableIncome0.0/TaxableIncome TaxableIncomeYTD0.0/TaxableIncomeYTD PositivePolicyEarnings0/PositivePolicyEarnings NegativePolicyEarnings0/NegativePolicyEarnings NetPolicyEarnings0/NetPolicyEarnings /AgentEarningsVO /AgentStatementVO Thanks, Matt -- Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Metalexis Transcending the Ordinary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [digester] internal object not populated
Wendy, Thanks for taking the time to recreate and solve the problem. I won't get a chance to implement it until I go to work, but I'm positive that will solve my problem. Thanks a bunch, Matt Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Transcending the Ordinary Wendy Smoak wrote: From: Matt Goodwin [EMAIL PROTECTED] 2 others are not populated (agentInfo - an AgentInfo object and agentEarning - an AgentEarning object). Tentatively, because I don't have a lot of Digester experience... I see you create and populate the AgentInfo and AgentEarning objects, but I don't see you adding them to the AgentStatement object. I was able to recreate the problem, and solve it by adding these lines beneath their respective lists of addBeanPropertySetters: digester.addSetNext( AgentStatementVO/AgentInfoVO, setAgentInfo, AgentInfo ); digester.addSetNext( AgentStatementVO/AgentEarningsVO, setAgentEarning, AgentEarning ); (Note that I used the default package, so the third argument needs the correct package name added to the class name.) Now printing the AgentStatement object shows: [EMAIL PROTECTED] statementDate=2004/10/08 [EMAIL PROTECTED] lastName=] agentStatementDetails=[] [EMAIL PROTECTED] positiveEarnings=0.0 netEarnings=0.0]] HTH, if you haven't solved it yourself by now. :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[betwixt] Collection property question
I have xml I need to map to my bean. It is very similar to the CustomerBean example, except I am using Collection instead of and array of objects (i.e. Order[]). Here is a sample of the xml, followed by my class, followed by my .betwixt file. The problem I am having is the List is always null. How do you map objects in the .betwixt file if the collection has no surrounding element tag (i.e. orders/order/order/orders)? Example xml: AgentStatementVO StatementDate2004/10/08/StatementDate AgentInfoVO.../AgentInfoVO AgentStatementLineVO.../AgentStatementLineVO AgentStatementLineVO.../AgentStatementLineVO AgentEarningsVO.../AgentEarningsVO /AgentStatementVO Class: public class AgentStatement implements java.io.Serializable { private Date statementDate; private AgentInfo agentInfo; private Collection agentStatementDetails = new java.util.ArrayList(); private AgentEarning agentEarning; /* .. snip non-relevant getters/setters */ public Collection getAgentStatementDetails() { return agentStatementDetails; } public void setAgentStatementDetails(Collection agentStatementDetails) { this.agentStatementDetails = agentStatementDetails; } public void addAgentStatementDetail(AgentStatementDetail agentStatementDetail) { this.agentStatementDetails.add(agentStatementDetail); } } Betwixt file: ?xml version='1.0' ? info element name='AgentStatementVO' element name='StatementDate' property='statementDate'/ element name='AgentInfoVO' property='agentInfo'/ element name='AgentStatementLineVO' property='agentStatementDetails' class='com.equitrust.commissionloader.beans.AgentStatementDetail'/ element name='AgentEarningsVO' property='agentEarning'/ /element /info Everything except the agentStatementDetails are populated correctly. Thanks, Matt -- Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Metalexis Transcending the Ordinary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [betwixt] Collection property question
I have that set. It appears that my class is not being recognized in the parse process. My add method on my class is never called. Matt Jason Wood wrote: I think you want this ... IntrospectionConfiguration.setWrapCollectionsInElement(false) Jason -Original Message- From: Matt Goodwin [mailto:[EMAIL PROTECTED] Sent: Thursday, January 13, 2005 11:02 AM To: Jakarta Commons Users List Subject: [betwixt] Collection property question I have xml I need to map to my bean. It is very similar to the CustomerBean example, except I am using Collection instead of and array of objects (i.e. Order[]). Here is a sample of the xml, followed by my class, followed by my .betwixt file. The problem I am having is the List is always null. How do you map objects in the .betwixt file if the collection has no surrounding element tag (i.e. orders/order/order/orders)? Example xml: AgentStatementVO StatementDate2004/10/08/StatementDate AgentInfoVO.../AgentInfoVO AgentStatementLineVO.../AgentStatementLineVO AgentStatementLineVO.../AgentStatementLineVO AgentEarningsVO.../AgentEarningsVO /AgentStatementVO Class: public class AgentStatement implements java.io.Serializable { private Date statementDate; private AgentInfo agentInfo; private Collection agentStatementDetails = new java.util.ArrayList(); private AgentEarning agentEarning; /* .. snip non-relevant getters/setters */ public Collection getAgentStatementDetails() { return agentStatementDetails; } public void setAgentStatementDetails(Collection agentStatementDetails) { this.agentStatementDetails = agentStatementDetails; } public void addAgentStatementDetail(AgentStatementDetail agentStatementDetail) { this.agentStatementDetails.add(agentStatementDetail); } } Betwixt file: ?xml version='1.0' ? info element name='AgentStatementVO' element name='StatementDate' property='statementDate'/ element name='AgentInfoVO' property='agentInfo'/ element name='AgentStatementLineVO' property='agentStatementDetails' class='com.equitrust.commissionloader.beans.AgentStatementDetail'/ element name='AgentEarningsVO' property='agentEarning'/ /element /info Everything except the agentStatementDetails are populated correctly. Thanks, Matt -- Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Metalexis Transcending the Ordinary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [betwixt] Collection property question
public void testReadBean() { try { File file = new File(FILE1); BeanReader beanReader = new BeanReader(); beanReader.registerBeanClass(AgentStatement.class); AgentStatement statement = (AgentStatement)beanReader.parse(file); } catch(Exception e) { fail(e.getMessage()); } } xml file: AgentStatementVO StatementDate2004/10/08/StatementDate AgentInfoVO FirstName/ Name/Name AgentId/AgentId Address1/Address1 Address2/Address2 City/City Statexx/State Zipx/Zip AgentType/AgentType DisbursementSource/DisbursementSource /AgentInfoVO AgentStatementLineVO AgentNumber/AgentNumber ProductType/ProductType FirstName/FirstName Name/Name EffectiveDate2004/10/04/EffectiveDate ProcessDate2004/10/05/ProcessDate OwnerName/OwnerName PolicyNumber0/PolicyNumber InitialPremium0/InitialPremium CommissionRate0.0/CommissionRate CommissionPremium0/CommissionPremium Type/Type AmountDue0/AmountDue /AgentStatementLineVO AgentStatementLineVO AgentNumber/AgentNumber ProductType/ProductType FirstName/FirstName Name/Name EffectiveDate2004/10/04/EffectiveDate ProcessDate2004/10/05/ProcessDate OwnerName/OwnerName PolicyNumber0/PolicyNumber InitialPremium0/InitialPremium CommissionRate0.0/CommissionRate CommissionPremium0/CommissionPremium Type/Type AmountDue0/AmountDue /AgentStatementLineVO AgentEarningsVO TaxableIncome0.0/TaxableIncome TaxableIncomeYTD0.0/TaxableIncomeYTD PositivePolicyEarnings0/PositivePolicyEarnings NegativePolicyEarnings0/NegativePolicyEarnings NetPolicyEarnings0/NetPolicyEarnings /AgentEarningsVO /AgentStatementVO reads all non-plural elements fine. when i change AgentStatementLineVO to non-plural (regular getter/setter for the object) it works fine as well. Thanks, Matt Tim O'Brien wrote: Could you send the complete code you are using to read with? Tim -Original Message- From: Matt Goodwin [mailto:[EMAIL PROTECTED] Sent: Thu 1/13/2005 2:58 PM To: Jakarta Commons Users List Subject: Re: [betwixt] Collection property question I have that set. It appears that my class is not being recognized in the parse process. My add method on my class is never called. Matt Jason Wood wrote: I think you want this ... IntrospectionConfiguration.setWrapCollectionsInElement(false) Jason -Original Message- From: Matt Goodwin [mailto:[EMAIL PROTECTED] Sent: Thursday, January 13, 2005 11:02 AM To: Jakarta Commons Users List Subject: [betwixt] Collection property question I have xml I need to map to my bean. It is very similar to the CustomerBean example, except I am using Collection instead of and array of objects (i.e. Order[]). Here is a sample of the xml, followed by my class, followed by my .betwixt file. The problem I am having is the List is always null. How do you map objects in the .betwixt file if the collection has no surrounding element tag (i.e. orders/order/order/orders)? Example xml: AgentStatementVO StatementDate2004/10/08/StatementDate AgentInfoVO.../AgentInfoVO AgentStatementLineVO.../AgentStatementLineVO AgentStatementLineVO.../AgentStatementLineVO AgentEarningsVO.../AgentEarningsVO /AgentStatementVO Class: public class AgentStatement implements java.io.Serializable { private Date statementDate; private AgentInfo agentInfo; private Collection agentStatementDetails = new java.util.ArrayList(); private AgentEarning agentEarning; /* .. snip non-relevant getters/setters */ public Collection getAgentStatementDetails() { return agentStatementDetails; } public void setAgentStatementDetails(Collection agentStatementDetails) { this.agentStatementDetails = agentStatementDetails; } public void addAgentStatementDetail(AgentStatementDetail agentStatementDetail) { this.agentStatementDetails.add(agentStatementDetail); } } Betwixt file: ?xml version='1.0' ? info element name='AgentStatementVO' element name='StatementDate' property='statementDate'/ element name='AgentInfoVO' property='agentInfo'/ element name='AgentStatementLineVO' property='agentStatementDetails' class='com.equitrust.commissionloader.beans.AgentStatementDetail'/ element name='AgentEarningsVO' property='agentEarning'/ /element /info Everything except the agentStatementDetails are populated correctly. Thanks, Matt - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Metalexis Transcending the Ordinary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail
Re: Validator outside Struts
Take a look at the commons-validator project http://jakarta.apache.org/commons/validator. Especially the javadocs description. Download the source there is an example there. It's actually real similar to using it within struts outside of how you have to initialize the resources which you've already done. I am using it outside of struts so if you need another example let me know. Matt Per Lövdinger wrote: Hi there, I would like to try out Validator outside Struts. I've got the initializion of validatorResources working. Does anyone have sample-code for using the resources and calling the validator,extracting validationResult ? thanks in advance -- Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Metalexis Transcending the Ordinary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [betwixt] ObjectStringConverter .betwixt file
Thanks for the response. I'll check it out and see what's going on. Matt robert burrell donkin wrote: On 29 Nov 2004, at 18:05, Matt Goodwin wrote: I have successfully been able to set a custom object string converter for a date format I have in java code using the BeanReader.getBindingConfiguration method (thank you for the documentation). However, I would like to be able to set this in the .betwixt file. I have the following snippet for .betwixt file ?xml version='1.0' ? info element name='ActivitySummary' element name='CommissionsYTD' property='commissionsYTD'/ element name='LastCommissionAmt' property='lastCommissionAmt'/ element name='LastCommissionDate' property='lastCommissionDate' option nameorg.apache.commons.betwixt.strategy.ObjectStringConverter/name valuecom.equitrust.dao.util.SEGDateConverter/value /option /element element name='PremiumYTD' property='premiumYTD'/ /element /info What am I missing. I still get a org.apache.commons.beanutils.ConversionException. What is the proper way to specify my custom converter in the .betwixt file. unfortunately, i have a feeling that you are missing some code in betwixt to do just that (but i could be wrong, i don't have time right now to check...) i'm already late for the start of a night out so sadly i doubt i'll be able to create some code that does what you want tonight. i do think that this should be reasonable easy to add so the quickest way to get what you want would be to install maven (http://maven.apache.org), download the latest code from CVS and start hacking! if you're feeling generous then please contribute it back (i think that this list bounces attachments so you might need to open a bugzilla). otherwise, i'll try to find some time but realistically it will be a few days... - robert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Metalexis Transcending the Ordinary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
betwixt and namespace
I have an object and I am trying to output as xml. That part is working fine, but I need to put a namespace on the elements. How is the namespace set? I am using the following code. In my startElement method in my ContentHandler, the namespaceURI is . What am I doing wrong? HardErrorContentHandler beanHandler = HardErrorContentHandlerFactory.getInstance(obj); beanHandler.setPrettyPrint(prettyPrint); SAXBeanWriter beanWriter = new SAXBeanWriter(beanHandler); if(capitalize) { beanWriter.getXMLIntrospector().getConfiguration().setElementNameMapper(new CapitalizeNameMapper()); } // set namespace NamespacePrefixMapper namespaceMapper = new NamespacePrefixMapper(); namespaceMapper.setPrefix(xmlns,http://tempuri.org/segHedge.xsd;); beanWriter.getXMLIntrospector().getConfiguration().setPrefixMapper(namespaceMapper); Thanks, Matt -- Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Metalexis Transcending the Ordinary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]