You are correct the only thing modifying User does is taking care of a
cast.

Here's the problem I'm running into:

The default LoginUser.java uses this line to create a new user:
User user = ((User)Class.forName(userClassName).newInstance
()).retrieveFromStorage(username);
where userClassName is read from the properties file.

If the method retrieveFromStorage( String, Criteria ) is added to
TurbineUser, but not User, this, of course, will not work.
The only way I know to get this work (without modifying User) is to do
something like this:
User user = ((TurbineUser)Class.forName(userClassName).newInstance
()).retrieveFromStorage(username, criteria);

The drawback here is that now TurbineUser must be hardcoded in the program,
reducing the advantage of putting the value in the properties file.  Now,
presumably if your calling this new method, you've already committed
yourself to some specialized code due to the criteria you've built, so I
don't think this is big sticking point.  I'm just looking for the most
flexible option.

Do you know of way to dynamically handle the cast?  That would solve
everything.


>i don't see a problem with adding this to TurbineUser, but why does it
need
>to be added to User.  Nothing in Turbine presently uses this method, so
>adding it to User would seem to only save a cast, or is there other
benefit?
>
>John McNally


----- Original Message -----
From: <[EMAIL PROTECTED]>
To: Turbine <[EMAIL PROTECTED]>
Sent: Tuesday, January 11, 2000 7:32 AM
Subject: User / TurbineUser selection criteria


> For my implementation of Turbine, I have added the concept of an 'active'
> and an 'inactive' account by adding a column to the Visitor table.
> To insure that I only get active accounts when validating a login, I
added
> a Criteria line to TurbineUser.retrieveFromStorage( username ) method.
>
> This works fine, but I'm thinking that others may want to perform their
own
> customizations and a small code change would alleviate the need for them
to
> extend TurbineUser to set their own criteria.
>
> If we added a retrieveFromStorage method that also accepted a Criteria
> object, then the programmer could set the special Criteria and simply use
> the existing TurbineUser class.  In this scenario, I would modify the
> existing retrieveFromStorage method to instantiate a Criteria object, not
> set any special restrictions and then pass it to the method (which would
> proceed to set the username in the Criteria as before).
>
> This would look something like this:
>
> >>>>>>>  Code   >>>>>>>
>
> //  Current method with change  //
> public User retrieveFromStorage( String username ) throws Exception
> {
>    Criteria criteria = new Criteria();
>    return retrieveFromStorage( username, criteria );
> }
>
> //  Proposed method  //
> public User retrieveFromStorage( String username, Criteria criteria )
>       throws Exception
> {
>    criteria.add( TurbineUserPeer.USERNAME, username );
>    Vector users = TurbineUserPeer.doSelect(criteria);
>    ...
> }
>
> >>>>>>>  Code   >>>>>>>
>
> Or, for those of you who prefer diffs:
>
> >>>>>>>  Code   >>>>>>>
>
> Index: TurbineUser.java
> ===================================================================
> RCS file:
>
/products/cvs/turbine/turbine/src/java/org/apache/turbine/util/TurbineUser.j

ava,v
> retrieving revision 1.11
> diff -r1.11 TurbineUser.java
> 306a307,315
> >               return retrieveFromStorage( username, criteria );
> >     }
> >
> >     /*
> >      * This function returns a TurbineUser which has been upcast to a
> User.
> >      */
> >     public User retrieveFromStorage( String username, Criteria
criteria )
> >               throws Exception
> >     {
>
> >>>>>>>  Code   >>>>>>>
>
> Now here's the catch.  To make this most useful, it would be nice if the
> User interface would provide this same new method, but that would mean
> anyone currently implementing User for their own work would need make the
> same modification.
>
> Comments?
>
> -----------------------------
> Parker J. May
> Outcome Technology Associates
> [EMAIL PROTECTED]
>
>
>
>
> ------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Problems?:           [EMAIL PROTECTED]
>



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]




------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to