Alex,

Yes, that should work.

--Victor

Alex Paransky wrote:

> Victor, the first approach sounds great.  I will have a "constant" reference
> called ejb/Owner, as well as a "hint" in the Address bean.  At the same time
> the actual Owner bean will implement a StateChangeListener interface.  When
> the address bean changes, I can always get the home of the owner by using
> ejb/Owner, and since I have the primary key of the object, I can find the
> object by using findByPrimaryKey method.  Then, I can narrow the object to
> the StateChangeListener type, and invoke the callback method passing the
> hint to notify the StateChangeListener as to the hint of the type of change
> that has occurred.
>
> Sounds like it should work, no?
>
> Thanks.
> -AP_
>
> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Victor Langelo
> Sent: Friday, August 10, 2001 1:40 PM
> To: [EMAIL PROTECTED]
> Subject: Re: How to duplicate ejb's handle functionality...
>
> Alex,
>
> What I would do is use ejb-ref(s) in the deployment descriptor of your
> dependent
> objects which reference the owner(s). The ejb-ref-name(s) should be
> constants.
> From here you have two choices:
>
> 1) Deploy the same bean class with different a ejb-ref to the owner. In this
> case you only need the id stored in the DB if you use separate tables for
> each
> deployed bean. Or you can store the ref name if you use a single table.
>
> 2) Deploy with mutiple ejb-refs. Create a map of interfaces to
> ejb-ref-names.
> Use the map to determine which ref-name to use for a given entity bean
> instance.
> Save the owner id and ejb-ref-name in the database.
>
> In either case, getting the owner is a simple matter of using the ejb-ref to
> get
> the home interface then calling findByPrimaryKey.
>
> By using ejb-ref you avoid using anything that might change outside of your
> bean
> class.
>
> --Victor
>
> Alex Paransky wrote:
>
> > I have developed a number of generic EJB objects (CMP2.0) such as Address,
> > EmailAddress, Phone, etc...  Now, I am trying to attach the objects to the
> > main User object, for example.  So, I have an ownerId in the address which
> > is a primary key for my user object (Long).  So now, from the User object,
> I
> > can process getAddress() by executing a
> > AddressHome.findByOwner(user.getId()).
> >
> > At this point, if Address object gets modified I want my User object to be
> > notified.
> >
> > From the point of view of the Address, I cannot resolve the ownerId to a
> > real object in order to call some (callback interface) method.  The only
> > thing I was able to think of, is storing the Handle to the owner EJB
> object
> > in the owned object.  However, the handle is not required to be portable
> > across EBJ servers, thus the root of the original question.
> >
> > I could, of course, create specialized address object such as UserAddress
> > which would then have a back-reference to the User object, it's self,
> > however, I think this might be too much work for what I am trying to do.
> >
> > -AP_
> >
> > -----Original Message-----
> > From: A mailing list for Enterprise JavaBeans development
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Victor Langelo
> > Sent: Friday, August 10, 2001 9:37 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: How to duplicate ejb's handle functionality...
> >
> > Alex,
> >
> > I don't understand why you want the "location" of the entity's home. But
> > whatever that is you don't want to save it or the JNDI name in your
> > database.
> > What if you redeploy the entity under a different name and app server. You
> > data
> > is garbage.
> >
> > What is it you're actually trying to do? Are you attempting to save a
> > reference
> > for which each instance will reference a different entity in some dynamic
> > way?
> >
> > --Victor
> >
> > Alex Paransky wrote:
> >
> > > I need to store a handle to an entity bean in the database for a long
> > term.
> > > I am concerned, however, that handles from one application server are
> not
> > > readable by another application server.  So in a way, you are locked in
> > with
> > > one vendor.  I there a way to obtain the handle functionality in other
> > > means?
> > >
> > > All the keys in our application are generated externally, and thus a
> > single
> > > Long value.  If I could gather the location of the home object in the
> JNDI
> > > name, then I could, using the JNDI name and ID of the object retrieve
> any
> > > entity.  I just don't know how to get the JNDI location of the home
> object
> > > from a reference to a remote ejb entity???
> > >
> > > Thanks.
> > > -AP_
> >
> >
> ===========================================================================
> > 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".
>
> ===========================================================================
> 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