Re: Java Packages for Dummies
Re: Java Packages for Dummies
- Subject: Re: Java Packages for Dummies
- From: David LeBer <email@hidden>
- Date: Tue, 4 Dec 2007 18:22:07 -0500
On 4-Dec-07, at 6:09 PM, Owen McKerrow wrote:
Hi All,
As part of preparing to move to Eclipse we are going back and
updating our projects so they are using packages ( this is the bit
where I run and hide in shame as I have to admit we never used them
before ) and EOGenerator if they weren't already. Anyways.....
Have you moved to Eclipse already? 'Cause moving to packages with the
re-factoring tools in Eclipse is one heck of a lot easier than in
Xcode... just sayin...
We're having some issues, lots of issues so I think we've done
something dumb. The first issue is that
addbjectToBothSidesOfRelationship is now causing a StackOverflow
error as it keeps calling itself. In the example below its for the
AuditLog class. First up is the old code, then the new code ( thanks
to EOGenerator ) and then the error message (I haven't included all
of the stack trace as its the same thing over and over again ).
So as a newbie to packages I can't see any rules that we're breaking
( although we probably are ). Any advise/suggestions/fixes would be
most appreciated.
---Old----
import com.webobjects.foundation.*;
import com.webobjects.eocontrol.*;
import java.math.BigDecimal;
import java.util.*;
/**
Log trail of each time a page is accessed/viewed on the website.
*/
public class AccessLog extends OMGenericRecord {
public AccessLog() {
super();
}
public Person person() {
return (Person)storedValueForKey("person");
}
public void setPerson(Person value) {
takeStoredValueForKey(value, "person");
}
----New-----
package edu.uow.ris.framework.eo;
import edu.uow.ris.framework.*;
import edu.uow.emlab.omframework.*;
import com.webobjects.eoaccess.*;
import com.webobjects.eocontrol.*;
import com.webobjects.foundation.*;
import java.math.BigDecimal;
import java.util.*;
import org.apache.log4j.Logger;
public abstract class _AccessLog extends OMGenericRecord {
private static Logger log = Logger.getLogger( _AccessLog.class );
public _AccessLog() {
super();
}
public void setPerson(edu.uow.ris.framework.eo.Person aValue) {
if( aValue == null ) {
edu.uow.ris.framework.eo.Person object = person();
if( object != null )
removeObjectFromBothSidesOfRelationshipWithKey( object, "person" );
} else
addObjectToBothSidesOfRelationshipWithKey( aValue,
"person" );
}
Ooo this is bad.
Don't do funky things in an attribute's accessor methods. As an
example, well, in this case, addObject... removeObject... will end up
calling setPerson and then... you get the idea.
;david
--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site: http://codeferous.com
blog: http://davidleber.net
profile: http://www.linkedin.com/in/davidleber
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden