Dave,

If you require  that the counter be persisted between server re-starts, you
could represent this as an Entity Bean which encapsulates the state of a
single persistent data object, or as a Session Bean which similarly
synchronizes access to a data object. In either case a proper isolation
level to achieve atomicity of the singleton, or pessimistic locking is
called for.

Alternatively you could use a UUID algorithm that is more stateless in
nature. I have one where the core algortihm was donated to me by Mr. Jim
Frentess (who used to frequent this list, where have you gone Jim?).

I have it wrapped up as a singleton GemStone/J CORBA service, but you could
also use it as a RMI service. In either case it is a system singleton.

If you are interested send me a note and I ship you the code.

Regards,

-Chris.
> -----Original Message-----
> From: DaveFord [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, March 24, 2000 10:20 AM
> To:   [EMAIL PROTECTED]
> Subject:      GuidFactory EJB
>
> I want to create a GuidFactory EJB. It's purpose will be to generate
> unique
> ID's for primary keys. The key will consist of:
>
> IP address
> current time in millis
> a counter
>
> The only state maintained by the EJB will be a counter. I don't want the
> current value of the counter to be lost should the server shut down, so I
> was thinking of using an entity bean. But since this will be a singleton,
> there doesn't really need to be a "findByPrimaryKey" method.
>
> So I guess my question is, how would you model this type of bean as an
> EJB.
>
> Dave Ford
>
> ==========================================================================
> =
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to