You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "Weaver, Scott" <Sw...@rippe.com> on 2001/12/03 17:04:26 UTC

Implementing a custom ID Broker

I want to something real simple.  I just want extend then use a custom
version of an ID broker.  

Basically, all I want to do is to append the table name to plus and "@" sign
to the beginning of an autogenerated key (String only, obviously) like so:
Extend org.apache.turbine.util.db.IDBroker then override getIdAsString

String getIdAsString(Connection connection, Object tableName)
{
	return tableName+"@"+(getIdAsBigDecimal(null,
tableName).toString());   
}

This will, theoretically, create system-wide, unique ID for this row.  

Okay, that was the simple part.  The part I'm missing is how to convince
Turbine to use my ID Broker Class instead of the default one.  

Any clues?

Thanks,
Scott

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Implementing a custom ID Broker

Posted by Jason van Zyl <jv...@zenplex.com>.
On 12/3/01 11:04 AM, "Weaver, Scott" <Sw...@rippe.com> wrote:

> I want to something real simple.  I just want extend then use a custom
> version of an ID broker.
> 
> Basically, all I want to do is to append the table name to plus and "@" sign
> to the beginning of an autogenerated key (String only, obviously) like so:
> Extend org.apache.turbine.util.db.IDBroker then override getIdAsString
> 
> String getIdAsString(Connection connection, Object tableName)
> {
> return tableName+"@"+(getIdAsBigDecimal(null,
> tableName).toString());
> }
> 
> This will, theoretically, create system-wide, unique ID for this row.
> 
> Okay, that was the simple part.  The part I'm missing is how to convince
> Turbine to use my ID Broker Class instead of the default one.
> 
> Any clues?

For expediency you should just modify the current IDBroker to do what you
want the IDBroker isn't pluggalbe at the moment. The IDBroker implements the
IdGenerator interface so you could make something similar to the IDBroker
but you would have to modify Torque to allow pluggable IdGenerators. It's
coming but won't be there soon and as you need it now I suggest just
modifying the IDBroker class.

It's probably easy to make this pluggable in Torque but it will require some
testing.
 
> Thanks,
> Scott
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>