db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: JDO 2.1 specification draft can be reviewed...
Date Sun, 05 Aug 2007 02:03:49 GMT
Hi Chris,

No, it's not too late for changes to the spec. That's why we've  
released it now, while there is still time to add useful things.

I'd like to see others' reaction to this proposal as well.

Regards,

Craig

On Aug 4, 2007, at 6:14 PM, cbeams wrote:

>
> Craig, all,
>
> This isn't so much a comment on the 2.1 spec changes, but rather a  
> suggestion for an addition to the JDOHelper interface in the 2.1  
> timeline (I don't know if it's too late for this sort of thing)...
>
> JPOX's JPOXJDOHelper implementation exposes a very useful method  
> with the following signature:
>
> 	String getObjectState(Object pc)
>
> I would love to see this method exposed by the standard JDOHelper  
> interface.  The spec currently provides status interrogation  
> methods (per section 8.5), but they're primarily useful assuming  
> one is testing for a particular state.  For example, I might care  
> to assert that a pc is 'detached-dirty':
>
> 	assert pc.isDetached() && pc.isDirty();
>
> That's not so bad; it's even elegant.   But if I'm debugging my way  
> through an application, there's no standardized way (that I know  
> of) to simply print out the state of the pc object.  Using JPOX  
> internals, I can do the following:
>
> 	logger.debug(JPOXJDOHelper.getObjectState(pc));  // prints out  
> 'detached-dirty', 'transient-clean', or whatever the state actually  
> is.
>
> or, just as easily:
>
> 	assert "detached-dirty".equals(JPOXJDOHelper.getObjectState(pc));
>
> This method is most useful from a practical point of view:  
> debugging.  One might argue that such code need not be portable and  
> thus standardized, but I'd counter with "why not"?  State  
> transitions in JDO are complex enough; if we can make the standard  
> interface for interrogation of those states friendlier, all the  
> better.
>
> IMHO, the only problem with the current JPOX getObjectState()  
> implementation is that it's string-based.  If this method were to  
> be considered for the 2.1 JDOHelper interface, I would suggest that  
> the return type be an enumeration that contains identifiers for all  
> the object states, optional and required:
>
> 	package javax.jdo;
> 	public interface JDOHelper {
> 		// ...
> 		ObjectState getObjectState(Object pc);
> 	}
>
> Where ObjectState is defined as:
>
> 	package javax.jdo;
> 	public enum ObjectState {
> 		TRANSIENT,
> 		TRANSIENT_CLEAN,
> 		TRANSIENT_DIRTY,
> 		PERSISTENT_NEW,
> 		PERSISTENT_NONTRANSACTIONAL,
> 		PERSISTENT_NONTRANSACTIONAL_DIRTY,
> 		PERSISTENT_CLEAN,
> 		PERSISTENT_DIRTY,
> 		HOLLOW,
> 		PERSISTENT_DELETED,
> 		PERSISTENT_NEW_DELETED,
> 		DETACHED_CLEAN,
> 		DETACHED_DIRTY;
> 	}
>
> With this addition in place, the user gets the best of both  
> worlds.  Asserting for a given state is trivially easy:
>
> 	assert JDOHelper.getObjectState(pc) == ObjectState.DETACHED_DIRTY;
>
> And determining object state with no a priori knowledge is simple,  
> too:
>
> 	logger.debug(JDOHelper.getObjectState(pc)); // prints out  
> "DETACHED_DIRTY"
>
> The ObjectState enum could also override toString() such that it  
> transforms the all-caps-and-underscores identifier to the lower- 
> case-and-dashes format used within the spec,  e.g.:  
> DETACHED_DIRTY.toString() returns "detached-dirty"
>
>
> Thanks for considering,
>
> - Chris Beams
>
>
>
>
>> From: Craig L Russell <Craig.Russell@Sun.COM>
>> Date: August 3, 2007 7:04:52 PM PDT
>> To: Apache JDO project <jdo-dev@db.apache.org>, JDO Expert Group  
>> <jdo-experts-ext@Sun.COM>
>> Subject: JDO 2.1 specification draft can be reviewed...
>>
>>
>> at http://db.apache.org/jdo/documentation.html
>>
>> Check it out, and send comments...
>>
>> Craig Russell
>> Architect, Sun Java Enterprise System http://java.sun.com/products/ 
>> jdo
>> 408 276-5638 mailto:Craig.Russell@sun.com
>> P.S. A good JDO? O, Gasp!
>>
>
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message