Aaron Mulder writes:
 >      Well... we could certainly do that, but...
 >
 >      The most reasonable way would be to use the DB-specific key
 > generation, but that only works for DBs that support it (Oracle and
 > PostgreSQL, that I'm aware of), and would require user configuration (to
 > pick a DB).  I suppose we could make a "generic" setting that just uses a
 > normal DB table, but it would have to just keep issuing SQL like "update
 > foo set counter = (value+1) where counter=(value)" until one went through,
 > to avoid clashing with other instances.

Hmmm? That seems a bit inefficient, if I understand you correctly.
Why 'until one went through'? Why not have a table:

CREATE TABLE JBOSS_KEYGEN_SEQUENCE
(
                                IDENTIFIER INT4 NOT NULL PRIMARY KEY,
                                VALUE                    INT8 NOT NULL
)

INSERT INTO JBOSS_KEYGEN_SEQUENCE VALUES ( 1, 0 );

Then whenever you want a new key:

COMMIT; (or however your db begins a tx)
SELECT value FROM jboss_keygen_sequence WHERE identifier=1;
UPDATE jboss_keygen_sequence SET value = value+1 where identifier=1;
COMMIT;

Also, if you only use the db to generate half of a 128 bit key then
you only need to hit the database once in every 2^64 keys.

 >      Anyway, if you want me to go ahead and put such a thing together,
 > say the word - any let me know if you can see a way to do it other than
 > involving the DB.

As I said in a different post I have a key generator mbean, but it
uses Oracle sequences.  Such a thing is not hard to put together,
though; it took me two hours, and that was including working out how
MBeans work.

Tom


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

Reply via email to